xena

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BTCUSDT Symbol = "BTC/USDT"
	ETHSDT  Symbol = "ETH/USDT"
	XBTUSD  Symbol = "XBTUSD"
	ETHUSD  Symbol = "ETHUSD"

	SideBuy  Side = "1"
	SideSell Side = "2"

	ThrottleDOMDefault DOMThrottle = "0s"
	ThrottleDOM500ms   DOMThrottle = "500ms"
	ThrottleDOM5s      DOMThrottle = "5s"

	RestThrottleDOMDefault RestDOMThrottle = 500
	RestThrottleDOM500ms   RestDOMThrottle = 50
	RestThrottleDOM0s      RestDOMThrottle = 0

	ThrottleCandlesDefault CandlesThrottle = "0s"
	ThrottleCandles250ms   CandlesThrottle = "250ms"
	ThrottleCandles1s      CandlesThrottle = "1s"

	ThrottleTradesDefault TradesThrottle = "0s"
	ThrottleTrades500ms   TradesThrottle = "500ms"
	ThrottleTrades5s      TradesThrottle = "5s"

	CancelOrdersForASecurity = "1"
	CancelAllOrders          = "7"

	PosTransTypeCollapse  = "20"
	PosMaintActionReplace = "2"

	PositionEffectClose   PositionEffect = "C"
	PositionEffectOpen    PositionEffect = "O"
	PositionEffectDefault PositionEffect = "D"

	AggregateBookDefault AggregateBook = 0
	AggregateBook5       AggregateBook = 5
	AggregateBook10      AggregateBook = 10
	AggregateBook25      AggregateBook = 25
	AggregateBook50      AggregateBook = 50
	AggregateBook100     AggregateBook = 100
	AggregateBook250     AggregateBook = 250

	MarketDepthDefault MarketDepth = 0
	MarketDepth10      MarketDepth = 10
	MarketDepth20      MarketDepth = 20
)

Variables

This section is empty.

Functions

func CreateCancelRequestFromExecutionReport

func CreateCancelRequestFromExecutionReport(cancelID string, executionReport *xmsg.ExecutionReport) *xmsg.OrderCancelRequest

CreateCancelRequestFromExecutionReport creates new cancel request of order, based on execution report.

func CreateLimitOrder

func CreateLimitOrder(clOrdId string, symbol string, side Side, orderQty string, account uint64, price string) limitOrder

CreateLimitOrder creates new builder of limit order.

func CreateMarketIfTouchOrder

func CreateMarketIfTouchOrder(clOrdId string, symbol string, side Side, orderQty string, account uint64, stopPx string) marketIfTouchOrder

CreateMarketIfTouchOrder creates new builder of market-if-touch order.

func CreateMarketOrder

func CreateMarketOrder(clOrdId string, symbol string, side Side, orderQty string, account uint64) marketOrder

CreateMarketOrder creates new builder of market order.

func CreateOrderMassCancel

func CreateOrderMassCancel(account uint64, clOrdId string) orderMassCancel

CreateOrderMassCancel creates new builder of mass cancel order.

func CreateReplace

func CreateReplace(replaceId string, executionReport *xmsg.ExecutionReport) xmsg.OrderCancelReplaceRequest

CreateReplace creates new cancel request and replace request of order, based on execution report.

func CreateStopOrder

func CreateStopOrder(clOrdId string, symbol string, side Side, orderQty string, account uint64, stopPx string) stopOrder

CreateStopOrder creates new builder of stop order.

func DefaultMarketDisconnectHandler

func DefaultMarketDisconnectHandler(client MarketDataClient, logger Logger)

DefaultMarketDisconnectHandler is a default reconnects handler.

func DefaultTradingDisconnectHandler

func DefaultTradingDisconnectHandler(client TradingClient, logger Logger)

DefaultTradingDisconnectHandler is a default reconnects handler.

func ID

func ID(prefix string) string

ID function generates new random id.

func IsMargin

func IsMargin(accountId uint64) bool

IsMargin returns true if accountId is margin account.

func WithRestMarketDataHost

func WithRestMarketDataHost(conf *restConf)

WithRestMarketDataHost sets the url for connection to market data api.

