Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature: Add price alert for a stock #68

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 104 additions & 86 deletions API.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents
Expand Down Expand Up @@ -25,31 +26,33 @@
- [Parameters][21]
- [removeFromWatchlist][22]
- [Parameters][23]
- [getInstrument][24]
- [addPriceAlert][24]
- [Parameters][25]
- [getOrderbook][26]
- [getInstrument][26]
- [Parameters][27]
- [getOrderbooks][28]
- [getOrderbook][28]
- [Parameters][29]
- [getChartdata][30]
- [getOrderbooks][30]
- [Parameters][31]
- [getInspirationLists][32]
- [getInspirationList][33]
- [Parameters][34]
- [subscribe][35]
- [getChartdata][32]
- [Parameters][33]
- [getInspirationLists][34]
- [getInspirationList][35]
- [Parameters][36]
- [placeOrder][37]
- [subscribe][37]
- [Parameters][38]
- [getOrder][39]
- [placeOrder][39]
- [Parameters][40]
- [editOrder][41]
- [getOrder][41]
- [Parameters][42]
- [deleteOrder][43]
- [editOrder][43]
- [Parameters][44]
- [search][45]
- [deleteOrder][45]
- [Parameters][46]
- [call][47]
- [search][47]
- [Parameters][48]
- [call][49]
- [Parameters][50]

## Avanza

Expand Down Expand Up @@ -145,11 +148,11 @@ generate codes can be provided in `totpSecret`.

#### Parameters

- `credentials` **[Object][49]**
- `credentials.username` **[String][50]**
- `credentials.password` **[String][50]**
- `credentials.totp` **[String][50]**
- `credentials.totpSecret` **[String][50]**
- `credentials` **[Object][51]**
- `credentials.username` **[String][52]**
- `credentials.password` **[String][52]**
- `credentials.totp` **[String][52]**
- `credentials.totpSecret` **[String][52]**

### disconnect

Expand Down Expand Up @@ -284,7 +287,7 @@ Get an overview of the users holdings for a specific account at Avanza Bank.

#### Parameters

- `accountId` **[String][50]** A valid account ID.
- `accountId` **[String][52]** A valid account ID.

### getDealsAndOrders

Expand Down Expand Up @@ -351,14 +354,14 @@ Get all transactions of an account.

#### Parameters

- `accountOrTransactionType` **[String][50]** A valid account ID or a
[Transaction Type][51].
- `options` **[Object][49]** Configuring which transactions to fetch.
- `options.from` **[String][50]?** On the form YYYY-MM-DD.
- `options.to` **[String][50]?** On the form YYYY-MM-DD.
- `options.maxAmount` **[Number][52]?** Only fetch transactions of at most this value.
- `options.minAmount` **[Number][52]?** Only fetch transactions of at least this value.
- `options.orderbookId` **([String][50] \| [Array][53])?** Only fetch transactions involving
- `accountOrTransactionType` **[String][52]** A valid account ID or a
[Transaction Type][53].
- `options` **[Object][51]** Configuring which transactions to fetch.
- `options.from` **[String][52]?** On the form YYYY-MM-DD.
- `options.to` **[String][52]?** On the form YYYY-MM-DD.
- `options.maxAmount` **[Number][54]?** Only fetch transactions of at most this value.
- `options.minAmount` **[Number][54]?** Only fetch transactions of at least this value.
- `options.orderbookId` **([String][52] \| [Array][55])?** Only fetch transactions involving
this/these orderbooks.

### getWatchlists
Expand Down Expand Up @@ -395,17 +398,28 @@ Add an instrument to the watchlist.

#### Parameters

- `instrumentId` **[String][50]** The ID of the instrument to add.
- `watchlistId` **[String][50]** The ID of the watchlist to add the instrument to.
- `instrumentId` **[String][52]** The ID of the instrument to add.
- `watchlistId` **[String][52]** The ID of the watchlist to add the instrument to.

### removeFromWatchlist

Remove an instrument from the watchlist.

#### Parameters

- `instrumentId` **[String][50]** The ID of the instrument to remove.
- `watchlistId` **[String][50]** The ID of the watchlist to remove the instrument from.
- `instrumentId` **[String][52]** The ID of the instrument to remove.
- `watchlistId` **[String][52]** The ID of the watchlist to remove the instrument from.

