hi Sujit i tried calculating running m2m for live positions every second using this formula pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
Convert.ToDouble((item.SellValue - item.BuyValue) + (item.Quantity * item.LastPrice * item.Multiplier)); here is code snip /* here item refers to position data
yes it works with that, but logically it should fatch correct lastprice as well with position API... even PNL also should have calculated in position API itself .. jsut an suggestion .. simply need to make extra call
but app need to sync with running positions right .. else how do we know that what all positions are running... before calling placeorder method ..i need to check weather order already exist with same script or not ... hence i need to check positions regularly .. and PNL i need to because based on latest PNL value i do square off all positions if meet my Max PNL conditions you can suggest better way to do this without calling position API regularly.. even i want to reduce this call
Positions only update when one places an order or modifies or when one gets an order update. One can fetch positions and cache it locally and keep updating the P&L using the last price fetched from Websockets API. An optimized solution is to fetch positions only in case of the above-mentioned events.
here is code snip
/* here item refers to position data
simply need to make extra call
you can suggest better way to do this without calling position API regularly.. even i want to reduce this call
One can fetch positions and cache it locally and keep updating the P&L using the last price fetched from Websockets API.
An optimized solution is to fetch positions only in case of the above-mentioned events.