btce

package module
v0.0.0-...-33f0460 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2017 License: MPL-2.0 Imports: 11 Imported by: 0

README

Build Status Go Report Card GoDoc Coverage Status

BTC-E API Go Client

Native Go client for interacting with BTC-E Public API v3 and Trading API.

Usage

package main

import (
	"fmt"
	btc "github.com/onuryilmaz/go-btce"
)

func main() {

	api := btc.API{}

	ticker, err := api.Public.Ticker([]string{"btc_usd"})
	if err == nil {
		fmt.Printf("BTC buy price: %.3f \n", ticker["btc_usd"].Buy)
		fmt.Printf("BTC sell price: %.3f \n", ticker["btc_usd"].Sell)
	}

	info, err := api.Trade.GetInfoAuth("API_KEY", "API_SECRET")
	if err == nil {
		fmt.Printf("BTC amount: %.3f \n", info.Funds["btc"])
	}
}

Documentation

Overview

Package btce provides native Go client for interacting with BTC-E Public API v3 and Trading API.

Example usage:

package main

import (
	"fmt"
	btc "github.com/onuryilmaz/go-btce"
)

func main() {

	api := btc.API{}

	ticker, err := api.Public.Ticker([]string{"btc_usd"})
	if err == nil {
		fmt.Printf("BTC buy price: %.3f \n", ticker["btc_usd"].Buy)
		fmt.Printf("BTC sell price: %.3f \n", ticker["btc_usd"].Sell)
	}

	info, err := api.Trade.GetInfoAuth("API_KEY", "API_SECRET")
	if err == nil {
		fmt.Printf("BTC amount: %.3f \n", info.Funds["btc"])
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Public PublicAPI
	Trade  TradeAPI
}

API allows to use public and trade APIs of BTC-E

type AccountInfo

type AccountInfo struct {
	Funds            map[string]float64 `json:"funds"`
	Rights           Rights             `json:"rights"`
	TransactionCount int64              `json:"transaction_count"`
	OpenOrders       int64              `json:"open_orders"`
	ServerTime       float64            `json:"server_time"`
}

type ActiveOrder

type ActiveOrder struct {
	Pair             string  `json:"pair"`
	Type             string  `json:"type"`
	Amount           float64 `json:"amount"`
	Rate             float64 `json:"rate"`
	TimestampCreated int64   `json:"timestamp_created"`
	Status           int     `json:"status"`
}

type ActiveOrders

type ActiveOrders map[string]ActiveOrder

type CancelOrder

type CancelOrder struct {
	OrderID int                `json:"order_id"`
	Funds   map[string]float64 `json:"funds"`
}

type CreateCoupon

type CreateCoupon struct {
	Coupon        string             `json:"coupon"`
	TransactionID int                `json:"transID"`
	Funds         map[string]float64 `json:"funds"`
}

type Depth

type Depth map[string]DepthPair

type DepthItem

type DepthItem []float64

type DepthPair

type DepthPair struct {
	Asks []DepthItem `json:"asks"`
	Bids []DepthItem `json:"bids"`
}

type HistoryFilter

type HistoryFilter struct {
	From   int
	Count  int
	FromID int
	EndID  int
	Order  string
	Since  time.Time
	End    time.Time
}

type Info

type Info struct {
	ServerTime int64               `json:"server_time"`
	Pairs      map[string]InfoPair `json:"pairs"`
}

type InfoPair

type InfoPair struct {
	DecimalPlaces int     `json:"decimal_places"`
	MinPrice      float64 `json:"min_price"`
	MaxPrice      float64 `json:"max_price"`
	MinAmount     float64 `json:"min_amount"`
	Hidden        int     `json:"hidden"`
	Fee           float64 `json:"fee"`
}

type OrderInfo

type OrderInfo map[string]OrderInfoItem

type OrderInfoItem

type OrderInfoItem struct {
	Pair             string  `json:"pair"`
	Type             string  `json:"type"`
	StartAmount      float64 `json:"start_amount"`
	Amount           float64 `json:"amount"`
	Rate             float64 `json:"rate"`
	TimestampCreated int64   `json:"timestamp_created"`
	Status           int     `json:"status"`
}

type PublicAPI

type PublicAPI struct{}

PublicAPI provides access to such information as tickers of currency pairs, active orders on different pairs, the latest trades for each pair etc.

func (*PublicAPI) Depth

func (api *PublicAPI) Depth(currency []string, limit int) (Depth, error)

Depth provides the information about active orders on the pair.

func (*PublicAPI) Info

func (api *PublicAPI) Info() (Info, error)

Info provides all the information about currently active pairs, such as the maximum number of digits after the decimal point, the minimum price, the maximum price, the minimum transaction size, whether the pair is hidden, the commission for each pair.

func (*PublicAPI) Ticker

func (api *PublicAPI) Ticker(currency []string, ignoreInvalid ...bool) (Ticker, error)

Ticker provides all the information about currently active pairs, such as: the maximum price, the minimum price, average price, trade volume, trade volume in currency, the last trade, Buy and Sell price. All information is provided over the past 24 hours.

func (*PublicAPI) Trades

func (api *PublicAPI) Trades(currency []string, limit int) (Trades, error)

Trades provides the information about the last trades.

type RedeemCoupon

type RedeemCoupon struct {
	CouponAmount   string             `json:"couponAmount"`
	CouponCurrency string             `json:"couponCurrency"`
	TransactionID  int                `json:"transID"`
	Funds          map[string]float64 `json:"funds"`
}

type Response

type Response struct {
	Success int             `json:"success"`
	Return  json.RawMessage `json:"return"`
	Error   string          `json:"error"`
}

type Rights

type Rights struct {
	Info     int `json:"info"`
	Trade    int `json:"trade"`
	Withdraw int `json:"withdraw"`
}

type Ticker

type Ticker map[string]TickerPair

type TickerPair

type TickerPair struct {
	High    float64 `json:"high"`
	Low     float64 `json:"low"`
	Avg     float64 `json:"avg"`
	Vol     float64 `json:"vol"`
	VolCur  float64 `json:"vol_cur"`
	Last    float64 `json:"last"`
	Buy     float64 `json:"buy"`
	Sell    float64 `json:"sell"`
	Updated int64   `json:"updated"`
}

type TradeAPI

type TradeAPI struct {
	API_KEY    string
	API_SECRET string
	// contains filtered or unexported fields
}

TradeAPI allows to trade on the exchange and receive information about the account.

To use this API, you need to create an API key. An API key can be created in your Profile in the API Keys section. After creating an API key you’ll receive a key and a secret. Note that the Secret can be received only during the first hour after the creation of the Key. API key information is used for authentication.

func (*TradeAPI) ActiveOrders

func (tapi *TradeAPI) ActiveOrders(pair string) (ActiveOrders, error)

ActiveOrders returns the list of your active orders. To use this method you need a privilege of the info key. If the order disappears from the list, it was either executed or canceled.

func (*TradeAPI) ActiveOrdersAuth

func (tapi *TradeAPI) ActiveOrdersAuth(key string, secret string, pair string) (ActiveOrders, error)

ActiveOrdersAuth provides ActiveOrders capability with authorization

func (*TradeAPI) Auth

func (tapi *TradeAPI) Auth(key string, secret string)

Auth provides API key and secret setting for Trade API

func (*TradeAPI) CancelOrder

func (tapi *TradeAPI) CancelOrder(orderID string) (CancelOrder, error)

CancelOrder provides method used for order cancellation. To use this method you need a privilege of the trade key.

func (*TradeAPI) CancelOrderAuth

func (tapi *TradeAPI) CancelOrderAuth(key string, secret string, orderID string) (CancelOrder, error)

CancelOrderAuth provides CancelOrder capability with authorization

func (*TradeAPI) CreateCoupon

func (tapi *TradeAPI) CreateCoupon(currency string, amount float64) (CreateCoupon, error)

CreateCoupon allows you to create Coupons. In order to use this method, you need the Coupon key privilege.

func (*TradeAPI) CreateCouponAuth

func (tapi *TradeAPI) CreateCouponAuth(key string, secret string, currency string, amount float64) (CreateCoupon, error)

CreateCouponAuth provides CreateCoupon capability with authorization

func (*TradeAPI) GetInfo

func (tapi *TradeAPI) GetInfo() (AccountInfo, error)

GetInfo returns information about the user’s current balance, API-key privileges, the number of open orders and Server Time. To use this method you need a privilege of the key info.

func (*TradeAPI) GetInfoAuth

func (tapi *TradeAPI) GetInfoAuth(key string, secret string) (AccountInfo, error)

GetInfoAuth provides GetInfo capability with authorization

func (*TradeAPI) OrderInfo

func (tapi *TradeAPI) OrderInfo(orderID string) (OrderInfo, error)

OrderInfo provides the information on particular order. To use this method you need a privilege of the info key.

func (*TradeAPI) OrderInfoAuth

func (tapi *TradeAPI) OrderInfoAuth(key string, secret string, orderID string) (OrderInfo, error)

OrderInfoAuth provides OrderInfo capability with authorization

func (*TradeAPI) RedeemCoupon

func (tapi *TradeAPI) RedeemCoupon(coupon string) (RedeemCoupon, error)

RedeemCoupon method is used to redeem coupons. In order to use this method, you need the Coupon key privilege.

func (*TradeAPI) RedeemCouponAuth

func (tapi *TradeAPI) RedeemCouponAuth(key string, secret string, coupon string) (RedeemCoupon, error)

RedeemCouponAuth provides RedeemCoupon capability with authorization

func (*TradeAPI) Trade

func (tapi *TradeAPI) Trade(pair string, orderType string, rate float64, amount float64) (TradeResponse, error)

Trade provide method that can be used for creating orders and trading on the exchange. To use this method you need an API key privilege to trade.

You can only create limit orders using this method, but you can emulate market orders using rate parameters. E.g. using rate=0.1 you can sell at the best market price.

Each pair has a different limit on the minimum / maximum amounts, the minimum amount and the number of digits after the decimal point. All limitations can be obtained using the info method in PublicAPI.

func (*TradeAPI) TradeAuth

func (tapi *TradeAPI) TradeAuth(key string, secret string, pair string, orderType string, rate float64, amount float64) (TradeResponse, error)

TradeAuth provides Trade capability with authorization

func (*TradeAPI) TradeHistory

func (tapi *TradeAPI) TradeHistory(filter HistoryFilter, pair string) (TradeHistory, error)

TradeHistory returns trade history. To use this method you need a privilege of the info key.

func (*TradeAPI) TradeHistoryAuth

func (tapi *TradeAPI) TradeHistoryAuth(key string, secret string, filter HistoryFilter, pair string) (TradeHistory, error)

TradeHistoryAuth provides TradeHistory capability with authorization

func (*TradeAPI) TransactionHistory

func (tapi *TradeAPI) TransactionHistory(filter HistoryFilter) (TransactionHistory, error)

TransactionHistory returns the history of transactions. To use this method you need a privilege of the info key.

func (*TradeAPI) TransactionHistoryAuth

func (tapi *TradeAPI) TransactionHistoryAuth(key string, secret string, filter HistoryFilter) (TransactionHistory, error)

TransactionHistoryAuth provides TransactionHistory capability with authorization

func (*TradeAPI) WithdrawCoin

func (tapi *TradeAPI) WithdrawCoin(coinName string, amount float64, address string) (WithdrawCoin, error)

WithdrawCoin provides cryptocurrency withdrawals. You need to have the privilege of the Withdraw key to be able to use this method.

func (*TradeAPI) WithdrawCoinAuth

func (tapi *TradeAPI) WithdrawCoinAuth(key string, secret string, coinName string, amount float64, address string) (WithdrawCoin, error)

WithdrawCoinAuth provides WithdrawCoin capability with authorization

type TradeError

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

custom error type for server/trading errors

func (TradeError) Error

func (e TradeError) Error() string

type TradeHistory

type TradeHistory map[string]TradeHistoryItem

type TradeHistoryItem

type TradeHistoryItem struct {
	Pair        string  `json:"pair"`
	Type        string  `json:"type"`
	Amount      float64 `json:"amount"`
	Rate        float64 `json:"rate"`
	OrderID     int     `json:"order_id"`
	IsYourOrder int     `json:"is_your_order"`
	Timestamp   int64   `json:"timestamp"`
}

type TradeItem

type TradeItem struct {
	Type      string  `json:"type"`
	Price     float64 `json:"price"`
	Amount    float64 `json:"amount"`
	TID       int64   `json:"tid"`
	Timestamp int64   `json:"timestamp"`
}

type TradePair

type TradePair []TradeItem

type TradeResponse

type TradeResponse struct {
	Received float64            `json:"received"`
	Remains  float64            `json:"remains"`
	OrderID  int                `json:"order_id"`
	Funds    map[string]float64 `json:"funds"`
}

type Trades

type Trades map[string]TradePair

type TransactionHistory

type TransactionHistory map[string]TransactionHistoryItem

type TransactionHistoryItem

type TransactionHistoryItem struct {
	Type        int     `json:"type"`
	Amount      float64 `json:"amount"`
	Currency    string  `json:"currency"`
	Description string  `json:"desc"`
	Status      int     `json:"status"`
	Timestamp   int64   `json:"timestamp"`
}

type WithdrawCoin

type WithdrawCoin struct {
	TransactionID int                `json:"tId"`
	AmountSent    float64            `json:"amountSent"`
	Funds         map[string]float64 `json:"funds"`
}

Jump to

Keyboard shortcuts

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