Giter Site home page Giter Site logo

gauss314 / defi Goto Github PK

View Code? Open in Web Editor NEW
547.0 12.0 144.0 2.56 MB

Tools for use in DeFi. Impermanent Loss calculations, staking and farming strategies, coingecko and pancakeswap API queries, liquidity pools and more

License: MIT License

Python 100.00%
blockchain defi cryptocurrency exchanges dapp api impermanent-loss dex cex coingecko pancakeswap stake farming crypto

defi's Issues

dft.geckoHistorical('bitcoin')

Buenas, intento correr el codigo en Spyder:

dft.geckoHistorical('bitcoin')

y me da el error

dft.geckoHistorical('bitcoin')
Traceback (most recent call last):

File "", line 1, in
dft.geckoHistorical('bitcoin')

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\defi\defi_tools.py", line 227, in geckoHistorical
df[0] = pd.to_datetime(df[0], unit='ms')

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\pandas\core\frame.py", line 2938, in setitem
self._set_item(key, value)

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\pandas\core\frame.py", line 3001, in _set_item
NDFrame._set_item(self, key, value)

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\pandas\core\generic.py", line 3624, in _set_item
self._data.set(key, value)

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 1086, in set
for blkno, val_locs in libinternals.get_blkno_placements(blknos, group=True):

File "pandas_libs\internals.pyx", line 448, in get_blkno_placements

File "pandas_libs\internals.pyx", line 352, in pandas._libs.internals.get_blkno_indexers

ValueError: Buffer has wrong number of dimensions (expected 1, got 0)

Cuando lo hago en colab no me sucede esto.

Getting error from 'iloss_simulate' function

I copy and run this code

import defi.defi_tools as dft
dft.value_f, iloss = dft.iloss_simulate('cake','bnb', value=1000, base_pct_chg=50, quote_pct_chg=-25)

TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

Last month it's worked. But now.

Any update Please help.

Thanks a lot.

Custom LP pool weights

Could you add an option for custom pool weights such as Bancor or BeethovenX use like 80/20 instead of the traditional 50/50?

Not an issue but

would it be possible to get token price\transations by contract address?

PCS - Get token/pair info

Unable to run for either even when using default values:

for line 490, in pcsPairInfo
for contract, values in data.items():
AttributeError: 'NoneType' object has no attribute 'items'

IndexError: single positional indexer is out-of-bounds

Received the following error:

pair = ['ethereum','nexus-governance-token']
apr = 553.94
dft.farmSimulate(pair, apr, start='2021-11-30')
Downloading ethereum
Downloading nexus-governance-token
Traceback (most recent call last):
File "<pyshell#35>", line 1, in
dft.farmSimulate(pair, apr, start='2021-11-30')
File "C:\Users\jadmin\AppData\Local\Programs\Python\Python39\lib\site-packages\defi\defi_tools.py", line 276, in farmSimulate
farm = farm.divide(farm.iloc[0])
File "C:\Users\jadmin\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\indexing.py", line 931, in getitem
return self._getitem_axis(maybe_callable, axis=axis)
File "C:\Users\jadmin\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\indexing.py", line 1566, in _getitem_axis
self._validate_integer(key, axis)
File "C:\Users\jadmin\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\indexing.py", line 1500, in _validate_integer
raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds

Add function for get LP token value

I think this would be a great addition to what you have already built here. Perhaps there is a way to calculate this from the 'pcsPairInfo'? I usually calculate it from manually looking at the contract and dividing the total LP value by the total token supply, so being able to look up a contract from address would work too. These contract addresses aren't available from "https://api.pancakeswap.info/api/tokens" as far as I know.

PancakeSwap Historical Data

I would like to retrieve the historical data for a liquidity pool on PancakeSwap. Is this possible using your defi package? If not would you mind giving me some pointers on how to do it? Is the best/easiest way to use Web3 to iterate through the smart contract event log and construct 5 minute candlesticks manually in Python?

Add other strategies

Thanks for sharing this great lib!
It would be event better if there was more uses cases like borrowing, cascading borrowing, governance stacking, etc... when calling the compare function.
See this anchor simulator for example: https://anchor-simulator.com/

Coingecko Farming Simulate missing graphics

CoinGecko - Farming Simulate section when I follow the example I do not get the graphics just the following below. How can I receive the additional data?

import defi.defi_tools as dft
pair = ['huobi-token','tether']
apr = 45
dft.farmSimulate(pair, apr, start='2021-01-01')
Downloading huobi-token
Downloading tether
{'Token 1': 'huobi-token', 'Token 2': 'tether', 'start': '2021-01-01', 'fixed APR': '45%', 'Buy & Hold': '51.45%', 'Impermanent Loss': '-5.95%', 'Farming Rewards': '84.08%', 'Farming + Rewards - IL': '141.49%'}

Reward token

Many farms provide additional reward token. It would be great to consider the price evolution of this token too in the compare function.

Error in Farming + Rewards - IL

pair = ['terra-luna','terrausd']
apr = 30
dft.farmSimulate(pair, apr, start='2021-01-01')
Downloading terra-luna
Downloading terrausd
{'Token 1': 'terra-luna', 'Token 2': 'terrausd', 'start': '2021-01-01', 'fixed APR': '30%', 'Buy & Hold': '4470.13%', 'Impermanent Loss': '-79.13%', 'Farming Rewards': '64.44%', 'Farming + Rewards - IL': '4613.70%'}

Seems to be incorrectly adding the IL to the total instead of subtracting. Additionally not sure the farming rewards are correct on how it could be 64.44% when its been slightly over a year and the APR has more than doubled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.