Skip to content
Filip Hallqvist edited this page Jul 17, 2017 · 9 revisions

NOTE: This Wiki is only for versions < 1.0.0. For 1.0.0 docs, refer to API.md.

getPositions

Promise getPositions()

Fetches and formats all positions currently held by the user.

getOverview

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.

getDealsAndOrders

Request getDealsAndOrders()

Fetches recent (last 24 hours) transactions made and orders placed by the current user.

getWatchlists

Request getWatchlists()

Fetches all watchlists created by the current user.

addToWatchlist

Request addToWatchlist(
    string instrumentId,
    string watchlistId
)

Adds an instrument to the specified watchlist.

getStock

Request getStock(
    string id
)

Fetches detailed information about a stock.

getFund

Request getFund(
    string id
)

Fetches detailed information about a mutual fund.

getOrderbook

Request getOrderbook(
    string id,
    string type
)

Fetches detailed information about the orderbook of a given instrument. Note that both id and type is required.

getOrderbooks

Request getOrderbooks(
    array ids
)

Fetches general information about the orderbook belonging to the each id.

placeOrder

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.

checkOrder

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.

deleteOrder

Request deleteOrder(
    string accountId,
    string orderId
)

Deletes an order.

search

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.

authenticate

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.

on

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.