Cancel order wrapper wrapup (#214)

* Reimplements order cancellation for alphapoint, anx, binance, bitfinex, bithumb, bitmex, bitstamp, bittrex,  btcmarkets, coinbasepro, coinut, exmo, gateio, gemini, gitbtc, huobi, hadax, itbit, kraken, lakebtc, liqui, okcoin, okex, poloniex, wex, yobit and zb wrappers. Adds new order cancellation struct type. Updates old tests that pointed to the wrong unrenamed methods

* Sets up tests for all supported exchanges. request.DoRequest errors when response status is not 200

* Updates alphapoint, coinut, hitbtc, lakebtc cancel order implementations. Finishes testing

* Adds localbitcoin cancel order wrapper support

* Fixes tests and build issues. Adds WexIssue flag for tests

* Changes CancelOrder signature to only return error. Allows exchange to format currency pairs with delimiters
This commit is contained in:
Scott
2018-11-30 16:20:34 +11:00
committed by Adrian Gallagher
parent d039593b67
commit 458aab301e
72 changed files with 1771 additions and 384 deletions

View File

@@ -1,7 +1,6 @@
package itbit
import (
"fmt"
"net/url"
"testing"
@@ -15,10 +14,10 @@ var i ItBit
// Please provide your own keys to do proper testing
const (
apiKey = ""
apiSecret = ""
clientID = ""
canPlaceOrders = false
apiKey = ""
apiSecret = ""
clientID = ""
canManipulateRealOrders = false
)
func TestSetDefaults(t *testing.T) {
@@ -245,18 +244,26 @@ func TestFormatWithdrawPermissions(t *testing.T) {
}
}
// This will really really use the API to place an order
// If you're going to test this, make sure you're willing to place real orders on the exchange
// Any tests below this line have the ability to impact your orders on the exchange. Enable canManipulateRealOrders to run them
// ----------------------------------------------------------------------------------------------------------------------------
func isRealOrderTestEnabled() bool {
if i.APIKey == "" || i.APISecret == "" ||
i.APIKey == "Key" || i.APISecret == "Secret" ||
!canManipulateRealOrders {
return false
}
return true
}
func TestSubmitOrder(t *testing.T) {
i.SetDefaults()
TestSetup(t)
i.Verbose = true
if i.APIKey == "" || i.APISecret == "" ||
i.APIKey == "Key" || i.APISecret == "Secret" ||
!canPlaceOrders {
t.Skip(fmt.Sprintf("ApiKey: %s. Can place orders: %v", i.APIKey, canPlaceOrders))
if !isRealOrderTestEnabled() {
t.Skip()
}
var p = pair.CurrencyPair{
Delimiter: "",
FirstCurrency: symbol.BTC,
@@ -267,3 +274,31 @@ func TestSubmitOrder(t *testing.T) {
t.Errorf("Order failed to be placed: %v", err)
}
}
func TestCancelExchangeOrder(t *testing.T) {
// Arrange
i.SetDefaults()
TestSetup(t)
if !isRealOrderTestEnabled() {
t.Skip()
}
i.Verbose = true
currencyPair := pair.NewCurrencyPair(symbol.LTC, symbol.BTC)
var orderCancellation = exchange.OrderCancellation{
OrderID: "1",
WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB",
AccountID: "1",
CurrencyPair: currencyPair,
}
// Act
err := i.CancelOrder(orderCancellation)
// Assert
if err != nil {
t.Errorf("Could not cancel order: %s", err)
}
}

View File

@@ -172,8 +172,8 @@ func (i *ItBit) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64,
}
// CancelOrder cancels an order by its corresponding ID number
func (i *ItBit) CancelOrder(orderID int64) error {
return common.ErrNotYetImplemented
func (i *ItBit) CancelOrder(order exchange.OrderCancellation) error {
return i.CancelExistingOrder(order.WalletAddress, order.OrderID)
}
// CancelAllOrders cancels all orders associated with a currency pair