OpenApi-5p / py5paisa

Official Python SDK for 5paisa APIs natively written in VB .NET
https://5paisa.github.io
92 stars 68 forks source link

Scripwise Average buy rate is not available in holding details #53

Open smit-s opened 3 years ago

smit-s commented 3 years ago

Description

Hi, there The api response of endpoint to fetch holding details does not provide average buy rate for a scrip. Is it possible to provide average Buy rate?

rishabhmaniyar commented 3 years ago

@smit-s will get this checked again

qalpesh commented 3 years ago

client.order_book() above code will return you order book as dictionary and you can filter out particular order based on ExchOrderID. 'Rate' in this dictionary is nothing but executed or average price (see below e.g. avg price is 144.5).

{'AHProcess': 'N', 'AfterHours': 'N', 'AtMarket': 'N', 'BrokerOrderId': 497974510, 'BrokerOrderTime': '/Date(1627014607180+0530)/', 'BuySell': 'S', 'DelvIntra': 'I', 'DisClosedQty': 0, 'Exch': 'N', 'ExchOrderID': '1600000017582332', 'ExchOrderTime': '/Date(1627014607000+0530)/', 'ExchType': 'D', 'MarketLot': 2, 'OldorderQty': 0, 'OrderRequesterCode': '52808434 ', 'OrderStatus': 'Pending', 'OrderValidUpto': '23 Jul 2021', 'OrderValidity': 0, 'PendingQty': 50, 'Qty': 50, 'Rate': 144.5, 'Reason': '', 'RequestType': 'P', 'SLTriggerRate': 289, 'SLTriggered': 'N', 'SMOProfitRate': 0, 'SMOSLLimitRate': 0, 'SMOSLTriggerRate': 0, 'SMOTrailingSL': 0, 'ScripCode': 53599, 'ScripName': 'BANKNIFTY 29 Jul 2021 PE 34800.00', 'TerminalId': 33796, 'TradedQty': 0, 'WithSL': 'Y'}

smit-s commented 3 years ago

@qalpesh ok, but here there's an issue. Consider I buy some scrip at 1000 and on second day I again buy it at 1050 so, average cost of my holding will be 1025. This is what I a looking for. this is also available on 5paisa ui. So, i want avg buy rate of my holdings in client.holdings(). If not so, I will have to keep track of all rates of order and average by myself which might be error prone. So it would be great if you could provide this.