How do you string the historical data and the live data together? Nice to see that you are making a profit.
Basically, I ask IB to get historical data using https://interactivebrokers.github.io/tws-api/historical_bars.html, I load that up until I get to the live data and then switch over. However, I can do a backtest while this is going on in a different process using IB gateway. Something is definitely fishy. No idea what yet
The tricky bit is in finding how to string the historical bars and the live market data together. You need to find out the "close" value of the most recent historical bar (assuming that is what you need). And the time of the live market data. And see how they add together. Be aware that historical bars include a bar for the period which is currently ongoing. I mean with this: if you request hourly bars and it is currently 11:45AM you will receive as most recent bar a bar with opening at 11:00AM and closing at 11:45AM (with the high and low of this 45 minutes). If you then string this together with a live market price of 11:45AM you might end up with double price data.
In my journal I explain that I am in the process of scaling my trading account to a size sufficiently large to create enough profit to pay for my costs of living. But automated trading remains a hobby. Until now am I paying the bills with revenues from other, more traditional, investments.
Journal entry Week of March 25 Profit (before commission): 334.5 Profit (after commission): -145.85 I would say this is as close to a "hands off" week as I've gotten so far. Unfortunately, it wasn't hands off because on Thursday I shut it down after data stopped coming through as I had assumed forex wouldn't be trading on Thursday/Friday. Turns out, this wasn't true (i.e., there was a data issue) so I restarted it part way through Friday. That isn't nearly as important as the new knowledge that the backtest bars are not matching the live bars. I have my suspicions as to why this is occurring: I am resampling the data while backtesting and trading live and the resampling may be too rigid but I haven't confirmed it. Things I need to get in place before trading this week: 1. Set up a good till cancelled time of t+30 seconds. If I don't get the price in 30 seconds, I don't want the trade. 2. Set up a order reference using IB's API so I can correlate trades if needed. 3. See if I can disable the resampling so that there is no possibility of data fudging in live or backtest. 4. See if after disabling the resampling, the strategy is still profitable.
Can't edit my old post so I will just update: * I have set up the valid-until t+30 seconds order * Disabled resampling to see if it makes a difference having backtests match live trading * Strategy is still profitable, after disabling resampling, and modelling comissions. One thing I noticed was that my stop loss was wrong (eep). This explains a lot. I have fixed the stop loss as well. Let's see how this week goes.
Had a nice signal today: Received signal, entering trade Price=1.29079> Order updated Order 1 Buy 1000000 1.2903 Submitted Price=1.29079> Ref: 1' Price=1.29079> Order updated' Price=1.29079> Order 2 Sell -1000000 None Submitted' Price=1.29079> Ref: 2' Did it fill? Nope. Did it cancel in 30 seconds? Nope. Had to go in and manually cancel. Wonderful.
Well-meant piece of advice: solve this issue first before wading again in the discussion at ET's thread "Daytrading & Divorce.....". Don't let yourself get distracted.