coinbase

package
v0.0.0-...-ab80339 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateVWAP

func CalculateVWAP(ctx context.Context, matchInfoIn <-chan MatchInfo, averagerMaxSize int, onVMAPInfo OnVWAPInfo) error

CalculateVWAP Consumes a matches channel and for each sample calculates the instantaneous VWAP for each ProductId that comes in the channel. For each received sample, the callback function onVMAPInfo will be called with the latest results in weighted average for the price, according to VWAP

func SubscribeMatchesChannel

func SubscribeMatchesChannel(ctx context.Context, matchInfoChan chan<- MatchInfo, websocketURL string, product_ids ...string) error

SubscribeMatchesChannel Connects to Coinbase websocket matches channel and publishes each "match" message to the matchInfoChan channel

Types

type MatchInfo

type MatchInfo struct {
	ProductId string
	Price     *big.Float
	Size      *big.Float
}

type OnMatchInfo

type OnMatchInfo func(MatchInfo)

type OnVWAPInfo

type OnVWAPInfo func(VWAPInfo)

type StreamResponse

type StreamResponse struct {
	// "type": "last_match",
	Type    string `json:"type"`
	Message string `json:"message"`
	Reason  string `json:"reason"`
	// "trade_id": 3168503,
	// "maker_order_id": "989df982-552b-47db-a247-2cb34386d25d",
	// "taker_order_id": "6c5e5552-130a-4460-9fb2-9084291814c7",
	// "side": "sell",
	// "size": "0.01",
	Size *big.Float `json:"size"`
	// "price": "0.06961",
	Price *big.Float `json:"price"`
	// "product_id": "ETH-BTC",
	ProductId string `json:"product_id"`
}

type VWAPInfo

type VWAPInfo struct {
	ProductId string
	Value     *big.Float
}

Jump to

Keyboard shortcuts

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