feedmodel

package
v0.0.0-...-db7d511 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeedCmd

type FeedCmd struct {
	Cmd  string      `json:"cmd"`
	Args interface{} `json:"args"`
}

Used when sending feed commands

type FeedIndicatorData

type FeedIndicatorData struct {
	Identifier     string  `json:"i,omitempty"`
	Market         string  `json:"m,omitempty"`
	Tick_timestamp int64   `json:"tick_timestamp,omitempty"`
	Open           float64 `json:"open,omitempty"`
	High           float64 `json:"high,omitempty"`
	Low            float64 `json:"low,omitempty"`
	Last           float64 `json:"last,omitempty"`
	Close          float64 `json:"close,omitempty"`
}

type FeedIndicatorDataSequence

type FeedIndicatorDataSequence []FeedIndicatorData

func (FeedIndicatorDataSequence) At

func (fids FeedIndicatorDataSequence) At(timestamp int64) (ret *FeedIndicatorData)

func (FeedIndicatorDataSequence) GroupMillis

func (fids FeedIndicatorDataSequence) GroupMillis(m int64) (ret []FeedIndicatorDataSequence)

func (FeedIndicatorDataSequence) Last

func (fids FeedIndicatorDataSequence) Last() (ret *FeedIndicatorData)

func (FeedIndicatorDataSequence) Len

func (fids FeedIndicatorDataSequence) Len() int

func (FeedIndicatorDataSequence) Less

func (fids FeedIndicatorDataSequence) Less(i, j int) bool

func (FeedIndicatorDataSequence) Sort

func (fids FeedIndicatorDataSequence) Sort()

func (FeedIndicatorDataSequence) Swap

func (fids FeedIndicatorDataSequence) Swap(i, j int)

type FeedMsg

type FeedMsg struct {
	Type string          `json:"type"`
	Data json.RawMessage `json:"data"`

	SeqId int64 `json:"seq,omitempty"` // Optional field that we can add local sequence to
}

func NewFeedMsg

func NewFeedMsg(data []byte) (ret *FeedMsg, err error)

func NewFeedMsgFromObject

func NewFeedMsgFromObject(typ string, data interface{}) (ret *FeedMsg, err error)

func (*FeedMsg) DecodeData

func (fm *FeedMsg) DecodeData(ret interface{}) error

func (*FeedMsg) Encode

func (fm *FeedMsg) Encode() (ret []byte)

TODO: See if we want to actually encode, or just fake

func (*FeedMsg) String

func (fm *FeedMsg) String() string

type FeedMsgSeqSorter

type FeedMsgSeqSorter []FeedMsg

func (FeedMsgSeqSorter) Len

func (fmss FeedMsgSeqSorter) Len() int

func (FeedMsgSeqSorter) Less

func (fmss FeedMsgSeqSorter) Less(i, j int) bool

func (FeedMsgSeqSorter) Swap

func (fmss FeedMsgSeqSorter) Swap(i, j int)

type FeedPriceData

type FeedPriceData struct {
	Identifier      string  `json:"i,omitempty"`
	Market          int64   `json:"m,omitempty"`
	Ask             float64 `json:"ask,omitempty"`
	Ask_volume      float64 `json:"ask_volume,omitempty"`
	Bid             float64 `json:"bid,omitempty"`
	Bid_volume      float64 `json:"bid_volume,omitempty"`
	Open            float64 `json:"open,omitempty"`
	High            float64 `json:"high,omitempty"`
	Low             float64 `json:"low,omitempty"`
	Last            float64 `json:"last,omitempty"`
	Last_volume     int64   `json:"last_volume,omitempty"`
	Close           float64 `json:"close,omitempty"`
	EP              float64 `json:"ep,omitempty"`
	Imbalance       int64   `json:"imbalance,omitempty"`
	Paired          int64   `json:"paired,omitempty"`
	Turnover        float64 `json:"turnover,omitempty"`
	Turnover_volume int64   `json:"turnover_volume,omitempty"`
	Vwap            float64 `json:"vwap,omitempty"`
	Tick_timestamp  int64   `json:"tick_timestamp,omitempty"`
	Trade_timestamp int64   `json:"trade_timestamp,omitempty"`
	// contains filtered or unexported fields
}

Struct to reprecent a price update

func (*FeedPriceData) Append

func (fpd *FeedPriceData) Append(fp *FeedPriceData) (ret *FeedPriceData)

Usage: fpd = fpd.Append(newFpd), like on slices

func (*FeedPriceData) Each

func (fpd *FeedPriceData) Each(fn func(in *FeedPriceData))

func (*FeedPriceData) IsTrade

func (fpd *FeedPriceData) IsTrade() bool

func (*FeedPriceData) Less

func (fpd *FeedPriceData) Less(other *FeedPriceData) bool

func (*FeedPriceData) ToLimitedSlice

func (fpd *FeedPriceData) ToLimitedSlice(fbm FilterBreakMatcher) (ret []*FeedPriceData)

func (*FeedPriceData) ToSlice

func (fpd *FeedPriceData) ToSlice() []*FeedPriceData

func (*FeedPriceData) TradeSide

func (fpd *FeedPriceData) TradeSide() TradeSide

type FeedPriceDataSorter

type FeedPriceDataSorter []FeedPriceData

func (FeedPriceDataSorter) Len

func (fpds FeedPriceDataSorter) Len() int

func (FeedPriceDataSorter) Less

func (fpds FeedPriceDataSorter) Less(i, j int) bool

func (FeedPriceDataSorter) Swap

func (fpds FeedPriceDataSorter) Swap(i, j int)

type FeedTradeData

type FeedTradeData struct {
	Identifier      string  `json:"i,omitempty"`
	Market          int64   `json:"m,omitempty"`
	Trade_timestamp int64   `json:"trade_timestamp,omitempty"`
	Trade_type      string  `json:"trade_type,omitempty"`
	Trade_id        string  `json:"trade_id,omitempty"`
	Price           float64 `json:"price,omitempty"`
	Volume          int64   `json:"volume,omitempty"`
	Broker_buying   string  `json:"broker_buying,omitempty"`
	Broker_selling  string  `json:"broker_selling,omitempty"`
}

func (*FeedTradeData) TradeIdNum

func (ftd *FeedTradeData) TradeIdNum() (ret int64, ok bool)

Like strconv.Atoi, but more hack 'n slash

type FeedTradeDataSequence

type FeedTradeDataSequence []FeedTradeData

func (FeedTradeDataSequence) Len

func (ftds FeedTradeDataSequence) Len() int

func (FeedTradeDataSequence) Less

func (ftds FeedTradeDataSequence) Less(i, j int) bool

func (FeedTradeDataSequence) Swap

func (ftds FeedTradeDataSequence) Swap(i, j int)

func (FeedTradeDataSequence) Tail

func (ftds FeedTradeDataSequence) Tail(num int) (ret FeedTradeDataSequence)

type FeedType

type FeedType uint64
const (
	PrivateFeedType FeedType = iota + 1
	PublicFeedType
)

type FilterBreakMatcher

type FilterBreakMatcher func(in *FeedPriceData) (include, brk bool)

Filter type, return true on include if matches, and true on brk if we need to break

func FilterCount

func FilterCount(num int64) FilterBreakMatcher

func FilterOnlyLastPerTickTimestamp

func FilterOnlyLastPerTickTimestamp() FilterBreakMatcher

func FilterTrades

func FilterTrades() FilterBreakMatcher

func (FilterBreakMatcher) Filter

type TradeCatcher

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

TradeCatcher: Will try and extract trades from a price stream. Will also feed normal trades, so if you want to filter, the type on all generated is 'TradeCatcher' A feed listener that will forward trades, or fake trades depending on submit on price or trade

func NewTradeCatcher

func NewTradeCatcher(callback func(*FeedTradeData)) (ret *TradeCatcher)

Creates a TradeCatcher

func (*TradeCatcher) OnFeed

func (tc *TradeCatcher) OnFeed(msg *FeedMsg)

Implement FeedClient. If from async source, then wrap with feed.FeedSorter

func (*TradeCatcher) OnPrice

func (tc *TradeCatcher) OnPrice(price *FeedPriceData)

Assume in order..

func (*TradeCatcher) OnTrade

func (tc *TradeCatcher) OnTrade(trade *FeedTradeData)

type TradeSide

type TradeSide int64
const (
	BID TradeSide = iota - 1
	Unknown
	ASK
)

func (TradeSide) String

func (ts TradeSide) String() string

Jump to

Keyboard shortcuts

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