Changing a particular trade to phantom

Posted By: Zheka

Changing a particular trade to phantom - 01/31/22 11:05

A system generated X trades across different assets and at the end of the run() I want to turn some of them Phantom (say, because the exposure to a particular asset would be above acceptable).

What would be the way of doing this in a for(open_trades) loop?

Posted By: jcl

Re: Changing a particular trade to phantom - 01/31/22 11:47

Calling the broker and begging him to cancel the over-exposed trade?
Posted By: Zheka

Re: Changing a particular trade to phantom - 01/31/22 12:19

soooo funny...

There are no 'overexposed' trades placed...yet...There could be some over-exposure, IF newly generated trades are placed - so I want to turn some of them phantom.

Regardless of a reason: what's the way to change a pending trade to phantom?
Posted By: DdlV

Re: Changing a particular trade to phantom - 01/31/22 19:19

Hi @Zheka,

I guess it depends on what you actually mean by "generated", "pending", "placed", etc.

It sounds like you're in a single Bar, correct? (I.e., you're not trying to do this on a later Bar after the trades were long ago entered & filled?)

So, don't enter a trade until you know whether you want it to be real or phantom.

Accumulate your "generated", "pending", desired trades in an array, and at the end of the run() spin through the array entering real or phantom as needed to "place" them correctly?

HTH.
Posted By: Zheka

Re: Changing a particular trade to phantom - 02/01/22 12:31

A "pending" trade is a "pending" trade. And there is a clear advantage of having "risk mngt" as a separate module, usable on top of any other existing system without having to modify it with parallel "order accumulation/ tracking mechanism"/arrays, etc.

The solution is simple : (ThisTrade->flags) |=TR_PHANTOM , but a "higher level interface" for doing this, e.g. via tradeUpdate(), would not harm.
Posted By: jcl

Re: Changing a particular trade to phantom - 02/01/22 15:16

If the trade is still pending, exit it and open a phantom trade instead.
Posted By: Zheka

Re: Changing a particular trade to phantom - 02/01/22 15:41

Why "exit - re-open", if simple setting of a flag works just fine?
Posted By: jcl

Re: Changing a particular trade to phantom - 02/02/22 10:23

Because I don't know if it works just fine, or will keep working just fine.
Posted By: Zheka

Re: Changing a particular trade to phantom - 02/02/22 12:03

Exiting / re-opening the trade with ALL the exact same parameters (except phantomness) is cumbersome.

Please provide a way of accomplishing this via tradeUpdate() (e.g with negative NewLots) or some other simple way.
© 2024 lite-C Forums