Skip to content

Commit

Permalink
basket margin
Browse files Browse the repository at this point in the history
  • Loading branch information
JenishSiifl committed Jan 20, 2024
1 parent 79e9865 commit a8a4a80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion py5paisa/py5paisa.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ def order_request(self, req_type) -> None:
try:
self.payload["body"]["ClientCode"] = self.client_code
self.payload["head"]["key"] = self.USER_KEY
HEADERS["Authorization"] = f'Bearer {self.access_token}'
if self.access_token != "":
HEADERS["Authorization"] = f'Bearer {self.Jwt_token}'
else:
HEADERS["Authorization"] = f'Bearer {self.access_token}'
HEADERS["5Paisa-API-Uid"] = self.APIUID
if req_type == "OP":
url = self.ORDER_PLACEMENT_ROUTE
Expand Down Expand Up @@ -260,6 +263,8 @@ def order_request(self, req_type) -> None:
url = self.GETVTTORDER_ROUTE
elif req_type == "HVTT":
url = self.HISVTTORDER_ROUTE
elif req_type == "BMC":
url = self.BASKETMARGIN_ROUTE
else:
raise Exception("Invalid request type!")
res = self.session.post(url, json=self.payload,
Expand Down Expand Up @@ -692,6 +697,7 @@ def set_url(self):
self.MODVTTORDER_ROUTE = MODVTTORDER_ROUTE
self.GETVTTORDER_ROUTE = GETVTTORDER_ROUTE
self.HISVTTORDER_ROUTE = HISVTTORDER_ROUTE
self.BASKETMARGIN_ROUTE = BASKETMARGIN_ROUTE
except Exception as e:
log_response(e)

Expand Down Expand Up @@ -947,5 +953,14 @@ def vtt_order(self, order_type, **order):
except KeyError:
# Handle unknown order_type if needed
pass
except Exception as e:
log_response(e)

def basket_margin(self, BasketID: str,CoverPositions : str):
try:
if self.client_code != None:
self.payload["body"]["BasketID"] = BasketID
self.payload["body"]["CoverPositions"] = CoverPositions
return self.order_request("BMC")
except Exception as e:
log_response(e)
1 change: 1 addition & 0 deletions py5paisa/urlconst.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@
MODVTTORDER_ROUTE=f'{BaseUrl}ModifyVTTOrder'
GETVTTORDER_ROUTE=f'{BaseUrl}GetVTTOrder'
HISVTTORDER_ROUTE=f'{BaseUrl}GetHistoryVTTOrder'
BASKETMARGIN_ROUTE= f'{BaseUrl}PreOrdMarginCalculationBulkVendor'

0 comments on commit a8a4a80

Please sign in to comment.