Broker / Zorro position synchronization

Posted By: AndrewAMD

Broker / Zorro position synchronization - 07/26/19 14:13

I have some questions about synchronizing Zorro's phantom trade position, pool position, and broker position.

This is for a stock trading system, NFA mode with Hedge = 5.

Allow me to propose some scenarios. My question for each is how to synchronize all of the positions? Assume we are talking about a single stock, say AAPL.

#1 - Broker position is 0, phantom trades are at +10, pool trade are at +10. I should cancel all open trades, including phantom and pool, correct?

#2 - Broker position is +10, phantom trades are at 0, pool trades are at 0. Is there some way I can inject a "trade", which when opened sends nothing to the broker, but when closed will actually close my position? So that it could be +10 +10 +10, and then closing the injected phantom trade will bring it all to 0 0 0.
Posted By: SBGuy

Re: Broker / Zorro position synchronization - 07/26/19 15:25

Sounds like we have a similar problem :-)

I haven't quite solve it yet but will work on it soon. My current thought is this:

- enter the trade as a phantom trade, so it is tracked inside Zorro
- when Zorro exits this trade, I would send a special brokerCommand to my custom broker plugin to close the trade.

My specific senario is when a short put is assigned by the broker, I want to track and close it as a long stock, under a long stock TMF.

I'm look forward to seeing other responses
Posted By: AndrewAMD

Re: Broker / Zorro position synchronization - 07/26/19 16:52

If your plugin is NFA, there is no need for a special brokerCommand. In that case, BrokerBuy2 is being used to change your position from A to B.

Anyways, my question is about Zorro scripting.

Question #3: I see that LotsPool is read-only. How often is it updated? Is there a way to force this value to update?

Question #4: On that note, how exactly does Zorro calculate the size of its pool? I don't suppose it iterates through the trade structs in some fashion?
Posted By: Petra

Re: Broker / Zorro position synchronization - 07/27/19 09:32

I think for 1 yes, cancel the trades. For killing a broker position I would enter a short position and then also cancel both trades.
Posted By: AndrewAMD

Re: Broker / Zorro position synchronization - 07/27/19 17:08

Originally Posted by Petra
I think for 1 yes, cancel the trades. For killing a broker position I would enter a short position and then also cancel both trades.

But which trades?

#5) If I only cancel the phantom trades and not the pool trades, what happens?
#6) If I only cancel the pool trades and not the phantom trades, what happens?
#7) If I only cancel both the pool trades and the phantom trades, what happens?
© 2024 lite-C Forums