btce

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

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

Go to latest
Published: Feb 23, 2015 License: MIT Imports: 14 Imported by: 1

README

Go-btce

Go-btce is an implementation of the btc-e.com API (public and private) in Go.

This version implements the version 3 btc-e.com API.

Install

go get github.com/TMKCodes/go-btce

Import

import "github.com/TMKCodes/go-btce"

Example

package main
import (
"fmt"
"github.com/TMKCodes/go-btce"
)
const (
KEY = "M7Z2I8HR-07RJRR6L-PO7DDGGX-LCJ7VW3B-NX7PCSET"
SECRET = "4a720e1de1ba08bec388209996df8141e48813c57dbc12425985eebf3e8e3b87"
)
func main() {
	btce := btce.New(KEY, SECRET);
	PublicInfo, err := btce.Info("btc_usd");
	if err != nil {
		fmt.Printf("Info: %v\n", err);
	} else {
		fmt.Printf("Info: %#v\n", Info);
	}
	Ticker, err := btce.Ticker("btc_usd");
	if err != nil {
		fmt.Printf("Ticker: %v\n", err);
	} else {
		fmt.Printf("Ticker: %#v\n", Ticker);
	}
	Trades, err := btce.Trades("btc_usd");
	if err != nil {
		fmt.Printf("Trades: %v\n", err);
	} else {
		fmt.Printf("Trades: %#v\n", Trades);
	}
	Depth, err := btce.Depth("btc_usd");
	if err != nil {
		fmt.Printf("Depth: %v\n", err);
	} else {
		fmt.Printf("Depth: %#v\n", Depth);
	}
	PrivateInfo, err := btce.GetInfo();
	if err != nil {
		fmt.Printf("Info: %v\n", err);
	} else {
		fmt.Printf("Info: %#v\n", PrivateInfo);
	}
	TransHistory, err := btce.TransHistory(0, 1000, 0, 0, "ASC", "", "");
	if err != nil {
		fmt.Printf("TransHistory: %v\n", err);
	} else {
		fmt.Printf("TransHistory: %#v\n", TransHistory);
	}
	TradeHistory, err := btce.TradeHistory(0, 1000, 0, 0, "DESC", "", "", "");
	if err != nil {
		fmt.Printf("TradeHistory: %v\n", err);
	} else {
		fmt.Printf("TradeHistory: %#v\n", TradeHistory);
	}
}

Documentation

Index

Constants

