Closed sirhc78 closed 6 years ago
First I am surprised to see : Successfully installed backtrader-1.9.65.122 and not version 1.9.66.122
Don't be. Although I'm trying to keep this project in sync with main backtrader it can be not in sync from time to time.
Then, I tried to run a previous script and get this error quickly:
Looks like a bug to me. Thanks for pointing it out.
Can you try if this commit fixes it for you?
Can you try if this commit fixes it for you?
Now getting this error :
File "D:\Dev2\Anaconda3\lib\site-packages\backtrader\brokers\ccxtbroker.py", line 43, in __init__
self.store = CCXTStore.get_store(exchange, config, retries)
File "D:\Dev2\Anaconda3\lib\site-packages\backtrader\stores\ccxtstore.py", line 87, in get_store
(exchange, store_conf))
ValueError: bitmex exchange is already configured: {'apiKey': '***', 'secret': ''}
I mean it seems to be the expected behavior.
That's normal. You're trying to configure the same exchange (bitmex) with different configs. It was possible before this issue was fixed, but not anymore. Try to use the same config for a feed and a broker. That should help.
same config but it still try to add twice the same config ?
broker_config = {'apiKey': '***',
'secret': '***',
'urls': {'api': 'https://testnet.bitmex.com'},
'enableRateLimit': True,
'rateLimit': 15000,
}
data = bt.feeds.CCXT(exchange="bitmex", symbol="BTC/USD",fromdate=datetime.utcnow()+timedelta(minutes=-4),
timeframe=bt.TimeFrame.Minutes,compression=1, config=**broker_config**,backfill_start=True)# ,todate=datetime(2018, 9, 6)
broker = bt.brokers.CCXTBroker(exchange='bitmex',
currency='Xbt',
config=**broker_config**)
cerebro.setbroker(broker)
cerebro.adddata(data)
Result
File "D:/Dev2/Dev/Jim/test/testBacktrader.py", line 83, in <module>
timeframe=bt.TimeFrame.Minutes,compression=1, config=broker_config,backfill_start=True)# ,todate=datetime(2018, 9, 6)
File "D:\Dev2\Anaconda3\lib\site-packages\backtrader\metabase.py", line 88, in __call__
_obj, args, kwargs = cls.doinit(_obj, *args, **kwargs)
File "D:\Dev2\Anaconda3\lib\site-packages\backtrader\metabase.py", line 78, in doinit
_obj.__init__(*args, **kwargs)
File "D:\Dev2\Anaconda3\lib\site-packages\backtrader\feeds\ccxt.py", line 64, in __init__
self.store = CCXTStore.get_store(exchange, config, retries)
File "D:\Dev2\Anaconda3\lib\site-packages\backtrader\stores\ccxtstore.py", line 87, in get_store
(exchange, store_conf))
ValueError: bitmex exchange is already configured: {'apiKey': '***', 'secret': ''}
Works for me just fine with this code:
cerebro = bt.Cerebro()
broker_config = {'apiKey': '***',
'secret': '***',
'urls': {'api': 'https://testnet.bitmex.com'},
'enableRateLimit': True,
'rateLimit': 15000,
}
data = bt.feeds.CCXT(exchange="bitmex", symbol="BTC/USD",fromdate=datetime.utcnow()+timedelta(minutes=-4),
timeframe=bt.TimeFrame.Minutes,compression=1, config=broker_config, backfill_start=True)# ,todate=datetime(2018, 9, 6)
broker = bt.brokers.CCXTBroker(exchange='bitmex',
currency='Xbt',
config=broker_config)
cerebro.setbroker(broker)
cerebro.adddata(data)
btw, looking at the line from your traceback
File "D:/Dev2/Dev/Jim/test/testBacktrader.py", line 83, in <module>
timeframe=bt.TimeFrame.Minutes,compression=1, config=broker_config,backfill_start=True)# ,todate=datetime(2018, 9, 6)
I'd say that you didn't show all your code. It breaks at adding the feed, where exchange is not configured yet. In your case it's already configured, so there was something that configured exchange before creating the feed. You didn't show that in your sample.
You are right. This is wierd. My code is a script I run on Spyder. I cleared all previous variables. And now it works correctly. Thank you.
Hi, I decided to get last vesion of Backtrader@ccxt and install it again with pip install git+https://github.com/bartosh/backtrader.git@ccxt
First I am surprised to see : Successfully installed backtrader-1.9.65.122
and not version 1.9.66.122 Edit : ok this is normal.
Then, I tried to run a previous script and get this error quickly:
My settings are :