kstreamdb

package module
v0.0.0-...-ccfd42e Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: LGPL-3.0 Imports: 17 Imported by: 2

README

kstreamdb

  • Embedded Database to store/read market ticks
  • Supports Streaming ticks using scalability protocol. Uses mongos socket
  • Supports Inproc Pub/Sub for ticks
go get github.com/sivamgr/kstreamdb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	DataPath string
}

DB Database

func SetupDatabase

func SetupDatabase(DataPath string) DB

SetupDatabase func

func (*DB) Compress

func (r *DB) Compress()

Compress function compresses data from each date into a single file

func (*DB) GetDates

func (r *DB) GetDates() ([]time.Time, error)

GetDates returns dates

func (*DB) Insert

func (r *DB) Insert(ticks []TickData) error

Insert method

func (*DB) LoadAllData

func (r *DB) LoadAllData() ([]TickData, error)

LoadAllData loads all ticks from db

func (*DB) LoadDataForDate

func (r *DB) LoadDataForDate(dt time.Time) ([]TickData, error)

LoadDataForDate loads ticks from the date

func (*DB) PlaybackAll

func (r *DB) PlaybackAll(fn PlaybackFunc) error

PlaybackAll all ticks from db

func (*DB) PlaybackDate

func (r *DB) PlaybackDate(dt time.Time, fn PlaybackFunc) error

PlaybackDate ticks from the date

func (*DB) PlaybackToday

func (r *DB) PlaybackToday(fn PlaybackFunc) error

PlaybackToday all ticks from db

func (*DB) RecordStream

func (r *DB) RecordStream(s *Socket)

RecordStream starts recording the tick stream in database

type DepthItem

type DepthItem struct {
	Price    float32
	Quantity uint32
	Orders   uint32
}

DepthItem represents a single market depth entry.

type PlaybackFunc

type PlaybackFunc func(TickData)

PlaybackFunc callback

type Socket

type Socket struct {
	InProcPubSub   *pubsub.PubSub
	Sock           mangos.Socket
	IsStreamServer bool
}

Socket struct

func ConnectToStream

func ConnectToStream(url string) (Socket, error)

ConnectToStream connect to a tick stream

func StartStreaming

func StartStreaming(url string) (Socket, error)

StartStreaming starts the stream publisher socket

func (*Socket) Publish

func (s *Socket) Publish(tick TickData) error

Publish publishes tick to channels

func (*Socket) SubscribeTicks

func (s *Socket) SubscribeTicks() chan interface{}

SubscribeTicks returns the ticks channel

type TickData

type TickData struct {
	TradingSymbol string
	IsTradable    bool

	Timestamp time.Time

	LastTradeTime      time.Time
	LastPrice          float32
	LastTradedQuantity uint32

	AverageTradePrice float32

	VolumeTraded      uint32
	TotalBuyQuantity  uint32
	TotalSellQuantity uint32

	DayOpen      float32
	DayHighPrice float32
	DayLowPrice  float32
	LastDayClose float32

	OI        uint32
	OIDayHigh uint32
	OIDayLow  uint32

	Bid [5]DepthItem
	Ask [5]DepthItem
}

TickData into .tck. symstr +16 len bytes

Jump to

Keyboard shortcuts

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