Dave-Vallance / bt-ccxt-store

Fork of Ed Bartosh's CCXT Store Work
MIT License
422 stars 185 forks source link

Plotting issues #22

Closed obiben closed 4 years ago

obiben commented 4 years ago

I can't figure out what needs to be done for trades to show up on plot, as well as cash balance. My strategies execute fine, for now my backend autofills any order at current bid/ask:

def fill(order):
    if 'trades' not in order:
        order['trades'] = []

    order['original_amount'] = order['quantity']
    order['executed_amount'] = order['quantity']
    order['remaining_amount'] = 0
    try:
        order['cost'] = int(order['quantity']) * float(order['price'])
    except:
        pass

    try:
        fee = int(order['quantity']) * 0.0005
    except:
        fee = 0.0

    order['trades'].append({
        'order_id': order['order_id'],
        'market': order['symbol'],
        'side': order['side'],
        'price': order['price'],
        'quantity': order['quantity'],
        'timestamp': time.time(),
        'fee_amount': fee,
        'fee_currency': 'CAD'
    })

Positions seem to update fine - I'm buying and selling according to position.

But when I stop the strategy, I can see my data feeds, signals and a flat line for account balance (at the number of the balance at the start) and no buy/sell markets on the feed.

Is it just that that's not supported?

obiben commented 4 years ago

I guess those are mostly questions for backtrader leading to a pull request here.

Dave-Vallance commented 4 years ago

Closing - merged the plotting enhancements. Let me know if this should still be open. It has been a while since I looked at it.