Shoonya-Dev / ShoonyaApi-py

141 stars 133 forks source link

Span Calculator not giving correct values #149

Closed RajasKhokle closed 4 months ago

RajasKhokle commented 7 months ago

The span_calculator does not work as explained in the test folder. Using the following I am trying to get the margin requirement for selling a strangle for Nifty 50 at 21000 PE and 22300 CE for 1 lot. The span calculator gives the output as follows {'request_time': '15:13:07 12-02-2024', 'stat': 'Ok', 'span': '273316.00', 'expo': '86359.80', 'span_trade': '273316.00', 'expo_trade': '86359.80'}. There is no way the span margin is 2.73 lakh and the exposure margin is 86.4 K. When I placed an order from the terminal, the margin blocked was ~1.25 lakh which seems correct. The span margin calculator is broken it seems or Maybe I am puttring wrong parameters.

Code:

positionlist = []
position1 = position()
position1.prd = 'M'
position1.exch = 'NFO'
position1.instname = 'OPTIDX'
position1.symname = 'NIFTY'
position1.exd = '15-FEB-2024'
position1.optt = 'PE'
position1.strprc = '21000'
position1.buyqty = '0'
position1.sellqty = '50'
position1.netqty = '-50'
positionlist.append(position1)

position2 = position()
position2.prd = 'H'
position2.exch = 'NFO'
position2.instname = 'OPTIDX'
position2.symname = 'NIFTY'
position2.exd = '15-FEB-2024'
position2.optt = 'CE'
position2.strprc = '22300'
position2.buyqty = '0'
position2.sellqty = '50'
position2.netqty = '-50'
positionlist.append(position2)

span_calculator = user_api.span_calculator(actid, positionlist)
rajas-soquiry commented 6 months ago

Still no support or solution

suresharni3 commented 5 months ago

position2.prd = 'H' CHANGE TO M

Shoonya-Dev commented 4 months ago

Greetings from Shoonya!

Please check your input parameters and run again; its working fine.