yobit

package
Version: v0.0.0-...-6a9f9bf Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: MIT Imports: 25 Imported by: 0

README

GoCryptoTrader package Yobit

Build Status Software License GoDoc Coverage Status Go Report Card

This yobit package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Yobit Exchange

Current Features
  • REST Support
How to enable
  // Exchanges will be abstracted out in further updates and examples will be
  // supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var y exchange.IBotExchange

for i := range bot.Exchanges {
  if bot.Exchanges[i].GetName() == "Yobit" {
    y = bot.Exchanges[i]
  }
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := y.FetchTicker()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := y.FetchOrderbook()
if err != nil {
  // Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := y.GetAccountInfo()
if err != nil {
  // Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := y.GetTicker()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := y.GetDepth()
if err != nil {
  // Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := y.GetAccountInfo()
if err != nil {
  // Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := y.Trade("BTCUSD", "MARKET", 1, 2)
if err != nil {
  // Handle error
}
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WithdrawalFees = map[currency.Code]float64{}/* 1139 elements not displayed */

WithdrawalFees the large list of predefined withdrawal fees Prone to change, using highest value

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	Funds           map[string]float64 `json:"funds"`
	FundsInclOrders map[string]float64 `json:"funds_incl_orders"`
	Rights          struct {
		Info     int `json:"info"`
		Trade    int `json:"trade"`
		Withdraw int `json:"withdraw"`
	} `json:"rights"`
	TransactionCount int     `json:"transaction_count"`
	OpenOrders       int     `json:"open_orders"`
	ServerTime       float64 `json:"server_time"`
	Error            string  `json:"error"`
}

AccountInfo stores the account information for a user

type ActiveOrders

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

ActiveOrders stores active order information

type CancelOrder

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

CancelOrder is used for the CancelOrder API request response

type CreateCoupon

type CreateCoupon struct {
	Coupon  string             `json:"coupon"`
	TransID int64              `json:"transID"`
	Funds   map[string]float64 `json:"funds"`
	Error   string             `json:"error"`
}

CreateCoupon stores information coupon information

type DepositAddress

type DepositAddress struct {
	Success int `json:"success"`
	Return  struct {
		Address         string  `json:"address"`
		ProcessedAmount float64 `json:"processed_amount"`
		ServerTime      int64   `json:"server_time"`
	} `json:"return"`
	Error string `json:"error"`
}

DepositAddress stores a curency deposit address

type Info

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

Info holds server time and pair information

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"`
	TimestampCreated float64 `json:"timestamp_created"`
	Status           int     `json:"status"`
}

OrderInfo stores order information

type Orderbook

type Orderbook struct {
	Asks [][]float64 `json:"asks"` // selling orders
	Bids [][]float64 `json:"bids"` // buying orders
}

Orderbook stores the asks and bids orderbook information

type Pair

type Pair struct {
	DecimalPlaces int     `json:"decimal_places"` // Quantity of permitted numbers after decimal point
	MinPrice      float64 `json:"min_price"`      // Minimal permitted price
	MaxPrice      float64 `json:"max_price"`      // Maximal permitted price
	MinAmount     float64 `json:"min_amount"`     // Minimal permitted buy or sell amount
	Hidden        int     `json:"hidden"`         // Pair is hidden (0 or 1)
	Fee           float64 `json:"fee"`            // Pair commission
}

Pair holds pair information

type RedeemCoupon

type RedeemCoupon struct {
	CouponAmount   float64            `json:"couponAmount,string"`
	CouponCurrency string             `json:"couponCurrency"`
	TransID        int64              `json:"transID"`
	Funds          map[string]float64 `json:"funds"`
	Error          string             `json:"error"`
}

RedeemCoupon stores redeem coupon information

type Response

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

Response is a generic struct used for exchange API request result

type Ticker

type Ticker struct {
	High          float64 // maximal price
	Low           float64 // minimal price
	Avg           float64 // average price
	Vol           float64 // traded volume
	VolumeCurrent float64 `json:"vol_cur"` // traded volume in currency
	Last          float64 // last transaction price
	Buy           float64 // buying price
	Sell          float64 // selling price
	Updated       int64   // last cache upgrade
}

Ticker stores the ticker information

type Trade

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

Trade stores the trade information

type TradeHistory

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

TradeHistory stores trade history

type TradeHistoryResponse

type TradeHistoryResponse struct {
	Success int64                   `json:"success"`
	Data    map[string]TradeHistory `json:"return,omitempty"`
	Error   string                  `json:"error,omitempty"`
}

TradeHistoryResponse returns all your trade history

type Trades

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

Trades stores trade information

type WithdrawCoinsToAddress

type WithdrawCoinsToAddress struct {
	ServerTime int64  `json:"server_time"`
	Error      string `json:"error"`
}

WithdrawCoinsToAddress stores information for a withdrawcoins request

type Yobit

type Yobit struct {
	exchange.Base
}

Yobit is the overarching type across the Yobit package

func (*Yobit) CancelAllOrders

func (y *Yobit) CancelAllOrders(_ *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*Yobit) CancelExistingOrder

func (y *Yobit) CancelExistingOrder(orderID int64) error

CancelExistingOrder cancels an order for a specific order ID

func (*Yobit) CancelOrder

func (y *Yobit) CancelOrder(order *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*Yobit) CreateCoupon

func (y *Yobit) CreateCoupon(currency string, amount float64) (CreateCoupon, error)

CreateCoupon creates an exchange coupon for a sepcific currency

func (*Yobit) FetchAccountInfo

func (y *Yobit) FetchAccountInfo() (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*Yobit) FetchOrderbook

func (y *Yobit) FetchOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns the orderbook for a currency pair

func (*Yobit) FetchTicker

func (y *Yobit) FetchTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker returns the ticker for a currency pair

func (*Yobit) FetchTradablePairs

func (y *Yobit) FetchTradablePairs(asset asset.Item) ([]string, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*Yobit) GetAccountInformation

func (y *Yobit) GetAccountInformation() (AccountInfo, error)

GetAccountInformation returns a users account info

func (*Yobit) GetActiveOrders

func (y *Yobit) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, error)

GetActiveOrders retrieves any orders that are active/open

func (*Yobit) GetCryptoDepositAddress

func (y *Yobit) GetCryptoDepositAddress(coin string) (DepositAddress, error)

GetCryptoDepositAddress returns the deposit address for a specific currency

func (*Yobit) GetDefaultConfig

func (y *Yobit) GetDefaultConfig() (*config.ExchangeConfig, error)

GetDefaultConfig returns a default exchange config

func (*Yobit) GetDepositAddress

func (y *Yobit) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Yobit) GetDepth

func (y *Yobit) GetDepth(symbol string) (Orderbook, error)

GetDepth returns the depth for a specific currency

func (*Yobit) GetExchangeHistory

func (y *Yobit) GetExchangeHistory(p currency.Pair, assetType asset.Item, timestampStart, timestampEnd time.Time) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data within the timeframe provided.

func (*Yobit) GetFee

func (y *Yobit) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*Yobit) GetFeeByType

