Backtrader Issues & What's wrong with these tactics?



  • Backtrader Question

    How to model "real" trading environment?

    1. For forex using Oanda as broker.. How do I realistically model slippage? Is there a best practice or "known" slippage parameters that I should be using?

    2. Completely noob question - For forex using Oanda as broker.. How do I realistically model commission on Cerebro? (I know the spread is built-in, which I get through the feed)

    3. Is there a way to tell (in next() or another predefined method) if the end of the data feed has been reached?

    4. Suppose i have a datafeed that I use pandas to resample in 1 minute time frame. And because of volume issues, instead of using cerebro.resampledata(), i want to use pandas to resample to 3 minute time frame. Do I need to pass this pandas resampled data by calling cerebro.resampledata() or cerebro.adddata()? And what timeframe/compression timeframe parameter do I need to add (since it's already resampled in pandas)? Is it bt.TimeFrame.Minutes / 3?

    General trading question

    1. Is "averaging" ask/bid data to tweak algo problematic?

    Currently, im taking the average (ask + bid / 2) to calculate OHLC for both price and via pandas. What is the fundamental problem with using the average to write your algo? I would think that it might be smarter to calculate long entry position based on ask price & volume... and short position on bid price / volume, but this would mean keeping "two" copies of data stream

    1. What are known problems using stop limit orders to minimize slippage, other than missing out on potential orders in markets with low volume and fast moving markets? THe only thing I would guess is that creating the stop limit order "gives" hints to the broker... who might be using it against you if their not None-Dealing-Desk broker.

  • administrators

    @Taewoo-Kim said in Backtrader Issues & What's wrong with these tactics?:

    1. Completely noob question - For forex using Oanda as broker.. How do I realistically model commission on Cerebro? (I know the spread is built-in, which I get through the feed)

    You cannot. As you point out: it is built in the spread. There is no way to separate it in real life and there cannot therefore be a way to simulate that.

    1. Is there a way to tell (in next() or another predefined method) if the end of the data feed has been reached?

    Your strategy will stop calling next and will call stop

    1. Suppose i have a datafeed that I use pandas to resample in 1 minute time frame. And because of volume issues, instead of using cerebro.resampledata(), i want to use pandas to resample to 3 minute time frame. Do I need to pass this pandas resampled data by calling cerebro.resampledata() or cerebro.adddata()? And what timeframe/compression timeframe parameter do I need to add (since it's already resampled in pandas)? Is it bt.TimeFrame.Minutes / 3?

    If you don't want to resample in backtrader, don't use resampledata, which means you use adddata. You should tell the platform that your data has a combination of Minutes and 3

    Currently, im taking the average (ask + bid / 2) to calculate OHLC for both price and via pandas. What is the fundamental problem with using the average to write your algo? I would think that it might be smarter to calculate long entry position based on ask price & volume... and short position on bid price / volume, but this would mean keeping "two" copies of data stream

    If your assumption about the slippage isn't that bad, using the MIDPOINT should be fine. Slippage will get you below/above the BID/ASK prices and therefore give you a good approximation.

    The only thing I would guess is that creating the stop limit order "gives" hints to the broker... who might be using it against you if their not None-Dealing-Desk broker.

    If you are worried about that, you should be operating with a different broker and probably a different market altogether.


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.