kiteticker

package
v0.0.0-...-5f92e86 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package kiteticker provides kite ticker access using callbacks.

Index

Constants

View Source
const (
	// Segment constants.
	NseCM = 1 + iota
	NseFO
	NseCD
	BseCM
	BseFO
	BseCD
	McxFO
	McxSX
	Indices

	// ModeLTP subscribes for last price.
	ModeLTP Mode = "ltp"
	// ModeFull subscribes for all the available fields.
	ModeFull Mode = "full"
	// ModeQuote represents quote mode.
	ModeQuote Mode = "quote"

	// TextMessage denotes a text data message. The text message payload is
	// interpreted as UTF-8 encoded text data.
	TextMessage = 1

	// BinaryMessage denotes a binary data message.
	BinaryMessage = 2

	// CloseMessage denotes a close control message. The optional message
	// payload contains a numeric code and text. Use the FormatCloseMessage
	// function to format a close message payload.
	CloseMessage = 8

	// PingMessage denotes a ping control message. The optional message payload
	// is UTF-8 encoded text.
	PingMessage = 9

	// PongMessage denotes a ping control message. The optional message payload
	// is UTF-8 encoded text.
	PongMessage = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Depth

type Depth struct {
	Buy  [5]DepthItem
	Sell [5]DepthItem
}

Depth represents a group of buy/sell market depths.

type DepthItem

type DepthItem struct {
	Price    float64
	Quantity uint32
	Orders   uint32
}

DepthItem represents a single market depth entry.

type LTP

type LTP struct {
	InstrumentToken uint32
	LastPrice       float64
}

LTP represents OHLC packets.

type Mode

type Mode string

Mode represents available ticker modes.

type OHLC

type OHLC struct {
	InstrumentToken uint32
	Open            float64
	High            float64
	Low             float64
	Close           float64
}

OHLC represents OHLC packets.

type Tick

type Tick struct {
	Mode            Mode
	InstrumentToken uint32
	IsTradable      bool
	IsIndex         bool

	Timestamp          kiteconnect.Time
	LastTradeTime      kiteconnect.Time
	LastPrice          float64
	LastTradedQuantity uint32
	TotalBuyQuantity   uint32
	TotalSellQuantity  uint32
	VolumeTraded       uint32
	TotalBuy           uint32
	TotalSell          uint32
	AverageTradePrice  float64
	OI                 uint32
	OIDayHigh          uint32
	OIDayLow           uint32
	NetChange          float64

	OHLC  OHLC
	Depth Depth
}

Tick represents a single packet in the market feed.

type Ticker

type Ticker struct {
	Conn *websocket.Conn
	// contains filtered or unexported fields
}

Ticker is a Kite connect ticker instance.

func New

func New(apiKey string, accessToken string) *Ticker

New creates a new ticker instance.

func (*Ticker) Close

func (t *Ticker) Close() error

Close tries to close the connection gracefully. If the server doesn't close it

func (*Ticker) OnClose

func (t *Ticker) OnClose(f func(code int, reason string))

OnClose callback.

func (*Ticker) OnConnect

func (t *Ticker) OnConnect(f func())

OnConnect callback.

func (*Ticker) OnError

func (t *Ticker) OnError(f func(err error))

OnError callback.

func (*Ticker) OnMessage

func (t *Ticker) OnMessage(f func(messageType int, message []byte))

OnMessage callback.

func (*Ticker) OnNoReconnect

func (t *Ticker) OnNoReconnect(f func(attempt int))

OnNoReconnect callback.

func (*Ticker) OnOrderUpdate

func (t *Ticker) OnOrderUpdate(f func(order kiteconnect.Order))

OnOrderUpdate callback.

func (*Ticker) OnReconnect

func (t *Ticker) OnReconnect(f func(attempt int, delay time.Duration))

OnReconnect callback.

func (*Ticker) OnTick

func (t *Ticker) OnTick(f func(tick Tick))

OnTick callback.

func (*Ticker) Resubscribe

func (t *Ticker) Resubscribe() error

Resubscribe resubscribes to the current stored subscriptions

func (*Ticker) Serve

func (t *Ticker) Serve()

Serve starts the connection to ticker server. Since its blocking its recommended to use it in go routine.

func (*Ticker) SetAccessToken

func (t *Ticker) SetAccessToken(aToken string)

SetAccessToken set access token.

func (*Ticker) SetAutoReconnect

func (t *Ticker) SetAutoReconnect(val bool)

SetAutoReconnect enable/disable auto reconnect.

func (*Ticker) SetConnectTimeout

func (t *Ticker) SetConnectTimeout(val time.Duration)

SetConnectTimeout sets default timeout for initial connect handshake

func (*Ticker) SetMode

func (t *Ticker) SetMode(mode Mode, tokens []uint32) error

SetMode changes mode for given list of tokens and mode.

func (*Ticker) SetReconnectMaxDelay

func (t *Ticker) SetReconnectMaxDelay(val time.Duration) error

SetReconnectMaxDelay sets maximum auto reconnect delay.

func (*Ticker) SetReconnectMaxRetries

func (t *Ticker) SetReconnectMaxRetries(val int)

SetReconnectMaxRetries sets maximum reconnect attempts.

func (*Ticker) SetRootURL

func (t *Ticker) SetRootURL(u url.URL)

SetRootURL sets ticker root url.

func (*Ticker) Subscribe

func (t *Ticker) Subscribe(tokens []uint32) error

Subscribe subscribes tick for the given list of tokens.

func (*Ticker) Unsubscribe

func (t *Ticker) Unsubscribe(tokens []uint32) error

Unsubscribe unsubscribes tick for the given list of tokens.

Jump to

Keyboard shortcuts

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