### addPriceAlert

Add an price alert.

#### Parameters

- `instrumentId` **[String][52]** The ID of the instrument to add.
- `options` **[Object][51]** Alert options.
- `options.price` **[Number][54]** The target price to receive an alert on.
- `options.validUntil` **[String][52]** A date on the form YYYY-MM-DD. Cancels alert if this date is passed.

### getInstrument

Expand Down Expand Up @@ -513,9 +527,9 @@ Get instrument information.

#### Parameters

- `instrumentType` **[String][50]** The type of the instrument. See
- `instrumentType` **[String][52]** The type of the instrument. See
[Instrument Types][3].
- `instrumentId` **[String][50]** Likely the same as the instrumentId.
- `instrumentId` **[String][52]** Likely the same as the instrumentId.

### getOrderbook

Expand Down Expand Up @@ -579,9 +593,9 @@ Get orderbook information.

#### Parameters

- `instrumentType` **[String][50]** The type of the instrument. See
- `instrumentType` **[String][52]** The type of the instrument. See
[Instrument Types][3].
- `orderbookId` **[String][50]** Likely the same as the instrumentId.
- `orderbookId` **[String][52]** Likely the same as the instrumentId.

### getOrderbooks

Expand Down Expand Up @@ -610,7 +624,7 @@ Get information about multiple orderbooks.

#### Parameters

- `orderbookIds` **[Array][53]** A list of orderbook IDs.
- `orderbookIds` **[Array][55]** A list of orderbook IDs.

### getChartdata

Expand Down Expand Up @@ -648,7 +662,7 @@ Get an array of prices over a period of time.

#### Parameters

- `orderbookId` **[String][50]** The orderbook to fetch price data about.
- `orderbookId` **[String][52]** The orderbook to fetch price data about.
- `period` **Period** The period from which to fetch data. See [Periods][4].

### getInspirationLists
Expand Down Expand Up @@ -722,36 +736,36 @@ Get information about a single inspiration list.

#### Parameters

- `type` **[String][50]** List type. See [Lists][5]
- `type` **[String][52]** List type. See [Lists][5]

### subscribe

Subscribe to real-time data.

#### Parameters

- `channel` **[String][50]** The channel on which to listen. See [Channels][6].
- `ids` **([String][50] \| [Array][53]&lt;[String][50]>)** One or many IDs to subscribe to.
- `callback` **[Function][54]** Function to call whenever the subscription receives a new message
- `channel` **[String][52]** The channel on which to listen. See [Channels][6].
- `ids` **([String][52] \| [Array][55]&lt;[String][52]>)** One or many IDs to subscribe to.
- `callback` **[Function][56]** Function to call whenever the subscription receives a new message

Returns **[Function][54]** Call to unsubscribe.
Returns **[Function][56]** Call to unsubscribe.

### placeOrder

Place a limit order.

#### Parameters

- `options` **[Object][49]** Order options.
- `options.accountId` **[String][50]** ID of the account to trade on.
- `options.orderbookId` **[String][50]** ID of the instrument to trade.
- `options.orderType` **[String][50]** One of "BUY" or "SELL".
- `options.price` **[Number][52]** The price limit of the order.
- `options.validUntil` **[String][50]** A date on the form YYYY-MM-DD. Cancels
- `options` **[Object][51]** Order options.
- `options.accountId` **[String][52]** ID of the account to trade on.
- `options.orderbookId` **[String][52]** ID of the instrument to trade.
- `options.orderType` **[String][52]** One of "BUY" or "SELL".
- `options.price` **[Number][54]** The price limit of the order.
- `options.validUntil` **[String][52]** A date on the form YYYY-MM-DD. Cancels
the order if this date is passed.
- `options.volume` **[Number][52]** How many securities to order.
- `options.volume` **[Number][54]** How many securities to order.

Returns **[Object][49]** Properties are `messages`, `requestId`, `status`, `orderId`.
Returns **[Object][51]** Properties are `messages`, `requestId`, `status`, `orderId`.

### getOrder

Expand All @@ -766,30 +780,30 @@ contains information you already have (such as order price or volume).

