Require symbols for only Futures category

sdhariwal_2211
Hi, I'm working on automating my trades in the futures segment.
One of the key things required for placing order is the exact trading symbol. For that I plan to use the "instruments" API for retrieving the complete list of data and searching through it based on the company initials.
One issue I see is that the instruments API gives complete data for NFO that includes both Futures and Options segment. This is a big database and is making my execution slow as with every trade getting the complete data and searching through it for particular symbol takes lot of time.
I would have wanted the API instruments to have "instrument_type" as an argument too so that it could retrieve only the "FUT" segment data. This would have significantly reduced the amount of data and the corresponding retrieval and search time.
Please can this be provided quickly or some alternate mechanism suggested for resolving my requirement.
  • sdhariwal_2211
    Additionally it would be good to have the company name in the data dictionary as well. The trading symbol only has partial name or initials of the company. With company name in the dictionary it would become easier to search.
  • sujith
    It is a huge file, you can fetch the file once in a day for NFO exchange and store it at your end by filtering by segment NFO-FUT.
    Use that cache as the source.
    The instruments file will only change once in a day.
    Additionally it would be good to have the company name in the data dictionary as well. The trading symbol only has partial name or initials of the company. With company name in the dictionary it would become easier to search.
    We will look into this.
  • sdhariwal_2211
    Can you elaborate on how to store in the cache? Do you mean any global variable? I'm a just a week into Python, any pointers would help.
  • zartimus
    zartimus edited September 2018
    @sdhariwal_2211 something like this

    # curl -O "https://api.kite.trade/instruments/NFO" -H "X-Kite-Version: 3" -H "Authorization: token api_key:access_token"
    import csv

    exchange_map = {}
    with open('NFO', 'r') as csv_file:
    csv_reader = csv.DictReader(csv_file, delimiter=",")
    for row in csv_reader:
    if row["segment"] == "NFO-FUT":
    exchange_map["%s:%s" % (row["tradingsymbol"], row["exchange"])] = row

    if __name__ == "__main__":
    assert exchange_map["INDIANB18OCTFUT:NFO"]["exchange_token"] == "49020"
    or maybe use redis as cache store
  • sdhariwal_2211
    Thanks Zartimus. Yes figured out quite similar method after bit of digging up. Although instead of taking the csv from KiteCOnnect I downloaded it from the NSE website. That had both company name and stock code as well as the lot size.
    Additionally realized that for futures trade the month has to be appended to the symbol too.
    Thanks for the suggestion of Redis will check and give it a go.
Sign In or Register to comment.