func WithRestTradingHost

func WithRestTradingHost(conf *restConf)

WithRestMarketDataHost sets the url for connection to trading api.

Types

type ActiveOrdersRequest

type ActiveOrdersRequest struct {
	Symbol *string
}

func (ActiveOrdersRequest) SetSymbol

func (p ActiveOrdersRequest) SetSymbol(symbol string) ActiveOrdersRequest

type AggregateBook

type AggregateBook int64

type BalanceIncrementalRefreshHandler

type BalanceIncrementalRefreshHandler func(t TradingClient, m *xmsg.BalanceIncrementalRefresh)

BalanceIncrementalRefreshHandler is used to handling BalanceIncrementalRefresh message.

type BalanceSnapshotRefreshHandler

type BalanceSnapshotRefreshHandler func(t TradingClient, m *xmsg.BalanceSnapshotRefresh)

BalanceSnapshotRefreshHandler is used to handling BalanceSnapshotRefresh message.

type CandlesThrottle

type CandlesThrottle string

type ConnectHandler

type ConnectHandler func(client WsClient)

ConnectHandler function is a connection handler.

type DOMHandler

type DOMHandler func(md MarketDataClient, m *xmsg.MarketDataRefresh)

DOMHandler function is a DOM handler.

type DOMThrottle

type DOMThrottle string

type DisconnectHandler

type DisconnectHandler func()

DisconnectHandler function is a disconnect handler.

type ErrHandler

type ErrHandler func(err error)

ErrHandler function is a error handler.

type ExecutionReportHandler

type ExecutionReportHandler func(t TradingClient, m *xmsg.ExecutionReport)

ExecutionReportHandler is used to handling ExecutionReport message.

type Handler

type Handler func(msg []byte)

Handler function is raw message handler.

type HeartbeatHandler

type HeartbeatHandler func(t TradingClient, m *xmsg.Heartbeat)

HeartbeatHandler is used to handling Heartbeat message.

type LastOrderStatusesRequest

type LastOrderStatusesRequest struct {
	Symbol     *string
	From       *time.Time
	To         *time.Time
	PageNumber *int
	Limit      *int
}

func (LastOrderStatusesRequest) SetFromTo

func (LastOrderStatusesRequest) SetPage

func (p LastOrderStatusesRequest) SetPage(pageNumber, limit int) LastOrderStatusesRequest

func (LastOrderStatusesRequest) SetSymbol

type ListStatusHandler

type ListStatusHandler func(t TradingClient, m *xmsg.ListStatus)

ListStatusHandler is used to handling ListStatus message.

type Logger

type Logger interface {
	// Debugf prints debug message. Arguments are handled in the manner of fmt.Printf.
	Debugf(format string, v ...interface{})
	// Errorf prints error message. Arguments are handled in the manner of fmt.Printf.
	Errorf(format string, v ...interface{})
}

Logger interface

type LogonHandler

type LogonHandler func(t TradingClient, m *xmsg.Logon)

LogonHandler is used to handling logon message.

type MDHandler

MDHandler function is a market date handler.

type MarginRequirementReportHandler

type MarginRequirementReportHandler func(t TradingClient, m *xmsg.MarginRequirementReport)

MarginRequirementReportHandler is used to handling MarginRequirementReport message.

type MarketDataClient

type MarketDataClient interface {
	// Client is obsolete and will be removed the next version
	Client() WsClient

	// SubscribeOnDOM is obsolete and it will be removed the next version
	SubscribeOnDOM(symbol Symbol, handler DOMHandler, opts ...interface{}) (streamID string, err error)

	// UnsubscribeOnDOM is obsolete and it will be removed the next version
	UnsubscribeOnDOM(streamID string) error

	// ConnectAndLogon connects to websocket and waits for Logon message.
	// Logon.RejectText contains reject reason.
	Connect() (*xmsg.Logon, error)

	// SetDisconnectHandler subscribes to disconnect events.
	SetDisconnectHandler(handler MarketDisconnectHandler)

	// SubscribeOnCandles subscribes on candles messages.
	SubscribeOnCandles(symbol, timeframe string, handler MDHandler, opts ...interface{}) (streamID string, err error)

	// SubscribeOnDom subscribes on candles messages.
	SubscribeOnDom(symbol string, handler MDHandler, opts ...interface{}) (streamID string, err error)

	// SubscribeOnTrades subscribes on candles messages.
	SubscribeOnTrades(symbol string, handler MDHandler, opts ...interface{}) (streamID string, err error)

	// SubscribeOnMarketWatch subscribes on candles messages.
	SubscribeOnMarketWatch(symbol string, handler MDHandler) (streamID string, err error)

	// Unsubscribe unsubscribes from messages by streamID.
	Unsubscribe(streamID string) error
}

