goetna

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: LGPL-2.1 Imports: 23 Imported by: 0

README

goetna

ETNA API client

Documentation

Index

Constants

View Source
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
)
View Source
const NASDAQ = "NASDAQ"

Variables

View Source
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

View Source
var DefaultConfig = defaultConfig()
View Source
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 ConnState

type ConnState uint32

type DisconnHandler

type DisconnHandler func(code int, text string) error

type EtnaConfig

type EtnaConfig struct {
	RestUrlPub, RestUrlNonRTH, RestUrlPriv string
	WSUrlPub, WSUrlPubFMP, WSUrlPriv       string
	RestTimeout                            time.Duration
	WSPingTimeout                          time.Duration
	WSMaxSilentPeriod                      int64 // Maximum period of silence, seconds
}

type EtnaREST

type EtnaREST struct {
	// contains filtered or unexported fields
}

func NewEtnaREST

func NewEtnaREST(apiKey, nonRTHToken string, login, passwd []byte, isPrivate bool, logger Logger) (*EtnaREST, error)

func (*EtnaREST) CancelOrder

func (api *EtnaREST) CancelOrder(ctx context.Context, accId uint32, orderId uint64) error

CancelOrder cancels an existing order for a specific account.

func (*EtnaREST) GetAvailableExchanges

func (api *EtnaREST) GetAvailableExchanges(ctx context.Context) ([]string, error)

GetAvailableExchanges retrieves the list of user's available exchanges.

func (*EtnaREST) GetBalance

func (api *EtnaREST) GetBalance(ctx context.Context, accId uint32) (sch.TradingBalance, error)

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

func (api *EtnaREST) GetBars(ctx context.Context, params *sch.ReqBars) ([]sch.BarHist, error)

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) GetOrder

func (api *EtnaREST) GetOrder(ctx context.Context, accId uint32, orderId uint64) (sch.Order, error)

GetOrder retrieves details for a specific order within an account.

func (*EtnaREST) GetOrders

func (api *EtnaREST) GetOrders(ctx context.Context, accId uint32, active bool) ([]sch.Order, error)

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

func (api *EtnaREST) GetPositions(ctx context.Context, accId uint32) ([]sch.Position, error)

GetPositions retrieves a slice of positions for the authenticated user.

func (*EtnaREST) GetSecurity

func (api *EtnaREST) GetSecurity(ctx context.Context, symbol string) (sch.Security, error)

GetSecurity retrieves details for a specific security by its symbol.

func (*EtnaREST) GetStreamers

func (api *EtnaREST) GetStreamers(ctx context.Context, isFMP bool) (sch.Streamers, error)

GetStreamers retrieves a list of streamers from the API.

func (*EtnaREST) GetTransfers

func (api *EtnaREST) GetTransfers(ctx context.Context, accId uint32) ([]sch.Transfer, error)

func (*EtnaREST) GetUser

func (api *EtnaREST) GetUser(ctx context.Context) (sch.UserInfo, error)

GetUser retrieves the authenticated user's information.

func (*EtnaREST) GetUserAccounts

func (api *EtnaREST) GetUserAccounts(ctx context.Context) ([]sch.Account, error)

GetUserAccounts retrieves a slice of user accounts for the authenticated user.

func (*EtnaREST) GetUserSettings

func (api *EtnaREST) GetUserSettings(ctx context.Context) (sch.UserTradingSettings, error)

GetUserSettings retrieves the authenticated user's trading settings.

func (*EtnaREST) ModifyUser

func (api *EtnaREST) ModifyUser(ctx context.Context) error

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

func (api *EtnaREST) RegisterUser(ctx context.Context, params *sch.ReqUserRegister) (sch.UserInfo, error)

func (*EtnaREST) ReplaceOrder

func (api *EtnaREST) ReplaceOrder(ctx context.Context, accId uint32, orderId uint64,
	params *sch.OrderParams) (sch.Order, error)

ReplaceOrder modifies an existing order for a specific account.

func (*EtnaREST) UpdateUserPasswd

func (api *EtnaREST) UpdateUserPasswd(ctx context.Context) error

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.

func (*EtnaWS) Subscribe

func (ws *EtnaWS) Subscribe(topic string, keys string) error

Subscribe sends a subscription request for a specific topic and keys. It checks for an existing connection and prevents duplicate subscriptions.

func (*EtnaWS) Unsubscribe

func (ws *EtnaWS) Unsubscribe(topic string, keys string) error

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 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

func (ws *FmpWS) Subscribe(key string) error

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

func (ws *FmpWS) Unsubscribe(key string) error

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

func ColouredLogger(name string) Logger

type MessageHandler added in v1.1.2

type MessageHandler func(topic string, dec *gjson.Decoder) error

type StdLogger

type StdLogger struct {
	// contains filtered or unexported fields
}

func (StdLogger) Debug

func (l StdLogger) Debug(format string, v ...any)

func (StdLogger) Error

func (l StdLogger) Error(format string, v ...any)

func (StdLogger) Fatal

func (l StdLogger) Fatal(format string, v ...any)

func (StdLogger) Info

func (l StdLogger) Info(format string, v ...any)

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

func (ws *WSClient) IsOperational() bool

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 (ws *WSClient) SetConnectFunc(f func() error)

func (*WSClient) SetMessageHandler added in v1.1.2

func (ws *WSClient) SetMessageHandler(h MessageHandler)

func (*WSClient) SetTopicFunc added in v1.1.2

func (ws *WSClient) SetTopicFunc(f func(data []byte) (string, error))

func (*WSClient) Start added in v1.1.2

func (ws *WSClient) Start() error

Start initiates the WebSocket connection and starts background processes for receiving messages.

func (*WSClient) Stop added in v1.1.2

func (ws *WSClient) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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