rodrigo-brito / backtrader-binance-bot

:money_with_wings: A example of bot using Backtrader to trade Bitcoins in Binance Exchange.
MIT License
265 stars 119 forks source link

broker mapping for Bitfinex #1

Closed planet-winter closed 5 years ago

planet-winter commented 5 years ago

Hi Rodrigo,

Thank you for your effort improving and enhancing Backtrader with ccxt!

would this be a valid broker mapping for Bitfinex?

    "broker_mapping": {
        "order_types": {  # https://docs.bitfinex.com/reference#rest-auth-new-order
             bt.Order.Market: 'exchange market',
             bt.Order.Limit: 'exchange limit',
             bt.Order.Stop: 'exchange stop',
             bt.Order.StopLimit: 'exchange stop-limit'
        },
        "mappings": {  # https://docs.bitfinex.com/reference#rest-auth-order-status
            'closed_order': {
                'key': 'is_live',
                'value': False
            },
            'canceled_order': {
                'key': 'is_cancelled',
                'value': True
            }
        }
    }

exchange stop-limit is not documented in the API guide but elsewhere.

rodrigo-brito commented 5 years ago

I do not test it for Bitfinex, i saw someone in backtrader forum changing the paremeter bt.Order.Stop: 'stop-loss' to bt.Order.Stop: 'stop'. But I don't now what is necessary for other parameters.

Maybe, you can found more informations in the ccxt official repository and examples: https://github.com/ccxt/ccxt/blob/master/examples/py/fetch-bitfinex-ohlcv-history.py

planet-winter commented 5 years ago

Thanks for your reply. I realize I got it all wrong. Will update when I have it all working.