MarketDataClient is websocket client interface of Xena market data.

func NewMarketData

func NewMarketData(opts ...WsOption) MarketDataClient

NewMarketData creates websocket client of Xena market data.

type MarketDataLogonHandler

type MarketDataLogonHandler func(md MarketDataClient, m *xmsg.Logon)

MarketDataLogonHandler function is logon response handler.

type MarketDataREST

type MarketDataREST interface {
	// GetServerTime returns server time.
	GetServerTime() (time.Time, error)
	// GetInstruments returns instruments.
	GetInstruments() ([]*xmsg.Instrument, error)
	// GetTrades returns trades.
	GetTrades(symbol string, from, to time.Time, page, limit int64) (*xmsg.MarketDataRefresh, error)
	// GetDom returns dom.
	GetDom(symbol string, opts ...interface{}) (*xmsg.MarketDataRefresh, error)
	// GetCandles returns candles.
	GetCandles(symbol string, timeFrame string, from, to time.Time) (*xmsg.MarketDataRefresh, error)
}

MarketDataREST is a rest client interface of the Xena market data.

func NewMarketDataREST

func NewMarketDataREST(options ...RestOption) MarketDataREST

NewMarketDataREST creates a rest client of Xena market data.

type MarketDataRejectHandler

type MarketDataRejectHandler func(md MarketDataClient, m *xmsg.MarketDataRequestReject)

MarketDataRejectHandler function is reject response handler.

type MarketDepth

type MarketDepth int64

MarketDepth is level depth limit in dom.

type MarketDisconnectHandler

type MarketDisconnectHandler func(client MarketDataClient, logger Logger)

MarketDisconnectHandler function is a disconnect handler.

type MassPositionReportHandler

type MassPositionReportHandler func(t TradingClient, m *xmsg.MassPositionReport)

MassPositionReportHandler is used to handling MassPositionReport message.

type MassTradeCaptureReportResponseHandler

type MassTradeCaptureReportResponseHandler func(t TradingClient, m *xmsg.MassTradeCaptureReportResponse)

MassTradeCaptureReportResponseHandler is used to handling MassTradeCaptureReportResponse message.

type OrderCancelRejectHandler

type OrderCancelRejectHandler func(t TradingClient, m *xmsg.OrderCancelReject)

OrderCancelRejectHandler is used to handling OrderCancelReject message.

type OrderHistoryRequest

type OrderHistoryRequest struct {
	ClOrdId    *string
	OrderId    *string
	Symbol     *string
	From       *time.Time
	To         *time.Time
	PageNumber *int
	Limit      *int
}

func (OrderHistoryRequest) SetClOrdId

func (p OrderHistoryRequest) SetClOrdId(clOrdId string) OrderHistoryRequest

func (OrderHistoryRequest) SetFromTo

func (p OrderHistoryRequest) SetFromTo(from, to time.Time) OrderHistoryRequest

func (OrderHistoryRequest) SetOrderId

func (p OrderHistoryRequest) SetOrderId(orderId string) OrderHistoryRequest

func (OrderHistoryRequest) SetPage

func (p OrderHistoryRequest) SetPage(pageNumber, limit int) OrderHistoryRequest

func (OrderHistoryRequest) SetSymbol

func (p OrderHistoryRequest) SetSymbol(symbol string) OrderHistoryRequest

type OrderMassCancelReportHandler

type OrderMassCancelReportHandler func(t TradingClient, m *xmsg.OrderMassCancelReport)

OrderMassCancelReportHandler is used to handling OrderMassCancelReport message.