#### Parameters

- `instrumentType` **[String][50]** Instrument type of the pertaining instrument.
- `instrumentType` **[String][52]** Instrument type of the pertaining instrument.
See [Instrument Types][3].
- `accountId` **[String][50]** ID of the account which this order was placed on.
- `orderId` **[String][50]** ID of the order.
- `accountId` **[String][52]** ID of the account which this order was placed on.
- `orderId` **[String][52]** ID of the order.

### editOrder

Edit an order.

#### Parameters

- `instrumentType` **[String][50]** Instrument type of the pertaining instrument.
- `instrumentType` **[String][52]** Instrument type of the pertaining instrument.
See [Instrument Types][3].
- `orderId` **[String][50]** Order ID received when placing the order.
- `options` **[Object][49]** Order options. See [placeOrder()][37].
- `orderId` **[String][52]** Order ID received when placing the order.
- `options` **[Object][51]** Order options. See [placeOrder()][37].

### deleteOrder

Delete and cancel an order.

#### Parameters

- `accountId` **[String][50]** ID of the account on which this order was placed.
- `orderId` **[String][50]** Order ID received when the order was placed.
- `accountId` **[String][52]** ID of the account on which this order was placed.
- `orderId` **[String][52]** Order ID received when the order was placed.

### search

Expand Down Expand Up @@ -827,8 +841,8 @@ Free text search for an instrument.

#### Parameters

- `searchQuery` **[String][50]** Search query.
- `type` **[String][50]?** An instrument type.
- `searchQuery` **[String][52]** Search query.
- `type` **[String][52]?** An instrument type.

### call

Expand All @@ -837,11 +851,11 @@ marks from `path`.

#### Parameters

- `method` **[String][50]** HTTP method to use. (optional, default `'GET'`)
- `path` **[String][50]** The URL to send the request to. (optional, default `''`)
- `data` **[Object][49]** JSON data to send with the request. (optional, default `{}`)
- `method` **[String][52]** HTTP method to use. (optional, default `'GET'`)
- `path` **[String][52]** The URL to send the request to. (optional, default `''`)
- `data` **[Object][51]** JSON data to send with the request. (optional, default `{}`)

Returns **[Promise][55]**
Returns **[Promise][57]**

[1]: #avanza

Expand Down Expand Up @@ -889,66 +903,70 @@ Returns **[Promise][55]**

[23]: #parameters-4

[24]: #getinstrument
[24]: #addpricealert

[25]: #parameters-5

[26]: #getorderbook
[26]: #getinstrument

[27]: #parameters-6

[28]: #getorderbooks
[28]: #getorderbook

[29]: #parameters-7

[30]: #getchartdata
[30]: #getorderbooks

[31]: #parameters-8

[32]: #getinspirationlists
[32]: #getchartdata

[33]: #getinspirationlist
[33]: #parameters-9

[34]: #parameters-9
[34]: #getinspirationlists

[35]: #subscribe
[35]: #getinspirationlist

[36]: #parameters-10

[37]: #placeorder
[37]: #subscribe

[38]: #parameters-11

[39]: #getorder
[39]: #placeorder

[40]: #parameters-12

[41]: #editorder
[41]: #getorder

[42]: #parameters-13

[43]: #deleteorder
[43]: #editorder

[44]: #parameters-14

[45]: #search
[45]: #deleteorder

[46]: #parameters-15

[47]: #call
[47]: #search

[48]: #parameters-16

[49]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[49]: #call

[50]: #parameters-17

[51]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[50]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[52]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[51]: #transaction-type
[53]: #transaction-type

[52]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[54]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[53]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[55]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[54]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[56]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[55]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
[57]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
1 change: 1 addition & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ constants.paths.AUTHENTICATION_PATH = '/_api/authentication/sessions/usercredent
constants.paths.TOTP_PATH = '/_api/authentication/sessions/totp'
constants.paths.INSPIRATION_LIST_PATH = '/_mobile/marketing/inspirationlist/{0}'
constants.paths.TRANSACTIONS_PATH = '/_mobile/account/transactions/{0}'
constants.paths.PRICE_ALERT_PATH = '/_cqbe/marketing/service/alert/{0}';

/**
* Search
Expand Down
Loading