Unable to convert position
-
-- coding: utf-8 --
"""
Angel One - placing order basics@author: Sourabh Chopra
"""from smartapi import SmartConnect
import os
import urllib
import json
from pyotp import TOTP
import pandas as pdkey_path = r"C:\Users\Chopras\Documents\Trading\Angelone\userdetail"
os.chdir(key_path)key_secret = open("key.txt","r").read().split()
obj=SmartConnect(api_key=key_secret[0])
data = obj.generateSession(key_secret[2],key_secret[3],TOTP(key_secret[4]).now())
feed_token = obj.getfeedToken()instrument_url = "https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json"
response = urllib.request.urlopen(instrument_url)
instrument_list = json.loads(response.read())def token_lookup(ticker, instrument_list, exchange="NSE"):
for instrument in instrument_list:
if instrument["name"] == ticker and instrument["exch_seg"] == exchange and instrument["symbol"].split('-')[-1] == "EQ":
return instrument["token"]def convert_intraday_order(instrument_list,ticker,quantity,price):
params = {
"exchange": "NSE",
"symboltoken": "2885",
"producttype": "DELIVERY",
"newproducttype": "INTRADAY",
"tradingsymbol": "RELIANCE-EQ",
"symbolname": "RELIANCE",
"instrumenttype": "",
"priceden": "1",
"pricenum": "1",
"genden": "1",
"gennum": "1",
"precision": "2",
"multiplier": "-1",
"boardlotsize": "1",
"buyqty": "1",
"sellqty": "0",
"buyamount": "2235.80",
"sellamount": "0",
"transactiontype": "BUY",
"quantity": 1,
"type": "DAY"
}
response = obj.convertPosition(params)
return response
convert_intraday_order(instrument_list,"JBMA",26,762) -
@admin request you to please help as this is giving unknown error