Comments (5)
Interesting, I'm assuming that we make an invalid assumption when Binance gives their first get_account
response.
If you go to the file at .\blankly\exchanges\interfaces\binance\binance_interface.py
and paste this code over the init_exchange
function on line 41
:
def init_exchange(self):
try:
symbols = self.calls.get_exchange_info()["symbols"]
except binance.exceptions.BinanceAPIException as e:
print(e)
raise exceptions.APIException("Invalid API Key, IP, or permissions for action - are you trying "
"to use your normal exchange keys while in sandbox mode? "
"\nTry toggling the \'use_sandbox\' setting in your settings.json or check "
"if the keys were input correctly into your keys.json.")
it will allow us to see what the binance package itself is saying about your keys.
It is interesting that it works inside the binance client package but not in the blankly framework.
We had someone who had a very similar error who fixed it by reinstalling the package: #41 (comment)
from blankly.
Thanks for the fast reply!
The script continued a litlle bit further, but then it failed again.
I started printing the uri.
With the settings.json "use_sandbox": true I get:
https://testnet.binance.vision/api/v3/account
which shouldn't work indeed because I didn't make an account there yet
I am trying out the backtesting so, I thought that it shouldn't be a big deal if I am not in the sanbox environment (correct me if I'm wrong), so I set the "use_sandbox" to false
The uri is then:
https://api.binance.us/api/v3/account
In my case, it should go to the .com domain and not the .us domain
replacing the binance settings to the below fixes that
"binance": {
"cash": "EU",
"binance_tld": "com"
}
This also works without your fix, so as a conclusion we can say that I had my settings.json messed up...
Maybe not relevant for the thread anymore, but now the script is failing a little bit further:
Any Idea why that would be? I've added the prints of the last requests:
get https://api.binance.com/api/v3/account True {'data': {}}
No cached data found for BTC-USD from: 1609227635 to 1640677235 at a resolution of 86400 seconds.
klines False v3 {'data': {'symbol': 'BTCUSD', 'startTime': 1609227635000, 'endTime': 1640677235000, 'interval': '1d', 'limit': 1000}}
get https://api.binance.com/api/v3/klines False {'data': {'symbol': 'BTCUSD', 'startTime': 1609227635000, 'endTime': 1640677235000, 'interval': '1d', 'limit': 1000}}
Traceback (most recent call last):
File "bot.py", line 75, in <module>
history = s.backtest(to='1y', initial_values={'USD': 100})
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/blankly/frameworks/strategy/strategy_base.py", line 511, in backtest
results = self.backtesting_controller.run()
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/blankly/exchanges/interfaces/paper_trade/backtest_controller.py", line 536, in run
prices = self.sync_prices()
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/blankly/exchanges/interfaces/paper_trade/backtest_controller.py", line 325, in sync_prices
resolution)
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 624, in get_product_history
return self.calls.get_product_history(symbol, epoch_start, epoch_stop, resolution)
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/blankly/exchanges/interfaces/binance/binance_interface.py", line 654, in get_product_history
limit=1000)
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/binance/client.py", line 870, in get_klines
return self._get('klines', data=params, version=self.PRIVATE_API_VERSION)
File "/Users/pascal/anaconda3/envs/py37/lib/python3.7/site-packages/binance/client.py", line 373, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/binance/client.py", line 335, in _request_api
return self._request(method, uri, signed, **kwargs)
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/binance/client.py", line 315, in _request
return self._handle_response(self.response)
File "/Users/user1/anaconda3/envs/py37/lib/python3.7/site-packages/binance/client.py", line 324, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1121): Invalid symbol.
from blankly.
Awesome I didn't notice the binance TLD setting and forgot to ask. I think the invalid symbol error is because binance uses USDT
instead of USD
so it should work if you set your symbol to BTC-USDT
.
from blankly.
Just added a suggestion to check the binance_tld
inside the binance auth error.
from blankly.
Changing the USD to USDT fixed it indeed.
Thanks a lot for the quick feedback!
From what I see so far, the project looks very nice
from blankly.
Related Issues (20)
- Binance futures not working HOT 7
- 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
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.