ticks

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WSS_URL = "wss://wss.tiqs.trading"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DepthLevel

type DepthLevel struct {
	Quantity int64 `json:"quantity"`
	Price    int32 `json:"price"`
	Orders   int16 `json:"orders"`
}

DepthLevel represents a single level in the market depth

type MarketDepth

type MarketDepth struct {
	Bids [5]DepthLevel `json:"bids"`
	Asks [5]DepthLevel `json:"asks"`
}

MarketDepth represents the full market depth with bids and asks

type TickData

type TickData struct {
	Token              int32       `json:"token"`
	LTP                int32       `json:"ltp"`
	NetChangeIndicator int32       `json:"net_change_indicator"`
	NetChange          int32       `json:"net_change"`
	LTQ                int32       `json:"ltq"`
	AvgPrice           int32       `json:"avg_price"`
	TotalBuyQty        int64       `json:"total_buy_qty"`
	TotalSellQty       int64       `json:"total_sell_qty"`
	Open               int32       `json:"open"`
	High               int32       `json:"high"`
	Close              int32       `json:"close"`
	Low                int32       `json:"low"`
	Volume             int64       `json:"volume"`
	LTT                int32       `json:"ltt"`
	Time               int32       `json:"time"`
	OI                 int32       `json:"oi"`
	OIDayHigh          int32       `json:"oi_day_high"`
	OIDayLow           int32       `json:"oi_day_low"`
	LowerLimit         int32       `json:"lower_limit"`
	UpperLimit         int32       `json:"upper_limit"`
	MarketDepth        MarketDepth `json:"market_depth"`
}

TickData represents the complete market data for a token

type WS

type WS struct {
	AppID      string
	Token      string
	TokenList  []int
	Conn       *websocket.Conn
	URL        string
	RetryDelay time.Duration
	MaxRetries int

	DataChan chan TickData
	// contains filtered or unexported fields
}

WS represents the WebSocket client

func NewWS

func NewWS(appId, token string) *WS

NewWS creates a new WebSocket client instance

func (*WS) Close

func (ws *WS) Close() error

Close closes the WebSocket connection and cleanup

func (*WS) Connect

func (ws *WS) Connect() error

Connect establishes a WebSocket connection

func (*WS) GetDataChannel

func (ws *WS) GetDataChannel() <-chan TickData

GetDataChannel returns the channel for receiving market data

func (*WS) GetErrorChannel

func (ws *WS) GetErrorChannel() <-chan error

GetErrorChannel returns the channel for receiving errors

func (*WS) Subscribe

func (ws *WS) Subscribe(tokens []int, mode string) error

Subscribe subscribes to market data for given tokens

func (*WS) Unsubscribe

func (ws *WS) Unsubscribe(tokens []int, mode string) error

Unsubscribe removes subscription for given tokens

Jump to

Keyboard shortcuts

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