api

package
v0.0.0-...-7f18eca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package api includes the HTTP client used to access the REST JSON API.

Information about specific endpoints and their parameters can be found at: https://api.test.nordnet.se/api-docs/index.html

Index

Constants

View Source
const (
	NNBASEURL     = `https://www.nordnet.se/next`
	NNTESTBASEURL = `https://api.test.nordnet.se/next`
	NNSERVICE     = `NEXTAPI`
	NNAPIVERSION  = `2`
)

Variables

View Source
var (
	TooManyRequestsError = errors.New("Too Many Requests, please wait for 10 seconds before trying again")
)

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	URL, Service, Version, Credentials, SessionKey string
	ExpiresAt, LastUsageAt                         time.Time

	http.Client
	sync.RWMutex
}

APIClient provides all API-endpoints available as methods.

func NewAPIClient

func NewAPIClient(credentials string) *APIClient

Constructor function takes the credentials string produced by the util package.

func NewAPITestClient

func NewAPITestClient(credentials string) *APIClient

Constructor function for creating a client pointing to the NEXT test environment.

func (*APIClient) Account

func (c *APIClient) Account(accountno int64) (res *AccountInfo, err error)

The account summary gives details of the account.

func (*APIClient) AccountLedgers

func (c *APIClient) AccountLedgers(accountno int64) (res []LedgerInformation, err error)

Information about the currency ledgers of an account.

func (*APIClient) AccountOrders

func (c *APIClient) AccountOrders(accountno int64, params *Params) (res []Order, err error)

Get all orders beloning to an account.

func (*APIClient) AccountPositions

func (c *APIClient) AccountPositions(accountno int64) (res []Position, err error)

Returns a list of all positions of the account.

func (*APIClient) AccountTrades

func (c *APIClient) AccountTrades(accountno int64, params *Params) (res []Trade, err error)

Get all trades belonging to an account.

func (*APIClient) Accounts

func (c *APIClient) Accounts() (res []Account, err error)

Returns a list of accounts that the user has access to.

func (*APIClient) ActivateOrder

func (c *APIClient) ActivateOrder(accountno int64, orderId int64) (res *OrderReply, err error)

Activate an inactive order. Please note that it is not possible to deactivate an order. The order must be entered as inactive.

func (*APIClient) Countries

func (c *APIClient) Countries() (res []Country, err error)

Get a list of all countries in the system. Please note that trading is not available everywhere.

func (*APIClient) CreateOrder

func (c *APIClient) CreateOrder(accountno int64, params *Params) (res *OrderReply, err error)

Enter a new order, market_id + identifier is the identifier of the tradable.

func (*APIClient) DeleteOrder

func (c *APIClient) DeleteOrder(accountno int64, orderId int64) (res *OrderReply, err error)

Delete an order.

func (*APIClient) Indicators

func (c *APIClient) Indicators() (res []Indicator, err error)

Returns a list indicators that the user has access to.

func (*APIClient) InstrumentLeverageFilters

func (c *APIClient) InstrumentLeverageFilters(id int64, params *Params) (res *LeverageFilter, err error)

Returns valid filter values. Can be used to fill comboboxes in clients to filter leverages results. The same filters can be applied on this request to exclude invalid filter combinations.

func (*APIClient) InstrumentLeverages

func (c *APIClient) InstrumentLeverages(id int64, params *Params) (res []Instrument, err error)

Returns a list of leverage instruments that have the current instrument as underlying. Leverage instruments is for example warrants and ETF:s. To get all valid filters for the current underlying please use "Get leverages filters". The filters can be used to narrow the search. If "Get leverages filters" is used to fill comboboxes the same filters can be applied on the that call to hide filter cominations that are not valid. Multiple filters can be applied.

func (*APIClient) InstrumentLookup

func (c *APIClient) InstrumentLookup(lookupType string, lookup string) (res []Instrument, err error)

Lookup specific instrument with prededfined fields. Please note that this is not a search, only exact matches is returned.

func (*APIClient) InstrumentOptionPairFilters

func (c *APIClient) InstrumentOptionPairFilters(id int64, params *Params) (res *OptionPairFilter, err error)

Returns valid filter values. Can be used to fill comboboxes in clients to filter options pair results. The same filters can be applied on this request to exclude invalid filter combinations.

func (*APIClient) InstrumentOptionPairs

func (c *APIClient) InstrumentOptionPairs(id int64, params *Params) (res []OptionPair, err error)

Returns a list of call/put option pairs. They are balanced on strike price. In order to find underlyings with options use "Get underlyings". To get available expiration dates use "Get option pair filters".

func (*APIClient) InstrumentSector

func (c *APIClient) InstrumentSector(sectors string) (res []Sector, err error)

Get one or more sectors

func (*APIClient) InstrumentSectors

func (c *APIClient) InstrumentSectors(params *Params) (res []Sector, err error)

Get all instrument sectors or the ones matching the group crtieria

func (*APIClient) InstrumentType

func (c *APIClient) InstrumentType(instrumentType string) (res []InstrumentType, err error)

Get info of one orde more instrument type.

func (*APIClient) InstrumentTypes

