bittrex

package module
v0.0.0-...-8f1721d Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2017 License: MIT Imports: 9 Imported by: 0

README

bitterex-api

A Go API wrapper implementation of the Bitterex API v1.1

Import

  import "github.com/joevak/bittrex-api"

Usage

package main

import (
	"fmt"
	"github.com/joevak/bittrex-api""
)

const (
	apiKey    = "API_KEY"
	apiSecret = "API_SECRET"
)

func main() {
    bittrex := bittrex.NewBittrex(apiKey, apiSecret)

    markets, err := bittrex.GetMarketSummary()

    if err != nil {
        fmt.Printf("%s", err)
    } else {
        fmt.Printf("%s", markets)
    }
}

Functions

Public

func (b *Bittrex)  GetCurrencies() ([]JSONCurrency, error) 
Retrives the latest trades for a specific market
func (b *Bittrex)  GetMarkets() ([]JSONMarket, error)
Retreives all open and available trading markets with other meta data
func (b *Bittrex) GetTicker(market string) (JSONTicker, error)
Retreives current tick values for defined market
func (b *Bittrex) GetMarketSummary(markets ...string) ([]JSONMarketSummary, error)
Retrives last 24 hour summary of defined markets.  If no markets are passed retrives summaries for all markets
func (b *Bittrex) GetOrderBook(market string, orderType OrderType) (JSONOrderBook, error)
Retrives the order book for a given market (buy, sell, or both)
func (b *Bittrex) GetMarketHistory(market string) ([]JSONMarketHistory, error)
Retrives the latest trades for a specific market

Market

requires API key
func (b *Bittrex) PlaceBuyOrder(market string, quantity float64, rate float64) (JSONUUID, error)
Places buy limit order for one market
func (b *Bittrex) PlaceSellOrder(market string, quantity float64, rate float64) (JSONUUID, error)
Places sell limit order for a specific market
func (b *Bittrex) CancelOrder(UUID string) error
Cancels buy or sell order
func (b *Bittrex) GetOrders(market string) ([]JSONOrder, error)
Retrives all open order for specified market.

Account

requires API key
func (b *Bittrex) GetBalance(currencies ...string) ([]JSONBalance, error)
Retrieves balance for defined currencies, if no currencies are defined return all balances
func (b *Bittrex) GetDepositAddress(currency string) (JSONDepositAddress, error)
Retrieves or generates an address for a specific currency. If one does not exist, the call will fail and return ADDRESS_GENERATING until one is available.
func (b *Bittrex) Withdraw(currency string, quantity float64, address string, paymentID ...string) (JSONUUID, error)
Withdraw fund from account
func (b *Bittrex) GetWithdrawHistory(currencies ...string) ([]JSONAccountHistory, error)
Retrives withdrawl history for defined currencies, if no currencies are defined retrives for all currencies
func (b *Bittrex) GetDepositHistory(currencies ...string) ([]JSONAccountHistory, error)
Retrives deposit history for defined currencies, if no currencies are defined retrives for all currencies
func (b *Bittrex) GetOrder(UUID string) (JSONUUIDOrder, error)
Retrives an order
func (b *Bittrex) GetOrderHistory(markets ...string) ([]JSONOrderHistory, error)
Retrives order history for defined markets, if no markets are defined retrives for all markets

Types

JSONBalance
type JSONBalance struct {
    Currency      string
    Balance       float64
    Available     float64
    Pending       float64
    CryptoAddress string
    Requested     bool
    UUID          string
}
JSONDepositAddress
type JSONDepositAddress struct {
    Currency string
    Address  string
}
JSONOrderUUID
type JSONOrderUUID struct {
    AccountID                  string
    OrderUUID                  string 
    Exchange                   string
    Type                       string
    Quantity                   float64
    QuantityRemaining          float64
    Limit                      float64
    Reserved                   float64
    ReserveRemaining           float64
    CommissionReserver         float64
    CommissionReserveRemaining float64
    CommissionPaid             float64
    Price                      float64
    PricePerUnit               float64
    Opened                     string
    Closed                     string
    IsOpen                     bool
    Sentinel                   string
    CancelInitiated            bool
    ImmediateOrCancel          bool
    IsConditional              bool
    Condition                  string
    ConditionTarget            string
}
JSONOrderHistory
type JSONOrderHistory struct {
    OrderUUID         string
    Exchange          string
    TimeStamp         string
    OrderType         string
    Quantity          float64
    QuantityRemaining float64
    Limit             float64
    Commission        float64
    Price             float64
    PricePerUnit      float64
    ImmediateOrCancel bool
    IsConditional     bool
    Condition         string
    ConditionTarget   string
}
JSONAccountHistory
type JSONAccountHistory struct {
    PaymentUUID    string 
    Currency       string
    Amount         float64
    Address        string
    Opened         string
    Authorized     bool
    PendingPayment bool
    TxCost         float64
    TxID           string
    Canceled       bool
    InvalidAddress bool
}
JSONCurrency
type JSONCurrency struct {
    Currency        string
    CurrencyLong    string
    MinConfirmation int
    TxFee           float64
    IsActive        bool
    CoinType        string
    BaseAddress     string
} 
JSONMarket
type JSONMarket struct {
    MarketCurrency     string
    BaseCurrency       string
    MarketCurrencyLong string
    BaseCurrencyLong   string
    MinTradeSize       float64
    MarketName         string
    IsActive           bool
    Created            string
}
JSONTicker
type JSONTicker struct {
    Bid  float64
    Ask  float64
    Last float64
}
JSONMarketSummary
type JSONMarketSummary struct {
    MarketName        string
    High              float64
    Low               float64
    Volume            float64
    Last              float64
    BaseVolume        float64
    TimeStamp         string
    Bid               float64
    Ask               float64
    OpenBuyOrders     int
    OpenSellOrders    int
    PrevDay           float64
    Created           string
    DisplayMarketName string
}
JSONOrderBookRate
type JSONOrderBookRate struct {
    Quantity float64
    Rate     float64
}
JSONOrderBook
type JSONOrderBook struct {
    Buy  []JSONOrderBookRate
    Sell []JSONOrderBookRate
}
JSONMarketHistory
type JSONMarketHistory struct {
    ID        int 
    TimeStamp string
    Quantity  float64
    Price     float64
    Total     float64
    FillType  string
    OrderType string
}
OrderType
type OrderType string

