Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search_assets does not return data when exchange parameter is set #34

Open
hamzaahmedzia1 opened this issue Oct 12, 2022 · 4 comments
Open
Assignees
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@hamzaahmedzia1
Copy link

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

  1. Search should return results related to the exchange searched in eg BSE, NSE
  2. limit parameter has unintended effect when set to 1
@alvarobartt
Copy link
Owner

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...

@alvarobartt alvarobartt self-assigned this Oct 13, 2022
@alvarobartt alvarobartt added bug Something isn't working invalid This doesn't seem right labels Oct 13, 2022
@alvarobartt
Copy link
Owner

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.

@joao-pm-santos96
Copy link

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.

@alvarobartt
Copy link
Owner

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! 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants