gauss314 / defi Goto Github PK
View Code? Open in Web Editor NEWTools for use in DeFi. Impermanent Loss calculations, staking and farming strategies, coingecko and pancakeswap API queries, liquidity pools and more
License: MIT License
Tools for use in DeFi. Impermanent Loss calculations, staking and farming strategies, coingecko and pancakeswap API queries, liquidity pools and more
License: MIT License
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.
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.
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?
Could you add an option for custom pool weights such as Bancor or BeethovenX use like 80/20 instead of the traditional 50/50?
would it be possible to get token price\transations by contract address?
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'
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/
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.
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%'}
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.
Please note that the Pancakeswap API has an udptate. The new url is https://api.pancakeswap.info/api/v2/.
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
Many farms provide additional reward token. It would be great to consider the price evolution of this token too in the compare function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.