-
Notifications
You must be signed in to change notification settings - Fork 59
API
Avanza
is the entry point to this library. Import it with import Avanza from 'avanza'
(or require('avanza')
).
Promise getPositions()
Fetches and formats all positions currently held by the user.
Request getOverview()
Fetches an overview of the accounts of the current user. Response includes financial data such as total balance, per-account balance, profit etc.
Request getDealsAndOrders()
Fetches recent (last 24 hours) transactions made and orders placed by the current user.
Request getWatchlists()
Fetches all watchlists created by the current user.
Request addToWatchlist(
string instrumentId,
string watchlistId
)
Adds an instrument to the specified watchlist.
Request getStock(
string id
)
Fetches detailed information about a stock.
Request getFund(
string id
)
Fetches detailed information about a mutual fund.
Request getOrderbook(
string id,
string type
)
Fetches detailed information about the orderbook of a given instrument. Note that both id
and type
is required.
Request getOrderbooks(
array ids
)
Fetches general information about the orderbook belonging to the each id.
Request placeOrder(
object options
)
Places an order and returns a requestId
belonging to that order. This kind (I.E. not the Avanza.Request
) of request is what later leads to an actual order. See checkOrder
and deleteOrder
for more details.
Request checkOrder(
string accountId,
string requestId
)
Fetches detailed information about a request
. The method itself is somewhat wrongfully named, since it looks up a request
rather than an order
, but in practice they're both the same.
Request deleteOrder(
string accountId,
string orderId
)
Deletes an order.
Request search(
string query,
string type
)
Searches for instruments by name, returning a maximum of 20 results. It's possible to narrow down the search by also specifying type
.
Promise authenticate(
object credentials,
boolean force
)
Tries to authenticate a user and saves the state on success (if it's successful the first time it's called, it won't even bother sending a request to the server the next time). This method must be called before being able to use any of the other methods.
void on(
string event,
function callback
)
Valid events are init
which passes the newly created instance, and authenticate
which is run on successful authentication and passes nothing.