Comments (11)
Hi thanks for posting an issue!
- Enable shorting is a new setting we added, take a look at this settings.json. The
enable_shorting
setting is under alpaca so it has no bearing on Coinbase Pro regardless of set true or false. - The coinbase timestamp message is new to me - a search brings up this thread that talks about the timestamp expired issue here. Your computer may just be sending an offset timestamp.
I might go ahead and add an exception for that query so that we can forward the Coinbase Pro error more easily but I will keep looking around to see if I can replicate the timing issue.
from blankly.
Thank you for the lightning fast reply! Really love Blankly!
- I suppose maybe it shouldn't print out as an info when using Coinbase
- You are absolutely right, during one of the Windows Updates somehow the "Auto-Set Time" in Settings got turned off and my time drifted by about 3 minutes. Turned it on and it seems the code has moved passed it. Maybe a clearer error message would have helped here for anyone that might run into it later on.
from blankly.
So just trying the sample MACD strategy. My code looks like:
coinbase = CoinbasePro()
s = Strategy(coinbase)
s.add_price_event(price_event, 'BTC-USD', resolution='30m', init=init)
result = s.backtest(initial_values={'USD': 10000}, to='2y')
print(result)
I get:
INFO: No portfolio name to load specified, defaulting to the first in the file: (my cool portfolio). This is fine if there is only one portfolio in use.
INFO: "enable_shorting" not specified in preferences, defaulting to: "True"
No cached data found for BTC-USD from: 1578075925 to 1641146125 at a resolution of 1800 seconds.
INFO: Granularity is not an accepted granularity...rounding to nearest valid value.
Progress: [##########] 99.75%
Initializing...
Traceback (most recent call last):
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Users\XXXXXXXX\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
cli.main()
File "c:\Users\XXXXXXXX\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\XXXXXXXX\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\git\crypto-test\src\macd\macd.py", line 59, in <module>
result = s.backtest(initial_values={'USD': 10000}, to='2y', settings_path="e:\\git\\crypto-trading\\backtest.json")
File "C:\Users\XXXXXXXX\AppData\Roaming\Python\Python38\site-packages\blankly\frameworks\strategy\strategy_base.py", line 517, in backtest
results = self.backtesting_controller.run()
File "C:\Users\XXXXXXXX\AppData\Roaming\Python\Python38\site-packages\blankly\exchanges\interfaces\paper_trade\backtest_controller.py", line 602, in run
i['init'](i['asset_id'], i['state_object'])
File "c:\git\crypto-test\src\macd\macd.py", line 17, in init
variables['history'] = interface.history(symbol, 800,
File "C:\Users\XXXXXXXX\AppData\Roaming\Python\Python38\site-packages\blankly\exchanges\interfaces\exchange_interface.py", line 212, in history
valid_time_in_past = utils.ceil_date(parsed_date,
File "C:\Users\XXXXXXXX\AppData\Roaming\Python\Python38\site-packages\blankly\utils\utils.py", line 605, in ceil_date
return dt.fromtimestamp(date.timestamp() + secs - date.timestamp() % secs)
AttributeError: 'numpy.int32' object has no attribute 'timestamp'
from blankly.
Thank you for the lightning fast reply! Really love Blankly!
- I suppose maybe it shouldn't print out as an info when using Coinbase
- You are absolutely right, during one of the Windows Updates somehow the "Auto-Set Time" in Settings got turned off and my time drifted by about 3 minutes. Turned it on and it seems the code has moved passed it. Maybe a clearer error message would have helped here for anyone that might run into it later on.
Awesome,
For us the settings are all blended together so I can't check if I should show an error per exchange but I can show where the setting should be set. Maybe the error should be enable_shorting not set in alpaca - defaulting to True
so that users can localize it and know it's not attached to their exchange.
It looks like we need to wrap all coinbase responses and check for the message
tag and throw errors when that occurs.
from blankly.
For your second comment above this is a critical issue that we have to fix. For some reason on Windows systems pandas pushes datatypes to numpy which messes up time conversion. I just got free so I might just go fix this right now.
from blankly.
Just pushed out a new release. If you update with pip install blankly --upgrade
it should have a fix for that numpy issue.
from blankly.
Great! Thank you. Will give it a shot tonight/tomorrow.
from blankly.
Hey @sparky2708 , any updates on if this issue was fixed?
from blankly.
Sorry, was out-of-town @bfan1256. Didn't work fully but got further in. Just trying to run your RSI script.
Progress: [##########] 99.99% H:\ProgramData\Anaconda3\lib\site-packages\blankly\metrics\portfolio.py:55: RuntimeWarning: invalid value encountered in double_scalars
return mean / std
Traceback (most recent call last):
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "c:\Users\me.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy_main.py", line 45, in
cli.main()
File "c:\Users\me.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\me.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("main"))
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "H:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "E:\git\crypto-trading/src/rsi/rsi.py", line 41, in
main()
File "E:\git\crypto-trading/src/rsi/rsi.py", line 37, in main
backtest_result = s.backtest(initial_values={'USD': 10000}, to='1y', settings_path="backtest.json")
File "H:\ProgramData\Anaconda3\lib\site-packages\blankly\frameworks\strategy\strategy_base.py", line 539, in backtest
results = self.backtesting_controller.run()
File "H:\ProgramData\Anaconda3\lib\site-packages\blankly\exchanges\interfaces\paper_trade\backtest_controller.py", line 910, in run
if np.isnan(metrics_indicators[i]):
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
from blankly.
Hey, I believe this should be addressed in a recent update. Try running pip install blankly --upgrade and tell me how it goes when you get a chance.
from blankly.
Hey @sparky2708 , let us know if this has fixed it! Cheers :D
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.