investiny
investiny copied to clipboard
search_assets does not return data when exchange parameter is set
Searching for a stock in Indian Bombay Stock Exchange BSE like below
type = 'Stock'
exchange='BSE'
query = 'kotak'
search_results = search_assets(query=query, limit=1, type=type, exchange=exchange)
print(search_results)
returns empty list
[]
Searching for a stock in Indian National Stock Exchange NSE like below
type = 'Stock'
exchange='NSE'
query = 'kotak'
search_results = search_assets(query=query, limit=1, type=type, exchange=exchange)
print(search_results)
returns empty list
[]
However searching without providing any exchange parameter like following
type = 'Stock'
exchange=''
query = 'kotak'
search_results = search_assets(query=query, limit=1, type=type, exchange=exchange)
print(search_results)
returns 2 elements although the limit parameter is set to 1
[{'symbol': 'KTKM', 'full_name': 'NSE:KTKM', 'description': 'Kotak Mahindra Bank Ltd.', 'type': 'Stock', 'ticker': '18260', 'exchange': 'NSE'}, {'symbol': 'KTKM_p', 'full_name': 'BSE:KTKM_p', 'description': 'Kotak Mahindra Bank Ltd Preferred', 'type': 'Stock', 'ticker': '1180379', 'exchange': 'BSE'}]
Even more confusing is when limit is increased as in the following
type = 'Stock'
exchange=''
query = 'kotak'
search_results = search_assets(query=query, limit=4, type=type, exchange=exchange)
print(search_results)
3 results are returned
[{'symbol': 'KTKM', 'full_name': 'NSE:KTKM', 'description': 'Kotak Mahindra Bank Ltd.', 'type': 'Stock', 'ticker': '18260', 'exchange': 'NSE'}, {'symbol': 'KTKM_p', 'full_name': 'BSE:KTKM_p', 'description': 'Kotak Mahindra Bank Ltd Preferred', 'type': 'Stock', 'ticker': '1180379', 'exchange': 'BSE'}, {'symbol': 'KTKM', 'full_name': 'BSE:KTKM', 'description': 'Kotak Mahindra Bank Ltd.', 'type': 'Stock', 'ticker': '39573', 'exchange': 'BSE'}]
Does anyone know the significance of _p preferred? Should I search BSE history in normal or preferred?
Attention Needed
- Search should return results related to the exchange searched in eg BSE, NSE
- limit parameter has unintended effect when set to 1
Thanks for reporting this @hamzaahmedzia1, I'm still fixing some things as you can check at #27, but I'll tackle this next, as you're right! Also I'll try to extend the unit tests, as I didn't have much time to do those...
Also, FYI same thing happens with the type
param, as the one provided in the results is not matching the one actually used for the filtering, so I had to manually check those and add those as Literal
. So I'll try to do the same for the exchanges, and also create a Literal
with all the possible values.
Hi @hamzaahmedzia1 & @alvarobartt
Some days ago I got into this too. What I have found out is that the https://tvc4.investing.com/ search request does not use the exchange names as we are used too. Here are some examples:
exch_toInvesting = {
"NDQ": "NASDAQ",
"NSY": "NYSE",
"XET": "ETR",
"FRA": "F",
"EAM": "AS",
"ELI": "ELI",
"SWX": "SIX",
}
I have found this by using the developer tools to analyze the network packets sent when searching for a stock and filtering by the desired exchange.
Thanks @joao-pm-santos96, that's why I'm trying to do to retrieve all the exchange names manually, but that takes some time, probably for the next release! :hugs: