cjol / Algo-Trading

An algorithmic trading game.
0 stars 0 forks source link

OrderBook Time Management #3

Open cjol opened 10 years ago

cjol commented 10 years ago

When we last discussed this, we made the decision that only the MarketView would keep track of the current time. StockHandle objects have a method "getOrderBookAtTime" which suggests that OrderBooks do have a time-dependent state. I'm now implementing MarketView's tick method, which iterates through outstanding trades and tries to get an update on their status from the OrderBooks. To do that, the OrderBook needs to go through all trades since the last update - it seems to me, then, that OrderBooks need to know the current simulation time.

AdamGleave commented 10 years ago

Thanks for raising this issue :) You're right, we didn't consider all the implications of making OrderBook's time-dependent at the meeting.

My understanding of what we were discussing is that each OrderBook knows the time it was last updated, but has no concept of simulation time. So if we lose interest in a stock, the OrderBook might never again be updated (or, indeed, be accessed at all) so it would fall behind simulation time. For OrderBook's of stocks where there is an outstanding trade, they would have to be updated at each tick, so moving in lockstep.

tl;dr: OrderBook has last updated time <= market simulation time

cjol commented 10 years ago

Alright, that changes a few other things then - we need to keep track of "open" OrderBooks which have been touched by the user, so that we can return that open book rather than open a new one (which wouldn't have any of the user's actions reflected in). I guess we can do that in MarketView's getOrderBook(StockHandle s) method.