Profile Picture

Realtime Hedge: OpenPosition() called form OrderFilled()

Posted By DrKoch 9 Years Ago

Realtime Hedge: OpenPosition() called form OrderFilled()

Message
Posted Monday January 14 2008
In order to get a realtime hedge I tried to open a short position whenever one of my long positions gets filled.

I placed an OpenPosition( ... Short ...) inside the OrderFilled() Event Handler.

BUT: it looks like RE ignores this OpenPosition() call. If I place exactly the same call somewhere outside the event handler (say in NewSymbolBar) everything works fine...

Any ideas?


www.finantic.de

Our Trading System at C2: Topaz
Posted Tuesday January 15 2008
Any hints?

(This one is urgent for me, its considered a show stopper today... Sad )


www.finantic.de

Our Trading System at C2: Topaz
Posted Tuesday January 15 2008
We've been putting our heads together on this one without coming to any conclusions yet.  One question I have though, are you saying that you're making the hedged call within NewSymbolBar or are you simply saying that if you call your method to hedge outside of OnOrderFilled it fails, but if you move the code within OnOrderFilled it works?
Posted Tuesday January 15 2008
I don't know why it would be ignoring the call.  Are you checking the return value to make sure the call was successful?

One workaround might be to wait until NewTick to hedge the position.  You could create a list of symbols that need hedge positions open.  When you get an OrderFilled event, add to the list.  In NewTick/NewBar, open a hedge position for each symbol in the list and then clear the list.

Daniel

Posted Tuesday January 15 2008
> are you saying that you're making the hedged call within NewSymbolBar or
> are you simply saying that if you call your method to hedge outside of OnOrderFilled it fails,
> but if you move the code within OnOrderFilled it works?

It is the other way round. If I put a straight OpenPosition() somewhere in NewSymbolBar() it works.
If I put exactly the same call inside OrderFilled() it is completely ignored.


www.finantic.de

Our Trading System at C2: Topaz
Posted Wednesday January 16 2008
> Are you checking the return value to make sure the call was successful?

Yes, OpenPositioon returns Success and a new position ID.
The OrderSubmitted() event gets called for this order, but there is never a fill.

If I move the exact same OpenPosition() to NewSymbolBar() I get fills...

(This is in backtest mode against PaperBroker)



www.finantic.de

Our Trading System at C2: Topaz
Posted Wednesday January 16 2008
DrKoch (1/16/2008)
>(This is in backtest mode against PaperBroker)

Oh, I had the impression this was in live mode.  My random intuitive guess is that the order is timing out before it has a chance to get filled.  Try submitting the order with a PositionOptions object with the BarsValid property set to 2.

Thanks,
Daniel

Posted Wednesday January 16 2008
> the order is timing out

This was it! Now it works Smile many, many thanks!


www.finantic.de

Our Trading System at C2: Topaz


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems