bittrex

package module
v0.0.0-...-005623a Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: MIT Imports: 12 Imported by: 0

README

go-bittrex

go-bittrex is an implementation of the Bittrex API (public and private) in Golang.

This version implement V1.1 Bittrex API and the new HMAC authentification.

Import

import "github.com/toorop/go-bittrex"

Usage

package main

import (
	"fmt"
	"github.com/toorop/go-bittrex"
)

const (
	API_KEY    = "YOUR_API_KEY"
	API_SECRET = "YOUR_API_SECRET"
)

func main() {
	// Bittrex client
	bittrex := bittrex.New(API_KEY, API_SECRET)

	// Get markets
	markets, err := bittrex.GetMarkets()
	fmt.Println(err, markets)
}

See "Examples" folder for more... examples

Documentation

GoDoc

Stay tuned

Follow me on Twitter

Donate

Donation QR

1HgpsmxV52eAjDcoNpVGpYEhGfgN7mM1JB

Documentation

Overview

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

Index

Constants

View Source
const (
	API_BASE                   = "https://bittrex.com/api/" // Bittrex API endpoint
	API_VERSION                = "v1.1"                     // Bittrex API version
	DEFAULT_HTTPCLIENT_TIMEOUT = 30                         // HTTP client timeout
)
View Source
const TIME_FORMAT = "2006-01-02T15:04:05"

Variables

View Source
var CANDLE_INTERVALS = map[string]bool{
	"oneMin":    true,
	"fiveMin":   true,
	"thirtyMin": true,
	"hour":      true,
	"day":       true,
}

Functions

func NewClient

func NewClient(apiKey, apiSecret string) (c *client)

NewClient return a new Bittrex HTTP client

Types

type Address

type Address struct {
	Currency string `json:"Currency"`
	Address  string `json:"Address"`
}

type Balance

type Balance struct {
	Currency      string  `json:"Currency"`
	Balance       float64 `json:"Balance"`
	Available     float64 `json:"Available"`
	Pending       float64 `json:"Pending"`
	CryptoAddress string  `json:"CryptoAddress"`
	Requested     bool    `json:"Requested"`
	Uuid          string  `json:"Uuid"`
}

type BalanceD

type BalanceD struct {
	BalanceD float64 `json:"Balance"`
}

type Bittrex

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

bittrex represent a bittrex client

func New

func New(apiKey, apiSecret string) *Bittrex

New return a instanciate bittrex struct

func (*Bittrex) BuyLimit

func (b *Bittrex) BuyLimit(market string, quantity, rate float64) (uuid string, err error)

BuyLimit is used to place a limited buy order in a specific market.

func (*Bittrex) BuyMarket

func (b *Bittrex) BuyMarket(market string, quantity float64) (uuid string, err error)

BuyMarket is used to place a market buy order in a spacific market.

func (*Bittrex) CancelOrder

func (b *Bittrex) CancelOrder(orderID string) (err error)

CancelOrder is used to cancel a buy or sell order.

func (*Bittrex) GetBalance

func (b *Bittrex) GetBalance(currency string) (balance Balance, err error)

Getbalance is used to retrieve the balance from your account for a specific currency. currency: a string literal for the currency (ex: LTC)

func (*Bittrex) GetBalances

func (b *Bittrex) GetBalances() (balances []Balance, err error)

GetBalances is used to retrieve all balances from your account

func (*Bittrex) GetCurrencies

func (b *Bittrex) GetCurrencies() (currencies []Currency, err error)

GetCurrencies is used to get all supported currencies at Bittrex along with other meta data.

func (*Bittrex) GetDepositAddress

func (b *Bittrex) GetDepositAddress(currency string) (address Address, err error)

GetDepositAddress is sed to generate or retrieve an address for a specific currency. currency a string literal for the currency (ie. BTC)

func (*Bittrex) GetDepositHistory

func (b *Bittrex) GetDepositHistory(currency string) (deposits []Deposit, err error)

GetDepositHistory is used to retrieve your deposit history currency string a string literal for the currency (ie. BTC). If set to "all", will return for all currencies

func (*Bittrex) GetDistribution

func (b *Bittrex) GetDistribution(market string) (distribution Distribution, err error)

GetDistribution is used to get the distribution.

func (*Bittrex) GetMarketHistory

func (b *Bittrex) GetMarketHistory(market string) (trades []Trade, err error)

GetMarketHistory is used to retrieve the latest trades that have occured for a specific market. market a string literal for the market (ex: BTC-LTC)

func (*Bittrex) GetMarketSummaries

