AttributeError: 'SpotExchange' object has no attribute 'futures_leverage'
See original GitHub issueHi,
I have a problem when I run backtest on Spot mode. The problem appear at the very end of the trading session, when we compute stats :
[2021-02-05T00:00:00+00:00]: Terminating strategy...
============================== EXCEPTION TRACEBACK:
File "/Users/floriancabirol/miniconda3/bin/jesse", line 8, in <module>
sys.exit(cli())
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/__init__.py", line 329, in backtest
json=json)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/modes/backtest_mode/__init__.py", line 59, in run
simulator(candles)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/modes/backtest_mode/__init__.py", line 287, in simulator
r.strategy._terminate()
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/strategies/Strategy.py", line 897, in _terminate
round(self.position.pnl_percentage, 2)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/models/Position.py", line 71, in pnl_percentage
return self.roi
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/models/Position.py", line 79, in roi
return self.pnl / self.total_cost * 100
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/models/Position.py", line 89, in total_cost
return self.entry_price * abs(self.qty) / self.exchange.futures_leverage
=========================================================================
My config :
Binance': {
'fee': 0.001,
# backtest mode only: accepted are 'spot' and 'futures'
'type': 'spot',
# futures mode only
'settlement_currency': 'USDT',
# accepted values are: 'cross' and 'isolated'
'futures_leverage_mode': 'cross',
# 1x, 2x, 10x, 50x, etc. Enter as integers
'futures_leverage': 1,
# used for spot exchange only
'assets': [
{'asset': 'USDT', 'balance': 10_000},
{'asset': 'BTC', 'balance': 0},
],
},
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
AttributeError: module 'concurrent' has no attribute 'futures ...
AttributeError : module 'concurrent' has no attribute 'futures' when I try parallel processing in python 3.6 ; in <module> import ; 17, in...
Read more >AttributeError: module 'concurrent' has no attribute 'futures' #6
Hi all, I am using Python 3.7.9, I am getting above issue. Here is my code block: `import concurrent.futures import ...
Read more >Short / Leverage
Shorting is not possible when trading with trading_mode set to spot . To short trade, trading_mode must be set to margin (currently unavailable)...
Read more >Python AttributeError — What is it and how do you fix it?
AttributeError : '***' object has no attribute '***'What is an AttributeError in Python? What can you do to fix it? When does it...
Read more >REPORT: A Cost Comparison of Futures & ETFs
Futures : Futures contracts are derivatives and provide leverage. Unlike an ETF, where the full notional amount is paid by the buyer to...
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 FreeTop 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
Top GitHub Comments
I have found a temporary fix but works only if you are in spot because it disable the leverage on futures.
Go to models/Position.py and replace L89 by :
return self.entry_price * abs(self.qty) / 1
Fixed thanks to @discohead