mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 07:26:47 +00:00
Feature: Add mock testing to ZB (#569)
* Adds mock testing to ZB
* STEALS improved time validation code from the original STOLEN validation code :D
* Mini fixes from review
* happy fun comment stealing
* Moves the loop checker earlier to ensure no double appendages
* Fixes sneaky test
* Fixes the important part where mock tests work instead of live tests
* Skips authenticated endpoints for mock testing.
* lint
* Updates candle wrapper functions to respect design
* basic linting fix
* Reverts configtest.json, updates readme to be way better, adds coverage to validateCandlesRequest
* Tiniest grammatical fix
* Fixes more outdated code references
* Closing out a high
* Fixes spacing
* Replaces all instances of 4 spaces in tmpl files with a tab
* fixes spacing and tab related readme issues once and for all 🤞
* tidy
* indentation violation identification situation
This commit is contained in:
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Binance" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Binance" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -817,7 +817,7 @@ func (b *Binance) GetHistoricCandles(pair currency.Pair, a asset.Item, start, en
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: candles[x].OpenTime,
|
||||
Open: candles[x].Open,
|
||||
High: candles[x].Close,
|
||||
High: candles[x].High,
|
||||
Low: candles[x].Low,
|
||||
Close: candles[x].Close,
|
||||
Volume: candles[x].Volume,
|
||||
@@ -865,7 +865,7 @@ func (b *Binance) GetHistoricCandlesExtended(pair currency.Pair, a asset.Item, s
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: candles[i].OpenTime,
|
||||
Open: candles[i].Open,
|
||||
High: candles[i].Close,
|
||||
High: candles[i].High,
|
||||
Low: candles[i].Low,
|
||||
Close: candles[i].Close,
|
||||
Volume: candles[i].Volume,
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Bitfinex" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Bitfinex" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -883,7 +883,7 @@ func (b *Bitfinex) GetHistoricCandles(pair currency.Pair, a asset.Item, start, e
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: candles[x].Timestamp,
|
||||
Open: candles[x].Open,
|
||||
High: candles[x].Close,
|
||||
High: candles[x].High,
|
||||
Low: candles[x].Low,
|
||||
Close: candles[x].Close,
|
||||
Volume: candles[x].Volume,
|
||||
@@ -925,7 +925,7 @@ func (b *Bitfinex) GetHistoricCandlesExtended(pair currency.Pair, a asset.Item,
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: candles[i].Timestamp,
|
||||
Open: candles[i].Open,
|
||||
High: candles[i].Close,
|
||||
High: candles[i].High,
|
||||
Low: candles[i].Low,
|
||||
Close: candles[i].Close,
|
||||
Volume: candles[i].Volume,
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Bitflyer" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Bitflyer" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,21 +100,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Bithumb" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Bithumb" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Bitmex" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Bitmex" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Bitstamp" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Bitstamp" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Bittrex" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Bittrex" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "BTCMarkets" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "BTCMarkets" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,13 +101,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var b exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "BTSE" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "BTSE" {
|
||||
b = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := b.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := b.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := b.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := b.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,13 +101,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := b.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := b.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var c exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "CoinbasePro" {
|
||||
c = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "CoinbasePro" {
|
||||
c = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := c.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := c.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := c.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := c.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := c.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := c.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := c.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var c exchange.IBotExchange
|
||||
|
||||
for i := range Bot.Exchanges {
|
||||
if Bot.Exchanges[i].GetName() == "Coinbene" {
|
||||
c = Bot.Exchanges[i]
|
||||
}
|
||||
if Bot.Exchanges[i].GetName() == "Coinbene" {
|
||||
c = Bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range Bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := c.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := c.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := c.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := c.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := c.GetOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := c.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
resp, err := c.SubmitOrder(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var c exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Coinut" {
|
||||
c = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Coinut" {
|
||||
c = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := c.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := c.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := c.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := c.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := c.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := c.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := c.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var e exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Exmo" {
|
||||
e = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Exmo" {
|
||||
e = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := e.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := e.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := e.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := e.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := e.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := e.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := e.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var f exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "FTX" {
|
||||
f = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "FTX" {
|
||||
f = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := f.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := f.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := f.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := f.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := f.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,13 +101,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := f.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := f.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var g exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "GateIO" {
|
||||
g = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "GateIO" {
|
||||
g = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := g.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := g.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := g.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := g.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := g.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,21 +100,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := g.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := g.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do LongPolling public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var g exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Gemini" {
|
||||
g = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Gemini" {
|
||||
g = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := g.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := g.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := g.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := g.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := g.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := g.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := g.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var h exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "HitBTC" {
|
||||
h = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "HitBTC" {
|
||||
h = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := h.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := h.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := h.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := h.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := h.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := h.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := h.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
### How to do REST public/private calls
|
||||
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var h exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Huobi" {
|
||||
h = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Huobi" {
|
||||
h = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := h.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := h.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := h.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := h.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := h.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,21 +100,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := h.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := h.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -1045,7 +1045,7 @@ func (h *HUOBI) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: time.Unix(candles[x].ID, 0),
|
||||
Open: candles[x].Open,
|
||||
High: candles[x].Close,
|
||||
High: candles[x].High,
|
||||
Low: candles[x].Low,
|
||||
Close: candles[x].Close,
|
||||
Volume: candles[x].Volume,
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var i exchange.IBotExchange
|
||||
|
||||
for x := range bot.Exchanges {
|
||||
if bot.Exchanges[x].GetName() == "Itbit" {
|
||||
i = bot.Exchanges[x]
|
||||
}
|
||||
if bot.Exchanges[x].GetName() == "Itbit" {
|
||||
i = bot.Exchanges[x]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for x := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := i.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := i.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := i.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := i.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := i.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := i.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := i.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var k exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Kraken" {
|
||||
k = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Kraken" {
|
||||
k = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := k.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := k.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := k.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := k.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := k.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := k.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := k.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -912,7 +912,7 @@ func (k *Kraken) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: timeValue,
|
||||
Open: candles[x].Open,
|
||||
High: candles[x].Close,
|
||||
High: candles[x].High,
|
||||
Low: candles[x].Low,
|
||||
Close: candles[x].Close,
|
||||
Volume: candles[x].Volume,
|
||||
@@ -955,7 +955,7 @@ func (k *Kraken) GetHistoricCandlesExtended(pair currency.Pair, a asset.Item, st
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: timeValue,
|
||||
Open: candles[i].Open,
|
||||
High: candles[i].Close,
|
||||
High: candles[i].High,
|
||||
Low: candles[i].Low,
|
||||
Close: candles[i].Close,
|
||||
Volume: candles[i].Volume,
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var l exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "LakeBTC" {
|
||||
l = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "LakeBTC" {
|
||||
l = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := l.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := l.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := l.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := l.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := l.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,13 +101,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := l.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := l.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var l exchange.IBotExchange
|
||||
|
||||
for i := range Bot.Exchanges {
|
||||
if Bot.Exchanges[i].GetName() == "Lbank" {
|
||||
l = Bot.Exchanges[i]
|
||||
}
|
||||
if Bot.Exchanges[i].GetName() == "Lbank" {
|
||||
l = Bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range Bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := l.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := l.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := l.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := l.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := l.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := l.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := l.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var l exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "LocalBitcoins" {
|
||||
l = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "LocalBitcoins" {
|
||||
l = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := l.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := l.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := l.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := l.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := l.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := l.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := l.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
[](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader)
|
||||
|
||||
|
||||
This Mock package is part of the GoCryptoTrader codebase.
|
||||
This mock package is part of the GoCryptoTrader codebase.
|
||||
|
||||
## This is still in active development
|
||||
|
||||
@@ -20,16 +20,17 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
|
||||
## Mock Testing Suite
|
||||
|
||||
### Current Features
|
||||
|
||||
+ REST recording service
|
||||
## Current Features for mock
|
||||
+ REST recording service
|
||||
+ REST mock response server
|
||||
|
||||
### How to enable
|
||||
|
||||
+ Mock testing is enabled by default in some exchanges; to disable and run live endpoint testing parse -tags=mock_test_off as a go test param.
|
||||
+ Any exchange with mock testing will be enabled by default. This is done using build tags which are highlighted in the examples below via `//+build mock_test_off`. To disable and run live endpoint testing parse `-tags=mock_test_off` as a go test param.
|
||||
|
||||
+ To record a live endpoint create two files for an exchange.
|
||||
## Mock test setup
|
||||
|
||||
+ Create two additional test files for the exchange. Examples are below:
|
||||
|
||||
### file one - your_current_exchange_name_live_test.go
|
||||
|
||||
@@ -58,12 +59,12 @@ func TestMain(m *testing.M) {
|
||||
if err != nil {
|
||||
log.Fatal("your_current_exchange_name Setup() init error", err)
|
||||
}
|
||||
your_current_exchange_nameConfig.AuthenticatedAPISupport = true
|
||||
your_current_exchange_nameConfig.APIKey = apiKey
|
||||
your_current_exchange_nameConfig.APISecret = apiSecret
|
||||
l.SetDefaults()
|
||||
l.Setup(&your_current_exchange_nameConfig)
|
||||
log.Printf(sharedtestvalues.LiveTesting, l.Name, l.APIUrl)
|
||||
your_current_exchange_nameConfig.API.AuthenticatedSupport = true
|
||||
your_current_exchange_nameConfig.API.Credentials.Key = apiKey
|
||||
your_current_exchange_nameConfig.API.Credentials.Secret = apiSecret
|
||||
s.SetDefaults()
|
||||
s.Setup(&your_current_exchange_nameConfig)
|
||||
log.Printf(sharedtestvalues.LiveTesting, s.Name, s.API.Endpoints.URL)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
```
|
||||
@@ -98,59 +99,96 @@ func TestMain(m *testing.M) {
|
||||
if err != nil {
|
||||
log.Fatal("your_current_exchange_name Setup() init error", err)
|
||||
}
|
||||
your_current_exchange_nameConfig.AuthenticatedAPISupport = true
|
||||
your_current_exchange_nameConfig.APIKey = apiKey
|
||||
your_current_exchange_nameConfig.APISecret = apiSecret
|
||||
l.SetDefaults()
|
||||
l.Setup(&your_current_exchange_nameConfig)
|
||||
your_current_exchange_nameConfig.API.AuthenticatedSupport = true
|
||||
your_current_exchange_nameConfig.API.Credentials.Key = apiKey
|
||||
your_current_exchange_nameConfig.API.Credentials.Secret = apiSecret
|
||||
s.SetDefaults()
|
||||
s.Setup(&your_current_exchange_nameConfig)
|
||||
|
||||
serverDetails, newClient, err := mock.NewVCRServer(mockfile)
|
||||
if err != nil {
|
||||
log.Fatalf("Mock server error %s", err)
|
||||
}
|
||||
|
||||
g.HTTPClient = newClient
|
||||
g.APIUrl = serverDetails
|
||||
s.HTTPClient = newClient
|
||||
s.API.Endpoints.URL = serverDetails
|
||||
|
||||
log.Printf(sharedtestvalues.MockTesting, l.Name, l.APIUrl)
|
||||
log.Printf(sharedtestvalues.MockTesting, s.Name, s.API.Endpoints.URL)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+ Once those files are completed go through each invidual test function and add
|
||||
## Mock test storage
|
||||
|
||||
+ Under `testdata/http_mock` create a folder matching the name of your exchange. Then create a JSON file matching the name of your exchange with the following formatting:
|
||||
```
|
||||
{
|
||||
"routes": {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Recording a test result
|
||||
|
||||
+ Once the files `your_current_exchange_name_mock_test.go` and `your_current_exchange_name_live_test.go` along with the JSON file `testdata/http_mock/our_current_exchange_name/our_current_exchange_name.json` are created, go through each individual test function and add
|
||||
|
||||
```go
|
||||
var s SomeExchange
|
||||
|
||||
func TestDummyTest(t *testing.T) {
|
||||
s.APIURL = exchangeDefaultURL // This will overwrite the current mock url at localhost
|
||||
s.Verbose = true // This will show you some fancy debug output
|
||||
s.HTTPRecording = true // This will record the request and response payloads
|
||||
|
||||
err := s.SomeExchangeEndpointFunction()
|
||||
// check error
|
||||
s.Verbose = true // This will show you some fancy debug output
|
||||
s.HTTPRecording = true // This will record the request and response payloads
|
||||
s.API.Endpoints.URL = apiURL // This will overwrite the current mock url at localhost
|
||||
s.API.Endpoints.URLSecondary = secondAPIURL // This is only if your API has multiple endpoints
|
||||
s.HTTPClient = http.DefaultClient // This will ensure that a real HTTPClient is used to record
|
||||
err := s.SomeExchangeEndpointFunction()
|
||||
// check error
|
||||
}
|
||||
```
|
||||
|
||||
+ After this is completed it should populate a new mocktest.json file for you with the relavent payloads in testdata
|
||||
+ This will store the request and results under the freshly created `testdata/http_mock/your_current_exchange/your_current_exchange.json`
|
||||
|
||||
## Validating
|
||||
|
||||
+ To check if the recording was successful, comment out recording and apiurl changes, then re-run test.
|
||||
|
||||
```go
|
||||
var s SomeExchange
|
||||
|
||||
func TestDummyTest(t *testing.T) {
|
||||
// s.APIURL = exchangeDefaultURL // This will overwrite the current mock url at localhost
|
||||
s.Verbose = true // This will show you some fancy debug output
|
||||
// s.HTTPRecording = true // This will record the request and response payloads
|
||||
|
||||
err := s.SomeExchangeEndpointFunction()
|
||||
// check error
|
||||
s.Verbose = true // This will show you some fancy debug output
|
||||
// s.HTTPRecording = true // This will record the request and response payloads
|
||||
// s.API.Endpoints.URL = apiURL // This will overwrite the current mock url at localhost
|
||||
// s.API.Endpoints.URLSecondary = secondAPIURL // This is only if your API has multiple endpoints
|
||||
// s.HTTPClient = http.DefaultClient // This will ensure that a real HTTPClient is used to record
|
||||
err := s.SomeExchangeEndpointFunction()
|
||||
// check error
|
||||
}
|
||||
```
|
||||
|
||||
+ The payload should be the same.
|
||||
|
||||
## Considerations
|
||||
|
||||
+ Some functions require timestamps. Mock tests _must_ match the same request structure, so `time.Now()` will cause problems for mock testing.
|
||||
+ To address this, use the boolean variable `mockTests` to create a consistent date. An example is below.
|
||||
```
|
||||
startTime := time.Now().Add(-time.Hour * 1)
|
||||
endTime := time.Now()
|
||||
if mockTests {
|
||||
startTime = time.Date(2020, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
endTime = time.Date(2020, 9, 2, 0, 0, 0, 0, time.UTC)
|
||||
}
|
||||
```
|
||||
+ Authenticated endpoints will typically require valid API keys and a signature to run successfully. Authenticated endpoints should be skipped. See an example below
|
||||
```
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
## Contribution
|
||||
@@ -171,4 +209,3 @@ When submitting a PR, please abide by our coding guidelines:
|
||||
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
|
||||
|
||||
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var o exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "OKCoin" {
|
||||
y = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "OKCoin" {
|
||||
y = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := o.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := o.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := o.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := o.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := o.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := o.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := o.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var o exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "OKex" {
|
||||
y = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "OKex" {
|
||||
y = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := o.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := o.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := o.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := o.GetSpotTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := o.GetSpotMarketDepth()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// GetContractPosition returns contract positioning
|
||||
accountInfo, err := o.GetContractPosition(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := o.PlaceContractOrders(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
|
||||
+ This package facilitates orderbook generation.
|
||||
+ Attaches methods to an orderbook
|
||||
- To Return total Bids
|
||||
- To Return total Asks
|
||||
- Update orderbooks
|
||||
- To Return total Bids
|
||||
- To Return total Asks
|
||||
- Update orderbooks
|
||||
+ Gets a loaded orderbook by exchange, asset type and currency pair.
|
||||
|
||||
+ This package is primarily used in conjunction with but not limited to the
|
||||
@@ -36,7 +36,7 @@ Examples below:
|
||||
```go
|
||||
ob, err := yobitExchange.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Find total asks which also returns total orderbook value
|
||||
@@ -49,7 +49,7 @@ the package itself.
|
||||
```go
|
||||
ob, err := orderbook.Get(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -49,9 +49,9 @@ main.go
|
||||
var p exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Poloniex" {
|
||||
y = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Poloniex" {
|
||||
y = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -59,13 +59,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := p.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := p.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -74,7 +74,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := p.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := p.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := p.GetOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -101,21 +101,21 @@ if err != nil {
|
||||
// Cancels current account order
|
||||
accountInfo, err := p.CancelOrder()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := p.PlaceOrder(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do Websocket public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -713,7 +713,7 @@ func (p *Poloniex) GetHistoricCandles(pair currency.Pair, a asset.Item, start, e
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: time.Unix(candles[x].Date, 0),
|
||||
Open: candles[x].Open,
|
||||
High: candles[x].Close,
|
||||
High: candles[x].High,
|
||||
Low: candles[x].Low,
|
||||
Close: candles[x].Close,
|
||||
Volume: candles[x].Volume,
|
||||
|
||||
@@ -21,7 +21,7 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
## Current Features for request
|
||||
|
||||
+ This package services the exchanges package with request handling.
|
||||
- Throttling of requests for an individual exchange
|
||||
- Throttling of requests for an individual exchange
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
|
||||
+ This stats package services the exchanges package by providing stats on
|
||||
enabled exchanges i.e.
|
||||
- Sort by largest volume
|
||||
- Sort by best price for currency
|
||||
- Others will be added soon
|
||||
- Sort by largest volume
|
||||
- Sort by best price for currency
|
||||
- Others will be added soon
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
|
||||
+ This package facilitates ticker generation.
|
||||
+ Attaches methods to an ticker
|
||||
- Returns a string of a value
|
||||
- Returns a string of a value
|
||||
|
||||
+ Gets a loaded ticker by exchange, asset type and currency pair.
|
||||
|
||||
@@ -37,7 +37,7 @@ Examples below:
|
||||
```go
|
||||
tick, err := yobitExchange.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Converts ticker value to string
|
||||
@@ -50,7 +50,7 @@ the package itself.
|
||||
```go
|
||||
tick, err := ticker.GetTicker(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
## Current Features for validate
|
||||
|
||||
+ This package allows for validation options to occur exchange side e.g.
|
||||
- Checking for ID in an order cancellation struct.
|
||||
- Determining the correct withdrawal bank details for a specific exchange.
|
||||
- Checking for ID in an order cancellation struct.
|
||||
- Determining the correct withdrawal bank details for a specific exchange.
|
||||
|
||||
+ Example Usage below:
|
||||
|
||||
@@ -32,21 +32,21 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
|
||||
// define your data structure across potential exchanges
|
||||
type Critical struct {
|
||||
ID string
|
||||
Person string
|
||||
Banks string
|
||||
MoneysUSD float64
|
||||
ID string
|
||||
Person string
|
||||
Banks string
|
||||
MoneysUSD float64
|
||||
}
|
||||
|
||||
// define validation and add a variadic param
|
||||
func (supercritcalinfo *Critical) Validate(opt ...validate.Checker) error {
|
||||
// define base level validation
|
||||
if supercritcalinfo != nil {
|
||||
// oh no this is nil, could panic program!
|
||||
}
|
||||
// define base level validation
|
||||
if supercritcalinfo != nil {
|
||||
// oh no this is nil, could panic program!
|
||||
}
|
||||
|
||||
// range over potential checks coming from individual packages
|
||||
var errs common.Errors
|
||||
// range over potential checks coming from individual packages
|
||||
var errs common.Errors
|
||||
for _, o := range opt {
|
||||
err := o.Check()
|
||||
if err != nil {
|
||||
@@ -57,18 +57,18 @@ func (supercritcalinfo *Critical) Validate(opt ...validate.Checker) error {
|
||||
if errs != nil {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// define an exchange or package level check that returns a validate.Checker
|
||||
// interface
|
||||
func (supercritcalinfo *Critical) PleaseDontSendMoneyToParents() validate.Checker {
|
||||
return validate.Check(func() error {
|
||||
return validate.Check(func() error {
|
||||
if supercritcalinfo.Person == "Mother Dearest" ||
|
||||
supercritcalinfo.Person == "Father Dearest" {
|
||||
return errors.New("nope")
|
||||
}
|
||||
return nil
|
||||
supercritcalinfo.Person == "Father Dearest" {
|
||||
return errors.New("nope")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,13 +79,13 @@ d := Critical{Person: "Mother Dearest", MoneysUSD: 1337.30}
|
||||
// This should not error
|
||||
err := d.Validate()
|
||||
if err != nil {
|
||||
return err
|
||||
return err
|
||||
}
|
||||
|
||||
// This should error
|
||||
err := d.Validate(d.PleaseDontSendMoneyToParents())
|
||||
if err != nil {
|
||||
return err
|
||||
return err
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var y exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "Yobit" {
|
||||
y = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "Yobit" {
|
||||
y = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := y.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := y.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := y.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := y.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := y.GetDepth()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,13 +100,13 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := y.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// 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
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
@@ -48,9 +48,9 @@ main.go
|
||||
var z exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "ZB" {
|
||||
z = bot.Exchanges[i]
|
||||
}
|
||||
if bot.Exchanges[i].GetName() == "ZB" {
|
||||
z = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
@@ -58,13 +58,13 @@ for i := range bot.Exchanges {
|
||||
// Fetches current ticker information
|
||||
tick, err := z.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := z.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
@@ -73,7 +73,7 @@ if err != nil {
|
||||
// Fetches current account information
|
||||
accountInfo, err := z.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ if err != nil {
|
||||
// Fetches current ticker information
|
||||
ticker, err := z.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := z.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
@@ -100,21 +100,21 @@ if err != nil {
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := z.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := z.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### How to do LongPolling public/private calls
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
|
||||
@@ -19,10 +19,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
zbTradeURL = "http://api.zb.live/data"
|
||||
zbMarketURL = "https://trade.zb.live/api"
|
||||
zbAPIVersion = "v1"
|
||||
|
||||
zbTradeURL = "http://api.zb.live"
|
||||
zbMarketURL = "https://trade.zb.live/api"
|
||||
zbAPIVersion = "v1"
|
||||
zbData = "data"
|
||||
zbAccountInfo = "getAccountInfo"
|
||||
zbMarkets = "markets"
|
||||
zbKline = "kline"
|
||||
@@ -136,7 +136,7 @@ func (z *ZB) GetOrders(currency string, pageindex, side int64) ([]Order, error)
|
||||
// GetMarkets returns market information including pricing, symbols and
|
||||
// each symbols decimal precision
|
||||
func (z *ZB) GetMarkets() (map[string]MarketResponseItem, error) {
|
||||
endpoint := fmt.Sprintf("%s/%s/%s", z.API.Endpoints.URL, zbAPIVersion, zbMarkets)
|
||||
endpoint := fmt.Sprintf("%s/%s/%s/%s", z.API.Endpoints.URL, zbData, zbAPIVersion, zbMarkets)
|
||||
|
||||
var res map[string]MarketResponseItem
|
||||
err := z.SendHTTPRequest(endpoint, &res, request.UnAuth)
|
||||
@@ -163,7 +163,7 @@ func (z *ZB) GetLatestSpotPrice(symbol string) (float64, error) {
|
||||
|
||||
// GetTicker returns a ticker for a given symbol
|
||||
func (z *ZB) GetTicker(symbol string) (TickerResponse, error) {
|
||||
urlPath := fmt.Sprintf("%s/%s/%s?market=%s", z.API.Endpoints.URL, zbAPIVersion, zbTicker, symbol)
|
||||
urlPath := fmt.Sprintf("%s/%s/%s/%s?market=%s", z.API.Endpoints.URL, zbData, zbAPIVersion, zbTicker, symbol)
|
||||
var res TickerResponse
|
||||
err := z.SendHTTPRequest(urlPath, &res, request.UnAuth)
|
||||
return res, err
|
||||
@@ -171,7 +171,7 @@ func (z *ZB) GetTicker(symbol string) (TickerResponse, error) {
|
||||
|
||||
// GetTickers returns ticker data for all supported symbols
|
||||
func (z *ZB) GetTickers() (map[string]TickerChildResponse, error) {
|
||||
urlPath := fmt.Sprintf("%s/%s/%s", z.API.Endpoints.URL, zbAPIVersion, zbTickers)
|
||||
urlPath := fmt.Sprintf("%s/%s/%s/%s", z.API.Endpoints.URL, zbData, zbAPIVersion, zbTickers)
|
||||
resp := make(map[string]TickerChildResponse)
|
||||
err := z.SendHTTPRequest(urlPath, &resp, request.UnAuth)
|
||||
return resp, err
|
||||
@@ -179,7 +179,7 @@ func (z *ZB) GetTickers() (map[string]TickerChildResponse, error) {
|
||||
|
||||
// GetOrderbook returns the orderbook for a given symbol
|
||||
func (z *ZB) GetOrderbook(symbol string) (OrderbookResponse, error) {
|
||||
urlPath := fmt.Sprintf("%s/%s/%s?market=%s", z.API.Endpoints.URL, zbAPIVersion, zbDepth, symbol)
|
||||
urlPath := fmt.Sprintf("%s/%s/%s/%s?market=%s", z.API.Endpoints.URL, zbData, zbAPIVersion, zbDepth, symbol)
|
||||
var res OrderbookResponse
|
||||
|
||||
err := z.SendHTTPRequest(urlPath, &res, request.UnAuth)
|
||||
@@ -217,7 +217,7 @@ func (z *ZB) GetSpotKline(arg KlinesRequestParams) (KLineResponse, error) {
|
||||
vals.Set("size", fmt.Sprintf("%d", arg.Size))
|
||||
}
|
||||
|
||||
urlPath := fmt.Sprintf("%s/%s/%s?%s", z.API.Endpoints.URL, zbAPIVersion, zbKline, vals.Encode())
|
||||
urlPath := fmt.Sprintf("%s/%s/%s/%s?%s", z.API.Endpoints.URL, zbData, zbAPIVersion, zbKline, vals.Encode())
|
||||
|
||||
var res KLineResponse
|
||||
var rawKlines map[string]interface{}
|
||||
|
||||
41
exchanges/zb/zb_live_test.go
Normal file
41
exchanges/zb/zb_live_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
//+build mock_test_off
|
||||
|
||||
// This will build if build tag mock_test_off is parsed and will do live testing
|
||||
// using all tests in (exchange)_test.go
|
||||
package zb
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
|
||||
)
|
||||
|
||||
var mockTests = false
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
cfg := config.GetConfig()
|
||||
err := cfg.LoadConfig("../../testdata/configtest.json", true)
|
||||
if err != nil {
|
||||
log.Fatal("ZB load config error", err)
|
||||
}
|
||||
zbConfig, err := cfg.GetExchangeConfig("ZB")
|
||||
if err != nil {
|
||||
log.Fatal("ZB Setup() init error", err)
|
||||
}
|
||||
zbConfig.API.AuthenticatedSupport = true
|
||||
zbConfig.API.Credentials.Key = apiKey
|
||||
zbConfig.API.Credentials.Secret = apiSecret
|
||||
z.SetDefaults()
|
||||
z.Websocket = sharedtestvalues.NewTestWebsocket()
|
||||
err = z.Setup(zbConfig)
|
||||
if err != nil {
|
||||
log.Fatal("ZB setup error", err)
|
||||
}
|
||||
log.Printf(sharedtestvalues.LiveTesting, z.Name, z.API.Endpoints.URL)
|
||||
z.Websocket.DataHandler = sharedtestvalues.GetWebsocketInterfaceChannelOverride()
|
||||
z.Websocket.TrafficAlert = sharedtestvalues.GetWebsocketStructChannelOverride()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
55
exchanges/zb/zb_mock_test.go
Normal file
55
exchanges/zb/zb_mock_test.go
Normal file
@@ -0,0 +1,55 @@
|
||||
//+build !mock_test_off
|
||||
|
||||
// This will build if build tag mock_test_off is not parsed and will try to mock
|
||||
// all tests in _test.go
|
||||
package zb
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/mock"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
|
||||
)
|
||||
|
||||
const mockfile = "../../testdata/http_mock/zb/zb.json"
|
||||
|
||||
var mockTests = true
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
cfg := config.GetConfig()
|
||||
err := cfg.LoadConfig("../../testdata/configtest.json", true)
|
||||
if err != nil {
|
||||
log.Fatal("ZB load config error", err)
|
||||
}
|
||||
var zbConfig *config.ExchangeConfig
|
||||
zbConfig, err = cfg.GetExchangeConfig("ZB")
|
||||
if err != nil {
|
||||
log.Fatal("ZB Setup() init error", err)
|
||||
}
|
||||
zbConfig.API.AuthenticatedSupport = true
|
||||
zbConfig.API.AuthenticatedWebsocketSupport = true
|
||||
zbConfig.API.Credentials.Key = apiKey
|
||||
zbConfig.API.Credentials.Secret = apiSecret
|
||||
z.SkipAuthCheck = true
|
||||
z.SetDefaults()
|
||||
z.Websocket = sharedtestvalues.NewTestWebsocket()
|
||||
err = z.Setup(zbConfig)
|
||||
if err != nil {
|
||||
log.Fatal("ZB setup error", err)
|
||||
}
|
||||
|
||||
serverDetails, newClient, err := mock.NewVCRServer(mockfile)
|
||||
if err != nil {
|
||||
log.Fatalf("Mock server error %s", err)
|
||||
}
|
||||
z.HTTPClient = newClient
|
||||
z.API.Endpoints.URL = serverDetails
|
||||
log.Printf(sharedtestvalues.MockTesting,
|
||||
z.Name,
|
||||
z.API.Endpoints.URL)
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
@@ -3,23 +3,20 @@ package zb
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||
"github.com/thrasher-corp/gocryptotrader/core"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/stream"
|
||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||
)
|
||||
@@ -29,39 +26,20 @@ const (
|
||||
apiKey = ""
|
||||
apiSecret = ""
|
||||
canManipulateRealOrders = false
|
||||
testCurrency = "btc_usdt"
|
||||
)
|
||||
|
||||
var z ZB
|
||||
var wsSetupRan bool
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
z.SetDefaults()
|
||||
cfg := config.GetConfig()
|
||||
err := cfg.LoadConfig("../../testdata/configtest.json", true)
|
||||
if err != nil {
|
||||
log.Fatal("ZB load config error", err)
|
||||
}
|
||||
zbConfig, err := cfg.GetExchangeConfig("ZB")
|
||||
if err != nil {
|
||||
log.Fatal("ZB Setup() init error", err)
|
||||
}
|
||||
zbConfig.API.AuthenticatedSupport = true
|
||||
zbConfig.API.AuthenticatedWebsocketSupport = true
|
||||
zbConfig.API.Credentials.Key = apiKey
|
||||
zbConfig.API.Credentials.Secret = apiSecret
|
||||
z.Websocket = sharedtestvalues.NewTestWebsocket()
|
||||
err = z.Setup(zbConfig)
|
||||
if err != nil {
|
||||
log.Fatal("ZB setup error", err)
|
||||
}
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func setupWsAuth(t *testing.T) {
|
||||
if wsSetupRan {
|
||||
return
|
||||
}
|
||||
if !z.Websocket.IsEnabled() && !z.API.AuthenticatedWebsocketSupport || !z.ValidateAPICredentials() || !canManipulateRealOrders {
|
||||
if !z.Websocket.IsEnabled() &&
|
||||
!z.API.AuthenticatedWebsocketSupport ||
|
||||
!z.ValidateAPICredentials() ||
|
||||
!canManipulateRealOrders {
|
||||
t.Skip(stream.WebsocketNotEnabled)
|
||||
}
|
||||
var dialer websocket.Dialer
|
||||
@@ -81,7 +59,7 @@ func TestSpotNewOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
arg := SpotNewOrderRequestParams{
|
||||
Symbol: "btc_usdt",
|
||||
Symbol: testCurrency,
|
||||
Type: SpotNewOrderRequestParamsTypeSell,
|
||||
Amount: 0.01,
|
||||
Price: 10246.1,
|
||||
@@ -99,7 +77,7 @@ func TestCancelExistingOrder(t *testing.T) {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
err := z.CancelExistingOrder(20180629145864850, "btc_usdt")
|
||||
err := z.CancelExistingOrder(20180629145864850, testCurrency)
|
||||
if err != nil {
|
||||
t.Errorf("ZB CancelExistingOrder: %s", err)
|
||||
}
|
||||
@@ -107,7 +85,7 @@ func TestCancelExistingOrder(t *testing.T) {
|
||||
|
||||
func TestGetLatestSpotPrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := z.GetLatestSpotPrice("btc_usdt")
|
||||
_, err := z.GetLatestSpotPrice(testCurrency)
|
||||
if err != nil {
|
||||
t.Errorf("ZB GetLatestSpotPrice: %s", err)
|
||||
}
|
||||
@@ -115,7 +93,7 @@ func TestGetLatestSpotPrice(t *testing.T) {
|
||||
|
||||
func TestGetTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := z.GetTicker("btc_usdt")
|
||||
_, err := z.GetTicker(testCurrency)
|
||||
if err != nil {
|
||||
t.Errorf("ZB GetTicker: %s", err)
|
||||
}
|
||||
@@ -131,7 +109,7 @@ func TestGetTickers(t *testing.T) {
|
||||
|
||||
func TestGetOrderbook(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := z.GetOrderbook("btc_usdt")
|
||||
_, err := z.GetOrderbook(testCurrency)
|
||||
if err != nil {
|
||||
t.Errorf("ZB GetTicker: %s", err)
|
||||
}
|
||||
@@ -145,18 +123,6 @@ func TestGetMarkets(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSpotKline(t *testing.T) {
|
||||
arg := KlinesRequestParams{
|
||||
Symbol: "btc_usdt",
|
||||
Type: kline.OneMin.Short() + "in",
|
||||
Size: 10,
|
||||
}
|
||||
_, err := z.GetSpotKline(arg)
|
||||
if err != nil {
|
||||
t.Errorf("ZB GetSpotKline: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func setFeeBuilder() *exchange.FeeBuilder {
|
||||
return &exchange.FeeBuilder{
|
||||
Amount: 1,
|
||||
@@ -172,6 +138,7 @@ func setFeeBuilder() *exchange.FeeBuilder {
|
||||
|
||||
// TestGetFeeByTypeOfflineTradeFee logic test
|
||||
func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
|
||||
t.Parallel()
|
||||
var feeBuilder = setFeeBuilder()
|
||||
z.GetFeeByType(feeBuilder)
|
||||
if !z.ValidateAPICredentials() {
|
||||
@@ -270,6 +237,9 @@ func TestFormatWithdrawPermissions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetActiveOrders(t *testing.T) {
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
var getOrdersRequest = order.GetOrdersRequest{
|
||||
Type: order.AnyType,
|
||||
Pairs: []currency.Pair{currency.NewPair(currency.XRP,
|
||||
@@ -278,13 +248,16 @@ func TestGetActiveOrders(t *testing.T) {
|
||||
|
||||
_, err := z.GetActiveOrders(&getOrdersRequest)
|
||||
if z.ValidateAPICredentials() && err != nil {
|
||||
t.Errorf("Could not get open orders: %s", err)
|
||||
t.Error(err)
|
||||
} else if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
t.Error("expecting an error when no keys are set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetOrderHistory(t *testing.T) {
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
var getOrdersRequest = order.GetOrdersRequest{
|
||||
Type: order.AnyType,
|
||||
Side: order.Buy,
|
||||
@@ -294,9 +267,9 @@ func TestGetOrderHistory(t *testing.T) {
|
||||
|
||||
_, err := z.GetOrderHistory(&getOrdersRequest)
|
||||
if z.ValidateAPICredentials() && err != nil {
|
||||
t.Errorf("Could not get order history: %s", err)
|
||||
t.Error(err)
|
||||
} else if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
t.Error("expecting an error when no keys are set")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,10 +278,12 @@ func TestGetOrderHistory(t *testing.T) {
|
||||
|
||||
func TestSubmitOrder(t *testing.T) {
|
||||
if z.ValidateAPICredentials() && !canManipulateRealOrders {
|
||||
t.Skip(fmt.Sprintf("ApiKey: %s. Can place orders: %v",
|
||||
z.API.Credentials.Key,
|
||||
t.Skip(fmt.Sprintf("Can place orders: %v",
|
||||
canManipulateRealOrders))
|
||||
}
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
|
||||
var orderSubmission = &order.Submit{
|
||||
Pair: currency.Pair{
|
||||
@@ -324,10 +299,13 @@ func TestSubmitOrder(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
}
|
||||
response, err := z.SubmitOrder(orderSubmission)
|
||||
if z.ValidateAPICredentials() && (err != nil || !response.IsOrderPlaced) {
|
||||
t.Errorf("Order failed to be placed: %v", err)
|
||||
if z.ValidateAPICredentials() && err != nil {
|
||||
t.Error(err)
|
||||
} else if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
t.Error("expecting an error when no keys are set")
|
||||
}
|
||||
if z.ValidateAPICredentials() && response.OrderID == "" {
|
||||
t.Error("expected order id")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,6 +313,9 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
if z.ValidateAPICredentials() && !canManipulateRealOrders {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
|
||||
currencyPair := currency.NewPair(currency.XRP, currency.USDT)
|
||||
var orderCancellation = &order.Cancel{
|
||||
@@ -346,11 +327,10 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
err := z.CancelOrder(orderCancellation)
|
||||
if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
}
|
||||
if z.ValidateAPICredentials() && err != nil {
|
||||
t.Errorf("Could not cancel orders: %v", err)
|
||||
t.Error(err)
|
||||
} else if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("expecting an error when no keys are set")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,6 +338,9 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
if z.ValidateAPICredentials() && !canManipulateRealOrders {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
|
||||
currencyPair := currency.NewPair(currency.XRP, currency.USDT)
|
||||
var orderCancellation = &order.Cancel{
|
||||
@@ -370,19 +353,20 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
|
||||
resp, err := z.CancelAllOrders(orderCancellation)
|
||||
|
||||
if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
}
|
||||
if z.ValidateAPICredentials() && err != nil {
|
||||
t.Errorf("Could not cancel orders: %v", err)
|
||||
t.Error(err)
|
||||
} else if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("expecting an error when no keys are set")
|
||||
}
|
||||
|
||||
if len(resp.Status) > 0 {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.Status))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAccountInfo(t *testing.T) {
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
if z.ValidateAPICredentials() {
|
||||
_, err := z.UpdateAccountInfo()
|
||||
if err != nil {
|
||||
@@ -397,6 +381,9 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
if z.ValidateAPICredentials() && !canManipulateRealOrders {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
@@ -407,6 +394,13 @@ func TestModifyOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWithdraw(t *testing.T) {
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
if z.ValidateAPICredentials() && !canManipulateRealOrders {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
|
||||
withdrawCryptoRequest := withdraw.Request{
|
||||
Crypto: withdraw.CryptoRequest{
|
||||
Address: core.BitcoinDonationAddress,
|
||||
@@ -417,20 +411,18 @@ func TestWithdraw(t *testing.T) {
|
||||
Description: "WITHDRAW IT ALL",
|
||||
}
|
||||
|
||||
if z.ValidateAPICredentials() && !canManipulateRealOrders {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
|
||||
_, err := z.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
|
||||
if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("Expecting an error when no keys are set")
|
||||
}
|
||||
if z.ValidateAPICredentials() && err != nil {
|
||||
t.Errorf("Withdraw failed to be placed: %v", err)
|
||||
t.Error(err)
|
||||
} else if !z.ValidateAPICredentials() && err == nil {
|
||||
t.Error("expecting an error when no keys are set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithdrawFiat(t *testing.T) {
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
if z.ValidateAPICredentials() && !canManipulateRealOrders {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
@@ -443,6 +435,9 @@ func TestWithdrawFiat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWithdrawInternationalBank(t *testing.T) {
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
if z.ValidateAPICredentials() && !canManipulateRealOrders {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
@@ -455,6 +450,9 @@ func TestWithdrawInternationalBank(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetDepositAddress(t *testing.T) {
|
||||
if mockTests {
|
||||
t.Skip("skipping authenticated function for mock testing")
|
||||
}
|
||||
if z.ValidateAPICredentials() {
|
||||
_, err := z.GetDepositAddress(currency.BTC, "")
|
||||
if err != nil {
|
||||
@@ -833,30 +831,59 @@ func TestWsCreateSubUserResponse(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSpotKline(t *testing.T) {
|
||||
arg := KlinesRequestParams{
|
||||
Symbol: testCurrency,
|
||||
Type: kline.OneMin.Short() + "in",
|
||||
Size: int64(z.Features.Enabled.Kline.ResultLimit),
|
||||
}
|
||||
if mockTests {
|
||||
startTime := time.Date(2020, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
arg.Since = convert.UnixMillis(startTime)
|
||||
arg.Type = "1day"
|
||||
}
|
||||
|
||||
_, err := z.GetSpotKline(arg)
|
||||
if err != nil {
|
||||
t.Errorf("ZB GetSpotKline: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetHistoricCandles(t *testing.T) {
|
||||
currencyPair, err := currency.NewPairFromString("btc_usdt")
|
||||
currencyPair, err := currency.NewPairFromString(testCurrency)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
startTime := time.Now().Add(-time.Hour * 1)
|
||||
_, err = z.GetHistoricCandles(currencyPair, asset.Spot, startTime, time.Now(), kline.OneHour)
|
||||
endTime := time.Now()
|
||||
if mockTests {
|
||||
startTime = time.Date(2020, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
endTime = time.Date(2020, 9, 2, 0, 0, 0, 0, time.UTC)
|
||||
}
|
||||
|
||||
_, err = z.GetHistoricCandles(currencyPair, asset.Spot, startTime, endTime, kline.OneDay)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = z.GetHistoricCandles(currencyPair, asset.Spot, startTime, time.Now(), kline.Interval(time.Hour*7))
|
||||
_, err = z.GetHistoricCandles(currencyPair, asset.Spot, startTime, endTime, kline.Interval(time.Hour*7))
|
||||
if err == nil {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetHistoricCandlesExtended(t *testing.T) {
|
||||
currencyPair, err := currency.NewPairFromString("btc_usdt")
|
||||
currencyPair, err := currency.NewPairFromString(testCurrency)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
start := time.Now().AddDate(0, -2, 0)
|
||||
end := time.Now()
|
||||
_, err = z.GetHistoricCandlesExtended(currencyPair, asset.Spot, start, end, kline.OneHour)
|
||||
startTime := time.Now().Add(-time.Hour * 1)
|
||||
endTime := time.Now()
|
||||
if mockTests {
|
||||
startTime = time.Date(2020, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
endTime = time.Date(2020, 9, 2, 0, 0, 0, 0, time.UTC)
|
||||
}
|
||||
_, err = z.GetHistoricCandlesExtended(currencyPair, asset.Spot, startTime, endTime, kline.OneDay)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -912,3 +939,40 @@ func Test_FormatExchangeKlineInterval(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateCandlesRequest(t *testing.T) {
|
||||
_, err := z.validateCandlesRequest(currency.Pair{}, "", time.Time{}, time.Time{}, kline.Interval(-1))
|
||||
if err != nil && err.Error() != "invalid time range supplied. Start: 0001-01-01 00:00:00 +0000 UTC End 0001-01-01 00:00:00 +0000 UTC" {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = z.validateCandlesRequest(currency.Pair{}, "", time.Date(2020, 1, 1, 1, 1, 1, 1, time.UTC), time.Time{}, kline.Interval(-1))
|
||||
if err != nil && err.Error() != "invalid time range supplied. Start: 2020-01-01 01:01:01.000000001 +0000 UTC End 0001-01-01 00:00:00 +0000 UTC" {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = z.validateCandlesRequest(currency.Pair{}, asset.Spot, time.Date(2020, 1, 1, 1, 1, 1, 1, time.UTC), time.Date(2020, 1, 1, 1, 1, 1, 3, time.UTC), kline.OneHour)
|
||||
if err != nil && err.Error() != "pair not enabled" {
|
||||
t.Error(err)
|
||||
}
|
||||
var p currency.Pair
|
||||
p, err = currency.NewPairFromString(testCurrency)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var item kline.Item
|
||||
item, err = z.validateCandlesRequest(p, asset.Spot, time.Date(2020, 1, 1, 1, 1, 1, 1, time.UTC), time.Date(2020, 1, 1, 1, 1, 1, 3, time.UTC), kline.OneHour)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !item.Pair.Equal(p) {
|
||||
t.Errorf("unexpected result, expected %v, received %v", p, item.Pair)
|
||||
}
|
||||
if item.Asset != asset.Spot {
|
||||
t.Errorf("unexpected result, expected %v, received %v", asset.Spot, item.Asset)
|
||||
}
|
||||
if item.Interval != kline.OneHour {
|
||||
t.Errorf("unexpected result, expected %v, received %v", kline.OneHour, item.Interval)
|
||||
}
|
||||
if item.Exchange != z.Name {
|
||||
t.Errorf("unexpected result, expected %v, received %v", z.Name, item.Exchange)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ type KlinesRequestParams struct {
|
||||
Symbol string // 交易对, zb_qc,zb_usdt,zb_btc...
|
||||
Type string // K线类型, 1min, 3min, 15min, 30min, 1hour......
|
||||
Since int64 // 从这个时间戳之后的
|
||||
Size int // 返回数据的条数限制(默认为1000,如果返回数据多于1000条,那么只返回1000条)
|
||||
Size int64 // 返回数据的条数限制(默认为1000,如果返回数据多于1000条,那么只返回1000条)
|
||||
}
|
||||
|
||||
// KLineResponseData Kline Data
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
@@ -590,7 +591,7 @@ func (z *ZB) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Requ
|
||||
|
||||
// GetFeeByType returns an estimate of fee based on type of transaction
|
||||
func (z *ZB) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
if !z.AllowAuthenticatedRequest() && // Todo check connection status
|
||||
if (!z.AllowAuthenticatedRequest() || z.SkipAuthCheck) && // Todo check connection status
|
||||
feeBuilder.FeeType == exchange.CryptocurrencyTradeFee {
|
||||
feeBuilder.FeeType = exchange.OfflineTradeFee
|
||||
}
|
||||
@@ -770,33 +771,29 @@ func (z *ZB) FormatExchangeKlineInterval(in kline.Interval) string {
|
||||
}
|
||||
|
||||
// GetHistoricCandles returns candles between a time period for a set time interval
|
||||
func (z *ZB) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error) {
|
||||
if err := z.ValidateKline(pair, a, interval); err != nil {
|
||||
func (z *ZB) GetHistoricCandles(p currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error) {
|
||||
ret, err := z.validateCandlesRequest(p, a, start, end, interval)
|
||||
if err != nil {
|
||||
return kline.Item{}, err
|
||||
}
|
||||
|
||||
formattedPair, err := z.FormatExchangeCurrency(pair, a)
|
||||
p, err = z.FormatExchangeCurrency(p, a)
|
||||
if err != nil {
|
||||
return kline.Item{}, err
|
||||
}
|
||||
|
||||
klineParams := KlinesRequestParams{
|
||||
Type: z.FormatExchangeKlineInterval(interval),
|
||||
Symbol: formattedPair.String(),
|
||||
Symbol: p.String(),
|
||||
Since: convert.UnixMillis(start),
|
||||
Size: int64(z.Features.Enabled.Kline.ResultLimit),
|
||||
}
|
||||
|
||||
candles, err := z.GetSpotKline(klineParams)
|
||||
var candles KLineResponse
|
||||
candles, err = z.GetSpotKline(klineParams)
|
||||
if err != nil {
|
||||
return kline.Item{}, err
|
||||
}
|
||||
|
||||
ret := kline.Item{
|
||||
Exchange: z.Name,
|
||||
Pair: pair,
|
||||
Asset: a,
|
||||
Interval: interval,
|
||||
}
|
||||
|
||||
for x := range candles.Data {
|
||||
if candles.Data[x].KlineTime.Before(start) || candles.Data[x].KlineTime.After(end) {
|
||||
continue
|
||||
@@ -804,7 +801,7 @@ func (z *ZB) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end tim
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: candles.Data[x].KlineTime,
|
||||
Open: candles.Data[x].Open,
|
||||
High: candles.Data[x].Close,
|
||||
High: candles.Data[x].High,
|
||||
Low: candles.Data[x].Low,
|
||||
Close: candles.Data[x].Close,
|
||||
Volume: candles.Data[x].Volume,
|
||||
@@ -817,5 +814,77 @@ func (z *ZB) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end tim
|
||||
|
||||
// GetHistoricCandlesExtended returns candles between a time period for a set time interval
|
||||
func (z *ZB) GetHistoricCandlesExtended(p currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error) {
|
||||
return z.GetHistoricCandles(p, a, start, end, interval)
|
||||
ret, err := z.validateCandlesRequest(p, a, start, end, interval)
|
||||
if err != nil {
|
||||
return kline.Item{}, err
|
||||
}
|
||||
|
||||
p, err = z.FormatExchangeCurrency(p, a)
|
||||
if err != nil {
|
||||
return kline.Item{}, err
|
||||
}
|
||||
|
||||
startTime := start
|
||||
allKlines:
|
||||
for {
|
||||
klineParams := KlinesRequestParams{
|
||||
Type: z.FormatExchangeKlineInterval(interval),
|
||||
Symbol: p.String(),
|
||||
Since: convert.UnixMillis(startTime),
|
||||
Size: int64(z.Features.Enabled.Kline.ResultLimit),
|
||||
}
|
||||
|
||||
candles, err := z.GetSpotKline(klineParams)
|
||||
if err != nil {
|
||||
return kline.Item{}, err
|
||||
}
|
||||
|
||||
for x := range candles.Data {
|
||||
if candles.Data[x].KlineTime.Before(start) || candles.Data[x].KlineTime.After(end) {
|
||||
continue
|
||||
}
|
||||
if startTime.Equal(candles.Data[x].KlineTime) {
|
||||
// no new data has been sent
|
||||
break allKlines
|
||||
}
|
||||
ret.Candles = append(ret.Candles, kline.Candle{
|
||||
Time: candles.Data[x].KlineTime,
|
||||
Open: candles.Data[x].Open,
|
||||
High: candles.Data[x].High,
|
||||
Low: candles.Data[x].Low,
|
||||
Close: candles.Data[x].Close,
|
||||
Volume: candles.Data[x].Volume,
|
||||
})
|
||||
if x == len(candles.Data)-1 {
|
||||
startTime = candles.Data[x].KlineTime
|
||||
}
|
||||
}
|
||||
if len(candles.Data) != int(z.Features.Enabled.Kline.ResultLimit) {
|
||||
break allKlines
|
||||
}
|
||||
}
|
||||
|
||||
ret.SortCandlesByTimestamp(false)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (z *ZB) validateCandlesRequest(p currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error) {
|
||||
if start.Equal(end) ||
|
||||
end.After(time.Now()) ||
|
||||
end.Before(start) ||
|
||||
(start.IsZero() && !end.IsZero()) {
|
||||
return kline.Item{}, fmt.Errorf("invalid time range supplied. Start: %v End %v",
|
||||
start,
|
||||
end)
|
||||
}
|
||||
if err := z.ValidateKline(p, a, interval); err != nil {
|
||||
return kline.Item{}, err
|
||||
}
|
||||
|
||||
return kline.Item{
|
||||
Exchange: z.Name,
|
||||
Pair: p,
|
||||
Asset: a,
|
||||
Interval: interval,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user