CME Lumber Changes

While I don’t typically actively trade Lumber Futures, I do track their prices. I recently was confused by a change to the symbol at Barchart.com from LS to LB.

I found this very helpful article about the change in the contract. Much more changed than just the symbol, the dimensions and other specifics about the contract changed as well.

https://www.lesprom.com/en/news/Everything_you_need_to_know_about_new_CME_lumber_futures_contract_107712/

The size of the contract is much smaller, from about a train car of lumber to a truck of lumber. Also the prices don’t really match up so this should be added as a new item and not spliced back into the old Lumber contract. This is a fairly substantial change.

Backtrader Testing vs Live Timeframe Considerations

I’ve been doing some backtesting using backtrader and then comparing that data with real trading on IBKR using the API.

I’ve attempted to make a profitable trading system using SPY or QQQ or other ETFs. I’ve found that the most profitable timeframe has been using 60 minute data.

One avenue that I’be been testing is using only certain times of the trading day for certain strategies. I’ve discovered that there is some nuance that is worth commenting on. One thing I discovered using 60 minute data was that using live trading, the “next” method isn’t called until a full hour has elapsed, after which the markets might actually be already closed. To fix this problem, I modified my code to use a smaller interval, say 2 minutes, to check for certain exit conditions while still using hourly data for any entrances.

When testing this in backtrader using historical data, I encountered some difficulty because of how the bars are labeled for time. The historical data has a timestamp at the beginning of the bar. For example, a timestamp of 10:00 on an hourly bar contains the data from 10:00 until 10:59:59.

This is different from the way that live data is handled by backtrader. In backtrader, the bar for 11:00:00 contains data from 10:00:00 until 11:00:00.

This difference caused problems for my testing logic until I added the interval (2 minutes for 2 minute data) to all of the timestamps in the dataframe prior to adding them to the backtrader engine.