valr_ws

package module
v0.0.0-...-6c20aac Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 12 Imported by: 0

README

Note that this project is still under development and not yet thoroughly tested. Any help welcome.

Installation

To install valr, use go get:

go get github.com/Rellum/valr_ws

Usage

API Key.

It is required that you set up a Valr API Key. See Valr's api documentation for details. View-only permission is fine.

Using the client.

See the example directory for sample code.

Contributing

Please feel free to submit issues, fork the repository and make pull requests!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccountStream

func NewAccountStream(ctx context.Context, apiKey, apiSecret string, opts ...AccountStreamOpt) error

func NewAggregatedOrderbookUpdatesStream

func NewAggregatedOrderbookUpdatesStream(ctx context.Context, apiKey, apiSecret string, pairs []string, fn func(AggregatedOrderbookUpdate)) error

func NewMarketSummaryUpdatesStream

func NewMarketSummaryUpdatesStream(ctx context.Context, apiKey, apiSecret string, pairs []string, fn func(MarketSummaryUpdate)) error

func NewTradeBucketStream

func NewTradeBucketStream(ctx context.Context, apiKey, apiSecret string, pairs []string, fn func(NewTradeBucket)) error

func NewTradeStream

func NewTradeStream(ctx context.Context, apiKey, apiSecret string, pairs []string, fn func(NewTrade)) error

Types

type AccountStreamOpt

type AccountStreamOpt func(*accountStreamOpts)

func OnAny

func OnAny(fn func(responseType string, bl []byte)) AccountStreamOpt

func OnBalanceUpdate

func OnBalanceUpdate(fn func(BalanceUpdate)) AccountStreamOpt

func OnOpenOrdersUpdate

func OnOpenOrdersUpdate(fn func([]OpenOrderUpdate)) AccountStreamOpt

func OnOrderStatusUpdate

func OnOrderStatusUpdate(fn func(OrderStatusUpdate)) AccountStreamOpt

type AggregatedOrderbookUpdate

type AggregatedOrderbookUpdate struct {
	Pair       string           `json:"currencyPairSymbol"`
	Asks       []OrderbookEntry `json:"Asks"`
	Bids       []OrderbookEntry `json:"Bids"`
	LastChange time.Time        `json:"LastChange"`
}

type BalanceUpdate

type BalanceUpdate struct {
	Currency  Currency        `json:"currency"`
	Available decimal.Decimal `json:"available"`
	Reserved  decimal.Decimal `json:"reserved"`
	Total     decimal.Decimal `json:"total"`
	UpdatedAt time.Time       `json:"updatedAt"`
}

type Currency

type Currency struct {
	ID                             int    `json:"id"`
	Symbol                         string `json:"symbol"`
	DecimalPlaces                  int    `json:"decimalPlaces"`
	IsActive                       bool   `json:"isActive"`
	ShortName                      string `json:"shortName"`
	LongName                       string `json:"longName"`
	CurrencyDecimalPlaces          int    `json:"currencyDecimalPlaces"`
	SupportedWithdrawDecimalPlaces int    `json:"supportedWithdrawDecimalPlaces"`
}

type CurrencyPair

type CurrencyPair struct {
	ID             int             `json:"id"`
	Symbol         string          `json:"symbol"`
	BaseCurrency   Currency        `json:"baseCurrency"`
	QuoteCurrency  Currency        `json:"quoteCurrency"`
	ShortName      string          `json:"shortName"`
	Exchange       string          `json:"exchange"`
	Active         bool            `json:"active"`
	MinBaseAmount  decimal.Decimal `json:"minBaseAmount"`
	MaxBaseAmount  decimal.Decimal `json:"maxBaseAmount"`
	MinQuoteAmount decimal.Decimal `json:"minQuoteAmount"`
	MaxQuoteAmount decimal.Decimal `json:"maxQuoteAmount"`
}

type MarketSummaryUpdate