func (b *Bittrex) GetMarketSummaries() (marketSummaries []MarketSummary, err error)

GetMarketSummaries is used to get the last 24 hour summary of all active exchanges

func (*Bittrex) GetMarketSummary

func (b *Bittrex) GetMarketSummary(market string) (marketSummary []MarketSummary, err error)

GetMarketSummary is used to get the last 24 hour summary for a given market

func (*Bittrex) GetMarkets

func (b *Bittrex) GetMarkets() (markets []Market, err error)

GetMarkets is used to get the open and available trading markets at Bittrex along with other meta data.

func (*Bittrex) GetOpenOrders

func (b *Bittrex) GetOpenOrders(market string) (openOrders []Order, err error)

GetOpenOrders returns orders that you currently have opened. If market is set to "all", GetOpenOrders return all orders If market is set to a specific order, GetOpenOrders return orders for this market

func (*Bittrex) GetOrder

func (b *Bittrex) GetOrder(order_uuid string) (order Order2, err error)

func (*Bittrex) GetOrderBook

func (b *Bittrex) GetOrderBook(market, cat string, depth int) (orderBook OrderBook, err error)

GetOrderBook is used to get retrieve the orderbook for a given market market: a string literal for the market (ex: BTC-LTC) cat: buy, sell or both to identify the type of orderbook to return. depth: how deep of an order book to retrieve. Max is 100

func (*Bittrex) GetOrderBookBuySell

func (b *Bittrex) GetOrderBookBuySell(market, cat string, depth int) (orderb []Orderb, err error)

GetOrderBookBuySell is used to get retrieve the buy or sell side of an orderbook for a given market market: a string literal for the market (ex: BTC-LTC) cat: buy or sell to identify the type of orderbook to return. depth: how deep of an order book to retrieve. Max is 100

func (*Bittrex) GetOrderHistory

func (b *Bittrex) GetOrderHistory(market string) (orders []Order, err error)

GetOrderHistory used to retrieve your order history. market string literal for the market (ie. BTC-LTC). If set to "all", will return for all market

func (*Bittrex) GetTicker

func (b *Bittrex) GetTicker(market string) (ticker Ticker, err error)

GetTicker is used to get the current ticker values for a market.

func (*Bittrex) GetTicks

func (b *Bittrex) GetTicks(market string, interval string) ([]Candle, error)

GetTicks is used to get ticks history values for a market.

func (*Bittrex) GetWithdrawalHistory

func (b *Bittrex) GetWithdrawalHistory(currency string) (withdrawals []Withdrawal, err error)

GetWithdrawalHistory is used to retrieve your withdrawal history currency string a string literal for the currency (ie. BTC). If set to "all", will return for all currencies

func (*Bittrex) SellLimit

func (b *Bittrex) SellLimit(market string, quantity, rate float64) (uuid string, err error)

SellLimit is used to place a limited sell order in a specific market.

func (*Bittrex) SellMarket

func (b *Bittrex) SellMarket(market string, quantity float64) (uuid string, err error)

SellMarket is used to place a market sell order in a specific market.

func (*Bittrex) Withdraw

func (b *Bittrex) Withdraw(address, currency string, quantity float64) (withdrawUuid string, err error)

Withdraw is used to withdraw funds from your account. address string the address where to send the funds. currency string literal for the currency (ie. BTC) quantity float the quantity of coins to withdraw

type Candle

type Candle struct {
	TimeStamp  CandleTime `json:"T"`
	Open       float64    `json:"O"`
	Close      float64    `json:"C"`
	High       float64    `json:"H"`
	Low        float64    `json:"L"`
	Volume     float64    `json:"V"`
	BaseVolume float64    `json:"BV"`
}

type CandleTime

type CandleTime struct {
	time.Time
}

func (*CandleTime) UnmarshalJSON

func (t *CandleTime) UnmarshalJSON(b []byte) error

type Currency

type Currency struct {
	Currency        string  `json:"Currency"`
	CurrencyLong    string  `json:"CurrencyLong"`
	MinConfirmation int     `json:"MinConfirmation"`
	TxFee           float64 `json:"TxFee"`
	IsActive        bool    `json:"IsActive"`
	CoinType        string  `json:"CoinType"`
	BaseAddress     string  `json:"BaseAddress"`
	Notice          string  `json:"Notice"`
}

type Deposit

type Deposit struct {
	Id            int64   `json:"Id"`
	Amount        float64 `json:"Amount"`
	Currency      string  `json:"Currency"`
	Confirmations int     `json:"Confirmations"`
	LastUpdated   jTime   `json:"LastUpdated"`
	TxId          string  `json:"TxId"`
	CryptoAddress string  `json:"CryptoAddress"`
}

