For my bot I need the SPX backfill data. Why is it that the backfill for the SPX (for instance in the 1 min timeframe) has such a difference between the close value of the last bar and the open of the current bar? Which value is the most accurate? thanks
Are you using SPX data in your analysis? If so, don't. Only use data from a tradeable market. There is a real difference between results generated from SPX and those from SPY.
I don't know how often IB update their calculation of SPX, but some futures traders calculate a 'fast cash index" directly from the (properly weighted) components of the index. If you really want a truly accurate snapshot of the index you will need to do this. As pointed out above, if you are trading a derivative of SPX such as SPY or ES, then the major consideration must be the price pf the tradeable instrument eg SPY, though this is not to say that the cash index value may not be a valid input to the system. Likewise if you are trading stocks I can't see why in principle, the index value should not be used as a component of the system.