btce

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

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

Go to latest
Published: Aug 19, 2016 License: MIT Imports: 15 Imported by: 0

README

btce-go

Unofficial HTTP client for btc-e writen on golang

Documentation

Index

Constants

View Source
const (
	BTCUSD Pair = "btc_usd"
	BTCEUR      = "btc_eur"
	BTCRUR      = "btc_rur"
	DSHBTC      = "dsh_btc"
	ETHBTC      = "eth_btc"
	ETHLTC      = "eth_ltc"
	ETHRUR      = "eth_rur"
	ETHUSD      = "eth_usd"
	EURRUR      = "eur_rur"
	EURUSD      = "eur_usd"
	LTCBTC      = "ltc_btc"
	LTCEUR      = "ltc_eur"
	LTCRUR      = "ltc_rur"
	LTCUSD      = "ltc_usd"
	NMCBTC      = "nmc_btc"
	NMCUSD      = "nmc_usd"
	NVCBTC      = "nvc_btc"
	NVCUSD      = "nvc_usd"
	PPCBTC      = "ppc_btc"
	PPCUSD      = "ppc_usd"
	USDRUR      = "usd_rur"
)

Variables

View Source
var (
	BaseURL         = "https://btc-e.nz/"
	InfoPath        = "api/2/"
	TradeAPIv1Path  = "tapi"
	PublicAPIv3Path = "api/3/"
)

URLs and path to api

It's yours responsibility to end paths with '/' if it's necessary

View Source
var NonceFile string = ".nonce"

NonceFile is local file to store nonce.

Functions

func LoadNonce

func LoadNonce()

LoadNonce loads last used nonce from file NonceFile

More info: https://btc-e.nz/tapi/docs#auth

func SaveNonce

func SaveNonce()

SaveNonce dumps current nonce value to file NonceFile

More info: https://btc-e.nz/tapi/docs#auth

func SetKeys

func SetKeys(k, secret string)

SetKeys sets authorization keys to use

func SetNonce

func SetNonce(n uint64)

SetNonce sets last used nonce for trade API calls

More info: https://btc-e.nz/tapi/docs#auth

Types

type AccountInfo

type AccountInfo struct {
	Funds
	Rights
	TransactionCount int  `json:"transaction_count"`
	OpenOrders       int  `json:"open_orders"`
	ServerTime       Time `json:"server_time"`
}

func GetInfo

func GetInfo() (AccountInfo, error)

GetInfo loads your account info.

Panics if key and secret key are not set.

Implements btc-e trade API v1 `getInfo` method.

More info: https://btc-e.nz/tapi/docs#getInfo

func (AccountInfo) String

func (a AccountInfo) String() string

type Bool

type Bool bool

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON int value

type Depth

type Depth struct {
	Asks []DepthItem
	Bids []DepthItem
}

func GetDepth

func GetDepth(pair Pair) (Depth, error)

GetDepth loads proces and volumes of active orders. It's wrapper around GetDepths.

Implements btc-e public API v3 `depth` method.

More info: https://btc-e.com/api/3/docs#depth

func (Depth) String

func (d Depth) String() string

type DepthItem

type DepthItem struct {
	Price  float64
	Volume float64
}

func (DepthItem) String

func (d DepthItem) String() string

func (*DepthItem) UnmarshalJSON

func (d *DepthItem) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON array [<price>, <volume>]

type DepthsMap

type DepthsMap map[Pair]Depth

func GetDepths

func GetDepths(pairs ...Pair) (DepthsMap, error)

GetDepths loads prices and amounts of active orders.

Implements btc-e public API v3 `depth` method.

More info: https://btc-e.com/api/3/docs#depth

type Fee

type Fee int64

func (Fee) String

func (f Fee) String() string

type Funds

type Funds map[Pair]float64

func CancelOrder

func CancelOrder(orderID uint64) (Funds, error)

CancelOrder cancels order.

Panics if key and secret key are not set.

Implements btc-e trade API v1 `cancelOrder` method.

More info: https://btc-e.nz/tapi/docs#CancelOrder

type Order