type Distribution

type Distribution struct {
	Distribution   []BalanceD `json:"Distribution"`
	Balances       float64    `json:"Balances"`
	AverageBalance float64    `json:"AverageBalance"`
}

type Market

type Market struct {
	MarketCurrency     string  `json:"MarketCurrency"`
	BaseCurrency       string  `json:"BaseCurrency"`
	MarketCurrencyLong string  `json:"MarketCurrencyLong"`
	BaseCurrencyLong   string  `json:"BaseCurrencyLong"`
	MinTradeSize       float64 `json:"MinTradeSize"`
	MarketName         string  `json:"MarketName"`
	IsActive           bool    `json:"IsActive"`
	Notice             string  `json:"Notice"`
	IsSponsored        bool    `json:"IsSponsored"`
	LogoUrl            string  `json:"LogoUrl"`
}

type MarketSummary

type MarketSummary struct {
	MarketName     string  `json:"MarketName"`
	High           float64 `json:"High"`
	Low            float64 `json:"Low"`
	Ask            float64 `json:"Ask"`
	Bid            float64 `json:"Bid"`
	OpenBuyOrders  int     `json:"OpenBuyOrders"`
	OpenSellOrders int     `json:"OpenSellOrders"`
	Volume         float64 `json:"Volume"`
	Last           float64 `json:"Last"`
	BaseVolume     float64 `json:"BaseVolume"`
	PrevDay        float64 `json:"PrevDay"`
	TimeStamp      string  `json:"TimeStamp"`
}

type NewCandles

type NewCandles struct {
	Ticks []Candle `json:"ticks"`
}

type Order

type Order struct {
	OrderUuid         string  `json:"OrderUuid"`
	Exchange          string  `json:"Exchange"`
	TimeStamp         jTime   `json:"TimeStamp"`
	OrderType         string  `json:"OrderType"`
	Limit             float64 `json:"Limit"`
	Quantity          float64 `json:"Quantity"`
	QuantityRemaining float64 `json:"QuantityRemaining"`
	Commission        float64 `json:"Commission"`
	Price             float64 `json:"Price"`
	PricePerUnit      float64 `json:"PricePerUnit"`
}

type Order2

type Order2 struct {
	AccountId                  string
	OrderUuid                  string `json:"OrderUuid"`
	Exchange                   string `json:"Exchange"`
	Type                       string
	Quantity                   float64 `json:"Quantity"`
	QuantityRemaining          float64 `json:"QuantityRemaining"`
	Limit                      float64 `json:"Limit"`
	Reserved                   float64
	ReserveRemaining           float64
	CommissionReserved         float64
	CommissionReserveRemaining float64
	CommissionPaid             float64
	Price                      float64 `json:"Price"`
	PricePerUnit               float64 `json:"PricePerUnit"`
	Opened                     string
	Closed                     string
	IsOpen                     bool
	Sentinel                   string
	CancelInitiated            bool
	ImmediateOrCancel          bool
	IsConditional              bool
	Condition                  string
	ConditionTarget            string
}

For getorder

type OrderBook

type OrderBook struct {
	Buy  []Orderb `json:"buy"`
	Sell []Orderb `json:"sell"`
}

type Orderb

type Orderb struct {
	Quantity float64 `json:"Quantity"`
	Rate     float64 `json:"Rate"`
}

type Ticker

type Ticker struct {
	Bid  float64 `json:"Bid"`
	Ask  float64 `json:"Ask"`
	Last float64 `json:"Last"`
}

type Trade

type Trade struct {
	OrderUuid string  `json:"OrderUuid"`
	Timestamp jTime   `json:"TimeStamp"`
	Quantity  float64 `json:"Quantity"`
	Price     float64 `json:"Price"`
	Total     float64 `json:"Total"`
	FillType  string  `json:"FillType"`
	OrderType string  `json:"OrderType"`
}

Used in getmarkethistory

type Uuid

type Uuid struct {
	Id string `json:"uuid"`
}

type Withdrawal

type Withdrawal struct {
	PaymentUuid    string  `json:"PaymentUuid"`
	Currency       string  `json:"Currency"`
	Amount         float64 `json:"Amount"`
	Address        string  `json:"Address"`
	Opened         jTime   `json:"Opened"`
	Authorized     bool    `json:"Authorized"`
	PendingPayment bool    `json:"PendingPayment"`
	TxCost         float64 `json:"TxCost"`
	TxId           string  `json:"TxId"`
	Canceled       bool    `json:"Canceled"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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