type OrderMassStatusResponseHandler

type OrderMassStatusResponseHandler func(t TradingClient, m *xmsg.OrderMassStatusResponse)

OrderMassStatusResponseHandler is used to handling OrderMassStatusResponse message.

type OrderRequest

type OrderRequest struct {
	ClOrdId *string
	OrderId *string
}

func (OrderRequest) SetClOrdId

func (p OrderRequest) SetClOrdId(clOrdId string) OrderRequest

func (OrderRequest) SetOrderId

func (p OrderRequest) SetOrderId(orderId string) OrderRequest

type PositionEffect

type PositionEffect string

type PositionMaintenanceReportHandler

type PositionMaintenanceReportHandler func(t TradingClient, m *xmsg.PositionMaintenanceReport)

PositionMaintenanceReportHandler is used to handling PositionMaintenanceReport message.

type PositionReportHandler

type PositionReportHandler func(t TradingClient, m *xmsg.PositionReport)

PositionReportHandler is used to handling PositionReport message.

type PositionsHistoryRequest

type PositionsHistoryRequest struct {
	PositionId       *uint64
	ParentPositionId *uint64
	Symbol           *string
	OpenFrom         *time.Time
	OpenTo           *time.Time
	CloseFrom        *time.Time
	CloseTo          *time.Time
	PageNumber       *int
	Limit            *int
}

func (PositionsHistoryRequest) SetCloseFrom

func (p PositionsHistoryRequest) SetCloseFrom(closeFrom time.Time) PositionsHistoryRequest

func (PositionsHistoryRequest) SetCloseTo

func (PositionsHistoryRequest) SetOpenFrom

func (p PositionsHistoryRequest) SetOpenFrom(openFrom time.Time) PositionsHistoryRequest

func (PositionsHistoryRequest) SetOpenTo

func (PositionsHistoryRequest) SetPage

func (p PositionsHistoryRequest) SetPage(limit, pageNumber int) PositionsHistoryRequest

func (PositionsHistoryRequest) SetParentPositionId

func (p PositionsHistoryRequest) SetParentPositionId(id uint64) PositionsHistoryRequest

func (PositionsHistoryRequest) SetPositionId

func (PositionsHistoryRequest) SetSymbol

type RejectHandler

type RejectHandler func(t TradingClient, m *xmsg.Reject)

RejectHandler is used to handling Reject message.

type RestDOMThrottle

type RestDOMThrottle int64

type RestOption

type RestOption func(conf *restConf)

func WithRestHost

func WithRestHost(url string) RestOption

WithRestHost sets the url for connection.

func WithRestLogger

func WithRestLogger(logger Logger) RestOption

WithRestLogger sets custom logger.

func WithRestUserAgent

func WithRestUserAgent(userAgent string) RestOption

WithRestUserAgent sets user agent.

type Side

type Side string

type Symbol

type Symbol string

Symbol is an instrument.

func (Symbol) String

func (s Symbol) String() string

type TradeHistoryRequest

type TradeHistoryRequest struct {
	TradeId    *string
	ClOrdId    *string
	Symbol     *string
	From       *time.Time
	To         *time.Time
	PageNumber *int
	Limit      *int
}

func (TradeHistoryRequest) SetClOrdId

func (p TradeHistoryRequest) SetClOrdId(clOrdId string) TradeHistoryRequest

func (TradeHistoryRequest) SetFromTo

func (p TradeHistoryRequest) SetFromTo(from, to time.Time) TradeHistoryRequest

func (TradeHistoryRequest) SetPage

func (p TradeHistoryRequest) SetPage(pageNumber, limit int) TradeHistoryRequest

func (TradeHistoryRequest) SetSymbol

func (p TradeHistoryRequest) SetSymbol(symbol string) TradeHistoryRequest

func (TradeHistoryRequest) SetTradeId

func (p TradeHistoryRequest) SetTradeId(tradeId string) TradeHistoryRequest

type TradesThrottle

type TradesThrottle string

type TradingClient

