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

Dealing with Adjusted Close Data



  • Hi there,

    I would like to confirm how Backtrader deals with OHLC data.

    My data has "Open, High, Low, Close, Adj_Close".

    To do a performance backtest back through history, I should be analyzing returns against "Adj_Close".
    How can I specify this in Backtrader?

    Secondly, I understand backtrader uses "Open" data (and possibly High, Low..); do I need to adjust the "Open" data also to ensure I am correctly reporting returns and performance in general?

    Thank you!
    CWSE


  • administrators

    This has nothing to do with backtrader. Most people use adjusted data and some people don't.

    @cwse said in Dealing with Adjusted Close Data:

    Secondly, I understand backtrader uses "Open" data (and possibly High, Low..);

    backtrader uses what you tell it to use.

    @cwse said in Dealing with Adjusted Close Data:

    do I need to adjust the "Open" data also to ensure I am correctly reporting returns and performance in general?

    If you adjust the close, you should be adjusting every other value or else the data would be meaningless.

    @cwse said in Dealing with Adjusted Close Data:

    How can I specify this in Backtrader?

    If you are lucky and the columns are in the same order as the YahooFinanceCSVData you can use that one and try to let it adjust the values for you. Docs - Data Feeds Reference

    If not, you probably want to preprocess it beforehand or



  • Thanks @backtrader

    Shouldn't I be making buy/sell decisions form the raw "Close" / "Open" as traded on the day.... but measuring performance of returns against "Adj Close"?

    How would I consider these scenarios? I.e. both data sources.

    And how does backtrader use "Open" data by default?

    Thanks,
    CWSE


  • administrators

    @cwse said in Dealing with Adjusted Close Data:

    Shouldn't I be making buy/sell decisions form the raw "Close" / "Open" as traded on the day.... but measuring performance of returns against "Adj Close"?

    Today, the current close is the adjusted close. You may also make buy/sell decisions without taking into consideration splits and/or reverse splits and see what happens.

    @cwse said in Dealing with Adjusted Close Data:

    And how does backtrader use "Open" data by default?

    You probably have to elaborate on that. There is no specific usage of Open.



  • @backtrader said in Dealing with Adjusted Close Data:

    close is the adjusted close. You may also make buy/sell decisions without taking into consid

    Hi @Backtrader, my question centers on BACKtesting. So in the past the adj_close is very important.

    Also, I understood the "Open" price was used for limit orders? And stoploss/take profits.
    I.e. where you have an open order, and on a new trading day the open price causes the limit order to execute?

    Thanks,
    CWSE


  • administrators

    @cwse said in Dealing with Adjusted Close Data:

    Also, I understood the "Open" price was used for limit orders?

    The 1st incoming tick of the next price set is used for some operations. If you only have 1-tick the 4 components which make up a price bar (OHLC) will be equal. If your timeframe is larger than tick, the 4 components may (and will usually) have different values.

    The name open only indicates that this is the 1st price point in the bar.

    @cwse said in Dealing with Adjusted Close Data:

    I.e. where you have an open order, and on a new trading day the open price causes the limit order to execute?

    The entire OHLC range is used to determine if a Limit order will be executed