Documentation
¶
Index ¶
- Constants
- Variables
- type ConnHandler
- type ConnState
- type DisconnHandler
- type EtnaConfig
- type EtnaREST
- func (api *EtnaREST) CancelOrder(ctx context.Context, accId uint32, orderId uint64) error
- func (api *EtnaREST) GetAvailableExchanges(ctx context.Context) ([]string, error)
- func (api *EtnaREST) GetBalance(ctx context.Context, accId uint32) (sch.TradingBalance, error)
- func (api *EtnaREST) GetBalanceHistory(ctx context.Context, accId uint32, fromTs, tillTs string) ([]sch.BalanceHistoryValue, error)
- func (api *EtnaREST) GetBars(ctx context.Context, params *sch.ReqBars) ([]sch.BarHist, error)
- func (api *EtnaREST) GetOrder(ctx context.Context, accId uint32, orderId uint64) (sch.Order, error)
- func (api *EtnaREST) GetOrders(ctx context.Context, accId uint32, active bool) ([]sch.Order, error)
- func (api *EtnaREST) GetPositions(ctx context.Context, accId uint32) ([]sch.Position, error)
- func (api *EtnaREST) GetSecurity(ctx context.Context, symbol string) (sch.Security, error)
- func (api *EtnaREST) GetStreamers(ctx context.Context, isFMP bool) (sch.Streamers, error)
- func (api *EtnaREST) GetTransfers(ctx context.Context, accId uint32) ([]sch.Transfer, error)
- func (api *EtnaREST) GetUser(ctx context.Context) (sch.UserInfo, error)
- func (api *EtnaREST) GetUserAccounts(ctx context.Context) ([]sch.Account, error)
- func (api *EtnaREST) GetUserSettings(ctx context.Context) (sch.UserTradingSettings, error)
- func (api *EtnaREST) ModifyUser(ctx context.Context) error
- func (api *EtnaREST) PlaceOrder(ctx context.Context, accId uint32, params *sch.OrderParams) (sch.Order, error)
- func (api *EtnaREST) RecoverStreamerSession(ctx context.Context, sessType sch.WSSessionType) (sch.SessionId, error)
- func (api *EtnaREST) RegisterUser(ctx context.Context, params *sch.ReqUserRegister) (sch.UserInfo, error)
- func (api *EtnaREST) ReplaceOrder(ctx context.Context, accId uint32, orderId uint64, params *sch.OrderParams) (sch.Order, error)
- func (api *EtnaREST) UpdateUserPasswd(ctx context.Context) error
- type EtnaWS
- type FmpWS
- type Logger
- type MessageHandler
- type StdLogger
- type WSClient
Constants ¶
const ( ConnectTimeout = 20 // the amount of seconds to wait for connection and authentication WSReconnInterval = 12 // base period in seconds for the reconnect period calculation WSMaxSilentPeriod = 30 // maximum period of silence, seconds )
const NASDAQ = "NASDAQ"
Variables ¶
var BaseSchedules = map[string]schema.MarketSchedule{
"NGS": {
MonOpen: 14400,
MonClose: 34199,
RegOpen: 34200,
RegClose: 56700,
EvnOpen: 57600,
EvnClose: 72000,
GateOpen: 29400,
Delta: -14400,
},
}
BaseSchedules contains the time of morning, regular and evening trading sessions
var DefaultConfig = defaultConfig()
var NasdaqMICs = map[string]struct{}{
"NMS": {},
"NGS": {},
"NCM": {},
"NDQ": {},
"NFI": {},
"NASD": {},
}
Functions ¶
This section is empty.
Types ¶
type ConnHandler ¶
type ConnHandler func(name string)
type DisconnHandler ¶
type EtnaConfig ¶
type EtnaREST ¶
type EtnaREST struct {
// contains filtered or unexported fields
}
func NewEtnaREST ¶
func (*EtnaREST) CancelOrder ¶
CancelOrder cancels an existing order for a specific account.
func (*EtnaREST) GetAvailableExchanges ¶
GetAvailableExchanges retrieves the list of user's available exchanges.
func (*EtnaREST) GetBalance ¶
GetBalance retrieves a trading balancedata for the authenticated user.
func (*EtnaREST) GetBalanceHistory ¶
func (api *EtnaREST) GetBalanceHistory(ctx context.Context, accId uint32, fromTs, tillTs string) ([]sch.BalanceHistoryValue, error)
GetBalanceHistory retrieves a slice of sch.TradingBalanceValue for the specified account of authenticated user.
func (*EtnaREST) GetBars ¶
GetBars retrieves historical bar data for a security based on the provided parameters. It validates the timeframe and makes a PUT request to the history API.
func (*EtnaREST) GetOrders ¶
GetOrders retrieves a list of orders for a specific account. Supports filtering for active orders and returns them sorted by creation date.
func (*EtnaREST) GetPositions ¶
GetPositions retrieves a slice of positions for the authenticated user.
func (*EtnaREST) GetSecurity ¶
GetSecurity retrieves details for a specific security by its symbol.
func (*EtnaREST) GetStreamers ¶
GetStreamers retrieves a list of streamers from the API.
func (*EtnaREST) GetTransfers ¶
func (*EtnaREST) GetUserAccounts ¶
GetUserAccounts retrieves a slice of user accounts for the authenticated user.
func (*EtnaREST) GetUserSettings ¶
GetUserSettings retrieves the authenticated user's trading settings.
func (*EtnaREST) PlaceOrder ¶
func (api *EtnaREST) PlaceOrder(ctx context.Context, accId uint32, params *sch.OrderParams) (sch.Order, error)
PlaceOrder submits a new order for a specific account. It automatically sets default values for TimeInforce and ExtendedHours if not provided.
func (*EtnaREST) RecoverStreamerSession ¶
func (api *EtnaREST) RecoverStreamerSession(ctx context.Context, sessType sch.WSSessionType) (sch.SessionId, error)
RecoverStreamerSession attempts to recover a streamer session of the specified type.
func (*EtnaREST) RegisterUser ¶
type EtnaWS ¶
type EtnaWS struct {
WSClient
QuotesChan chan sch.EtnaQuote
BarsChan chan sch.Bar
BalanceChan chan sch.TradingBalance
PositionsChan chan sch.Position
OrdersChan chan sch.Order
// contains filtered or unexported fields
}
func NewEtnaWS ¶
func NewEtnaWS(name, url string, login, passwd []byte, userSessId, streamSessId sch.SessionId, logger Logger, hdlConn ConnHandler, hdlDisconn DisconnHandler) *EtnaWS
NewEtnaWS creates the instance of EtnaWS, connects it to th e `baseUrl` and starts receive and ping goroutines.
type FmpWS ¶ added in v1.1.2
type FmpWS struct {
WSClient
QuotesChan chan sch.FmpQuote
// contains filtered or unexported fields
}
func NewFmpWS ¶ added in v1.1.2
func NewFmpWS(name string, fmpKey string, logger Logger, hdlConn ConnHandler, hdlDisconn DisconnHandler) *FmpWS
NewFmpWS creates the instance of FmpWS
func (*FmpWS) Subscribe ¶ added in v1.1.2
Subscribe sends a subscription request for a specific topic and keys. It checks for an existing connection and prevents duplicate subscriptions.
func (*FmpWS) Unsubscribe ¶ added in v1.1.2
Unsubscribe sends an unsubscription request for a specific topic and keys. It checks for an existing connection and the presence of the subscription before sending the unsubscribe command.
type Logger ¶
type Logger interface {
Info(format string, v ...any)
Debug(format string, v ...any)
Error(format string, v ...any)
Fatal(format string, v ...any)
}
func ColouredLogger ¶
type MessageHandler ¶ added in v1.1.2
type WSClient ¶ added in v1.1.2
type WSClient struct {
// contains filtered or unexported fields
}
func NewWSClient ¶ added in v1.1.2
func NewWSClient(name string, logger Logger, hdlConn ConnHandler, hdlDisconn DisconnHandler) WSClient
func (*WSClient) IsOperational ¶ added in v1.1.2
IsOperational returns the current connection status of the WebSocket client.
Returns:
true if the client is currently connected, false otherwise.
func (*WSClient) SetConnectFunc ¶ added in v1.1.2
func (*WSClient) SetMessageHandler ¶ added in v1.1.2
func (ws *WSClient) SetMessageHandler(h MessageHandler)