type TradingClient interface {
	// ListenLogon subscribes to Logon event.
	ListenLogon(handler LogonHandler)
	// ListenMarginRequirementReport subscribes to MarginRequirementReport event.
	ListenMarginRequirementReport(handler MarginRequirementReportHandler)
	// ListenExecutionReport subscribes to ExecutionReport event.
	ListenExecutionReport(handler ExecutionReportHandler)
	// ListenOrderCancelReject subscribes to OrderCancelReject event.
	ListenOrderCancelReject(handler OrderCancelRejectHandler)
	// ListenOrderMassStatusResponse subscribes to OrderMassStatusResponse event.
	ListenOrderMassStatusResponse(handler OrderMassStatusResponseHandler)
	// ListenMassTradeCaptureReportResponse subscribes to MassTradeCaptureReportResponse event.
	ListenMassTradeCaptureReportResponse(handler MassTradeCaptureReportResponseHandler)
	// ListenBalanceIncrementalRefresh subscribes to BalanceIncrementalRefresh event.
	ListenBalanceIncrementalRefresh(handler BalanceIncrementalRefreshHandler)
	// ListenBalanceSnapshotRefresh subscribes to BalanceSnapshotRefresh event.
	ListenBalanceSnapshotRefresh(handler BalanceSnapshotRefreshHandler)
	// ListenPositionReport subscribes to PositionReport event.
	ListenPositionReport(handler PositionReportHandler)
	// ListenMassPositionReport subscribes to MassPositionReport event.
	ListenMassPositionReport(handler MassPositionReportHandler)
	// ListenPositionMaintenanceReport subscribes to PositionMaintenanceReport event.
	ListenPositionMaintenanceReport(handler PositionMaintenanceReportHandler)
	// ListenReject subscribes to Reject event.
	ListenReject(handler RejectHandler)
	// ListenListStatus subscribes to ListStatus event.
	ListenListStatus(handler ListStatusHandler)
	// ListenOrderMassCancelReport subscribes to OrderMassCancelReport event.
	ListenOrderMassCancelReport(handler OrderMassCancelReportHandler)
	// ListenHeartbeat subscribes to Heartbeat event.
	ListenHeartbeat(handler HeartbeatHandler)

	// ConnectAndLogon connects to websocket and sends Logon message.
	// Logon.RejectText contains reject reason.
	ConnectAndLogon() (*xmsg.Logon, error)

	// Send function sends command to server.
	Send(cmd interface{}) error

	// AccountStatusReport requests an account status report.
	// To receive a response, the client should listen for ListenBalanceSnapshotRefresh.
	GetAccountStatusReport(account uint64, requestId string) error

	// GetPositions requests all positions.
	// To receive a response, the client should listen for ListenMassPositionReport.
	GetPositions(account uint64, requestId string) error

	// Order request for last execution report for order or cancel/replace requests
	// To receive a response, the client should listen for ListenExecutionReport.
	GetOrder(account uint64, requestId string, opt OrderRequest) error

	// Orders requests list of last execution reports for active orders.
	// To receive a response, the client should listen for ListenOrderMassStatusResponse.
	GetActiveOrders(account uint64, requestId string, opt ActiveOrdersRequest) error

	// Orders requests list of last execution reports for non-active orders.
	// To receive a response, the client should listen for ListenOrderMassStatusResponse.
	GetLastOrderStatuses(account uint64, requestId string, opt LastOrderStatusesRequest) error

	// Orders requests list of historical execution reports
	// To receive a response, the client should listen for ListenOrderMassStatusResponse.
	GetOrderHistory(account uint64, requestId string, opt OrderHistoryRequest) error

	// Orders requests list of historical execution reports
	// To receive a response, the client should listen for ListenOrderMassStatusResponse.
	GetTradeHistory(account uint64, requestId string, opt TradeHistoryRequest) error

	// MarketOrder places new market order.
	MarketOrder(account uint64, clOrdId string, symbol string, side Side, orderQty string) error

	// LimitOrder places new limit order.
	LimitOrder(account uint64, clOrdId string, symbol string, side Side, price string, orderQty string) error

	// StopOrder places new stop order.
	StopOrder(account uint64, clOrdId string, symbol string, side Side, stopPx string, orderQty string) error

	// MarketIfTouchOrder places new market-if-touch order.
	MarketIfTouchOrder(account uint64, clOrdId string, symbol string, side Side, stopPx string, orderQty string) error

	// Cancel function cancels an existing order.
	Cancel(cmd *xmsg.OrderCancelRequest) error

	// CancelByClOrdId cancels an existing order by original client order id.
	CancelByClOrdId(account uint64, clOrdId, origClOrdId, symbol string, side Side) error

	// CancelByOrderId cancels an existing order by order id.
	CancelByOrderId(account uint64, clOrdId, orderId, symbol string, side Side) error

	// MassCancel cancels all existing orders.
	// To receive a response, the client should listen for ListenOrderMassCancelReport.
	MassCancel(account uint64, clOrdId string) error

	// Replace cancels existing order and replaces by new order.
	Replace(request xmsg.OrderCancelReplaceRequest) error

	// CollapsePositions collapses all existing positions for margin account and symbol.
	CollapsePositions(account uint64, symbol string, requestId string) error

	// SetDisconnectHandler subscribes to disconnect events.
	SetDisconnectHandler(handler TradingDisconnectHandler)

	// SendApplicationHeartbeat sends application heartbeat.
	SendApplicationHeartbeat(groupId string, heartbeatInSec int32) error
}