const (
    BUY  OrderType = "buy"
    SELL OrderType = "sell"
    BOTH OrderType = "both"
)
JSONOrder
type JSONOrder struct {
    UUID              string
    OrderUUID         string 
    Exchange          string
    OrderType         string
    Quantity          float64
    QuantityRemaning  float64
    Limit             float64
    CommissionPaid    float64
    Price             float64
    PricePerUnit      float64
    Opened            string
    closed            string
    CancelInitiated   bool
    ImmediateOrCancel bool
    IsConditional     bool
    Condition         string
    ConditionTarget   string
}

Documentation

Index

Constants

View Source
const (
	BASE_URL        = "https://bittrex.com/api"
	API_VERSION     = "v1.1"
	DEFAULT_TIMEOUT = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bittrex

type Bittrex struct {
	Key    string
	Secret string
	// contains filtered or unexported fields
}

func NewBittrex

func NewBittrex(key string, secret string, config ...BittrexConfig) *Bittrex

func (*Bittrex) CancelOrder

func (b *Bittrex) CancelOrder(UUID string) error

Cancels buy or sell order by UUID

func (*Bittrex) GetBalance

func (b *Bittrex) GetBalance(currencies ...string) ([]JSONBalance, error)

Retrieves balance for defined currencies, if no currencies are defined return all balances

func (*Bittrex) GetCurrencies

func (b *Bittrex) GetCurrencies() ([]JSONCurrency, error)

Retreives all supported currencies with other meta data

func (*Bittrex) GetDepositAddress

func (b *Bittrex) GetDepositAddress(currency string) (JSONDepositAddress, error)

Retrieves or generates an address for a specific currency. If one does not exist, the call will fail and return ADDRESS_GENERATING until one is available.

func (*Bittrex) GetDepositHistory

func (b *Bittrex) GetDepositHistory(currencies ...string) ([]JSONAccountHistory, error)

Retrives deposit history for defined currencies, if no currencies are defined retrives for all currencies

func (*Bittrex) GetMarketHistory

func (b *Bittrex) GetMarketHistory(market string) ([]JSONMarketHistory, error)

Retrives the latest trades for a specific market

func (*Bittrex) GetMarketSummary

func (b *Bittrex) GetMarketSummary(markets ...string) ([]JSONMarketSummary, error)

Retrives last 24 hour summary of defined markets. If no markets are passed retrives summaries for all markets

func (*Bittrex) GetMarkets

func (b *Bittrex) GetMarkets() ([]JSONMarket, error)

Retreives all open and available trading markets with other meta data

func (*Bittrex) GetOrder

func (b *Bittrex) GetOrder(UUID string) (JSONOrderUUID, error)

Retrives an order

func (*Bittrex) GetOrderBook

func (b *Bittrex) GetOrderBook(market string, orderType OrderType) (JSONOrderBook, error)

Retrives the order book for a given market (buy, sell, or both)

func (*Bittrex) GetOrderHistory

func (b *Bittrex) GetOrderHistory(markets ...string) ([]JSONOrderHistory, error)

Retrives order history for defined markets, if no markets are defined retrives for all markets

func (*Bittrex) GetOrders

func (b *Bittrex) GetOrders(market string) ([]JSONOrder, error)

Retrives all open order for specified market.

func (*Bittrex) GetTicker

func (b *Bittrex) GetTicker(market string) (JSONTicker, error)

Retreives current tick values for defined market

func (*Bittrex) GetWithdrawHistory

func (b *Bittrex) GetWithdrawHistory(currencies ...string) ([]JSONAccountHistory, error)

Retrives withdrawl history for defined currencies, if no currencies are defined retrives for all currencies

func (*Bittrex) PlaceBuyOrder

func (b *Bittrex) PlaceBuyOrder(market string, quantity float64, rate float64) (JSONUUID, error)

Places buy limit order for one market

func (*Bittrex) PlaceSellOrder

func (b *Bittrex) PlaceSellOrder(market string, quantity float64, rate float64) (JSONUUID, error)

Places sell limit order for a specific market

func (*Bittrex) Request

func (b *Bittrex) Request(endPoint string, authenticate bool) (json.RawMessage, error)

func (*Bittrex) Withdraw

func (b *Bittrex) Withdraw(currency string, quantity float64, address string, paymentID ...string) (JSONUUID, error)

Withdraw fund from account

type BittrexConfig

type BittrexConfig struct {
	Debug   bool
	Timeout time.Duration
}

type JSONAccountHistory

type JSONAccountHistory struct {
	PaymentUUID    string `json:"PaymentUuid"`
	Currency       string
	Amount         float64
	Address        string
	Opened         string
	Authorized     bool
	PendingPayment bool
	TxCost         float64
	TxID           string
	Canceled       bool
	InvalidAddress bool
}

type JSONBalance

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

type JSONCurrency

type JSONCurrency struct {
	Currency        string
	CurrencyLong    string
	MinConfirmation int
	TxFee           float64
	IsActive        bool
	CoinType        string
	BaseAddress     string
}

JSONCurrency : JSON currency result structure

type JSONDepositAddress

type JSONDepositAddress struct {
	Currency string
	Address  string
}

type JSONMarket

type JSONMarket struct {
	MarketCurrency     string
	BaseCurrency       string
	MarketCurrencyLong string
	BaseCurrencyLong   string
	MinTradeSize       float64
	MarketName         string
	IsActive           bool
	Created            string
}

JSONMarket : JSON market result structure

type JSONMarketHistory

type JSONMarketHistory struct {
	ID        int `json:"Id"`
	TimeStamp string
	Quantity  float64
	Price     float64
	Total     float64
	FillType  string
	OrderType string
}

type JSONMarketSummary

type JSONMarketSummary struct {
	MarketName        string
	High              float64
	Low               float64
	Volume            float64
	Last              float64
	BaseVolume        float64
	TimeStamp         string
	Bid               float64
	Ask               float64
	OpenBuyOrders     int
	OpenSellOrders    int
	PrevDay           float64
	Created           string
	DisplayMarketName string
}

JSONMarketSummary : JSON market summary result structure

type JSONOrder

type JSONOrder struct {
	UUID             string `json:"uuid"`
	OrderUUID        string `json:"OrderUuid"`
	Exchange         string
	OrderType        string
	Quantity         float64
	QuantityRemaning float64
	Limit            float64
	CommissionPaid   float64
	Price            float64
	PricePerUnit     float64
	Opened           string

	CancelInitiated   bool
	ImmediateOrCancel bool
	IsConditional     bool
	Condition         string
	ConditionTarget   string
	// contains filtered or unexported fields
}

type JSONOrderBook

type JSONOrderBook struct {
	Buy  []JSONOrderBookRate `json:"buy,omitempty"`
	Sell []JSONOrderBookRate `json:"sell,omitempty"`
}

JSONOrderBook : JSON orderbook structure (buy, sell)

type JSONOrderBookRate

type JSONOrderBookRate struct {
	Quantity float64
	Rate     float64
}

JSONOrderBookRate : JSON orderbook result structure

type JSONOrderHistory

type JSONOrderHistory struct {
	OrderUUID         string `json:"OrderUuid"`
	Exchange          string
	TimeStamp         string
	OrderType         string
	Quantity          float64
	QuantityRemaining float64
	Limit             float64
	Commission        float64
	Price             float64
	PricePerUnit      float64
	ImmediateOrCancel bool
	IsConditional     bool
	Condition         string
	ConditionTarget   string
}

type JSONOrderUUID

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

type JSONResponseBody

type JSONResponseBody struct {
	Success bool            `json:"success"`
	Message string          `json:"message"`
	Result  json.RawMessage `json:"result"`
}

JSONResponseBody : JSON high level template for Bittrex API

type JSONTicker

type JSONTicker struct {
	Bid  float64
	Ask  float64
	Last float64
}

JSONTicker : JSON ticker result structure

type JSONUUID

type JSONUUID struct {
	UUID string `json:"uuid"`
}

type OrderType

type OrderType string
const (
	BUY  OrderType = "buy"
	SELL OrderType = "sell"
	BOTH OrderType = "both"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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