Comments (8)
Cleaning cache folders helped - all errors are gone. Thank you very much for your advice. The library looks great and I hope I'll use it in near future to test my models.
Regarding quote_account_value_in
I left USDT
because there are no nans in metrics anymore and for Binance USD
throws error
Traceback (most recent call last):
File "/home/jakub/PycharmProjects/bot/venv/lib/python3.8/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 306, in get_account
return trade_local.get_account(symbol)
File "/home/jakub/PycharmProjects/bot/venv/lib/python3.8/site-packages/blankly/exchanges/interfaces/paper_trade/local_account/trade_local.py", line 125, in get_account
return copy.deepcopy(utils.AttributeDict(local_account.account[asset_id]))
KeyError: 'USD'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jakub/PycharmProjects/bot/blankly/rsi.py", line 39, in <module>
results = strategy.backtest(to='1y', initial_values={'USDT': 10000})
File "/home/jakub/PycharmProjects/bot/venv/lib/python3.8/site-packages/blankly/frameworks/strategy/strategy_base.py", line 495, in backtest
results = self.backtesting_controller.run()
File "/home/jakub/PycharmProjects/bot/venv/lib/python3.8/site-packages/blankly/exchanges/interfaces/paper_trade/backtest_controller.py", line 637, in run
available_dict, no_trade_dict = self.format_account_data(self.initial_time)
File "/home/jakub/PycharmProjects/bot/venv/lib/python3.8/site-packages/blankly/exchanges/interfaces/paper_trade/backtest_controller.py", line 448, in format_account_data
true_account[i] = self.interface.get_account(i)
File "/home/jakub/PycharmProjects/bot/venv/lib/python3.8/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 309, in get_account
raise KeyError("Symbol not found. This can be caused by an invalid quote currency "
KeyError: 'Symbol not found. This can be caused by an invalid quote currency in backtest.json.'
from blankly.
Interesting, I will look into this. This is a dependency problem inside the metrics library that we use. We haven't tested the code on an Anaconda distribution so if I were to guess it might be an issue building the extension modules that tuliply requires. I will test it out and respond asap. I believe that the Binance library we use might also have issues with Anaconda.
Thanks for opening an issue!
from blankly.
Thanks for the reply. Unfortunately, the standalone virtual environment on python 3.9 (pip install blankly) throws the same errors
from blankly.
Interesting, are there any errors with the install or does it run smoothly (besides version conflicts)?
from blankly.
The pip log looks clean both in venv and anaconda
from blankly.
Ah so I figured it out. The Binance sandbox deletes their historical data at the beginning of the month. There is only 15 hours of data inside the sandbox exchange which won't work with price events at a day resolution. We use data keys inside our tests to get around this issue (read only no trade on the live exchange).
You're just getting really unlucky - I would recommend creating low permission live keys for binance data.
from blankly.
Thank you. The mentioned errors in rsi.py and mlp_model.py are gone when I use a standard Binance account. But bot.py error is still present.
Also when I use rsi.py and mlp_model.py the metrics returns a lot of nan's and zeros (associated output and error/warning below)
No cached data found for BTC-USDT from: 1635897059 to 1635897125 at a resolution of 60 seconds.
Initializing...
Backtesting...
Progress: [##########] 98.81% /home/jakub/PycharmProjects/bot/venv/lib/python3.8/site-packages/blankly/metrics/portfolio.py:31: RuntimeWarning: divide by zero encountered in double_scalars
return (end_value / start_value) ** (1 / years) - 1
/home/jakub/PycharmProjects/bot/venv/lib/python3.8/site-packages/blankly/metrics/portfolio.py:68: RuntimeWarning: Degrees of freedom <= 0 for slice.
return np.nanvar(returns) * np.sqrt(n) if n else np.nanvar(returns)
Historical Dataframes:
Account History:
USDT BTC time Account Value (USDT)
0 100.00000 0.0000 1.635835e+09 100.000000
1 0.56640 0.0016 1.635835e+09 99.382400
2 0.56640 0.0016 1.635835e+09 99.316912
3 0.56640 0.0016 1.635835e+09 99.385776
4 0.56640 0.0016 1.635835e+09 99.282112
... ... ... ... ...
1032 612.02581 0.0000 1.635897e+09 612.025810
1033 612.02581 0.0000 1.635897e+09 612.025810
1034 612.02581 0.0000 1.635897e+09 612.025810
1035 612.02581 0.0000 1.635897e+09 612.025810
1036 612.02581 0.0000 1.635897e+09 612.025810
[1037 rows x 4 columns]
Account Returns:
time value
0 1.635835e+09 NaN
Resampled Account Value:
time value
0 1.635835e+09 100.0
Blankly Metrics:
Compound Annual Growth Rate (%): 0.0%
Cumulative Returns (%): 0.0%
Max Drawdown (%): nan%
Variance (%): nan%
Sortino Ratio: nan
Sharpe Ratio: nan
Calmar Ratio: nan
Volatility: nan
Value-at-Risk: nan
Conditional Value-at-Risk: nan
from blankly.
Yes these should both be easy fixes!
We cache the prices to avoid slow downloads, the empty sandbox data is inside the cache right now, so try deleting the ./price_caches
folder.
For the metrics, did you switch the quote_account_value_in
to USD
? The nan
results are common for quoting a currency the exchange does not use. I see from the backtest.json
provided its in USDT
but I want to double check!
I'm going to improve the IndexError: single positional indexer is out-of-bounds
error because it is impossible debug without context.
from blankly.
Related Issues (20)
- IndexError: list index out of range HOT 1
- state.interface.history duplicating prices HOT 3
- Title:Trailing Stop with limit orders in Blankly Finance paper trading environment HOT 9
- Implementing Upbit Exchange HOT 1
- Cannot run blankly login HOT 6
- Alpaca not working with crypto HOT 1
- Integrate Blankly with a timeseries database HOT 1
- Accept in memory data for backtest
- strategy.backtest without `to` argument should infer `start_time` and `end_time`
- KeyError: 'bidMultiplierUp' HOT 3
- Alpaca Cryptocurrency error(maybe just an alpaca related data error) HOT 1
- Inconsistencies in asset visualisation HOT 1
- Ow
- Innaccurate Historical Data HOT 2
- bar_event squashes price_event price HOT 1
- `state.interface.history` not returning history with correct time intervals
- `ignore_user_exceptions=False` parameter in `strategy.backtest` doesn't work
- Error installing blankly. 'ti.pxd' not found HOT 2
- Can't place bracket orders (stop-loss and take-profit) one after the other HOT 1
- Closing orders by id HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blankly.