TradingClient is websocket client interface of the Xena trading api.

func NewTradingClient

func NewTradingClient(apiKey, apiSecret string, accounts []uint64, opts ...WsOption) TradingClient

NewTradingClient creates websocket client of Xena trading.

type TradingDisconnectHandler

type TradingDisconnectHandler func(client TradingClient, logger Logger)

TradingDisconnectHandler function is a disconnect handler.

type TradingREST

type TradingREST interface {
	// NewOrder places new order.
	NewOrder(cmd *xmsg.NewOrderSingle) (*xmsg.ExecutionReport, error)

	// SendMarketOrder places new market order.
	SendMarketOrder(accountId uint64, clOrdId string, symbol string, side Side, orderQty string) (*xmsg.ExecutionReport, error)

	// SendLimitOrder places new limit order.
	SendLimitOrder(accountId uint64, clOrdId string, symbol string, side Side, price string, orderQty string) (*xmsg.ExecutionReport, error)

	// SendStopOrder places new stop order.
	SendStopOrder(accountId uint64, clOrdId string, symbol string, side Side, stopPx string, orderQty string) (*xmsg.ExecutionReport, error)

	// SendMarketIfTouchOrder place new market-if-touch order.
	SendMarketIfTouchOrder(accountId uint64, clOrdId string, symbol string, side Side, stopPx string, orderQty string) (*xmsg.ExecutionReport, error)

	// SendCancel function cancels existing order.
	SendCancel(cmd *xmsg.OrderCancelRequest) (*xmsg.ExecutionReport, error)

	// SendMassCancelCmd cancels all existing orders.
	SendMassCancelCmd(cmd *xmsg.OrderMassCancelRequest) (*xmsg.ExecutionReport, error)

	// SendCancelByClOrdId cancels existing order by original client order id.
	SendCancelByClOrdId(account uint64, clOrdId, origClOrdId, symbol string, side Side) (*xmsg.ExecutionReport, error)

	// SendCancelByOrderId cancels existing order by order id.
	SendCancelByOrderId(account uint64, clOrdId, orderId, symbol string, side Side) (*xmsg.ExecutionReport, error)

	// SendMassCancel cancels all existing orders.
	SendMassCancel(account uint64, clOrdId string) (*xmsg.ExecutionReport, error)

	// SendReplace cancels existing order and replaces by new order.
	SendReplace(request xmsg.OrderCancelReplaceRequest) (*xmsg.ExecutionReport, error)

	// SendCollapsePositions collapses all existing positions for margin account and symbol.
	SendCollapsePositions(account uint64, symbol string, requestId string) (*xmsg.PositionMaintenanceReport, error)

	// GetPositions requests all positions.
	GetPositions(account uint64, requestId string) ([]*xmsg.PositionReport, error)

	// GetPositionsHistory requests all positions history.
	GetPositionsHistory(accountId uint64, request PositionsHistoryRequest) ([]*xmsg.PositionReport, error)

	// GetOrder returns last execution report for order or cancel/replace request.
	GetOrder(account uint64, request OrderRequest) (*xmsg.ExecutionReport, error)

	// GetActiveOrders return list of active orders
	GetActiveOrders(account uint64, requeset ActiveOrdersRequest) ([]*xmsg.ExecutionReport, error)

	// GetLastOrderStatuses return list of last execution reports for non-active orders
	GetLastOrderStatuses(account uint64, requeset LastOrderStatusesRequest) ([]*xmsg.ExecutionReport, error)

	// GetOrderHistory return list of historical execution reports
	GetOrderHistory(account uint64, requeset OrderHistoryRequest) ([]*xmsg.ExecutionReport, error)

	// GetTradeHistory returns trade history.
	GetTradeHistory(accountId uint64, request TradeHistoryRequest) ([]*xmsg.ExecutionReport, error)

	// GetTradeHistory returns balance.
	GetBalance(accountId uint64) (*xmsg.BalanceSnapshotRefresh, error)

	// GetTradeHistory returns MarginRequirements.
	GetMarginRequirements(accountId uint64) (*xmsg.MarginRequirementReport, error)

	// GetTradeHistory returns accounts.
	GetAccounts() ([]*xmsg.AccountInfo, error)

	// SendApplicationHeartbeat sends application heartbeat.
	SendApplicationHeartbeat(groupId string, heartbeatInSec int32) error
}

