Anyone use backtrader to do live trading on Bitcoin exchange?
sirhc last edited by
Definitively coming to the same conclusion and probably the same solution or a solution using a smart ratelimiter.
But If we don't need those broker values intensively, we can cheat.
You can check my thought here : https://github.com/bartosh/backtrader/issues/22
Even for getposition(). A strategy can store and update his own size with orders notifications.
monejava last edited by
First of all thanks @Ed-Bartosh for implementing the CCXT broker.
I was wandering what is the official repo for this and if there is any plan to contribute this back to backtrader or to develop as a standalone module that people could use.
I'm starting to use it, and I'd be happy to contribute to it but so far the only thing I have found is this fork: https://github.com/bartosh/backtrader/tree/ccxt
Sandro Böhme last edited by
I think the most up to date repo is this one:
Thanks @sandro-böhme , the repo that you mention seems to be the latest one and is working fine with Binance as per my testings. I have a question in regards to the order status. I do place orders correctly and can see the order status in the dashboard. However, in the notify_order() when it comes to printing exections details like :
It always prints 0 for all 3 values, I am not sure why I cant see the order execution details. Does it work for you? Also, is there anyone actively looking at fixing the reported issues?
Noh last edited by Noh
Hey, Im having a problem when trying to run the following code.
I get the error: AttributeError: module 'backtrader.feeds' has no attribute 'CCXT'
I'm running the latest version of python on the latest version of ubuntu and when I check pip3 freeze, I have backtrader and ccxt installed.
import backtrader as bt
import pandas as pd
def init(self, client, timeframe='5m'):
self.client = client
self.timeframe = timeframe
def getSignal(self): cerebro = bt.Cerebro() data = bt.feeds.CCXT(exchange='bitmex', symbol='BTC/USD', timeframe=bt.TimeFrame.Minutes, compression=1) cerebro.addstrategy(bt.Strategy) cerebro.adddata(data) print(data) cerebro.run() cerebro.plot(style="candlesticks")
any help would be appreciated
@noh I did have a similar issue which resolved it. You need to make sure to create a new environment with correct version of the BT fork for CCXT. See below the steps I followed to fix my issue:
conda create --name New-env
source activate New-env
conda install -c anaconda git
pip install ccxt
pip install git+https://github.com/Dave-Vallance/bt-ccxt-store.git
This should resolve your issue.
I published a simple example with Binance integration: https://github.com/rodrigo-brito/backtrader-binance-bot
@rodrigo-brito This looks great thanks for sharing!
CooleRnax last edited by
how do you achieve data persistence between restarts?
@coolernax I don't persist the feed or strategies positions. The feed loads a delayed history when started. About the trade position, I'm start always with no funds in crypto, the first operation should be a buy. Maybe it can be improved with a simple flag in the script.
- When running your script in live mode does the notify_order() return correct order details? when i place order I am unable to get filled price back from order.executed.price,order.executed.value,order.executed.comm all the fileds returning 0. Is this something that anyone looking at fixing?
- How stable do you think the CCXT Live broker for BT is at the moment? Do you have high confidence in it's stability? Are you running it live?
- Also, the Dave-wallace fork seems to have a new function self.getposition() whch does not seem to work for Binance as i receive empty object where I should get a list of my open positions.
- I have the same issue in
notify_order(), it works only in simulations to me.
- I think the fork has a lot of issues, but work very well for the main features, like order and feed.
- The get positions does not work for me very well, it has a precision issue. I'm using a function to get my wallet ballance and settting a custom sizer. I'm also defining a global variable with the last operation (BUY/SELL) to control the next operation. It is a working arrond, but working in live.
- I have the same issue in