trade

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateTrades

func AggregateTrades(aggWindow time.Duration, chanMessages chan []byte, chanAggregates chan *AggregateTrade)

AggregateTrades collects and aggregates incoming trade data. It also signals to the printer routine when aggregates should be printed. Aggregates that are older than an hour are garbage collected. This func should be run in its own goroutine.

func PrintAggregates

func PrintAggregates(chanAggregates chan *AggregateTrade)

PrintAggregates prints aggregates after the window has passed or reprints them when updates occur outside of the window. This func should run in its own goroutine.

func VerifyCryptoPair

func VerifyCryptoPair(apiKey string, cryptoPair string) error

VerifyCryptoPair searches the Polygon API to make sure the desired crypto pair is valid.

Types

type AggregateTrade

type AggregateTrade struct {
	Time      time.Time // Timestamp of the end of the aggregate window
	Open      float64   // Price of the first trade of the window
	OpenTime  time.Time // Timestamp of the open trade
	Close     float64   // Price of the last trade of the window
	CloseTime time.Time // Timestamp of the close trade
	High      float64   // Highest trade during the window
	Low       float64   // Lowest trade during the window
	Volume    float64   // Total trade volume during the window
	Print     bool      // Flag indicating whether the trade has been printed yet
	Update    bool      // Flag indicating whether the trade has been updated outside of the window and needs to be printed again
}

AggregateTrade contains aggregated trade data for a given window (e.g. 30s).

func (AggregateTrade) MarshalJSON

func (agg AggregateTrade) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON encoded aggregate trade.

Jump to

Keyboard shortcuts

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