How to manage a combination of assets in scripts?

Posted By: mhdus

How to manage a combination of assets in scripts? - 03/09/18 10:23

I know it is on the list of future features: "Artificial assets from a linear combination of real assets, for basket trading or multi-asset arbitrage." but I wonder how to best approach this in scripts while Zorro does not have the feature yet?
In particular for option strategies this is an important topic. E. g. how to manage a "short strangle" (combination of short put and short call) as a single position (or "trade", in Zorro terms) with e. g. a combined profit target and combined stop loss? TMFs appear only partially useful as they are focused on the individual trade, so they could only serve as input for a separate logic managing the combined positions, I believe. So I wonder if one would e. g. have to define a dedicated STRUCT CombinedAsset with some position-related parameters such as CombinedProfit etc. and a list of pointers to the individual trades, and then using individual TMFs to feed/update these structs? Or are there better/alternative approaches?
I'd appreciate any experience/ideas shared around this topic... thanks!
Or to avoid unnecessary work: @jcl, any timelines by when the artificial assets feature might be built into Zorro?
Posted By: Brax

Re: How to manage a combination of assets in scripts? - 03/09/18 12:35

AFAIK there is a library to code option strategies <contract.h>, you can find more info in the following links:

http://www.financial-hacker.com/algorithmic-options-trading/
http://www.financial-hacker.com/algorithmic-options-trading-2/
http://www.financial-hacker.com/algorithmic-options-trading-part-3/

If you search on the forum you'll find some more questions relating to options trading. I can't further help you as i haven't done any research with options trading yet.

Hope it helps.
Posted By: mhdus

Re: How to manage a combination of assets in scripts? - 03/09/18 12:50

Thank you. In fact I'm well aware of the options-specific functions. However, the topic of "artifical" (=combined) assets is not covered. In fact it is not an options-specific topic as such, it just happens to be quite important in the context of options trading. Also the options-related articles on FH are not helping in this direction as the topic of combined positions is not touched (or only very rudimentary in the way the margin is calculated).
Posted By: Zheka

Re: How to manage a combination of assets in scripts? - 03/09/18 14:32

As long as a Straddle/Spread is not bought/sold as a single instrument to begin with, you will not escape handling each leg separately and "adding" them for CombinedProfit,etc
Whether Zorro does this under the hood or you do in the script, the steps will be more or less the same.
Your approach looks sound.
Posted By: mhdus

Re: How to manage a combination of assets in scripts? - 03/09/18 19:43

What do you mean by "bought/sold as a single instrument to begin with"? I know how to do that manually in TWS - but I would have never thought this is possible via the API... thanks for the suggestion! It appears to be possible indeed. Unfortunetaly it is somewhat beyond my Zorro/IB-Bridge skills to translate these code samples into the Zorro environment - if possible at all?
If not: @jcl, would that be something that could be added to Zorro with significantly less effort than a full-blown solution for artificial assets managed internally by Zorro?
Posted By: Zheka

Re: How to manage a combination of assets in scripts? - 03/09/18 21:13

There is no saving on commission with IB when you trade a "combo" instrument.
So, unless your strategy really, really requires perfect synchronisation of legs, you gain no benefit trading e.g.a straddle in one go, except for some simpler position handling.
However, with options it is better to execute "bargaining" within the spread (with limit orders) - so pricing/executing the whole combo at once can be faster/better synced than working 2-3 separate leg orders.
Supporting combo orders in a plug-in should not be difficult.
Lets organize a small riot to kindly ask for improvements to the current IB plug-in (both speed and features). smile
Posted By: AndrewAMD

Re: How to manage a combination of assets in scripts? - 03/09/18 22:26

Originally Posted By: Zheka
Supporting combo orders in a plug-in should not be difficult.
Side note: the DTC protocol does not support combo options orders, but the Ally plugin does.
Posted By: Zheka

Re: How to manage a combination of assets in scripts? - 03/10/18 09:48

Quote:
the DTC protocol does not support combo options orders
Unfortunately. I was going to say that we can wait for your DTC plug-in but then realised DTC would most probably not support such things, unless it is an exchange-traded spread(which are e.g. very actively traded in energies).
Posted By: AndrewAMD

Re: How to manage a combination of assets in scripts? - 03/10/18 17:31

Spreads are only explicitly supported by DTC if the broker supplies a symbol for it (such as CQG). Otherwise, you have to manually construct the asset using a sequence of orders.
© 2024 lite-C Forums