Added general test and fixed partial linter issues.

This commit is contained in:
Ryan O'Hara-Reid
2017-11-23 14:12:00 +11:00
parent 061e2a239d
commit 1644936b78
3 changed files with 184 additions and 94 deletions

View File

@@ -16,42 +16,44 @@ import (
)
const (
POLONIEX_API_URL = "https://poloniex.com"
POLONIEX_API_TRADING_ENDPOINT = "tradingApi"
POLONIEX_API_VERSION = "1"
POLONIEX_BALANCES = "returnBalances"
POLONIEX_BALANCES_COMPLETE = "returnCompleteBalances"
POLONIEX_DEPOSIT_ADDRESSES = "returnDepositAddresses"
POLONIEX_GENERATE_NEW_ADDRESS = "generateNewAddress"
POLONIEX_DEPOSITS_WITHDRAWALS = "returnDepositsWithdrawals"
POLONIEX_ORDERS = "returnOpenOrders"
POLONIEX_TRADE_HISTORY = "returnTradeHistory"
POLONIEX_ORDER_BUY = "buy"
POLONIEX_ORDER_SELL = "sell"
POLONIEX_ORDER_CANCEL = "cancelOrder"
POLONIEX_ORDER_MOVE = "moveOrder"
POLONIEX_WITHDRAW = "withdraw"
POLONIEX_FEE_INFO = "returnFeeInfo"
POLONIEX_AVAILABLE_BALANCES = "returnAvailableAccountBalances"
POLONIEX_TRADABLE_BALANCES = "returnTradableBalances"
POLONIEX_TRANSFER_BALANCE = "transferBalance"
POLONIEX_MARGIN_ACCOUNT_SUMMARY = "returnMarginAccountSummary"
POLONIEX_MARGIN_BUY = "marginBuy"
POLONIEX_MARGIN_SELL = "marginSell"
POLONIEX_MARGIN_POSITION = "getMarginPosition"
POLONIEX_MARGIN_POSITION_CLOSE = "closeMarginPosition"
POLONIEX_CREATE_LOAN_OFFER = "createLoanOffer"
POLONIEX_CANCEL_LOAN_OFFER = "cancelLoanOffer"
POLONIEX_OPEN_LOAN_OFFERS = "returnOpenLoanOffers"
POLONIEX_ACTIVE_LOANS = "returnActiveLoans"
POLONIEX_LENDING_HISTORY = "returnLendingHistory"
POLONIEX_AUTO_RENEW = "toggleAutoRenew"
poloniexAPIURL = "https://poloniex.com"
poloniexAPITradingEndpoint = "tradingApi"
poloniexAPIVersion = "1"
poloniexBalances = "returnBalances"
poloniexBalancesComplete = "returnCompleteBalances"
poloniexDepositAddresses = "returnDepositAddresses"
poloniexGenerateNewAddress = "generateNewAddress"
poloniexDepositsWithdrawals = "returnDepositsWithdrawals"
poloniexOrders = "returnOpenOrders"
poloniexTradeHistory = "returnTradeHistory"
poloniexOrderBuy = "buy"
poloniexOrderSell = "sell"
poloniexOrderCancel = "cancelOrder"
poloniexOrderMove = "moveOrder"
poloniexWithdraw = "withdraw"
poloniexFeeInfo = "returnFeeInfo"
poloniexAvailableBalances = "returnAvailableAccountBalances"
poloniexTradableBalances = "returnTradableBalances"
poloniexTransferBalance = "transferBalance"
poloniexMarginAccountSummary = "returnMarginAccountSummary"
poloniexMarginBuy = "marginBuy"
poloniexMarginSell = "marginSell"
poloniexMarginPosition = "getMarginPosition"
poloniexMarginPositionClose = "closeMarginPosition"
poloniexCreateLoanOffer = "createLoanOffer"
poloniexCancelLoanOffer = "cancelLoanOffer"
poloniexOpenLoanOffers = "returnOpenLoanOffers"
poloniexActiveLoans = "returnActiveLoans"
poloniexLendingHistory = "returnLendingHistory"
poloniexAutoRenew = "toggleAutoRenew"
)
// Poloniex is the overarching type across the poloniex package
type Poloniex struct {
exchange.Base
}
// SetDefaults sets default settings for poloniex
func (p *Poloniex) SetDefaults() {
p.Name = "Poloniex"
p.Enabled = false
@@ -66,6 +68,7 @@ func (p *Poloniex) SetDefaults() {
p.AssetTypes = []string{ticker.Spot}
}
// Setup sets user exchange configuration settings
func (p *Poloniex) Setup(exch config.ExchangeConfig) {
if !exch.Enabled {
p.SetEnabled(false)
@@ -90,36 +93,32 @@ func (p *Poloniex) Setup(exch config.ExchangeConfig) {
}
}
// GetFee returns the fee for poloniex
func (p *Poloniex) GetFee() float64 {
return p.Fee
}
// GetTicker returns current ticker information
func (p *Poloniex) GetTicker() (map[string]PoloniexTicker, error) {
type response struct {
Data map[string]PoloniexTicker
}
resp := response{}
path := fmt.Sprintf("%s/public?command=returnTicker", POLONIEX_API_URL)
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp.Data)
path := fmt.Sprintf("%s/public?command=returnTicker", poloniexAPIURL)
if err != nil {
return resp.Data, err
}
return resp.Data, nil
return resp.Data, common.SendHTTPGetRequest(path, true, p.Verbose, &resp.Data)
}
// GetVolume returns a list of currencies with associated volume
func (p *Poloniex) GetVolume() (interface{}, error) {
var resp interface{}
path := fmt.Sprintf("%s/public?command=return24hVolume", POLONIEX_API_URL)
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
path := fmt.Sprintf("%s/public?command=return24hVolume", poloniexAPIURL)
if err != nil {
return resp, err
}
return resp, nil
return resp, common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
}
// GetOrderbook returns the full orderbook from poloniex
func (p *Poloniex) GetOrderbook(currencyPair string, depth int) (PoloniexOrderbook, error) {
vals := url.Values{}
vals.Set("currencyPair", currencyPair)
@@ -129,13 +128,18 @@ func (p *Poloniex) GetOrderbook(currencyPair string, depth int) (PoloniexOrderbo
}
resp := PoloniexOrderbookResponse{}
path := fmt.Sprintf("%s/public?command=returnOrderBook&%s", POLONIEX_API_URL, vals.Encode())
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
path := fmt.Sprintf("%s/public?command=returnOrderBook&%s", poloniexAPIURL, vals.Encode())
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
if err != nil {
return PoloniexOrderbook{}, err
}
if len(resp.Error) != 0 {
log.Println(resp.Error)
return PoloniexOrderbook{}, fmt.Errorf("Poloniex GetOrderbook() error: %s", resp.Error)
}
ob := PoloniexOrderbook{}
for x := range resp.Asks {
data := resp.Asks[x]
@@ -159,6 +163,7 @@ func (p *Poloniex) GetOrderbook(currencyPair string, depth int) (PoloniexOrderbo
return ob, nil
}
// GetTradeHistory returns trades history from poloniex
func (p *Poloniex) GetTradeHistory(currencyPair, start, end string) ([]PoloniexTradeHistory, error) {
vals := url.Values{}
vals.Set("currencyPair", currencyPair)
@@ -172,15 +177,12 @@ func (p *Poloniex) GetTradeHistory(currencyPair, start, end string) ([]PoloniexT
}
resp := []PoloniexTradeHistory{}
path := fmt.Sprintf("%s/public?command=returnTradeHistory&%s", POLONIEX_API_URL, vals.Encode())
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
path := fmt.Sprintf("%s/public?command=returnTradeHistory&%s", poloniexAPIURL, vals.Encode())
if err != nil {
return nil, err
}
return resp, nil
return resp, common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
}
// GetChartData returns chart data for a specific currency pair
func (p *Poloniex) GetChartData(currencyPair, start, end, period string) ([]PoloniexChartData, error) {
vals := url.Values{}
vals.Set("currencyPair", currencyPair)
@@ -198,43 +200,39 @@ func (p *Poloniex) GetChartData(currencyPair, start, end, period string) ([]Polo
}
resp := []PoloniexChartData{}
path := fmt.Sprintf("%s/public?command=returnChartData&%s", POLONIEX_API_URL, vals.Encode())
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
path := fmt.Sprintf("%s/public?command=returnChartData&%s", poloniexAPIURL, vals.Encode())
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
if err != nil {
return nil, err
}
return resp, nil
}
// GetCurrencies returns information about currencies
func (p *Poloniex) GetCurrencies() (map[string]PoloniexCurrencies, error) {
type Response struct {
Data map[string]PoloniexCurrencies
}
resp := Response{}
path := fmt.Sprintf("%s/public?command=returnCurrencies", POLONIEX_API_URL)
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp.Data)
path := fmt.Sprintf("%s/public?command=returnCurrencies", poloniexAPIURL)
if err != nil {
return resp.Data, err
}
return resp.Data, nil
return resp.Data, common.SendHTTPGetRequest(path, true, p.Verbose, &resp.Data)
}
// GetLoanOrders returns the list of loan offers and demands for a given
// currency, specified by the "currency" GET parameter.
func (p *Poloniex) GetLoanOrders(currency string) (PoloniexLoanOrders, error) {
resp := PoloniexLoanOrders{}
path := fmt.Sprintf("%s/public?command=returnLoanOrders&currency=%s", POLONIEX_API_URL, currency)
err := common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
path := fmt.Sprintf("%s/public?command=returnLoanOrders&currency=%s", poloniexAPIURL, currency)
if err != nil {
return resp, err
}
return resp, nil
return resp, common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
}
func (p *Poloniex) GetBalances() (PoloniexBalance, error) {
var result interface{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_BALANCES, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexBalances, url.Values{}, &result)
if err != nil {
return PoloniexBalance{}, err
@@ -257,7 +255,7 @@ type PoloniexCompleteBalances struct {
func (p *Poloniex) GetCompleteBalances() (PoloniexCompleteBalances, error) {
var result interface{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_BALANCES_COMPLETE, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexBalancesComplete, url.Values{}, &result)
if err != nil {
return PoloniexCompleteBalances{}, err
@@ -282,7 +280,7 @@ func (p *Poloniex) GetCompleteBalances() (PoloniexCompleteBalances, error) {
func (p *Poloniex) GetDepositAddresses() (PoloniexDepositAddresses, error) {
var result interface{}
addresses := PoloniexDepositAddresses{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_DEPOSIT_ADDRESSES, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexDepositAddresses, url.Values{}, &result)
if err != nil {
return addresses, err
@@ -307,7 +305,7 @@ func (p *Poloniex) GenerateNewAddress(currency string) (string, error) {
values := url.Values{}
values.Set("currency", currency)
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_GENERATE_NEW_ADDRESS, values, &resp)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexGenerateNewAddress, values, &resp)
if err != nil {
return "", err
@@ -336,7 +334,7 @@ func (p *Poloniex) GetDepositsWithdrawals(start, end string) (PoloniexDepositsWi
values.Set("end", strconv.FormatInt(time.Now().Unix(), 10))
}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_DEPOSITS_WITHDRAWALS, values, &resp)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexDepositsWithdrawals, values, &resp)
if err != nil {
return resp, err
@@ -351,7 +349,7 @@ func (p *Poloniex) GetOpenOrders(currency string) (interface{}, error) {
if currency != "" {
values.Set("currencyPair", currency)
result := PoloniexOpenOrdersResponse{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_ORDERS, values, &result.Data)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOrders, values, &result.Data)
if err != nil {
return result, err
@@ -361,7 +359,7 @@ func (p *Poloniex) GetOpenOrders(currency string) (interface{}, error) {
} else {
values.Set("currencyPair", "all")
result := PoloniexOpenOrdersResponseAll{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_ORDERS, values, &result.Data)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOrders, values, &result.Data)
if err != nil {
return result, err
@@ -385,7 +383,7 @@ func (p *Poloniex) GetAuthenticatedTradeHistory(currency, start, end string) (in
if currency != "" && currency != "all" {
values.Set("currencyPair", currency)
result := PoloniexAuthenticatedTradeHistoryResponse{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_TRADE_HISTORY, values, &result.Data)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexTradeHistory, values, &result.Data)
if err != nil {
return result, err
@@ -395,7 +393,7 @@ func (p *Poloniex) GetAuthenticatedTradeHistory(currency, start, end string) (in
} else {
values.Set("currencyPair", "all")
result := PoloniexAuthenticatedTradeHistoryAll{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_TRADE_HISTORY, values, &result.Data)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexTradeHistory, values, &result.Data)
if err != nil {
return result, err
@@ -411,9 +409,9 @@ func (p *Poloniex) PlaceOrder(currency string, rate, amount float64, immediate,
var orderType string
if buy {
orderType = POLONIEX_ORDER_BUY
orderType = poloniexOrderBuy
} else {
orderType = POLONIEX_ORDER_SELL
orderType = poloniexOrderSell
}
values.Set("currencyPair", currency)
@@ -442,7 +440,7 @@ func (p *Poloniex) CancelOrder(orderID int64) (bool, error) {
values := url.Values{}
values.Set("orderNumber", strconv.FormatInt(orderID, 10))
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_ORDER_CANCEL, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOrderCancel, values, &result)
if err != nil {
return false, err
@@ -465,7 +463,7 @@ func (p *Poloniex) MoveOrder(orderID int64, rate, amount float64) (PoloniexMoveO
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_ORDER_MOVE, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOrderMove, values, &result)
if err != nil {
return result, err
@@ -486,7 +484,7 @@ func (p *Poloniex) Withdraw(currency, address string, amount float64) (bool, err
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("address", address)
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_WITHDRAW, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexWithdraw, values, &result)
if err != nil {
return false, err
@@ -501,7 +499,7 @@ func (p *Poloniex) Withdraw(currency, address string, amount float64) (bool, err
func (p *Poloniex) GetFeeInfo() (PoloniexFee, error) {
result := PoloniexFee{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_FEE_INFO, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexFeeInfo, url.Values{}, &result)
if err != nil {
return result, err
@@ -516,7 +514,7 @@ func (p *Poloniex) GetTradableBalances() (map[string]map[string]float64, error)
}
result := Response{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_TRADABLE_BALANCES, url.Values{}, &result.Data)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexTradableBalances, url.Values{}, &result.Data)
if err != nil {
return nil, err
@@ -543,7 +541,7 @@ func (p *Poloniex) TransferBalance(currency, from, to string, amount float64) (b
values.Set("fromAccount", from)
values.Set("toAccount", to)
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_TRANSFER_BALANCE, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexTransferBalance, values, &result)
if err != nil {
return false, err
@@ -558,7 +556,7 @@ func (p *Poloniex) TransferBalance(currency, from, to string, amount float64) (b
func (p *Poloniex) GetMarginAccountSummary() (PoloniexMargin, error) {
result := PoloniexMargin{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_MARGIN_ACCOUNT_SUMMARY, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexMarginAccountSummary, url.Values{}, &result)
if err != nil {
return result, err
@@ -573,9 +571,9 @@ func (p *Poloniex) PlaceMarginOrder(currency string, rate, amount, lendingRate f
var orderType string
if buy {
orderType = POLONIEX_MARGIN_BUY
orderType = poloniexMarginBuy
} else {
orderType = POLONIEX_MARGIN_SELL
orderType = poloniexMarginSell
}
values.Set("currencyPair", currency)
@@ -601,7 +599,7 @@ func (p *Poloniex) GetMarginPosition(currency string) (interface{}, error) {
if currency != "" && currency != "all" {
values.Set("currencyPair", currency)
result := PoloniexMarginPosition{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_MARGIN_POSITION, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexMarginPosition, values, &result)
if err != nil {
return result, err
@@ -616,7 +614,7 @@ func (p *Poloniex) GetMarginPosition(currency string) (interface{}, error) {
}
result := Response{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_MARGIN_POSITION, values, &result.Data)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexMarginPosition, values, &result.Data)
if err != nil {
return result, err
@@ -631,7 +629,7 @@ func (p *Poloniex) CloseMarginPosition(currency string) (bool, error) {
values.Set("currencyPair", currency)
result := PoloniexGenericResponse{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_MARGIN_POSITION_CLOSE, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexMarginPositionClose, values, &result)
if err != nil {
return false, err
@@ -666,7 +664,7 @@ func (p *Poloniex) CreateLoanOffer(currency string, amount, rate float64, durati
result := Response{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_CREATE_LOAN_OFFER, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexCreateLoanOffer, values, &result)
if err != nil {
return 0, err
@@ -684,7 +682,7 @@ func (p *Poloniex) CancelLoanOffer(orderNumber int64) (bool, error) {
values := url.Values{}
values.Set("orderID", strconv.FormatInt(orderNumber, 10))
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_CANCEL_LOAN_OFFER, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexCancelLoanOffer, values, &result)
if err != nil {
return false, err
@@ -703,7 +701,7 @@ func (p *Poloniex) GetOpenLoanOffers() (map[string][]PoloniexLoanOffer, error) {
}
result := Response{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_OPEN_LOAN_OFFERS, url.Values{}, &result.Data)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOpenLoanOffers, url.Values{}, &result.Data)
if err != nil {
return nil, err
@@ -718,7 +716,7 @@ func (p *Poloniex) GetOpenLoanOffers() (map[string][]PoloniexLoanOffer, error) {
func (p *Poloniex) GetActiveLoans() (PoloniexActiveLoans, error) {
result := PoloniexActiveLoans{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_ACTIVE_LOANS, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexActiveLoans, url.Values{}, &result)
if err != nil {
return result, err
@@ -739,7 +737,7 @@ func (p *Poloniex) GetLendingHistory(start, end string) ([]PoloniexLendingHistor
}
resp := []PoloniexLendingHistory{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_LENDING_HISTORY, vals, &resp)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexLendingHistory, vals, &resp)
if err != nil {
return nil, err
@@ -752,7 +750,7 @@ func (p *Poloniex) ToggleAutoRenew(orderNumber int64) (bool, error) {
values.Set("orderNumber", strconv.FormatInt(orderNumber, 10))
result := PoloniexGenericResponse{}
err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_AUTO_RENEW, values, &result)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexAutoRenew, values, &result)
if err != nil {
return false, err
@@ -784,7 +782,7 @@ func (p *Poloniex) SendAuthenticatedHTTPRequest(method, endpoint string, values
hmac := common.GetHMAC(common.HashSHA512, []byte(values.Encode()), []byte(p.APISecret))
headers["Sign"] = common.HexEncodeToString(hmac)
path := fmt.Sprintf("%s/%s", POLONIEX_API_URL, POLONIEX_API_TRADING_ENDPOINT)
path := fmt.Sprintf("%s/%s", poloniexAPIURL, poloniexAPITradingEndpoint)
resp, err := common.SendHTTPRequest(method, path, headers, bytes.NewBufferString(values.Encode()))
if err != nil {

View File

@@ -0,0 +1,90 @@
package poloniex
import (
"testing"
"github.com/thrasher-/gocryptotrader/config"
)
var p Poloniex
// Please supply your own APIKEYS here for due diligence testing
const (
apiKey = ""
apiSecret = ""
)
func TestSetDefaults(t *testing.T) {
p.SetDefaults()
}
func TestSetup(t *testing.T) {
cfg := config.GetConfig()
cfg.LoadConfig("../../testdata/configtest.json")
poloniexConfig, err := cfg.GetExchangeConfig("Poloniex")
if err != nil {
t.Error("Test Failed - Poloniex Setup() init error")
}
poloniexConfig.AuthenticatedAPISupport = true
poloniexConfig.APIKey = apiKey
poloniexConfig.APISecret = apiSecret
p.Setup(poloniexConfig)
}
func TestGetFee(t *testing.T) {
if p.GetFee() != 0 {
t.Error("Test faild - Poloniex GetFee() error")
}
}
func TestGetTicker(t *testing.T) {
_, err := p.GetTicker()
if err != nil {
t.Error("Test faild - Poloniex GetTicker() error")
}
}
func TestGetVolume(t *testing.T) {
_, err := p.GetVolume()
if err != nil {
t.Error("Test faild - Poloniex GetVolume() error")
}
}
func TestGetOrderbook(t *testing.T) {
_, err := p.GetOrderbook("BTC_XMR", 50)
if err != nil {
t.Error("Test faild - Poloniex GetOrderbook() error", err)
}
}
func TestGetTradeHistory(t *testing.T) {
_, err := p.GetTradeHistory("BTC_XMR", "", "")
if err != nil {
t.Error("Test faild - Poloniex GetTradeHistory() error", err)
}
}
func TestGetChartData(t *testing.T) {
_, err := p.GetChartData("BTC_XMR", "1405699200", "1405699400", "300")
if err != nil {
t.Error("Test faild - Poloniex GetChartData() error", err)
}
}
func TestGetCurrencies(t *testing.T) {
_, err := p.GetCurrencies()
if err != nil {
t.Error("Test faild - Poloniex GetCurrencies() error", err)
}
}
func TestGetLoanOrders(t *testing.T) {
_, err := p.GetLoanOrders("BTC")
if err != nil {
t.Error("Test faild - Poloniex GetLoanOrders() error", err)
}
}

View File

@@ -16,6 +16,7 @@ type PoloniexOrderbookResponse struct {
Asks [][]interface{} `json:"asks"`
Bids [][]interface{} `json:"bids"`
IsFrozen string `json:"isFrozen"`
Error string `json:"error"`
}
type PoloniexOrderbookItem struct {
@@ -47,6 +48,7 @@ type PoloniexChartData struct {
Volume float64 `json:"volume"`
QuoteVolume float64 `json:"quoteVolume"`
WeightedAverage float64 `json:"weightedAverage"`
Error string `json:"error"`
}
type PoloniexCurrencies struct {