RavirajDataEngineering / jbooktrader

Automatically exported from code.google.com/p/jbooktrader
0 stars 0 forks source link

Strategy may not rollover to new contract if jbook stays running through the volume crossover date #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

This is hard to test specifically, but I base this on code review of the 
makeContract relationship to Strategy.  If I understand it correctly, Strategy 
is not constructed each day, so a new contract selection is never made.  So, 
rules about new contracts during crossover are only executed when the Strategy 
is first constructed.

The fix would be to check and replace the contract info each day.

Original issue reported on code.google.com by mwillif...@gmail.com on 9 Jan 2013 at 9:28

GoogleCodeExporter commented 9 years ago
I suppose to switch contracts, the current contract might need to be 
automatically closed.  This presents a question, should it works this way, and 
then should it reopen the new position?  What do you think the right way to 
handle this business logic is?

Original comment by mwillif...@gmail.com on 9 Jan 2013 at 10:34

GoogleCodeExporter commented 9 years ago
JBookTrader is designed specifically for intraday-trading. That is, all current 
open contracts are closed by the end time specified in TradingSchedule.java. If 
the next day happens to be a rollover day, then the new front month contract 
should be traded. The needed code change is to check whether the front month 
has changed and to set the contract accordingly. This needs to happen after the 
close of the trading interval.

Original comment by eugene.k...@gmail.com on 9 Jan 2013 at 11:31

GoogleCodeExporter commented 9 years ago

Original comment by eugene.k...@gmail.com on 9 Jan 2013 at 11:31

GoogleCodeExporter commented 9 years ago

Original comment by mwillif...@gmail.com on 10 Jan 2013 at 5:06

GoogleCodeExporter commented 9 years ago

Original comment by mwillif...@gmail.com on 10 Jan 2013 at 5:07

GoogleCodeExporter commented 9 years ago
Added another call to TraderAssistant.createMarketBook(), which switches on 
crossover this data structure as well now.  I see there IS a lot of complexity 
and lifecycle of objects with respect to how/when they are all created.  I 
suspect my solution leaves the old MarketBook structure in memory, in the 
marketBooks collection, etc.  However, it is too risky at the moment to remove 
the old MarketBook, because another strategy might still be trading it (even 
though crossover occurs, it's trading hours might still be ongoing).  

I renamed the class to: CLNYMEXMostLiquid, as it is really only good for CL

Testing:
-  I tested crossover, by forcing a crossover right away with test code, it 
worked.  At least the new marketBook was created, and started writting to the 
filesystem.

Let me know if you have any other testing ideas.

Original comment by mwillif...@gmail.com on 11 Jan 2013 at 6:42