bittrex

package module
v0.0.0-...-dc24129 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2014 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 (public and private).

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

This section is empty.

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 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 map[string]Balance, err error)

GetBalances is used to retrieve all balances from your account

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, count int) (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 count int the number of records to return. Is set to 0 will return the max set.

func (*Bittrex) GetHisCandles

func (b *Bittrex) GetHisCandles(market string) (candles []Candle, err error)

GetCandles is used to get the ohlcv.

func (*Bittrex) GetMarketHistory

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

GetMarketHistory is used to retrieve the latest trades that have occured for a specific market. mark a string literal for the market (ex: BTC-LTC) count a number between 1-100 for the number of entries to return

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) 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) GetNewCandles

func (b *Bittrex) GetNewCandles(market, LastEpoch string) (candles []Candle, err error)

GetCandles is used to get the ohlcv.

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) 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) GetOrderHistory

func (b *Bittrex) GetOrderHistory(market string, count int) (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 count int : the number of records to return. Is set to 0, will return max history

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) GetWithdrawalHistory

func (b *Bittrex) GetWithdrawalHistory(currency string, count int) (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 count int the number of records to return. Is set to 0 will return the max set.

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 string
	Open      float64
	Close     float64
	High      float64
	Low       float64
	Volume    float64
}

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 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"`
}

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"`
	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         string  `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 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"`
}

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