jerokpradeep / pya3

Other
46 stars 29 forks source link

Search_instrument method - Shows method not allowed. #89

Open alandprem opened 1 year ago

alandprem commented 1 year ago

Search_instrument method showing method not allowed error message. Please take a look.

search_instrument_issue

subi26 commented 1 year ago

Facing the same issue in my app too

all_sensex_scrips = alice.search_instruments('BSE', 'SENSEX')
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\lussia\venv\Lib\site-packages\pya3\alicebluepy.py", line 776, in search_instruments
    inst.append(Instrument(scrip_response[i]['exch'],scrip_response[i]['token'],scrip_response[i]['formattedInsName'],scrip_response[i]['symbol'],scrip_response[i]['expiry'],scrip_response[i]['lotSize']))
                           ~~~~~~~~~~~~~~^^^
KeyError: 0
Harihara90 commented 1 year ago

Any alternate API to get this search instrument?

Harihara90 commented 1 year ago

Facing the same issue in my app too

all_sensex_scrips = alice.search_instruments('BSE', 'SENSEX')
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\lussia\venv\Lib\site-packages\pya3\alicebluepy.py", line 776, in search_instruments
    inst.append(Instrument(scrip_response[i]['exch'],scrip_response[i]['token'],scrip_response[i]['formattedInsName'],scrip_response[i]['symbol'],scrip_response[i]['expiry'],scrip_response[i]['lotSize']))
                           ~~~~~~~~~~~~~~^^^
KeyError: 0

I am also facing the same issue, Did you figure out any way, When I search about python api, Now it is showing (https://github.com/krishnavelu/alice_blue) API, Do you have any idea if this is legit?

Harihara90 commented 1 year ago

Any alternate API to get this search instrument?

I need the search instrument for latest expiry date of given strike price. Here is an alternate

def get_expiry_date(): df = pd.read_csv("NFO.csv", parse_dates=["Expiry Date"]) expriry_date_ts = df.loc[df.Symbol == "BANKNIFTY"].sort_values( by=["Expiry Date"]).iloc[0]["Expiry Date"] return expriry_date_ts

expriry_date_ts = None if os.path.exists("NFO.csv"): expriry_date_ts = get_expiry_date() date_today = datetime.now().date() print("in if") if date_today >= expriry_date_ts.date(): alice.get_contract_master("NFO") else: print("in else") alice.get_contract_master("NFO") expriry_date_ts = self.get_expiry_date()