binance.py fetch_positions_risk() - Missing arguments?
See original GitHub issueI’m getting an error here using the default binance exchange object and calling fetchPositions() with:
binance.fetchPositions(params={'type': 'future'})
From what I see in the code, fetch_positions_risk() is calling load_leverage_brackets() but not passing params
. The error below shouldn’t be happening imo if I’m passing params
to fetch_positions_risk (i.e., it should be passed through so L5109 should be self.load_leverage_brackets(params=params)
. Am I completely off here?
def load_leverage_brackets(self, reload=False, params={}):
self.load_markets()
# by default cache the leverage bracket
# it contains useful stuff like the maintenance margin and initial margin for positions
leverageBrackets = self.safe_value(self.options, 'leverageBrackets')
if (leverageBrackets is None) or (reload):
method = None
defaultType = self.safe_string(self.options, 'defaultType', 'future')
type = self.safe_string(params, 'type', defaultType)
query = self.omit(params, 'type')
if type == 'future':
method = 'fapiPrivateGetLeverageBracket'
elif type == 'delivery':
method = 'dapiPrivateV2GetLeverageBracket'
else:
> raise NotSupported(self.id + ' loadLeverageBrackets() supports linear and inverse contracts only')
E ccxt.base.errors.NotSupported: binance loadLeverageBrackets() supports linear and inverse contracts only
venv/lib/python3.8/site-packages/ccxt/binance.py:4943: NotSupported
Happy to open a PR to update this if need be…I’ve just started using ccxt though so may not be on the right track.
Edit:
Seems the defaultType
is set to 'spot'
so that’s why this is failing:
if (leverageBrackets is None) or (reload):
method = None
defaultType = self.safe_string(self.options, 'defaultType', 'future')
type = self.safe_string(params, 'type', defaultType)
query = self.omit(params, 'type')
if type == 'future':
method = 'fapiPrivateGetLeverageBracket'
elif type == 'delivery':
method = 'dapiPrivateV2GetLeverageBracket'
else:
raise NotSupported(self.id + ' loadLeverageBrackets() supports linear and inverse contracts only')
Definitely think params
should get passed through here…simple fix
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Exchanges — ccxt 2.4.71 documentation
The ccxt library is a collection of available crypto exchanges or exchange classes. Each class implements the public and private API for a...
Read more >Inputting parameters for Binance API in Python - Stack Overflow
I'm trying to get information for a coin pairing called ADAETH for an example. this is the line, but I can't figure the...
Read more >python-binance Documentation - Read the Docs
The Binance API documentation references a timestamp parameter, this is generated for ... added missing dateparser dependency to setup.py.
Read more >Welcome to python-binance v1.0.16 — python-binance 0.2.0 ...
This is an unofficial Python wrapper for the Binance exchange REST API v3. ... quantity=100) # get all symbol prices prices = client.get_all_tickers()...
Read more >binance-connector-python - Python package - Snyk
Looks like binance-connector-python is missing a security policy. ... from binance.spot import Spot client = Spot() print(client.time()) client ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ttodua thanks and makes sense. I had the js fix in without issue and checked it transpiled properly into php and python by reading the code. Next time I’ll PR it there but I would like to get the whole test suite working anyway.
Hello @hedeer-showk, you’re right
params
should be propagated toload_leverage_brackets
. However, to avoid conflicts, if you’re handling ‘futures’ it is advisable to instantiatebinanceusdm
instead