type MarketSummaryUpdate struct {
	Pair        string          `json:"currencyPairSymbol"`
	Ask         decimal.Decimal `json:"askPrice"`
	Bid         decimal.Decimal `json:"bidPrice"`
	Last        decimal.Decimal `json:"lastTradedPrice"`
	Close       decimal.Decimal `json:"previousClosePrice"`
	BaseVolume  decimal.Decimal `json:"baseVolume"`
	QuoteVolume decimal.Decimal `json:"quoteVolume"`
	High        decimal.Decimal `json:"highPrice"`
	Low         decimal.Decimal `json:"lowPrice"`
	Created     time.Time       `json:"created"`
	Change      decimal.Decimal `json:"changeFromPrevious"`
}

type NewTrade

type NewTrade struct {
	Pair     string          `json:"currencyPair"`
	TradedAt time.Time       `json:"tradedAt"`
	Side     Side            `json:"takerSide"`
	Price    decimal.Decimal `json:"price"`
	Quantity decimal.Decimal `json:"quantity"`
}

type NewTradeBucket

type NewTradeBucket struct {
	Pair   string          `json:"currencyPair"`
	Period int             `json:"bucketPeriodInSeconds"`
	Start  time.Time       `json:"startTime"`
	Open   decimal.Decimal `json:"open"`
	High   decimal.Decimal `json:"high"`
	Low    decimal.Decimal `json:"low"`
	Close  decimal.Decimal `json:"close"`
	Volume decimal.Decimal `json:"volume"`
}

type OpenOrderUpdate

type OpenOrderUpdate struct {
	OrderID          string          `json:"orderId"`
	Side             Side            `json:"side"`
	Quantity         decimal.Decimal `json:"quantity"`
	Price            decimal.Decimal `json:"price"`
	CurrencyPair     string          `json:"currencyPair"`
	CreatedAt        time.Time       `json:"createdAt"`
	OriginalQuantity decimal.Decimal `json:"originalQuantity"`
	FilledPercentage decimal.Decimal `json:"filledPercentage"`
	CustomerOrderID  string          `json:"customerOrderId"`
}

type OrderStatusType

type OrderStatusType string
const OrderStatusTypeCancelled OrderStatusType = "Cancelled"
const OrderStatusTypeFailed OrderStatusType = "Failed"
const OrderStatusTypeFilled OrderStatusType = "Filled"
const OrderStatusTypeInstantOrderCompleted OrderStatusType = "Instant Order Completed"
const OrderStatusTypeInstantOrderReserveFailed OrderStatusType = "Instant Order Balance Reserve Failed"
const OrderStatusTypeInstantOrderReserved OrderStatusType = "Instant Order Balance Reserved"
const OrderStatusTypePartiallyFilled OrderStatusType = "Partially Filled"
const OrderStatusTypePlaced OrderStatusType = "Placed"

type OrderStatusUpdate

type OrderStatusUpdate struct {
	OrderID           string          `json:"orderId"`
	OrderStatusType   OrderStatusType `json:"orderStatusType"`
	CurrencyPair      string          `json:"currencyPair"`
	OriginalPrice     decimal.Decimal `json:"originalPrice"`
	RemainingQuantity decimal.Decimal `json:"remainingQuantity"`
	OriginalQuantity  decimal.Decimal `json:"originalQuantity"`
	OrderSide         Side            `json:"orderSide"`
	OrderType         OrderType       `json:"orderType"`
	FailedReason      string          `json:"failedReason"`
	OrderUpdatedAt    time.Time       `json:"orderUpdatedAt"`
	OrderCreatedAt    time.Time       `json:"orderCreatedAt"`
	CustomerOrderID   string          `json:"customerOrderId"`
}

type OrderType

type OrderType string

type OrderbookEntry

type OrderbookEntry struct {
	Price      decimal.Decimal `json:"price"`
	Quantity   decimal.Decimal `json:"quantity"`
	Side       Side            `json:"side"`
	Pair       string          `json:"currencyPair"`
	OrderCount int             `json:"orderCount"`
}

type Side

type Side string
const SideBuy Side = "buy"
const SideSell Side = "sell"

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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