
My strategy need the unrealized PL of my trades to decide take profit or stop loss.
I checked the tech doc a few times but still can't find related implementation details.
Anyone know what is the API function??
Original Posted by - b'Ultraman': Seems no such API yet.You can simply calculate using this formula: PL = Position*(market price - open price)
We are pleased to announce that this feature has been newly implemented on the platform!
For more details, please refer to the Technical Documentation: Tech Doc.
For instance, if you are utilizing a pair trading strategy that assigns a unique order reference to each pair, you can calculate the total profit and loss (PL) of a specific pair as follows:
def on_marketdatafeed(self, md, ab): pl = 0 myRef = "XXX" _, orders, _ = self.evt.getSystemOrders() for tradeID in orders: if orders[tradeID]['orderRef']==myRef: pl+=orders[tradeID]['pl'] self.evt.consoleLog('my pair trades pl is ',pl)