- Avanza
- Constants
- authenticate
- disconnect
- getPositions
- getOverview
- getAccountOverview
- getDealsAndOrders
- getTransactions
- getWatchlists
- addToWatchlist
- removeFromWatchlist
- getInstrument
- getOrderbook
- getOrderbooks
- getChartdata
- getInspirationLists
- getInspirationList
- subscribe
- placeOrder
- getOrder
- editOrder
- deleteOrder
- search
- call
Extends EventEmitter
An Avanza API wrapper.
Some methods require certain constants as parameters. These are described below.
Type | Note |
---|---|
Avanza.STOCK |
|
Avanza.FUND |
|
Avanza.BOND |
|
Avanza.OPTION |
|
Avanza.FUTURE_FORWARD |
|
Avanza.CERTIFICATE |
|
Avanza.WARRANT |
|
Avanza.EXCHANGE_TRADED_FUND |
|
Avanza.INDEX |
|
Avanza.PREMIUM_BOND |
|
Avanza.SUBSCRIPTION_OPTION |
|
Avanza.EQUITY_LINKED_BOND |
|
Avanza.CONVERTIBLE |
Period | Note |
---|---|
Avanza.TODAY |
|
Avanza.ONE_WEEK |
|
Avanza.ONE_MONTH |
|
Avanza.THREE_MONTHS |
|
Avanza.THIS_YEAR |
|
Avanza.ONE_YEAR |
|
Avanza.FIVE_YEARS |
List | Note |
---|---|
Avanza.HIGHEST_RATED_FUNDS |
|
Avanza.LOWEST_FEE_INDEX_FUNDS |
|
Avanza.BEST_DEVELOPMENT_FUNDS_LAST_THREE_MONTHS |
|
Avanza.MOST_OWNED_FUNDS |
Note that for all channels where a sequence of account IDs are expected
(<accountId1>,<accountId2>,...
), you must supply all of your account IDs,
regardless of whether or not you want data for that account.
Channel | Note |
---|---|
Avanza.QUOTES |
Minute-wise data containing current price, change, total volume traded etc. Expects an orderbookId. |
Avanza.ORDERDEPTHS |
Best five offers and current total volume on each side. Expects an orderbookId. |
Avanza.TRADES |
Updates whenever a new trade is made. Data contains volume, price, broker etc. Expects an orderbookId. |
Avanza.BROKERTRADESUMMARY |
Pushes data about which brokers are long/short and how big their current net volume is. Expects an orderbookId. |
Avanza.POSITIONS |
Your positions in an instrument. Expects a string of <orderbookId>_<accountId1>,<accountId2,<accountId3>,... . |
Avanza.ORDERS |
Your current orders. Expects a string of _<accountId1>,<accountId2,<accountId3>,... . |
Avanza.DEALS |
Recent trades you have made. Expects a string of _<accountId1>,<accountId2,<accountId3>,... . |
Avanza.ACCOUNTS |
N/A. Expects a string of _<accountId> . |
Transaction type | Note |
---|---|
Avanza.OPTIONS |
|
Avanza.FOREX |
|
Avanza.DEPOSIT_WITHDRAW |
|
Avanza.BUY_SELL |
|
Avanza.DIVIDEND |
|
Avanza.INTEREST |
|
Avanza.FOREIGN_TAX |
Order type | Note |
---|---|
Avanza.BUY |
|
Avanza.SELL |
Authenticate the client.
If second factor authentication is needed, either the one time code can be provided in totp
, or the secret to
generate codes can be provided in totpSecret
.
credentials
Object
Disconnects by simulating a client that just goes away.
Get all positions
held by this user.
Returns
getPositions()
Property | Type | Note |
---|---|---|
instrumentPositions |
Array | |
totalBalance |
Number | |
totalBuyingPower |
Number | |
totalOwnCapital |
Number | |
totalProfit |
Number | |
totalProfitPercent |
Number |
Get an overview of the users holdings at Avanza Bank.
Returns
getOverview()
Property | Type | Note |
---|---|---|
accounts |
Array | |
numberOfDeals |
Number | |
numberOfIntradayTransfers |
Number | |
numberOfOrders |
Number | |
numberOfTransfers |
Number | |
totalBalance |
Number | |
totalBuyingPower |
Number | |
totalOwnCapital |
Number | |
totalPerformance |
Number | |
totalPerformancePercent |
Number |
getOverview().accounts[i]
Property | Type | Note |
---|---|---|
accountId |
String | |
accountPartlyOwned |
Boolean | |
accountType |
String | |
active |
Boolean | |
attorney |
Boolean | |
buyingPower |
Number | |
depositable |
Boolean | |
interestRate |
Number | |
name |
String | |
ownCapital |
Number | |
performance |
Number | |
performancePercent |
Number | |
totalBalance |
Number | |
totalBalanceDue |
Number | |
totalProfit |
Number | |
totalProfitPercent |
Number | |
tradable |
Boolean |
Get an overview of the users holdings for a specific account at Avanza Bank.
Returns
getAccountOverview()
Property | Type | Note |
---|---|---|
accountId |
String | |
accountName |
String | |
accountType |
String | |
accountTypeName |
String | |
accruedInterest |
Number | |
allowMonthlySaving |
Boolean | |
availableSuperLoanAmount |
Number | |
buyingPower |
Number | |
clearingNumber |
String | |
courtageClass |
String | |
creditAfterInterest |
Number | |
creditLimit |
Number | |
currencyAccounts |
Array | |
depositable |
Boolean | |
forwardBalance |
Number | |
instrumentTransferPossible |
Boolean | |
interestRate |
Number | |
internalTransferPossible |
Boolean | |
jointlyOwned |
Boolean | |
numberOfDeals |
Number | |
numberOfIntradayTransfers |
Number | |
numberOfOrders |
Number | |
numberOfTransfers |
Number | |
overdrawn |
Boolean | |
overMortgaged |
Boolean | |
ownCapital |
Number | |
performance |
Number | |
performancePercent |
Number | |
performanceSinceOneMonth |
Number | |
performanceSinceOneMonthPercent |
Number | |
performanceSinceOneWeek |
Number | |
performanceSinceOneWeekPercent |
Number | |
performanceSinceOneYear |
Number | |
performanceSinceOneYearPercent |
Number | |
performanceSinceSixMonths |
Number | |
performanceSinceSixMonthsPercent |
Number | |
performanceSinceThreeMonths |
Number | |
performanceSinceThreeMonthsPercent |
Number | |
performanceSinceThreeYears |
Number | |
performanceSinceThreeYearsPercent |
Number | |
reservedAmount |
Number | |
sharpeRatio |
Number | |
standardDeviation |
Number | |
totalBalance |
Number | |
totalCollateralValue |
Number | |
totalPositionsValue |
Number | |
totalProfit |
Number | |
totalProfitPercent |
Number | |
withdrawable |
Boolean |
getAccountOverview().currencyAccounts[i]
Property | Type | Note |
---|---|---|
balance |
Number | |
currency |
String |
accountId
String A valid account ID.
Get recent deals and orders.
Returns
getDealsAndOrders()
Property | Type | Note |
---|---|---|
accounts |
Array | |
deals |
Array | |
orders |
Array | |
reservedAmount |
Number |
getDealsAndOrders().accounts[i]
Property | Type | Note |
---|---|---|
id |
String | |
name |
String | |
type |
String |
getDealsAndOrders().deals[i]
Property | Type | Note |
---|---|---|
account |
Object | |
dealId |
String | |
dealTime |
String | |
marketTransaction |
Boolean | |
orderbook |
Object | |
orderId |
String | |
price |
Number | |
sum |
Number | |
type |
String | |
volume |
Number |
Get all transactions of an account.
Returns
getTransactions()
Property | Type | Note |
---|---|---|
totalNumberOfTransactions |
Number | |
transactions |
Array |
getTransactions().transactions[i]
Property | Type | Note |
---|---|---|
account |
Object | |
amount |
Number | |
currency |
String | |
description |
String | |
id |
String | |
transactionType |
String | |
verificationDate |
String |
accountOrTransactionType
String A valid account ID or a Transaction Type.options
Object Configuring which transactions to fetch.options.from
String? On the form YYYY-MM-DD.options.to
String? On the form YYYY-MM-DD.options.maxAmount
Number? Only fetch transactions of at most this value.options.minAmount
Number? Only fetch transactions of at least this value.options.orderbookId
(String | Array)? Only fetch transactions involving this/these orderbooks.
Get all watchlists created by this user. Note that the second table was created from a specific watchlist, and so the response from the API will be different for you.
Returns
getWatchlists()[i]
Property | Type | Note |
---|---|---|
editable |
Boolean | |
id |
String | |
name |
String | |
orderbooks |
Array |
getWatchlists()[i].orderbooks[i]
Property | Type | Note |
---|---|---|
0 |
String | |
1 |
String | |
2 |
String | |
3 |
String | |
4 |
String | |
5 |
String |
Add an instrument to the watchlist.
instrumentId
String The ID of the instrument to add.watchlistId
String The ID of the watchlist to add the instrument to.
Remove an instrument from the watchlist.
instrumentId
String The ID of the instrument to remove.watchlistId
String The ID of the watchlist to remove the instrument from.
Get instrument information.
Returns
getInstrument()
Property | Type | Note |
---|---|---|
annualMeetings |
Array | |
brokerTradeSummary |
Object | |
change |
Number | |
changePercent |
Number | |
company |
Object | |
companyOwners |
Object | |
companyReports |
Array | |
country |
String | |
currency |
String | |
dividends |
Array | |
flagCode |
String | |
hasInvestmentFees |
Boolean | |
highestPrice |
Number | |
id |
String | |
isin |
String | |
keyRatios |
Object | |
lastPrice |
Number | |
lastPriceUpdated |
String | |
latestTrades |
Array | |
loanFactor |
Number | |
lowestPrice |
Number | |
marketList |
String | |
marketMakerExpected |
Boolean | |
marketPlace |
String | |
marketTrades |
Boolean | |
morningStarFactSheetUrl |
String | |
name |
String | |
numberOfOwners |
Number | |
numberOfPriceAlerts |
Number | |
orderDepthLevels |
Array | |
orderDepthReceivedTime |
String | |
positions |
Array | |
positionsTotalValue |
Number | |
priceAtStartOfYear |
Number | |
priceFiveYearsAgo |
Number | |
priceOneMonthAgo |
Number | |
priceOneWeekAgo |
Number | |
priceOneYearAgo |
Number | |
priceSixMonthsAgo |
Number | |
priceThreeMonthsAgo |
Number | |
priceThreeYearsAgo |
Number | |
pushPermitted |
Boolean | |
quoteUpdated |
String | |
relatedStocks |
Array | |
shortSellable |
Boolean | |
superLoan |
Boolean | |
tickerSymbol |
String | |
totalValueTraded |
Number | |
totalVolumeTraded |
Number | |
tradable |
Boolean |
getInstrument().annualMeetings[i]
Property | Type | Note |
---|---|---|
eventDate |
String | |
extra |
Boolean |
getInstrument().companyReports[i]
Property | Type | Note |
---|---|---|
eventDate |
String | |
reportType |
String |
getInstrument().dividends[i]
Property | Type | Note |
---|---|---|
amountPerShare |
Number | |
currency |
String | |
exDate |
String | |
paymentDate |
String |
getInstrument().latestTrades[i]
Property | Type | Note |
---|---|---|
cancelled |
Boolean | |
dealTime |
String | |
matchedOnMarket |
Boolean | |
price |
Number | |
volume |
Number |
getInstrument().relatedStocks[i]
Property | Type | Note |
---|---|---|
flagCode |
String | |
id |
String | |
lastPrice |
Number | |
name |
String | |
priceOneYearAgo |
Number |
instrumentType
String The type of the instrument. See Instrument Types.instrumentId
String Likely the same as the instrumentId.
Get orderbook information.
Returns
getOrderbook()
Property | Type | Note |
---|---|---|
account |
Object | |
brokerTradeSummary |
Object | |
customer |
Object | |
firstTradableDate |
String | |
hasInstrumentKnowledge |
Boolean | |
hasInvestmentFees |
Object | |
hasShortSellKnowledge |
Boolean | |
lastTradableDate |
String | |
latestTrades |
Array | |
marketMakerExpected |
Boolean | |
marketTrades |
Boolean | |
orderbook |
Object | |
orderDepthLevels |
Array | |
orderDepthReceivedTime |
String | |
tickSizeRules |
Array | |
untradableDates |
Array |
getOrderbook().latestTrades[i]
Property | Type | Note |
---|---|---|
cancelled |
Boolean | |
dealTime |
String | |
matchedOnMarket |
Boolean | |
price |
Number | |
volume |
Number |
getOrderbook().tickSizeRules[i]
Property | Type | Note |
---|---|---|
maxPrice |
Number | |
minPrice |
Number | |
tickSize |
Number |
getOrderbook().untradableDates[i]
Property | Type | Note |
---|---|---|
0 |
String | |
1 |
String | |
2 |
String | |
3 |
String | |
4 |
String | |
5 |
String | |
6 |
String | |
7 |
String | |
8 |
String | |
9 |
String |
instrumentType
String The type of the instrument. See Instrument Types.orderbookId
String Likely the same as the instrumentId.
Get information about multiple orderbooks.
Returns
getOrderbooks()[i]
Property | Type | Note |
---|---|---|
change |
Number | |
changePercent |
Number | |
currency |
String | |
flagCode |
String | |
highestPrice |
Number | |
id |
String | |
instrumentType |
String | |
lastPrice |
Number | |
lowestPrice |
Number | |
name |
String | |
priceThreeMonthsAgo |
Number | |
totalVolumeTraded |
Number | |
tradable |
Boolean | |
updated |
String |
orderbookIds
Array A list of orderbook IDs.
Get an array of prices over a period of time.
Returns
getChartdata()
Property | Type | Note |
---|---|---|
ceiling |
Number | |
change |
Number | |
changePercent |
Number | |
comparisonName |
String | |
comparisonSeries |
Array | |
dataSeries |
Array | |
floor |
Number | |
max |
Number | |
min |
Number |
getChartdata().comparisonSeries[i]
Property | Type | Note |
---|---|---|
timestamp |
String | |
value |
Number |
getChartdata().dataSeries[i]
Property | Type | Note |
---|---|---|
timestamp |
String | |
value |
Number |
orderbookId
String The orderbook to fetch price data about.period
Period The period from which to fetch data. See Periods.
List all inspiration lists.
Returns
getInspirationLists()[i]
Property | Type | Note |
---|---|---|
averageChange |
Number | |
averageChangeSinceThreeMonths |
Number | |
highlightField |
Object | |
id |
String | |
imageUrl |
String | |
information |
String | |
instrumentType |
String | |
name |
String | |
orderbooks |
Array | |
statistics |
Object |
getInspirationLists()[i].orderbooks[i]
Property | Type | Note |
---|---|---|
change |
Number | |
changePercent |
Number | |
currency |
String | |
flagCode |
String | |
highlightValue |
Number | |
id |
String | |
lastPrice |
Number | |
name |
String | |
priceOneYearAgo |
Number | |
priceThreeMonthsAgo |
Number | |
updated |
String |
Get information about a single inspiration list.
Returns
getInspirationList()
Property | Type | Note |
---|---|---|
averageChangeSinceThreeMonths |
Number | |
highlightField |
Object | |
id |
String | |
imageUrl |
String | |
information |
String | |
instrumentType |
String | |
name |
String | |
orderbooks |
Array | |
statistics |
Object |
getInspirationList().orderbooks[i]
Property | Type | Note |
---|---|---|
changeSinceOneDay |
Number | |
changeSinceOneYear |
Number | |
changeSinceThreeMonths |
Number | |
highlightValue |
Number | |
id |
String | |
lastUpdated |
String | |
name |
String |
Subscribe to real-time data.
channel
String The channel on which to listen. See Channels.ids
(String | Array<String>) One or many IDs to subscribe to.callback
Function Function to call whenever the subscription receives a new message
Returns Function Call to unsubscribe.
Place a limit order.
options
Object Order options.options.accountId
String ID of the account to trade on.options.orderbookId
String ID of the instrument to trade.options.orderType
String One of "BUY" or "SELL".options.price
Number The price limit of the order.options.validUntil
String A date on the form YYYY-MM-DD. Cancels the order if this date is passed.options.volume
Number How many securities to order.
Returns Object Properties are messages
, requestId
, status
, orderId
.
Get information about an order.
It is quite hard to automatically generate tables of what this endpoint returns since orders are merely temporary entities.
The returned object however looks very much like that from
getOrderbook() with an extra property order
which
contains information you already have (such as order price or volume).
instrumentType
String Instrument type of the pertaining instrument. See Instrument Types.accountId
String ID of the account which this order was placed on.orderId
String ID of the order.
Edit an order.
instrumentType
String Instrument type of the pertaining instrument. See Instrument Types.orderId
String Order ID received when placing the order.options
Object Order options. See placeOrder().
Delete and cancel an order.
accountId
String ID of the account on which this order was placed.orderId
String Order ID received when the order was placed.
Free text search for an instrument.
Returns
search()
Property | Type | Note |
---|---|---|
hits |
Array | |
totalNumberOfHits |
Number |
search().hits[i]
Property | Type | Note |
---|---|---|
instrumentType |
String | |
numberOfHits |
Number | |
topHits |
Array |
search().hits[i].topHits[i]
Property | Type | Note |
---|---|---|
changePercent |
Number | |
currency |
String | |
flagCode |
String | |
id |
String | |
lastPrice |
Number | |
name |
String | |
tickerSymbol |
String | |
tradable |
Boolean |
Make a call to the API. Note that this method will filter dangling question
marks from path
.
method
String HTTP method to use. (optional, default'GET'
)path
String The URL to send the request to. (optional, default''
)data
Object JSON data to send with the request. (optional, default{}
)
Returns Promise