fhqvst / avanza

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

Download FUND Data #30

Closed stenne4 closed 5 years ago

stenne4 commented 5 years ago

Hi !

First of all, I´m new to Node, only build som bash scripts before.

Ok, I have got it working and downloading some FUND Data from my Avanza Account But how would a simple code look like, if I would like to download data for a few FUND ID´s that I supply as arguments ?

Another though of code I´m thinking about is how to download FUND Data for FUNDS´s in a specific watchlist ?

Many thanks /Stefan

fhqvst commented 5 years ago

Assuming you have followed the steps in the readme to set up two-factor auth, the following example fetches historical prices for a fund

avanza.authenticate({
  username: 'MY_USERNAME',
  password: 'MY_PASSWORD',
  totpSecret: 'MY_TOTP_SECRET'
}).then(async () => {
  const fund = await avanza.getInstrument(41567) // Instrument ID for Avanza Zero
  console.log(fund)
})

Watchlists can be fetched using avanza.getWatchlists().