SmartQuant Discussion
http://www.smartquant.com/forums/

Reenter trade data if restart SQ?
http://www.smartquant.com/forums/viewtopic.php?f=42&t=5564
Page 1 of 1

Author:  Gary99 [ Thu May 10, 2007 6:00 pm ]
Post subject:  Reenter trade data if restart SQ?

This morning I had to restart SQ after having two active trades with IB. Of course the strategy didn’t know about the trades that had been previously started. Is there a way to enter in-progress trades into the strategy so it can pick up where it left off? I would like to be able to see the charts showing the time the stock was bought and at what price, etc. Then my internal state flags could be set to be accurate. Obviously I would want to be able to reenter the trade info WITHOUT executing the trade again.

Gary

Author:  Dr. Anton Fokin [ Thu May 10, 2007 7:02 pm ]
Post subject: 

You can navigate to Tools->Options and then set Persistent to true for Live mode. Then your orders and execution reports (as well as portfolio transactions) will be stored in the database and reloaded next time you run OQ.

Regards,
Anton

Author:  Gary99 [ Thu May 10, 2007 8:15 pm ]
Post subject: 

I double checked and I did have live mode set to Persist. But I see no affect from this setting. If I restart SQ and my strategy, how can I get back to the trades that were in progress? I am using OCA so there will be a stop-loss and profit-limit order “queued.�

I have my own log which I built into the strategy to document to a file the trade activity with timestamps. I guess I would want to somehow reissue these to the strategy WITHOUT them being sent for a second time to IB.

Hope that makes sense,

Gary

Author:  TickJob [ Wed Jul 11, 2007 11:59 am ]
Post subject: 

It is neccessary to have a clear documentation on what this Persistent does. These two days, every time I start to run my strategy, I get some orders filled. At first I don't know where these orders come from, later I guessed they might be sent out by the Persistent function.

Exactly what does Persistent do I have still no idea.

Author:  OnIslandTrader [ Fri Jun 06, 2008 6:37 am ]
Post subject: 

TickJob -- Do you preload data in your strategy?

Author:  warren631 [ Tue Dec 01, 2009 12:15 am ]
Post subject: 

Did anyone ever get a clear answer about what Persistent does? I have often wondered....

Author:  kkkwj [ Tue Dec 01, 2009 7:52 pm ]
Post subject: 

This is not a definitive answer, but it will probably help. The persistent flag helps OQ to reload the _state_ of the strategy positions, by (I think) reprocessing the original transactions much like a database does during rollback operations.

In a typical scenario, the strategy is not saving real time trades/bars either, so there is no way for OQ to display the original trade orders on the chart, because the chart starts fresh again on real time data at reboot time. (If you save trade/bar data during the run, and then preload all that same data on a new OQ reboot, maybe the original Persistent orders will be visible on the chart, I don't know because I've never done that.)

So after you reboot OQ after a crash/loss of communication, the strategy thinks it has a bunch of open positions. It will try to close them according to strategy rules, which is why you can suddenly see "weird" orders and positions show up after the reboot.

For example, the sequence I always fell into was: (1) strategy runs and opens a position, (2) loss of comm with TWS, (3) I would get scared and manually close out my TWS broker positions, (4) then I would reboot OQ (which under Persistent would pick up the open positions internally--but of course I had manually closed them at the broker, so OQ was out of step with reality, (5) OQ would close the positions according to my strategy rules, and by "closing" them internally, it would actually open them at the broker, (6) I would close them at the broker, and now the broker and OQ were back in sync.

I found the Persistent flag more trouble than it was worth, so I disable it now. For me, it's far easier and less stressful to just manually close the broker positions and start fresh again with a new OQ reboot. Trying to write code to get OQ and the broker back in sync after a random communication event is too much work and hassle for me, with all the problems of having to be sure that all the recovery code works perfectly.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/