For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Anyone use backtrader to do live trading on Bitcoin exchange?

  • @thatblokedave
    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 :

    Even for getposition(). A strategy can store and update his own size with orders notifications.

  • Hi everyone,

    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:


  • 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 :
    self.log (order.executed.price,order.executed.value,order.executed.comm)

    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?


  • 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 ccxt
    import pandas as pd

    class Strategy():
    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)

    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+

    This should resolve your issue.

  • I published a simple example with Binance integration:

  • @rodrigo-brito This looks great thanks for sharing!

  • @rodrigo-brito
    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.

  • @rodrigo-brito -

    1. 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?
    2. 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?
    3. 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.

  • Hi, @pfederra

    1. I have the same issue in notify_order(), it works only in simulations to me.
    2. I think the fork has a lot of issues, but work very well for the main features, like order and feed.
    3. 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.