trade

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultProcessorIntervalTime = time.Second * 15

DefaultProcessorIntervalTime is the default timer to process queued trades and save them to the database

Variables

View Source
var (

	// BufferProcessorIntervalTime is the interval to save trade buffer data to the database.
	// Change this by changing the runtime param `-tradeprocessinginterval=15s`
	BufferProcessorIntervalTime = DefaultProcessorIntervalTime
)

Functions

func AddTradesToBuffer

func AddTradesToBuffer(exchangeName string, data ...Data) error

AddTradesToBuffer will push trade data onto the buffer

func ConvertTradesToCandles

func ConvertTradesToCandles(interval kline.Interval, trades ...Data) (kline.Item, error)

ConvertTradesToCandles turns trade data into kline.Items

Types

type ByDate

type ByDate []Data

ByDate sorts trades by date ascending

func (ByDate) Len

func (b ByDate) Len() int

func (ByDate) Less

func (b ByDate) Less(i, j int) bool

func (ByDate) Swap

func (b ByDate) Swap(i, j int)

type Data

type Data struct {
	ID           uuid.UUID `json:"ID,omitempty"`
	TID          string
	Exchange     string
	CurrencyPair currency.Pair
	AssetType    asset.Item
	Side         order.Side
	Price        float64
	Amount       float64
	Timestamp    time.Time
}

Data defines trade data

func FilterTradesByTime

func FilterTradesByTime(trades []Data, startTime, endTime time.Time) []Data

FilterTradesByTime removes any trades that are not between the start and end times

type Processor

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

Processor used for processing trade data in batches and saving them to the database

func (*Processor) Run

func (p *Processor) Run(wg *sync.WaitGroup)

Run will save trade data to the database in batches

Jump to

Keyboard shortcuts

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