fhqvst / avanza

A JavaScript client for the unofficial Avanza API
MIT License
229 stars 59 forks source link

Get lastPrice from market maker? #70

Open tommiehansen opened 2 years ago

tommiehansen commented 2 years ago

A current problem both with Avanza's usual site and accounts and with this API is that it isn't that easy to get the last price (not last trade, there is a difference) from instruments that have a market maker.

This is especially true if its an instrument that is traded less frequently like some index futures.

eg:

MINI L DAX 363 lastPrice: 14.9

...but last price, as of writing this, from MM (Market Maker) is 17.07: image

Any way of getting the so called marketMakerBidPoints ?

ausrasul commented 2 years ago

The most reliable way of getting it is by looking at the volume. The market maker has a fixed volume which is way higher than anyone in the order depth. So it usually lays in the top of the order depth, but not necessarily.

You can make a rule to look at the order depth from top to bottom and take the first price that is higher than a set volume like 7000 (depends on the finance level).

Here is a complete message from channel "order depths" There you'll find marketMakerLevelAsk and bid, I think it means which level is the market maker's bid. But what do you care if there is someone with more volume and better price? hence my decision to look for volume and price instead of MM level.

image

tommiehansen commented 2 years ago

Wouldn't the most reliable way to get it to look at the chart data since that does have the data i'm after?

There is an endpoint for it eg: https://www.avanza.se/_mobile/chart/orderbook/1186214?timePeriod=one_month

However that endpoint does not work since it doesn't actually return the chart data but instead returns trades and not the chart data (mm bidpoints) like on the site and on the mobile app.

The endpoint for the regular chart data is: https://www.avanza.se/ab/component/highstockchart/getchart/orderbook

..but uses POST instead of a GET.