Closed AmirEghbali closed 1 year ago
probably related to #70
Or maybe related to #68 since I have observed similar changes but I could not get it work. Other than websocket, is there any other way to get price (and more detailed relevant) information about a stock?
Hej all,
I made an extension in my code to this Avanza API to use some other endpoints (_api instead of _mobile). The responses are different but sometimes contain way more helpful info.
Stock info price could be retrieved using https://www.avanza.se/_api/market-guide/{instrument_type}/{instrument_it} And more detailed stock info lays under https://www.avanza.se/_api/market-guide/{instrument_type}/{instrument_it} /details
Check this for example - https://www.avanza.se/_api/market-guide/stock/5564/details
Hi, have you observed that the prices have a lag of ca 15-20 minutes? Also before we could get the sellPrice and buyPrice which we do not now.
I did not observe that. I have a script that fetches the chart data once per minute and verifies that the latest complete data point is no older than 2 minutes (I worked with OMX index and certificates) - so far that checkup gave me no log of massively outdated chart data
The endpoint that I fetch OMX data from is /_api/price-chart/stock/{order_book_id} (it contains Volume for OMX index, compared to the endpoint in the repo where this info is missing)
At least change from
INSTRUMENT_PATH = '/_mobile/market/{}/{}'
to
INSTRUMENT_PATH = '/_api/market-guide/{}/{}'
solves the problem of getting the price for stocks in realtime using get_stock_info().
However, some information (like how many one owns etc) is not available now. Those information can be acquired by accounts_positions() but you will need to extract it for the desired stock_id. Any better solution?
Hi, have you observed that the prices have a lag of ca 15-20 minutes? Also before we could get the sellPrice and buyPrice which we do not now.
Hi, you'll see that data delay if you haven't authenticated.
However, some information (like how many one owns etc) is not available now. Those information can be acquired by accounts_positions() but you will need to extract it for the desired stock_id. Any better solution?
add /details to the end and you'll get holding info as well
In the 5.0.0 version, I'm missing buy/sell/lastPrice in get_stock_info(). Any suggestions on what to use instead?
INSTRUMENT_PATH = '/_api/market-guide/{}/{}'
Make this change and it should work
Using get_instrument_details()
directly might work
https://github.com/Qluxzz/avanza/blob/d1ada7ccdeaf55becfcd00e5f71a5e69d4ec1fc7/avanza/avanza.py#L948
or you could add a function similar to get_certificate_details()
https://github.com/Qluxzz/avanza/blob/d1ada7ccdeaf55becfcd00e5f71a5e69d4ec1fc7/avanza/avanza.py#L763
Change has been applied in a different PR.
Cannot retrieve price information etc.
404 Client Error: Not Found for url: https://www.avanza.se/_mobile/market/stock/'WHATERVER_ID'