alice_blue icon indicating copy to clipboard operation
alice_blue copied to clipboard

use dictionary look up instead of for loop search [Improvement]

Open sivankumar86 opened this issue 3 years ago • 1 comments
trafficstars

Improve performance on loop up.

concat with Symbol+Month+strike+call/put

Example,

"BANKNIFTYAUG31100.0CE": [ "NFO", 82505, "BANKNIFTYAUG31100.0CE", "", "2022-08-26", "25" ]

sivankumar86 avatar May 29 '22 05:05 sivankumar86

def get_instrument_for_option(self, symbol, expiry_date, strike=None,option_type='CE' , exchange='NFO'): """ get instrument for FNO """ master_con = self.get_master_contract('NFO') strike_str="{:.1f}".format(strike) symbol_u=symbol.upper() dateFormatted = expiry_date.strftime("%b").upper() key="{} {} {} {}".format(symbol_u,dateFormatted,strike_str,option_type) if (key in master_con): res=master_con[key] return res.token return

sivankumar86 avatar May 29 '22 05:05 sivankumar86

I didn't get what it is.

krishnavelu avatar Sep 09 '22 11:09 krishnavelu