bittrex

package
v0.0.202 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package Bittrex is an implementation of the Bittrex API in Golang.

Index

Constants

View Source
const (
	TIME_FORMAT = time.RFC3339
	API_BASE    = "https://api.bittrex.com"
	API_VERSION = "v3"
)
View Source
const (
	INTENSITY_LOW   = 1  // 1 req/second
	INTENSITY_TWO   = 2  // 0.5 req/second
	INTENSITY_SUPER = 60 // 1 req/minute
)

Variables

View Source
var (
	BeforeRequest      func(path string) (bool, error)      = nil // -> (cooled, error)
	AfterRequest       func()                               = nil
	HandleRateLimitErr func(path string, cooled bool) error = nil
)
View Source
var Calls = []Call{}
View Source
var OperandString = map[Operand]string{
	LTE: "LTE",
	GTE: "GTE",
}
View Source
var OrderSideString = map[OrderSide]string{
	BUY:  "BUY",
	SELL: "SELL",
}
View Source
var OrderTypeString = map[OrderType]string{
	LIMIT:  "LIMIT",
	MARKET: "MARKET",
}
View Source
var TimeInForceString = map[TimeInForce]string{
	GTC: "GOOD_TIL_CANCELLED",
	IOC: "IMMEDIATE_OR_CANCEL",
	FOK: "FILL_OR_KILL",
}

Functions

func RequestsPerSecond

func RequestsPerSecond(intensity int) float64

Types

type BookEntry

type BookEntry struct {
	Quantity float64 `json:"quantity,string"`
	Rate     float64 `json:"rate,string"`
}

type Call

type Call struct {
	Path      string `json:"path"`
	Intensity int    `json:"intensity"`
}

type Client

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

func New

func New(apiKey, apiSecret, appId string) *Client

func (*Client) CancelConditionalOrder

func (client *Client) CancelConditionalOrder(orderId OrderId) (err error)

func (*Client) CancelOrder

func (client *Client) CancelOrder(orderId OrderId) (err error)

func (*Client) CreateConditionalOrder

func (client *Client) CreateConditionalOrder(
	marketSymbol string,
	operand Operand,
	triggerPrice float64,
	orderToCreate *NewOrder,
	orderToCancel OrderId,
) (*ConditionalOrder, error)

func (*Client) CreateOrder

func (client *Client) CreateOrder(
	marketSymbol string,
	direction OrderSide,
	orderType OrderType,
	quantity float64,
	limit float64,
	timeInForce TimeInForce,
) (*Order, error)

func (*Client) GetMarketSummary

func (client *Client) GetMarketSummary(market string) (*MarketSummary, error)

func (*Client) GetMarkets

func (client *Client) GetMarkets() (markets []Market, err error)

func (*Client) GetOpenConditionalOrders

func (client *Client) GetOpenConditionalOrders(market string) (orders []ConditionalOrder, err error)

func (*Client) GetOpenOrders

func (client *Client) GetOpenOrders(market string) (orders Orders, err error)

func (*Client) GetOrder

func (client *Client) GetOrder(orderId OrderId) (*Order, error)

func (*Client) GetOrderBook

func (client *Client) GetOrderBook(market string, depth int) (*OrderBook, error)

func (*Client) GetOrderHistory

func (client *Client) GetOrderHistory(market string) (Orders, error)

func (*Client) GetTicker

func (client *Client) GetTicker(market string) (*Ticker, error)

type ConditionalOrder

type ConditionalOrder struct {
	Id                       OrderId                    `json:"id"`
	MarketSymbol             string                     `json:"marketSymbol"`
	Operand                  string                     `json:"operand"` // LTE or GTE
	TriggerPrice             float64                    `json:"triggerPrice,string"`
	TrailingStopPercent      float64                    `json:"trailingStopPercent,string"`
	CreatedOrderId           OrderId                    `json:"createdOrderId"`
	OrderToCreate            *newOrder                  `json:"orderToCreate"`
	OrderToCancel            *newCancelConditionalOrder `json:"orderToCancel"`
	ClientConditionalOrderId OrderId                    `json:"clientConditionalOrderId"`
	Status                   string                     `json:"status"` // OPEN or COMPLETED or CANCELLED or FAILED
	OrderCreationErrorCode   string                     `json:"orderCreationErrorCode"`
	CreatedAt                string                     `json:"createdAt"`
	UpdatedAt                string                     `json:"updatedAt"`
	ClosedAt                 string                     `json:"closedAt"`
}

type Market