TradingClient is rest client interface of the Xena trading api.

func NewTradingREST

func NewTradingREST(apiKey, apiSecret string, options ...RestOption) TradingREST

NewTradingREST creates rest client of Xena trading api.

type WsClient

type WsClient interface {
	IsConnected() bool
	Connect() error
	With(opt WsOption)
	Close()
	Write(m interface{}) error
	WriteString(msg string) error
	WriteBytes(data []byte) error
	Logger() Logger
	// contains filtered or unexported methods
}

WsClient is base websocket client interface of Xena.

func NewWsClient

func NewWsClient(opts ...WsOption) WsClient

NewWsClient creates instance of WsClient.

type WsOption

type WsOption func(s *wsClient)

WsOption is function that alter behavior.

func WithConnectHandler

func WithConnectHandler(fnc ConnectHandler) WsOption

WithConnectHandler sets custom connection handler.

func WithConnectTimeoutConnect

func WithConnectTimeoutConnect(interval time.Duration) WsOption

WithConnectTimeoutConnect sets timeout interval connection.

func WithDebug

func WithDebug() WsOption

WithDebug enables debug logging.

func WithDisconnectHandler

func WithDisconnectHandler(fnc DisconnectHandler) WsOption

WithDisconnectHandler sets custom disconnection handler.

func WithDisconnectTimeoutInterval

func WithDisconnectTimeoutInterval(interval time.Duration) WsOption

WithConnectTimeoutConnect sets timeout interval disconnect.

func WithErrHandler

func WithErrHandler(fnc ErrHandler) WsOption

WithErrHandler sets custom common error handler.

func WithHandler

func WithHandler(fnc Handler) WsOption

WithHandler sets custom common message handler.

func WithHeartbeatInterval

func WithHeartbeatInterval(d time.Duration) WsOption

WithHeartbeatInterval sets time interval between heartbeats.

func WithIgnorePingLog

func WithIgnorePingLog(disable bool) WsOption

WithIgnorePingLog disables ping logs.

func WithLocalURL

func WithLocalURL() WsOption

WithTradingURL sets the url for connection to the local market data.

func WithLogger

func WithLogger(logger Logger) WsOption

WithLogger sets custom logger.

func WithMarketDataURL

func WithMarketDataURL() WsOption

WithLocalURL sets the url for connection to the market data.

func WithTradingURL

func WithTradingURL() WsOption

WithTradingURL sets the url for connection to the trading api.

func WithURL

func WithURL(url string) WsOption

WithURL sets the url for connection.

func WithoutDebug

func WithoutDebug() WsOption

WithoutDebug disables debug logging.

Directories

Path Synopsis
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.

Jump to

Keyboard shortcuts

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