Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Margin Calculator in Python

    General Discussion
    0
    1
    6
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Deepak8052 last edited by

      Hi, Can someone help me share the code of the Margin calculator I tried the one shared on https://smartapi.angelbroking.com/docs/MarginCalculator but it's not working for me.
      Below is the code:
      import http.client

      conn = http.client.HTTPSConnection("apiconnect.angelbroking.com")
      payload = "{\n" +
      " "positions": [\n" +
      " {\n" +
      " "exchange": "NFO",\n" +
      " "qty": 50,\n" +
      " "price": 0,\n" +
      " "productType": "INTRADAY",\n" +
      " "token": "67300",\n" +
      " "tradeType": "BUY"\n" +
      " },\n" +
      " {\n" +
      " "exchange": "NFO",\n" +
      " "qty": 50,\n" +
      " "price": 0,\n" +
      " "productType": "INTRADAY",\n" +
      " "token": "67308",\n" +
      " "tradeType": "SELL"\n" +
      " }\n" +
      " ]\n" +
      "}"
      headers = {
      'X-PrivateKey': 'API_KEY',
      'Accept': 'application/json',
      'X-SourceID': 'WEB',
      'X-ClientLocalIP': 'CLIENT_LOCAL_IP',
      'X-ClientPublicIP': 'CLIENT_PUBLIC_IP',
      'X-MACAddress': 'MAC_ADDRESS',
      'X-UserType': 'USER',
      'Authorization': 'Bearer AUTHORIZATION_TOKEN',
      'Accept': 'application/json',
      'X-SourceID': 'WEB',
      'Content-Type': 'application/json'
      }
      conn.request("POST", "/rest/secure/angelbroking/margin/v1/batch", payload, headers)
      res = conn.getresponse()
      data = res.read()
      print(data.decode("utf-8"))

      pls help me out.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post