type Order struct {
	Pair
	Type             TradeType
	Amount           float64
	Rate             float64
	TimestampCreated Time `json:"timestamp_created"`
	IsYourOrder      Bool `json:"is_your_order"`
}

type OrdersMap

type OrdersMap map[uint64]Order

func ActiveOrders

func ActiveOrders(pair Pair) (OrdersMap, error)

ActiveOrders loads list of your active orders.

Panics if key and secret key are not set.

Implements btc-e trade API v1 `activeOrders` method.

More info: https://btc-e.nz/tapi/docs#ActiveOrders

func OrderInfo

func OrderInfo(orderID uint64) (OrdersMap, error)

OrderInfo loads info about your specified order.

Panics if key and secret key are not set.

Implements btc-e trade API v1 `orderInfo` method.

More info: https://btc-e.nz/tapi/docs#OrderInfo

func TradeHistory

func TradeHistory() (OrdersMap, error)

TradeHistory loads your completed orders history.

It's don't support any arhuments for now

Panics if key and secret key are not set.

Implements btc-e trade API v1 `tradeHistory` method.

More info: https://btc-e.nz/tapi/docs#TradeHistory

type Pair

type Pair string

type PairInfo

type PairInfo struct {
	DecimapPlaces int     `json:"decimal_places"`
	MinPrice      float64 `json:"min_price"`
	MaxPrice      float64 `json:"max_price"`
	MinAmount     float64 `json:"min_amount"`
	Hidden        Bool
	Fee
}

type PairsMap

type PairsMap map[Pair]PairInfo

func GetPairs

func GetPairs() (PairsMap, error)

GetPairs loads list of tradable pairs and info about them.

Implements btc-e public API v3 `info` method.

More info: https://btc-e.com/api/3/docs#info

func (PairsMap) String

func (p PairsMap) String() string

type Rights

type Rights struct {
	Info     Bool
	Trade    Bool
	Withdraw Bool
}

type Tick

type Tick struct {
	Low        float64 `json:"low"`
	High       float64 `json:"high"`
	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    Time    `json:"updated"`
	ServerTime Time    `json:"server_time"`
}

func GetTick

func GetTick(pair Pair) (Tick, error)

GetTick loads last tick (prices) for specified pair. It's wrapper around GetTicks.

Implements btc-e public API v3 `ticker` method.

More info: https://btc-e.com/api/3/docs#ticker

func (Tick) String

func (t Tick) String() string

type TicksMap

type TicksMap map[Pair]Tick

func GetTicks

func GetTicks(pairs ...Pair) (TicksMap, error)

GetTicks loads last ticks (prices) for specified pairs.

Implements btc-e public API v3 `ticker` method.

More info: https://btc-e.com/api/3/docs#ticker

type Time

type Time int32

Time represents server time in seconds since UNIX epoch

type TradeInfo

type TradeInfo struct {
	TID       uint64    `json:"tid"`
	Type      TradeType `json:"type"`
	Price     float64   `json:"price"`
	Amount    float64   `json:"amount"`
	Timestamp Time      `json:"timestamp"`
}

func (TradeInfo) String

func (t TradeInfo) String() string

type TradeResult

type TradeResult struct {
	Received float64
	Remains  float64
	OrderID  uint64 `json:"order_id"`
	Funds
}

func Trade

func Trade(pair Pair, tp TradeType, rate, amount float64) (TradeResult, error)

Trade create order or execute it right away.

Panics if key and secret key are not set.

Implements btc-e trade API v1 `trade` method.

More info: https://btc-e.nz/tapi/docs#Trade

type TradeType

type TradeType string
const (
	Bid TradeType = "bid"
	Ask TradeType = "ask"
)

type TradesInfo

type TradesInfo []TradeInfo

func (TradesInfo) String

func (t TradesInfo) String() string

type TradesMap

type TradesMap map[Pair]TradesInfo

func GetTrades

func GetTrades(pairs ...Pair) (TradesMap, error)

GetTrades loads last completed trades.

Implements btc-e public API v3 `trades` method.

More info: https://btc-e.com/api/3/docs#trades

Jump to

Keyboard shortcuts

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