fhqvst / avanza

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

How could I to get volume of previous trades? #57

Open gEssayas opened 3 years ago

gEssayas commented 3 years ago

I have tested the APIs it all works fine. Thanks. But could not figure out how to get the volume of previous trades like getChartdata with volume. Same information like Avanza.TRADES but for previous trades. Do know how or if this is available in this project?

tarentula commented 3 years ago

Not sure how to use the mobile api for that. I would use the web api instead, so if you post to https://www.avanza.se/ab/component/highstockchart/getchart/orderbook with this body

{
    "orderbookId": 5447,
    "chartType": "CANDLESTICK",
    "widthOfPlotContainer": 558,
    "chartResolution": "MINUTE",
    "navigator": false,
    "percentage": false,
    "volume": true,
    "owners": false,
    "timePeriod": "today",
    "ta": [
        {
            "type": "sma",
            "timeFrame": 50
        }
    ],
    "compareIds": [
        19002
    ]
}

you will get a response including an array of "volumePoints". Play around with it in Postman and you will soon get a hang of all possible combos in the json.

JakobWestergarden commented 2 years ago

Not sure how to use the mobile api for that. I would use the web api instead, so if you post to https://www.avanza.se/ab/component/highstockchart/getchart/orderbook with this body

{
    "orderbookId": 5447,
    "chartType": "CANDLESTICK",
    "widthOfPlotContainer": 558,
    "chartResolution": "MINUTE",
    "navigator": false,
    "percentage": false,
    "volume": true,
    "owners": false,
    "timePeriod": "today",
    "ta": [
        {
            "type": "sma",
            "timeFrame": 50
        }
    ],
    "compareIds": [
        19002
    ]
}

you will get a response including an array of "volumePoints". Play around with it in Postman and you will soon get a hang of all possible combos in the json.

I tried this, but it would always be missing the 15min latest volumePoints. I assume this is due to avanza blocking non customers from accessing the latest 15mins, as seen if looking at any stock in avanza when not logged in. Does the web-api have any way of authenticating to simulate a login, so that we can access all the volume for the day and not miss the last 15 min?

Thanks in advance