func (c *APIClient) InstrumentTypes() (res []InstrumentType, err error)

Get all instrument types. Please note that these types is used for both instrument_type and instrument_group_type.

func (*APIClient) InstrumentUnderlyings

func (c *APIClient) InstrumentUnderlyings(derivateType string, currency string) (res []Instrument, err error)

Get instruments that are underlyings for a specific type of instruments. The query can return instrument that have option derivatives or leverage derivatives. Warrants are included in the leverage derivatives.

func (*APIClient) Instruments

func (c *APIClient) Instruments(ids string) (res []Instrument, err error)

Get one or more instruments, the instrument id is used as key

func (*APIClient) List

func (c *APIClient) List(id int64) (res []Instrument, err error)

Get all instruments in a list.

func (*APIClient) Lists

func (c *APIClient) Lists() (res []List, err error)

Get all instrument lists

func (*APIClient) Login

func (c *APIClient) Login() (res *Login, err error)

Before any other of the services (except for the system info request) can be called the user must login. The username, password and phrase must be sent encrypted. TODO: move the params into function arguments since its only used here?

func (*APIClient) Logout

func (c *APIClient) Logout() (res *LoggedInStatus, err error)

Invalidates the session.

func (*APIClient) LookupCountries

func (c *APIClient) LookupCountries(countries string) (res []Country, err error)

Lookup one or more countries by country code. Multiple countries can be queried at the same time by comma separating the country codes. TODO: Merge with Countries call above?

func (*APIClient) LookupIndicators

func (c *APIClient) LookupIndicators(indicators string) (res []Indicator, err error)

Returns info of one or more indicators. TODO: Merge with Indicators call above?

func (*APIClient) Market

func (c *APIClient) Market(ids string) (res []Market, err error)

Lookup one or more markets by market_id. Multiple market can be queried at the same time by comma separating the market_ids. Market 80 is the smart order market. Instruments that can be traded on 2 or more markets gets a tradable on the smart order market. Orders entered with the smart order tradable get smart order routed with the current Nordnet best execution policy.

func (*APIClient) Markets

func (c *APIClient) Markets() (res []Market, err error)

Get all tradable markets. Market 80 is the smart order market. Instruments that can be traded on 2 or more markets gets a tradable on the smart order market. Orders entered with the smart order tradable get smart order routed with the current Nordnet best execution policy.

func (*APIClient) News

func (c *APIClient) News(ids string) (res []NewsItem, err error)

Show one or more news items. Search for news. If no search field is used the last news available to the user is returned.

func (*APIClient) NewsSources

func (c *APIClient) NewsSources() (res []NewsSource, err error)

Returns a list of news sources the user has access to

func (*APIClient) Perform

func (c *APIClient) Perform(method, path string, params *Params, res interface{}) (err error)

func (*APIClient) RealtimeAccess

func (c *APIClient) RealtimeAccess() (res []RealtimeAccess, err error)

Get realtime data access. This applies to the access on the feeds. If the market is missing the user don't have realtime access on that market.

func (*APIClient) SearchInstruments

func (c *APIClient) SearchInstruments(params *Params) (res []Instrument, err error)

Free text search. A list of instruments is returned.

func (*APIClient) SearchNews

func (c *APIClient) SearchNews(params *Params) (res []NewsPreview, err error)

Search for news. If no search field is used the last news available to the user is returned.

func (*APIClient) SystemStatus

func (c *APIClient) SystemStatus() (res *SystemStatus, err error)

Information about the system status can be retrieved by this HTTP request. This is the only service that can be called without authentication.

func (*APIClient) TickSize

func (c *APIClient) TickSize(ids string) (res []TicksizeTable, err error)

Get one or more ticksize tables.

func (*APIClient) TickSizes

func (c *APIClient) TickSizes() (res []TicksizeTable, err error)

Get all ticksize tables.

func (*APIClient) Touch

func (c *APIClient) Touch() (res *LoggedInStatus, err error)

If the application needs to keep the session alive the session can be touched. Note the basic auth header field must be set as for all other calls. All calls to any REST service is touching the session. So touching the session manually is only needed if no other calls are done during the session timeout interval.

func (*APIClient) TradableInfo

func (c *APIClient) TradableInfo(ids string) (res []TradableInfo, err error)

Get trading calender and allowed trading types for one or more tradable.

func (*APIClient) TradableIntraday

func (c *APIClient) TradableIntraday(ids string) (res []IntradayGraph, err error)

Can be used for populating instrument price graphs for today. Resolution is one minute.

func (*APIClient) TradableTrades

func (c *APIClient) TradableTrades(ids string) (res []PublicTrades, err error)

Get all public trades (all trades done on the marketplace) beloning to one ore more tradable.

func (*APIClient) UpdateOrder

func (c *APIClient) UpdateOrder(accountno int64, orderId int64, params *Params) (res *OrderReply, err error)

Modify price and or volume on an order.

type APIError

type APIError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

Error type for errors returned by the API

func (APIError) Error

func (e APIError) Error() string

APIError implements the error interface

type Params

type Params map[string]string

Represents the options available for various methods.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL