Documentation ¶
Index ¶
- Variables
- type Aggregator
- type AgrTickMsg
- type AppspotFeed
- type AppspotMsgCurrency
- type BaseFeed
- type BtceFeed
- type BtceMsgTicker
- type FakeFeed
- type Feed
- type FeedConstructor
- type FeedInfo
- type FixerFeed
- type FixerMsgLatest
- type GdaxWebSocketFeed
- func (f *GdaxWebSocketFeed) Close()
- func (f *GdaxWebSocketFeed) GetInfo() FeedInfo
- func (f *GdaxWebSocketFeed) GetName() string
- func (f *GdaxWebSocketFeed) Run() error
- func (f *GdaxWebSocketFeed) Stop() error
- func (f *GdaxWebSocketFeed) Subscribe() error
- func (f *GdaxWebSocketFeed) Wait() chan struct{}
- type MsgGdax
- type MsgGdaxOrderBook
- type OrderBook
- type RestFeed
- type TickMsg
Constants ¶
This section is empty.
Variables ¶
var FeedRegistry map[FeedInfo]FeedConstructor
The registry of all supported feedsources
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
type Aggregator struct { // Writing to ForecTick forces aggreagtor to emit tick // for specified product ForceTick chan ProductType // Aggregator starts gracefull shutdown when Done channel is closed Done chan struct{} // Tick is outbound queue of aggregated messages Tick chan *AgrTickMsg // contains filtered or unexported fields }
Aggregator mananges starting/stopping feed source listeners/pollers. Selects best prices from active sources per each product and sends aggregated message to upstream.
func NewAggregator ¶
func NewAggregator(done chan struct{}) (*Aggregator, error)
NewAggregator creates new instance of Aggregator. When passed done channel is closed aggregator will start graceful shutdown.
func (*Aggregator) Run ¶
func (a *Aggregator) Run(feedNameList []string)
Run() starts each feed in a separate goroutine (feed runner). Listens channels to: - external interrupt - register/deregister feeds - update last message for each "product-feed" pair - based on updated last message emits new aggregated message - emit aggregated tick message by force
func (*Aggregator) Wait ¶
func (a *Aggregator) Wait()
type AgrTickMsg ¶
type AgrTickMsg struct { Product ProductType PriceSell float64 PriceBuy float64 TsSell int64 TsBuy int64 AskPrice float64 BidPrice float64 ActiveSources int TotalSources int }
func (AgrTickMsg) String ¶
func (t AgrTickMsg) String() string
type AppspotFeed ¶
type AppspotFeed struct {
RestFeed
}
type AppspotMsgCurrency ¶
type BaseFeed ¶
type BaseFeed struct { Info FeedInfo // contains filtered or unexported fields }
BaseFeed is base 'class' for all feed sources
type BtceMsgTicker ¶
type BtceMsgTicker struct { Product struct { High float64 `json:"high"` Low float64 `json:"low"` Avg float64 `json:"avg"` Vol float64 `json:"vol"` VolCur float64 `json:"vol_cur"` Last float64 `json:"last"` Buy float64 `json:"buy"` Sell float64 `json:"sell"` Updated int64 `json:"updated"` } `json:"btc_usd"` }
type Feed ¶
type Feed interface { // human-readable string name for feed source GetName() string // FeedInfo about feed source GetInfo() FeedInfo // run feed (non-blockable) Run() error // signals feed to exit Stop() error // feed source should block here until it's safe to exit Wait() chan struct{} }
Feed source interface
func NewAppspotFeed ¶
func NewAppspotFeed(agr *Aggregator) (Feed, error)
func NewBtceFeed ¶
func NewBtceFeed(agr *Aggregator) (Feed, error)
func NewFakeEurUsdFeed ¶
func NewFakeEurUsdFeed(agr *Aggregator) (Feed, error)
func NewFixerFeed ¶
func NewFixerFeed(agr *Aggregator) (Feed, error)
func NewGdaxWebSocketFeed ¶
func NewGdaxWebSocketFeed(agr *Aggregator) (Feed, error)
func NewGdaxWebSocketFeed(agr *Aggregator, wsUrl string, wsHeaders http.Header) (*GdaxWebSocketFeed, error) {
type FeedConstructor ¶
type FeedConstructor func(*Aggregator) (Feed, error)
type FixerMsgLatest ¶
type GdaxWebSocketFeed ¶
type GdaxWebSocketFeed struct { Info FeedInfo // deadline timeout for websocket read operations TimeoutRead time.Duration // deadline timeout for websocket write operations TimeoutWrite time.Duration // contains filtered or unexported fields }
GDAX websocket feed source
func (*GdaxWebSocketFeed) Close ¶
func (f *GdaxWebSocketFeed) Close()
func (*GdaxWebSocketFeed) GetInfo ¶
func (f *GdaxWebSocketFeed) GetInfo() FeedInfo
func (*GdaxWebSocketFeed) GetName ¶
func (f *GdaxWebSocketFeed) GetName() string
func (*GdaxWebSocketFeed) Run ¶
func (f *GdaxWebSocketFeed) Run() error
Run registers feed source with aggreator. Starts pull and push goroutines in background.
func (*GdaxWebSocketFeed) Stop ¶
func (f *GdaxWebSocketFeed) Stop() error
func (*GdaxWebSocketFeed) Subscribe ¶
func (f *GdaxWebSocketFeed) Subscribe() error
Send "subscribe" message
func (*GdaxWebSocketFeed) Wait ¶
func (f *GdaxWebSocketFeed) Wait() chan struct{}
type MsgGdax ¶
type MsgGdax struct { Type string `json:"type"` // "match" | "error" | "heartbeat" Sequence *int64 `json:"sequence,omitempty"` // 50 OrderId *string `json:"order_id,omitempty"` // "d50ec984-77a8-460a-b958-66f114b0de9b" Time *time.Time `json:"time,omitempty"` // "2014-11-07T08:19:27.028459Z" ProductId *string `json:"product_id,omitempty"` // "BTC-USD" Size *string `json:"size,omitempty"` // "5.23512" Price *string `json:"price,omitempty"` // "400.23", Side *string `json:"side,omitempty"` // "sell" Message *string `json:"message,omitempty"` // "error message" }
Aggregated GDAX Websocket API message stucture with only important fields
type MsgGdaxOrderBook ¶
type MsgGdaxOrderBook struct { Asks [][]string `json:"asks"` Bids [][]string `json:"bids"` Sequence int64 `json:"sequence"` }
REST order book data
type RestFeed ¶
type RestFeed struct { BaseFeed // contains filtered or unexported fields }
RestFeed is a generic base 'class' for basic http REST-polling feed sources
func NewRestFeed ¶
func (*RestFeed) SetPollHandler ¶
SetPollHandler() sets handler which will be invoked on each polling round
type TickMsg ¶
type TickMsg struct { Info FeedInfo // Last price for sell trade PriceSell float64 // Last price for buy trade PriceBuy float64 // Best ask price AskPrice float64 // Best bid price BidPrice float64 // Last timestamp for sell trade TsSell int64 // Last timestamp for buy trade TsBuy int64 // Current timestamp for message Ts int64 }
TickMsg contains update message from feed source which should be propagated to aggregator