View Source
const (
	PRIVATE_API_ENDPOINT = "https://btc-e.com/tapi"
)
View Source
const (
	PUBLIC_API_ENDPOINT = "https://btc-e.com/api/3/"
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(public string, secret string, hmac bool) *clientTLS

func NewPrivate

func NewPrivate(public string, private string) *btcePrivate

func NewPublic

func NewPublic() *btcePublic

Types

type ActiveOrders

type ActiveOrders struct {
	Success int                `json:"success"`
	Return  ActiveOrdersReturn `json:"return"`
	Error   string             `json:"error"`
}

type ActiveOrdersOrder

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

type ActiveOrdersReturn

type ActiveOrdersReturn map[string]ActiveOrdersOrder

type Btce

type Btce struct {
	Public  *btcePublic
	Private *btcePrivate
}

func New

func New(public string, secret string) *Btce

func (*Btce) ActiveOrders

func (this *Btce) ActiveOrders(Pair string) (*ActiveOrders, error)

func (*Btce) Balances

func (this *Btce) Balances(Pair string) ([]float64, error)

func (*Btce) CancelOrder

func (this *Btce) CancelOrder(OrderID int) (*CancelOrder, error)

func (*Btce) Depth

func (this *Btce) Depth(Pair string) (*Depth, error)

func (*Btce) GetInfo

func (this *Btce) GetInfo() (*PrivateInfo, error)

func (*Btce) Info

func (this *Btce) Info() (*PublicInfo, error)

func (*Btce) LastTrade

func (this *Btce) LastTrade(Pair string) (*TradeHistoryTrade, error)

func (*Btce) OrderedActiveOrders

func (this *Btce) OrderedActiveOrders(Pair string) (*ActiveOrders, error)

func (*Btce) OrderedTradeHistory

func (this *Btce) OrderedTradeHistory(From int, Count int, FromID int, EndID int, Order string, Since string, End string, Pair string) (*TradeHistory, error)

func (*Btce) Ticker

func (this *Btce) Ticker(Pair string) (*Ticker, error)

func (*Btce) Trade

func (this *Btce) Trade(Pair string, Type string, Rate float64, Amount float64) (*Trade, error)

func (*Btce) TradeHistory

func (this *Btce) TradeHistory(From int, Count int, FromID int, EndID int, Order string, Since string, End string, Pair string) (*TradeHistory, error)

func (*Btce) Trades

func (this *Btce) Trades(Pair string) (*Trades, error)

func (*Btce) TransHistory

func (this *Btce) TransHistory(From int, Count int, FromID int, EndID int, Order string, Since string, End string) (*TransHistory, error)

type ByActiveOrdersTimestampCreated

type ByActiveOrdersTimestampCreated []ActiveOrdersOrder

func (ByActiveOrdersTimestampCreated) Len

func (ByActiveOrdersTimestampCreated) Less

func (this ByActiveOrdersTimestampCreated) Less(i, j int) bool

func (ByActiveOrdersTimestampCreated) Swap

func (this ByActiveOrdersTimestampCreated) Swap(i, j int)

type ByTradeTimestamp

type ByTradeTimestamp []TradeHistoryTrade

func (ByTradeTimestamp) Len

func (this ByTradeTimestamp) Len() int

func (ByTradeTimestamp) Less

func (this ByTradeTimestamp) Less(i, j int) bool

func (ByTradeTimestamp) Swap

func (this ByTradeTimestamp) Swap(i, j int)

type CancelOrder

type CancelOrder struct {
	Success int               `json:"success"`
	Return  CancelOrderReturn `json:"return"`
	Error   string            `json:"error"`
}

type CancelOrderReturn

type CancelOrderReturn struct {
	OrderID int       `json:"order_id"`
	Funds   InfoFunds `json:"funds"`
}

type Depth

type Depth map[string]DepthPair

type DepthPair

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

type InfoFunds

type InfoFunds struct {
	USD float64 `json:"usd"`
	BTC float64 `json:"btc"`
	LTC float64 `json:"ltc"`
	NMC float64 `json:"nmc"`
	RUR float64 `json:"rur"`
	EUR float64 `json:"eur"`
	NVC float64 `json:"nvc"`
	TRC float64 `json:"trc"`
	PPC float64 `json:"ppc"`
	FTC float64 `json:"ftc"`
	XPM float64 `json:"xpm"`
}

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           int     `json:"fee"`
}

type InfoReturn

type InfoReturn struct {
	Funds             InfoFunds  `json:"funds"`
	Rights            InfoRights `json:"rights"`
	TransactionsCount int        `json:"Transaction_count"`
	OpenOrders        int        `json:"open_orders"`
	Time              int        `json:"server_time"`
}

type InfoRights

type InfoRights struct {
	Info     int `json:"Info"`
	Trade    int `json:"Trade"`
	Withdraw int `json:"withdraw"`
}

type PrivateInfo

type PrivateInfo struct {
	Success int        `json:"success"`
	Return  InfoReturn `json:"return"`
	Error   string     `json:"error"`
}

type PublicInfo

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

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 int     `json:"updated"`
}

type Trade

type Trade struct {
	Success int         `json:"success"`
	Return  TradeReturn `json:"return"`
	Error   string      `json:"error"`
}

type TradeHistory

type TradeHistory struct {
	Success int                `json:"success"`
	Return  TradeHistoryReturn `json:"return"`
	Error   string             `json:"error"`
}

type TradeHistoryReturn

type TradeHistoryReturn map[string]TradeHistoryTrade

type TradeHistoryTrade

type TradeHistoryTrade 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   int     `json:"timestamp"`
}

type TradeReturn

type TradeReturn struct {
	Received float64   `json:"received"`
	Remains  float64   `json:"remains"`
	Order    int       `json:"order_id"`
	Funds    InfoFunds `json:"funds"`
}

type Trades

type Trades map[string]TradesPair

type TradesPair

type TradesPair []TradesPairTrade

type TradesPairTrade

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

type TransHistory

type TransHistory struct {
	Success int                `json:"success"`
	Return  TransHistoryReturn `json:"return"`
	Error   string             `json:"error"`
}

type TransHistoryReturn

type TransHistoryReturn map[string]TransHistoryTransaction

type TransHistoryTransaction

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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