Documentation ¶
Overview ¶
Package api contains definitions for the client and transports
Index ¶
- Constants
- type AccountOrder
- type ApiClient
- func (ac *ApiClient) Account(accno int64) (res swagger.AccountInfo, err error)
- func (ac *ApiClient) AccountLedgers(accno int64) (res swagger.LedgerInformation, err error)
- func (ac *ApiClient) AccountOrders(accno int64) (res []swagger.Order, err error)
- func (ac *ApiClient) AccountPositions(accno int64) (res []swagger.Position, err error)
- func (ac *ApiClient) AccountTrades(accno int64) (res []swagger.Trade, err error)
- func (ac *ApiClient) Accounts() (res []swagger.Account, err error)
- func (ac *ApiClient) ActivateOrder(accno, id int64) (res swagger.OrderReply, err error)
- func (ac *ApiClient) Countries(countries ...string) (res []swagger.Country, err error)
- func (ac *ApiClient) CreateOrder(order *AccountOrder) (res swagger.OrderReply, err error)
- func (ac *ApiClient) CreateSimpleOrder(accno int64, identifier string, market int64, price float64, vol int64, ...) (res swagger.OrderReply, err error)
- func (ac *ApiClient) CustomRequest(command string) (rb *RequestBuilder)
- func (ac *ApiClient) DeleteOrder(accno, id int64) (res swagger.OrderReply, err error)
- func (ac *ApiClient) FeedStatus() (res map[string]interface{}, err error)
- func (ac *ApiClient) FeedSub(typ, id, mark string) (res map[string]interface{}, err error)
- func (ac *ApiClient) FeedSubNews(source int64) (res map[string]interface{}, err error)
- func (ac *ApiClient) FeedUnsub(subId string) (res map[string]string, err error)
- func (ac *ApiClient) GetTransport() TransportHandler
- func (ac *ApiClient) Indicators(indicators ...string) (res []swagger.Indicator, err error)
- func (ac *ApiClient) InstrumentLeverages(id int64, instrument_type, instrument_group_type string) (res []swagger.Instrument, err error)
- func (ac *ApiClient) InstrumentLookup(typ, instrument string) (res []swagger.Instrument, err error)
- func (ac *ApiClient) InstrumentSearch(query string) (res []swagger.Instrument, err error)
- func (ac *ApiClient) InstrumentSearchStream(query, types string, fuzzy bool) (ret chan swagger.Instrument)
- func (ac *ApiClient) InstrumentTypes() (res []swagger.InstrumentType, err error)
- func (ac *ApiClient) InstrumentUnderlyings(typ, currency string) (res []swagger.Instrument, err error)
- func (ac *ApiClient) Instruments(ids ...int64) (res []swagger.Instrument, err error)
- func (ac *ApiClient) List(id int64) (res []swagger.Instrument, err error)
- func (ac *ApiClient) Lists() (res []swagger.List, err error)
- func (ac *ApiClient) Market(ids ...int64) (res []swagger.Market, err error)
- func (ac *ApiClient) NewsSources() (res []swagger.NewsSource, err error)
- func (ac *ApiClient) RealtimeAccess() (res []swagger.RealtimeAccess, err error)
- func (ac *ApiClient) Session() (res swagger.Login, err error)
- func (ac *ApiClient) TickSize(ids ...int64) (res []swagger.TicksizeTable, err error)
- func (ac *ApiClient) TickSizes() (res []swagger.TicksizeTable, err error)
- func (ac *ApiClient) TradableDay(ids ...string) (res []swagger.IntradayGraph, err error)
- func (ac *ApiClient) TradableInfo(ids ...string) (res []swagger.TradableInfo, err error)
- func (ac *ApiClient) TradableTrades(ids ...string) (res []swagger.PublicTrades, err error)
- func (ac *ApiClient) UpdateOrder(accno, id int64) (res swagger.OrderReply, err error)
- type ErrorHolder
- type ErrorStatus
- type OrderCondition
- type OrderSide
- type OrderTriggerDir
- type OrderType
- type Params
- type Request
- type RequestArgumentInfo
- type RequestBuilder
- func (rb *RequestBuilder) Exec(res interface{}) error
- func (rb *RequestBuilder) F(key string, val float64) *RequestBuilder
- func (rb *RequestBuilder) FA(key string, val []float64) *RequestBuilder
- func (rb *RequestBuilder) I(key string, val int64) *RequestBuilder
- func (rb *RequestBuilder) IA(key string, val []int64) *RequestBuilder
- func (rb *RequestBuilder) Price(key string, val float64) *RequestBuilder
- func (rb *RequestBuilder) S(key, val string) *RequestBuilder
- func (rb *RequestBuilder) V(key string, val interface{}) *RequestBuilder
- type RequestCommand
- type RequestCommandInfo
- func (rci *RequestCommandInfo) AddArgument(name string) *RequestCommandInfo
- func (rci *RequestCommandInfo) AddFullArgument(name, desc string, opts []string, optional bool) *RequestCommandInfo
- func (rci *RequestCommandInfo) AddOptArgument(name string) *RequestCommandInfo
- func (rci *RequestCommandInfo) Description(desc string) *RequestCommandInfo
- func (rci *RequestCommandInfo) GetArgumentNames() (res []string)
- func (rci *RequestCommandInfo) Handler(fun func(Params) (json.RawMessage, error)) *RequestCommandInfo
- func (rci *RequestCommandInfo) TTL(ttl int64) *RequestCommandInfo
- func (rci *RequestCommandInfo) TTLHours(hours int64) *RequestCommandInfo
- type RequestCommandTransport
- type Response
- type Transport
- type TransportCacheHandler
- type TransportCacheHandlerFn
- type TransportHandler
- type TransportRouter
Constants ¶
View Source
const ( FAK OrderType = "FAK" FOK = "FOK" LIMIT = "LIMIT" STOP_LIMIT = "STOP_LIMIT" STOP_TRAILING = "STOP_TRAILING" OCO = "OCO" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountOrder ¶
type AccountOrder struct { Accno int64 `json:"accno"` OrderId int64 `json:"orderid,omitempty"` // Only when modifying existing // Mandatory Identifier string `json:"identifier"` MarketId int64 `json:"market_id"` Price float64 `json:"price"` Volume int64 `json:"volume,omitempty"` Side OrderSide `json:"side"` // Omited == LIMIT OrderType OrderType `json:"order_type,omitempty"` // Special Currency string `json:"currency,omitempty"` ValidUntil string `json:"valid_until,omitempty"` OpenVolume int64 `json:"open_volume,omitempty"` Reference string `json:"reference,omitempty"` ActivationCondition OrderCondition `json:"activation_condition,omitempty"` TriggerCondition OrderTriggerDir `json:"trigger_condition,omitempty"` TriggerValue float64 `json:"trigger_value,omitempty"` }
func (AccountOrder) Apply ¶
func (ao AccountOrder) Apply(b *RequestBuilder) (ret *RequestBuilder)
type ApiClient ¶
type ApiClient struct {
// contains filtered or unexported fields
}
func NewApiClient ¶
func NewApiClient(ph TransportHandler) *ApiClient
func (*ApiClient) Account ¶
func (ac *ApiClient) Account(accno int64) (res swagger.AccountInfo, err error)
func (*ApiClient) AccountLedgers ¶
func (ac *ApiClient) AccountLedgers(accno int64) (res swagger.LedgerInformation, err error)
func (*ApiClient) AccountOrders ¶
func (*ApiClient) AccountPositions ¶
func (*ApiClient) AccountTrades ¶
func (*ApiClient) ActivateOrder ¶
func (ac *ApiClient) ActivateOrder(accno, id int64) (res swagger.OrderReply, err error)
func (*ApiClient) CreateOrder ¶
func (ac *ApiClient) CreateOrder(order *AccountOrder) (res swagger.OrderReply, err error)
func (*ApiClient) CreateSimpleOrder ¶
func (*ApiClient) CustomRequest ¶
func (ac *ApiClient) CustomRequest(command string) (rb *RequestBuilder)
Custom
func (*ApiClient) DeleteOrder ¶
func (ac *ApiClient) DeleteOrder(accno, id int64) (res swagger.OrderReply, err error)
func (*ApiClient) FeedStatus ¶
func (*ApiClient) FeedSubNews ¶
func (*ApiClient) GetTransport ¶
func (ac *ApiClient) GetTransport() TransportHandler
func (*ApiClient) Indicators ¶
func (*ApiClient) InstrumentLeverages ¶
func (*ApiClient) InstrumentLookup ¶
func (ac *ApiClient) InstrumentLookup(typ, instrument string) (res []swagger.Instrument, err error)
func (ac *ApiClient) InstrumentLeverageFilters(pathMap{id int64})(res swagger.,err error) { err = ac.build(InstrumentLeverageFiltersCmd). &) return }
func (ac *ApiClient) InstrumentOptionPairs(pathMap{id int64})(res swagger.,err error) { err = ac.build(InstrumentOptionPairsCmd). &) return }
func (ac *ApiClient) InstrumentOptionPairFilters(pathMap{id int64})(res swagger.,err error) { err = ac.build(InstrumentOptionPairFiltersCmd). &) return }
The lookup_type is isin_code_currency_market_id or market_id_identifier
func (*ApiClient) InstrumentSearch ¶
func (ac *ApiClient) InstrumentSearch(query string) (res []swagger.Instrument, err error)
func (*ApiClient) InstrumentSearchStream ¶
func (ac *ApiClient) InstrumentSearchStream(query, types string, fuzzy bool) (ret chan swagger.Instrument)
The advanced instrument search will page, and return the results in a chan. Ignoring error for now
func (*ApiClient) InstrumentTypes ¶
func (ac *ApiClient) InstrumentTypes() (res []swagger.InstrumentType, err error)
func (*ApiClient) InstrumentUnderlyings ¶
func (ac *ApiClient) InstrumentUnderlyings(typ, currency string) (res []swagger.Instrument, err error)
func (ac *ApiClient) InstrumentType(pathMap{pathMap{"Type",fmtInt}})(res swagger.,err error) { err = ac.build(InstrumentTypeCmd). &) return }
func (*ApiClient) Instruments ¶
func (ac *ApiClient) Instruments(ids ...int64) (res []swagger.Instrument, err error)
func (*ApiClient) NewsSources ¶
func (ac *ApiClient) NewsSources() (res []swagger.NewsSource, err error)
func (ac *ApiClient) SearchNews()(res swagger.,err error) { err = ac.build(SearchNewsCmd). &) return }
func (ac *ApiClient) News(pathMap{ids []int64})(res swagger.,err error) { err = ac.build(NewsCmd). &) return }
func (*ApiClient) RealtimeAccess ¶
func (ac *ApiClient) RealtimeAccess() (res []swagger.RealtimeAccess, err error)
func (*ApiClient) TickSize ¶
func (ac *ApiClient) TickSize(ids ...int64) (res []swagger.TicksizeTable, err error)
func (*ApiClient) TickSizes ¶
func (ac *ApiClient) TickSizes() (res []swagger.TicksizeTable, err error)
func (*ApiClient) TradableDay ¶
func (ac *ApiClient) TradableDay(ids ...string) (res []swagger.IntradayGraph, err error)
func (*ApiClient) TradableInfo ¶
func (ac *ApiClient) TradableInfo(ids ...string) (res []swagger.TradableInfo, err error)
func (*ApiClient) TradableTrades ¶
func (ac *ApiClient) TradableTrades(ids ...string) (res []swagger.PublicTrades, err error)
func (*ApiClient) UpdateOrder ¶
func (ac *ApiClient) UpdateOrder(accno, id int64) (res swagger.OrderReply, err error)
type ErrorHolder ¶
type ErrorHolder struct { Status ErrorStatus `json:"status,omitempty"` Message string `json:"message,omitempty"` }
func (*ErrorHolder) Error ¶
func (eh *ErrorHolder) Error() string
type ErrorStatus ¶
type ErrorStatus int64
type OrderCondition ¶
type OrderCondition string
type OrderTriggerDir ¶
type OrderTriggerDir string
type Request ¶
type Request struct { Command RequestCommand `json:"cmd"` Args Params `json:"args,omitempty"` }
func NewRequest ¶
func NewRequest(command RequestCommand, params map[string]string) (req *Request, err error)
type RequestArgumentInfo ¶
type RequestBuilder ¶
type RequestBuilder struct {
// contains filtered or unexported fields
}
func (*RequestBuilder) Exec ¶
func (rb *RequestBuilder) Exec(res interface{}) error
func (*RequestBuilder) F ¶
func (rb *RequestBuilder) F(key string, val float64) *RequestBuilder
func (*RequestBuilder) FA ¶
func (rb *RequestBuilder) FA(key string, val []float64) *RequestBuilder
func (*RequestBuilder) I ¶
func (rb *RequestBuilder) I(key string, val int64) *RequestBuilder
func (*RequestBuilder) IA ¶
func (rb *RequestBuilder) IA(key string, val []int64) *RequestBuilder
func (*RequestBuilder) Price ¶
func (rb *RequestBuilder) Price(key string, val float64) *RequestBuilder
func (*RequestBuilder) S ¶
func (rb *RequestBuilder) S(key, val string) *RequestBuilder
func (*RequestBuilder) V ¶
func (rb *RequestBuilder) V(key string, val interface{}) *RequestBuilder
type RequestCommand ¶
type RequestCommand string
const ( // Internally used. A well behaving transport should return the commands it can handle TransportRespondsToCmd RequestCommand = "TransportRespondsTo" SessionCmd RequestCommand = "Session" AccountsCmd RequestCommand = "Accounts" AccountCmd RequestCommand = "Account" AccountLedgersCmd RequestCommand = "AccountLedgers" AccountOrdersCmd RequestCommand = "AccountOrders" CreateOrderCmd RequestCommand = "CreateOrder" ActivateOrderCmd RequestCommand = "ActivateOrder" UpdateOrderCmd RequestCommand = "UpdateOrder" DeleteOrderCmd RequestCommand = "DeleteOrder" AccountPositionsCmd RequestCommand = "AccountPositions" AccountTradesCmd RequestCommand = "AccountTrades" CountriesCmd RequestCommand = "Countries" IndicatorsCmd RequestCommand = "Indicators" InstrumentsCmd RequestCommand = "Instruments" InstrumentSearchCmd RequestCommand = "InstrumentSearch" InstrumentLookupCmd RequestCommand = "InstrumentLookup" InstrumentLeveragesCmd RequestCommand = "InstrumentLeverages" InstrumentLeverageFiltersCmd RequestCommand = "InstrumentLeverageFilters" InstrumentOptionPairsCmd RequestCommand = "InstrumentOptionPairs" InstrumentOptionPairFiltersCmd RequestCommand = "InstrumentOptionPairFilters" InstrumentSectorsCmd RequestCommand = "InstrumentSectors" InstrumentSectorCmd RequestCommand = "InstrumentSector" InstrumentTypesCmd RequestCommand = "InstrumentTypes" InstrumentUnderlyingsCmd RequestCommand = "InstrumentUnderlyings" ListsCmd RequestCommand = "Lists" ListCmd RequestCommand = "List" MarketCmd RequestCommand = "Market" SearchNewsCmd RequestCommand = "SearchNews" NewsCmd RequestCommand = "News" NewsSourcesCmd RequestCommand = "NewsSources" RealtimeAccessCmd RequestCommand = "RealtimeAccess" TickSizesCmd RequestCommand = "TickSizes" TickSizeCmd RequestCommand = "TickSize" TradableInfoCmd RequestCommand = "TradableInfo" TradableIntradayCmd RequestCommand = "TradableIntraday" TradableTradesCmd RequestCommand = "TradableTrades" FeedSubCmd RequestCommand = "FeedSubscribe" FeedUnsubCmd RequestCommand = "FeedUnsubscribe" FeedStatusCmd RequestCommand = "FeedStatus" FeedLastCmd RequestCommand = "FeedLast" )
The commands that we support. Will be mapped in the low level TransportHandler
type RequestCommandInfo ¶
type RequestCommandInfo struct { Command RequestCommand `json:"cmd"` Desc string `json:"desc,omitempty"` Arguments []RequestArgumentInfo `json:"args,omitempty"` TimeToLive int64 `json:"ttl,omitempty"` HandlerFn func(Params) (json.RawMessage, error) `json:"-"` // If implemented, we can }
Is used as return struct for TransportRespondsToCmd
func (*RequestCommandInfo) AddArgument ¶
func (rci *RequestCommandInfo) AddArgument(name string) *RequestCommandInfo
For builder pattern
func (*RequestCommandInfo) AddFullArgument ¶
func (rci *RequestCommandInfo) AddFullArgument(name, desc string, opts []string, optional bool) *RequestCommandInfo
For builder pattern
func (*RequestCommandInfo) AddOptArgument ¶
func (rci *RequestCommandInfo) AddOptArgument(name string) *RequestCommandInfo
For builder pattern
func (*RequestCommandInfo) Description ¶
func (rci *RequestCommandInfo) Description(desc string) *RequestCommandInfo
For builder pattern
func (*RequestCommandInfo) GetArgumentNames ¶
func (rci *RequestCommandInfo) GetArgumentNames() (res []string)
func (*RequestCommandInfo) Handler ¶
func (rci *RequestCommandInfo) Handler(fun func(Params) (json.RawMessage, error)) *RequestCommandInfo
For builder pattern
func (*RequestCommandInfo) TTL ¶
func (rci *RequestCommandInfo) TTL(ttl int64) *RequestCommandInfo
For builder pattern
func (*RequestCommandInfo) TTLHours ¶
func (rci *RequestCommandInfo) TTLHours(hours int64) *RequestCommandInfo
For builder pattern
type RequestCommandTransport ¶
type RequestCommandTransport map[RequestCommand]*RequestCommandInfo
func (RequestCommandTransport) AddCommand ¶
func (rct RequestCommandTransport) AddCommand(name string) *RequestCommandInfo
func (RequestCommandTransport) Preform ¶
func (rct RequestCommandTransport) Preform(req *Request) (res Response)
type Response ¶
type Response struct { Error *ErrorHolder `json:"error,omitempty"` // Error, if any. nil if not Payload json.RawMessage `json:"payload,omitempty"` // Response payload as JSON }
func (*Response) Fail ¶
func (ar *Response) Fail(status ErrorStatus, msg string)
type TransportCacheHandler ¶
type TransportCacheHandler interface {
Handle(RequestCommandInfo, TransportHandler, *Request) Response
}
type TransportCacheHandlerFn ¶
type TransportCacheHandlerFn func(RequestCommandInfo, TransportHandler, *Request) Response
func (TransportCacheHandlerFn) Handle ¶
func (tchf TransportCacheHandlerFn) Handle(rci RequestCommandInfo, th TransportHandler, r *Request) Response
type TransportHandler ¶
type TransportRouter ¶
type TransportRouter struct {
// contains filtered or unexported fields
}
func NewCachedTransportRouter ¶
func NewCachedTransportRouter(ch TransportCacheHandler, transports ...TransportHandler) (tr *TransportRouter, err error)
func NewTransportRouter ¶
func NewTransportRouter(transports ...TransportHandler) (tr *TransportRouter, err error)
func (*TransportRouter) AddTransportHandler ¶
func (tr *TransportRouter) AddTransportHandler(th TransportHandler) (err error)
func (TransportRouter) Preform ¶
func (tr TransportRouter) Preform(req *Request) (res Response)
Click to show internal directories.
Click to hide internal directories.