Documentation
¶
Overview ¶
Package ODINMarketFeed provides a Go Library for connecting to ODIN Market Feed WebSocket API. This library enables real-time market data streaming with built-in compression, fragmentation handling, and subscription management for trading applications.
Features:
- WebSocket connectivity with SSL/TLS support
- ZLIB compression and decompression
- Automatic message fragmentation handling
- Multiple subscription types (ChannelNum, SnapQuote, BestFive)
- Heartbeat mechanism for connection maintenance
- Thread-safe operations
- Binary data parsing for market data
Basic Usage:
client := odinclient.NewODINMarketFeedClient()
client.OnOpen = func() {
fmt.Println("Connected")
client.SubscribeChannelNum("1234,5678", 1)
}
client.OnMessage = func(message string) {
fmt.Println("Received:", message)
}
client.Connect("host.com", 8080, true, "user_id")
defer client.Disconnect()
For detailed examples and documentation, visit: https://github.com/SIPL-Dev/go-odinmarketfeedclient
Index ¶
- type CompressionStatus
- type FragmentationHandler
- type MarketData
- type ODINMarketFeedClient
- func (tw *ODINMarketFeedClient) Connect(host string, port int, useSSL bool, userID string, apiKey string) error
- func (tw *ODINMarketFeedClient) Disconnect() error
- func (tw *ODINMarketFeedClient) Dispose()
- func (tw *ODINMarketFeedClient) SendMessage(message string) error
- func (tw *ODINMarketFeedClient) SetCompression(enabled bool)
- func (tw *ODINMarketFeedClient) SubscribeBestFive(token string, marketSegmentID int) error
- func (c *ODINMarketFeedClient) SubscribeLTPTouchline(tokenList []string) error
- func (c *ODINMarketFeedClient) SubscribePauseResume(isPause bool) error
- func (tw *ODINMarketFeedClient) SubscribeTouchline(tokenList []string, responseType string, ltpChangeOnly bool) error
- func (tw *ODINMarketFeedClient) SubscribeTouchlineOld(tokenList []string) error
- func (tw *ODINMarketFeedClient) UnsubscribeBestFive(token string, marketSegmentID int) error
- func (c *ODINMarketFeedClient) UnsubscribeLTPTouchline(tokenList []string) error
- func (tw *ODINMarketFeedClient) UnsubscribeTouchline(tokenList []string) error
- type ZLIBCompressor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompressionStatus ¶
type CompressionStatus int
CompressionStatus represents compression state
const ( CompressionON CompressionStatus = iota CompressionOFF )
type FragmentationHandler ¶
type FragmentationHandler struct {
UnCompressMsgLength int
HeaderLength int
IsUncompress bool
// contains filtered or unexported fields
}
FragmentationHandler handles message fragmentation
func NewFragmentationHandler ¶
func NewFragmentationHandler() *FragmentationHandler
NewFragmentationHandler creates a new FragmentationHandler
func (*FragmentationHandler) Defragment ¶
func (fh *FragmentationHandler) Defragment(data []byte) ([][]byte, error)
Defragment defragments received data
func (*FragmentationHandler) FragmentData ¶
func (fh *FragmentationHandler) FragmentData(data []byte) ([]byte, error)
FragmentData fragments and compresses data for sending
func (*FragmentationHandler) GetMessageLength ¶
func (fh *FragmentationHandler) GetMessageLength(messageData []byte) int
GetMessageLength extracts the message length from the message data You'll need to implement this based on your protocol
type MarketData ¶
type MarketData struct {
MktSegID uint32
Token uint32
LUT uint32
LTP uint32
ClosePrice uint32
DecimalLocator uint32
}
MarketData represents market data structure
type ODINMarketFeedClient ¶
type ODINMarketFeedClient struct {
OnOpen func()
OnMessage func(message string)
OnError func(err string)
OnClose func(code int, reason string)
// contains filtered or unexported fields
}
ODINMarketFeedClient represents the WebSocket client
func NewODINMarketFeedClient ¶
func NewODINMarketFeedClient() *ODINMarketFeedClient
NewODINMarketFeedClient creates a new ODINMarketFeedClient instance
func (*ODINMarketFeedClient) Connect ¶
func (tw *ODINMarketFeedClient) Connect(host string, port int, useSSL bool, userID string, apiKey string) error
Connect connects to the WebSocket server
func (*ODINMarketFeedClient) Disconnect ¶
func (tw *ODINMarketFeedClient) Disconnect() error
Disconnect disconnects from the WebSocket server
func (*ODINMarketFeedClient) Dispose ¶
func (tw *ODINMarketFeedClient) Dispose()
Dispose releases resources
func (*ODINMarketFeedClient) SendMessage ¶
func (tw *ODINMarketFeedClient) SendMessage(message string) error
SendMessage sends a message to the WebSocket server
func (*ODINMarketFeedClient) SetCompression ¶
func (tw *ODINMarketFeedClient) SetCompression(enabled bool)
SetCompression enables or disables compression
func (*ODINMarketFeedClient) SubscribeBestFive ¶
func (tw *ODINMarketFeedClient) SubscribeBestFive(token string, marketSegmentID int) error
SubscribeBestFive subscribes to Market Depth (Best Five) for the provided token and market segment
func (*ODINMarketFeedClient) SubscribeLTPTouchline ¶
func (c *ODINMarketFeedClient) SubscribeLTPTouchline(tokenList []string) error
SubscribeLTPTouchline sends LTP touchline request for market data tokenList: List of tokens to subscribe (e.g., "1_22", "1_2885")
func (*ODINMarketFeedClient) SubscribePauseResume ¶
func (c *ODINMarketFeedClient) SubscribePauseResume(isPause bool) error
SubscribePauseResume pauses or resumes the broadcast subscription isPause: true to pause, false to resume
func (*ODINMarketFeedClient) SubscribeTouchline ¶
func (tw *ODINMarketFeedClient) SubscribeTouchline(tokenList []string, responseType string, ltpChangeOnly bool) error
SubscribeTouchline sends touchline request for market data tokenList: List of tokens to subscribe (e.g., "1_22", "1_2885") responseType: "1" = Touchline with fixed length native data, "0" = Normal touchline ltpChangeOnly: Send response on LTP change only if true
func (*ODINMarketFeedClient) SubscribeTouchlineOld ¶
func (tw *ODINMarketFeedClient) SubscribeTouchlineOld(tokenList []string) error
SubscribeTouchline subscribes to touchline for the provided tokens
func (*ODINMarketFeedClient) UnsubscribeBestFive ¶
func (tw *ODINMarketFeedClient) UnsubscribeBestFive(token string, marketSegmentID int) error
UnsubscribeBestFive unsubscribes from Market Depth (Best Five) for the provided token and market segment
func (*ODINMarketFeedClient) UnsubscribeLTPTouchline ¶
func (c *ODINMarketFeedClient) UnsubscribeLTPTouchline(tokenList []string) error
UnsubscribeLTPTouchline unsubscribes from LTP touchline tokens
func (*ODINMarketFeedClient) UnsubscribeTouchline ¶
func (tw *ODINMarketFeedClient) UnsubscribeTouchline(tokenList []string) error
UnsubscribeTouchline unsubscribes from touchline for the provided tokens
type ZLIBCompressor ¶
type ZLIBCompressor struct{}
ZLIBCompressor handles ZLIB compression/decompression
func (*ZLIBCompressor) Compress ¶
func (z *ZLIBCompressor) Compress(data []byte) ([]byte, error)
Compress compresses data using ZLIB
func (*ZLIBCompressor) Uncompress ¶
func (z *ZLIBCompressor) Uncompress(data []byte) ([]byte, error)
Uncompress decompresses data using ZLIB