type Market struct {
	Symbol              string   `json:"symbol"`
	BaseCurrencySymbol  string   `json:"baseCurrencySymbol"`
	QuoteCurrencySymbol string   `json:"quoteCurrencySymbol"`
	MinTradeSize        float64  `json:"minTradeSize,string"`
	Precision           int      `json:"precision"`
	Status              string   `json:"status"`
	CreatedAt           string   `json:"createdAt"`
	Notice              string   `json:"notice,omitempty"`
	ProhibitedIn        []string `json:"prohibitedIn,omitempty"`
}

func (*Market) Active

func (market *Market) Active() bool

true if this market is currently online (and not about to be removed), otherwise false.

func (*Market) IsProhibited

func (market *Market) IsProhibited(regions []string) bool

func (*Market) MarketName

func (market *Market) MarketName() string

MarketName returns the old (v1) market name that was reversed.

func (*Market) Online

func (market *Market) Online() bool

type MarketSummary

type MarketSummary struct {
	Symbol        string  `json:"symbol"`
	High          float64 `json:"high,string"`
	Low           float64 `json:"low,string"`
	Volume        float64 `json:"volume,string"`
	QuoteVolume   float64 `json:"quoteVolume,string"`
	PercentChange float64 `json:"percentChange,string"`
	UpdatedAt     string  `json:"updatedAt"`
}

type NewOrder

type NewOrder struct {
	MarketSymbol string
	Direction    OrderSide
	OrderType    OrderType
	Quantity     float64
	Limit        float64
	TimeInForce  TimeInForce
}

type Operand

type Operand int
const (
	LTE Operand = iota
	GTE
)

func (*Operand) String

func (op *Operand) String() string

type Order

type Order struct {
	Id            OrderId                    `json:"id"`
	MarketSymbol  string                     `json:"marketSymbol"`
	Direction     string                     `json:"direction"` // BUY or SELL
	OrderType     string                     `json:"type"`      // LIMIT or MARKET
	Quantity      float64                    `json:"quantity,string"`
	Limit         float64                    `json:"limit,string,omitempty"`
	Ceiling       float64                    `json:"ceiling,string,omitempty"`
	TimeInForce   string                     `json:"timeInForce,omitempty"`
	ClientOrderId OrderId                    `json:"clientOrderId,omitempty"`
	FillQuantity  float64                    `json:"fillQuantity,string,omitempty"`
	Commission    float64                    `json:"commission,string,omitempty"`
	Proceeds      float64                    `json:"proceeds,string,omitempty"`
	Status        string                     `json:"status,omitempty"` // OPEN or CLOSED
	CreatedAt     string                     `json:"createdAt,omitempty"`
	UpdatedAt     string                     `json:"updatedAt,omitempty"`
	ClosedAt      string                     `json:"closedAt,omitempty"`
	OrderToCancel *newCancelConditionalOrder `json:"orderToCancel,omitempty"`
}

func (*Order) MarketName

func (order *Order) MarketName() string

MarketName returns the old (v1) market name that was reversed.

func (*Order) Price

func (order *Order) Price() float64

func (*Order) QuantityFilled

func (order *Order) QuantityFilled() float64

func (*Order) Type

func (order *Order) Type() OrderType

type OrderBook

type OrderBook struct {
	Bid []BookEntry `json:"bid"`
	Ask []BookEntry `json:"ask"`
}

type OrderId

type OrderId string

type OrderSide

type OrderSide int
const (
	BUY OrderSide = iota
	SELL
)

func (*OrderSide) String

func (os *OrderSide) String() string

type OrderType

type OrderType int
const (
	LIMIT OrderType = iota
	MARKET
)

func (*OrderType) String

func (ot *OrderType) String() string

type Orders

type Orders []Order

func (Orders) IndexByOrderId

func (orders Orders) IndexByOrderId(id OrderId) int

func (Orders) IndexByOrderIdEx

func (orders Orders) IndexByOrderIdEx(id OrderId, side OrderSide) int

type Ticker

type Ticker struct {
	Symbol        string  `json:"symbol"`
	LastTradeRate float64 `json:"lastTradeRate,string"`
	BidRate       float64 `json:"bidRate,string"`
	AskRate       float64 `json:"askRate,string"`
}

type TimeInForce

type TimeInForce int
const (
	// Lasts until the order is completed, expired, or cancelled. The maximum lifetime of any order is 28 days.
	// Any order older then 28 days will be automatically canceled by the system and all reserved funds will be returned to your account.
	GTC TimeInForce = iota
	// Must be executed immediately. Any portion of an IOC order that cannot be filled immediately will be cancelled.
	IOC
	// This option allows orders to be placed which will be filled immediately and completely, or not at all.
	FOK
)

func (*TimeInForce) String

func (tif *TimeInForce) String() string

Jump to

Keyboard shortcuts

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