yobit

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2018 License: MIT Imports: 19 Imported by: 0

README

go-yobit

go-yobit is an implementation of the Yobit exchange API in Golang.

##Supports

  • Public API
  • Trade API
  • Cloudflare challenge solver

##Import

import "github.com/ikonovalov/go-yobit"

##Usage

package main
import "github.com/ikonovalov/go-yobit"

credential := yobit.ApiCredential{Key: 'zzz', Secret: 'ggg'}
yo := yobit.New(credential)
defer yo.Release()

// get tickers
tickersChan := make(chan yobit.TickerInfoResponse)
go yo.Tickers24(usdPairs, tickersChan)
tickerRs := <-tickersChan

// get wallet balances
channel := make(chan yobit.GetInfoResponse)
go yo.GetInfo(channel)
getInfoRes := <-channel

MIT License

Documentation

Index

Constants

View Source
const (
	Url        = "https://yobit.net"
	ApiVersion = "3"
)

Variables

This section is empty.

Functions

func CreateNonceFileIfNotExists

func CreateNonceFileIfNotExists()

func WriteNonce

func WriteNonce(data []byte)

Types

type ActiveOrder

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

type ActiveOrdersResponse

type ActiveOrdersResponse struct {
	Success uint8                  `json:"success"`
	Error   string                 `json:"error"`
	Orders  map[string]ActiveOrder `json:"return"`
}

type ApiCredential

type ApiCredential struct {
	Key    string `json:"key"`
	Secret string `json:"secret"`
}

type CallArg

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

type CancelOrderResponse

type CancelOrderResponse struct {
	Success uint8        `json:"success"`
	Error   string       `json:"error"`
	Result  CancelResult `json:"return"`
}

type CancelResult

type CancelResult struct {
	OrderId uint64             `json:"order_id"`
	Funds   map[string]float64 `json:"funds"`
}

type DepthResponse

type DepthResponse struct {
	Offers map[string]Offers
}

type ErrorResponse

type ErrorResponse struct {
	Success uint8  `json:"success"`
	Error   string `json:"error"`
}

============ PUBLIC API OBJECTS =================

type GetInfoResponse

type GetInfoResponse struct {
	Success uint8         `json:"success"`
	Error   string        `json:"error"`
	Data    GetInfoReturn `json:"return"`
}

============ TRADE API OBJECTS =====================

type GetInfoReturn

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

type HistoricOrder

type HistoricOrder struct {
	Pair        string  `json:"pair"`
	Type        string  `json:"type"`
	Amount      float64 `json:"amount"`
	Rate        float64 `json:"rate"`
	OrderId     string  `json:"order_id"`
	IsYourOrder uint8   `json:"is_your_order"`
	Timestamp   string  `json:"timestamp"`
}

type InfoResponse

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

type LocalStorage

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

func NewStorage

func NewStorage() *LocalStorage

func (*LocalStorage) LoadCookies

func (s *LocalStorage) LoadCookies(url *url.URL) []*http.Cookie

func (*LocalStorage) Release

func (s *LocalStorage) Release()

func (*LocalStorage) SaveCookies

func (s *LocalStorage) SaveCookies(url *url.URL, cookies []*http.Cookie)

type Offer

type Offer struct {
	Price    float64
	Quantity float64
}

func (*Offer) UnmarshalJSON

func (n *Offer) UnmarshalJSON(buf []byte) error

type Offers

type Offers struct {
	Asks []Offer `json:"asks"`
	Bids []Offer `json:"bids"`
}

type OrderInfo

type OrderInfo struct {
	Pair        string  `json:"pair"`
	Type        string  `json:"type"`
	StartAmount float64 `json:"start_amount"`
	Amount      float64 `json:"amount"`
	Rate        float64 `json:"rate"`
	Created     string  `json:"timestamp_created"`
	Status      uint8   `json:"status"`
}

type OrderInfoResponse

type OrderInfoResponse struct {
	Success uint8                `json:"success"`
	Error   string               `json:"error"`
	Orders  map[string]OrderInfo `json:"return"`
}

type PairInfo

type PairInfo struct {
	DecimalPlace uint16  `json:"decimal_places"`
	MinPrice     float64 `json:"min_price"`
	MaxPrice     float64 `json:"max_price"`
	MinAmount    float64 `json:"min_amount"`
	Hidden       uint8   `json:"hidden"`
	Fee          float64 `json:"fee"`
}

type Ticker

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

type TickerInfoResponse

type TickerInfoResponse struct {
	Tickers map[string]Ticker
}

type Trade

type Trade struct {
	Type      string  `json:"type"`
	Price     float64 `json:"price"`
	Amount    float64 `json:"amount"`
	Tid       uint64  `json:"tid"`
	Timestamp int64   `json:"timestamp"`
}

type TradeHistoryResponse

type TradeHistoryResponse struct {
	Success uint8                    `json:"success"`
	Error   string                   `json:"error"`
	Orders  map[string]HistoricOrder `json:"return"`
}

type TradeResponse

type TradeResponse struct {
	Success uint8       `json:"success"`
	Error   string      `json:"error"`
	Result  TradeResult `json:"return"`
}

type TradeResult

type TradeResult struct {
	Received float64            `json:"received"`
	Remains  float64            `json:"remains"`
	OrderId  uint64             `json:"order_id"`
	Funds    map[string]float64 `json:"funds"`
}

type TradesResponse

type TradesResponse struct {
	Trades map[string][]Trade
}

type Yobit

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

func New

func New(credential ApiCredential) *Yobit

func (*Yobit) ActiveOrders

func (y *Yobit) ActiveOrders(pair string, ch chan<- ActiveOrdersResponse)

func (*Yobit) CancelOrder

func (y *Yobit) CancelOrder(orderId string, ch chan CancelOrderResponse)

func (*Yobit) Depth

func (y *Yobit) Depth(pairs string, ch chan<- DepthResponse)

func (*Yobit) DepthLimited

func (y *Yobit) DepthLimited(pairs string, limit int, ch chan<- DepthResponse)

func (*Yobit) GetAndIncrementNonce

func (y *Yobit) GetAndIncrementNonce() (nonce uint64)

func (*Yobit) GetInfo

func (y *Yobit) GetInfo(ch chan<- GetInfoResponse)

func (*Yobit) Info

func (y *Yobit) Info(ch chan<- InfoResponse)

func (*Yobit) IsMarketExists

func (y *Yobit) IsMarketExists(market string) bool

func (*Yobit) LoadCookies

func (y *Yobit) LoadCookies()

func (*Yobit) OrderInfo

func (y *Yobit) OrderInfo(orderId string, ch chan<- OrderInfoResponse)

func (*Yobit) PassCloudflare

func (y *Yobit) PassCloudflare()

func (*Yobit) Release

func (y *Yobit) Release()

func (*Yobit) SaveCookies

func (y *Yobit) SaveCookies()

func (*Yobit) SetCookies

func (y *Yobit) SetCookies(cookies []*http.Cookie)

func (*Yobit) Tickers24

func (y *Yobit) Tickers24(pairs []string, ch chan<- TickerInfoResponse)

func (*Yobit) Trade

func (y *Yobit) Trade(pair string, tradeType string, rate float64, amount float64, ch chan TradeResponse)

func (*Yobit) TradeHistory

func (y *Yobit) TradeHistory(pair string, ch chan<- TradeHistoryResponse)

func (*Yobit) TradesLimited

func (y *Yobit) TradesLimited(pairs string, limit int, ch chan<- TradesResponse)

Jump to

Keyboard shortcuts

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