Added Reload Persistence of Option Calcs
Tuesday, January 31st, 2012One of the things the traders have complained about in their testing this week has been that the values of the calculations change when we restart the servers. Well… yes, they do. We load up the instrument data, flush in the ticks, and then calc the results. If the prices have changed, and they will in after-hours and pre-hours trading, then the values you see at 8:00 am the ext morning are not the same as the ones you saw at 3:00 pm the night before. So it goes. The prices change, and I was thinking they'd want to see that.
Nope. Count not possibly have been more wrong.
OK, so what's the solution? Well… the easiest thing is just to not calculate the Option values outside of the trading day. The problem with that is: how do we get the last known good data back in after a reload or a restart? Ah… the plot thickens.
We don't want to save all the input values - that's just too much data. So let's just save the results. Thankfully, these are already confined in a simple object in the code, so that's all we have to deal with. Let's tackle the reload first. (In truth, I forgot about the restart at this point, and had to go back and put it in. Ick.)
Every morning, we drop all the instruments we have in memory and load them up from the local replica copy postgres database. It's a wonderfully efficient system we have built. So we load these guys up. If we're careful, and save off these option calculation results before we drop the instruments, and then re-apply them after the new instruments are loaded, then it'll appear that the values are persistent for all instruments that are in the reload.
Clearly, new instruments won't have any values, but they would not have had any the night before, either. Seems to be a reasonable trade-off. Not the ideal I'd like, but it's workable. I personally think it'd be better to look at those new instruments and see if they happen to have a last price in the database, and if so, then use that. But if it's really a new instrument, then we have to wait for ticks - there's just no two ways about it.
This took a good chunk of the afternoon for me to write up, but it tests out fine and should work OK too.