Recomended 'uniqueness' for instruments is currently being violated

skazazes
Hello,

I am setting up a local cache of the instruments list returned by the latest version of the python pykiteconnect client. This table will be updated daily.

In the note at the bottom of the instruments section here, the documentation recommends you to use a combination of the 'exchange' and 'tradingsymbol' fields in order to establish uniqueness of each returned instrument.

I have created a SQL database table to store the data, using the recommended fields in a UNIQUE constraint on the database table. When inserting the instruments into such a table, you currently hit a UNIQUE constraint violation between two rows for one of the instruments. Loading the instruments into a Pandas dataframe you can find the duplicate using the DataFrame.duplicated() method.

The offending rows:
instrument_token exchange_token tradingsymbol name expiry strike tick_size lot_size instrument_type segment exchange underlier_token
15728 240456196 939282 1025UCL25 0.0 0.01 1 EQ BSE BSE NaN
17747 249272580 973721 1025UCL25 0.0 0.01 1 EQ BSE BSE NaN
At the moment, this can seemingly be remedied by using the exchange_token field instead of the exchange field.

This has lead me to a few questions...

1. Will this remain as a valid solution?
2. Is the documentation's recommendation no longer valid? If so, it would be nice to update it for people in the future.

Thanks!
  • rakeshr
    combination of the 'exchange' and 'tradingsymbol' fields in order to establish uniqueness of each returned instrument
    eg: "BSE:1025UCL25"
    1. Will this remain as a valid solution?
    Yes, it will be a valid UNIQUE key. The case of BSE:1025UCL25 is a case-specific issue from the exchange, and we have raised it with them.
    2. Is the documentation's recommendation no longer valid? If so, it would be nice to update it for people in the future.
    It stands valid. If for any changes in the future, we will update the public documentation accordingly.
Sign In or Register to comment.