func (y *Yobit) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*Yobit) GetFundingHistory

func (y *Yobit) GetFundingHistory() ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*Yobit) GetHistoricCandles

func (y *Yobit) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandles returns candles between a time period for a set time interval

func (*Yobit) GetHistoricCandlesExtended

func (y *Yobit) GetHistoricCandlesExtended(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandlesExtended returns candles between a time period for a set time interval

func (*Yobit) GetInfo

func (y *Yobit) GetInfo() (Info, error)

GetInfo returns the Yobit info

func (*Yobit) GetOpenOrders

func (y *Yobit) GetOpenOrders(pair string) (map[string]ActiveOrders, error)

GetOpenOrders returns the active orders for a specific currency

func (*Yobit) GetOrderHistory

func (y *Yobit) GetOrderHistory(req *order.GetOrdersRequest) ([]order.Detail, error)

GetOrderHistory retrieves account order information Can Limit response to specific order status

func (*Yobit) GetOrderInfo

func (y *Yobit) GetOrderInfo(orderID string) (order.Detail, error)

GetOrderInfo returns information on a current open order

func (*Yobit) GetOrderInformation

func (y *Yobit) GetOrderInformation(orderID int64) (map[string]OrderInfo, error)

GetOrderInformation returns the order info for a specific order ID

func (*Yobit) GetTicker

func (y *Yobit) GetTicker(symbol string) (map[string]Ticker, error)

GetTicker returns a ticker for a specific currency

func (*Yobit) GetTradeHistory

func (y *Yobit) GetTradeHistory(tidFrom, count, tidEnd, since, end int64, order, pair string) (map[string]TradeHistory, error)

GetTradeHistory returns the trade history

func (*Yobit) GetTrades

func (y *Yobit) GetTrades(symbol string, start int64, sortAsc bool) ([]Trades, error)

GetTrades returns the trades for a specific currency

func (*Yobit) ModifyOrder

func (y *Yobit) ModifyOrder(action *order.Modify) (string, error)

ModifyOrder will allow of changing orderbook placement and limit to market conversion

func (*Yobit) RedeemCoupon

func (y *Yobit) RedeemCoupon(coupon string) (RedeemCoupon, error)

RedeemCoupon redeems an exchange coupon

func (*Yobit) Run

func (y *Yobit) Run()

Run implements the Yobit wrapper

func (*Yobit) SendAuthenticatedHTTPRequest

func (y *Yobit) SendAuthenticatedHTTPRequest(path string, params url.Values, result interface{}) (err error)

SendAuthenticatedHTTPRequest sends an authenticated HTTP request to Yobit

func (*Yobit) SendHTTPRequest

func (y *Yobit) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*Yobit) SetDefaults

func (y *Yobit) SetDefaults()

SetDefaults sets current default value for Yobit

func (*Yobit) Setup

func (y *Yobit) Setup(exch *config.ExchangeConfig) error

Setup sets exchange configuration parameters for Yobit

func (*Yobit) Start

func (y *Yobit) Start(wg *sync.WaitGroup)

Start starts the WEX go routine

func (*Yobit) SubmitOrder

func (y *Yobit) SubmitOrder(s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order Yobit only supports limit orders

func (*Yobit) Trade

func (y *Yobit) Trade(pair, orderType string, amount, price float64) (int64, error)

Trade places an order and returns the order ID if successful or an error

func (*Yobit) UpdateAccountInfo

func (y *Yobit) UpdateAccountInfo() (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies for the Yobit exchange

func (*Yobit) UpdateOrderbook

func (y *Yobit) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Yobit) UpdateTicker

func (y *Yobit) UpdateTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Yobit) UpdateTradablePairs

func (y *Yobit) UpdateTradablePairs(forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them in the exchanges config

func (*Yobit) ValidateCredentials

func (y *Yobit) ValidateCredentials() error

ValidateCredentials validates current credentials used for wrapper functionality

func (*Yobit) WithdrawCoinsToAddress

func (y *Yobit) WithdrawCoinsToAddress(coin string, amount float64, address string) (WithdrawCoinsToAddress, error)

WithdrawCoinsToAddress initiates a withdrawal to a specified address

func (*Yobit) WithdrawCryptocurrencyFunds

func (y *Yobit) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Yobit) WithdrawFiatFunds

func (y *Yobit) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Yobit) WithdrawFiatFundsToInternationalBank

func (y *Yobit) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL