btcm: add modify order functionality, change return to pointer (#940)

* btcm: add modify order functionality, change return to pointer

* glorious: nits

* glorious: nits

* btcm: Adjust function name

* thrasher: nits

* thrasher: nits cont...
This commit is contained in:
Ryan O'Hara-Reid
2022-05-16 10:55:23 +10:00
committed by GitHub
parent ccde38d25a
commit 16a93b49a4
35 changed files with 241 additions and 114 deletions

View File

@@ -1063,8 +1063,8 @@ func (b *Binance) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submi
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Binance) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (b *Binance) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -675,14 +675,14 @@ func (b *Bitfinex) SubmitOrder(ctx context.Context, o *order.Submit) (order.Subm
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Bitfinex) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
func (b *Bitfinex) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error) {
if err := action.Validate(); err != nil {
return order.Modify{}, err
return nil, err
}
orderIDInt, err := strconv.ParseInt(action.ID, 10, 64)
if err != nil {
return order.Modify{ID: action.ID}, err
return &order.Modify{ID: action.ID}, err
}
if b.Websocket.CanUseAuthenticatedWebsocketForWrapper() {
request := WsUpdateOrderRequest{
@@ -694,17 +694,16 @@ func (b *Bitfinex) ModifyOrder(ctx context.Context, action *order.Modify) (order
request.Amount *= -1
}
err = b.WsModifyOrder(&request)
return order.Modify{
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: action.ID,
Price: action.Price,
Amount: action.Amount,
Price: action.Price,
Amount: action.Amount,
}, err
}
return order.Modify{}, common.ErrNotYetImplemented
return nil, common.ErrNotYetImplemented
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -395,8 +395,8 @@ func (b *Bitflyer) SubmitOrder(_ context.Context, _ *order.Submit) (order.Submit
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Bitflyer) ModifyOrder(_ context.Context, _ *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (b *Bitflyer) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -512,9 +512,9 @@ func (b *Bithumb) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submi
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Bithumb) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
func (b *Bithumb) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error) {
if err := action.Validate(); err != nil {
return order.Modify{}, err
return nil, err
}
o, err := b.ModifyTrade(ctx,
@@ -523,20 +523,18 @@ func (b *Bithumb) ModifyOrder(ctx context.Context, action *order.Modify) (order.
action.Side.Lower(),
action.Amount,
int64(action.Price))
if err != nil {
return order.Modify{}, err
return nil, err
}
return order.Modify{
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: o.Data[0].ContID,
Price: float64(int64(action.Price)),
Amount: action.Amount,
Side: action.Side,
Price: float64(int64(action.Price)),
Amount: action.Amount,
Side: action.Side,
}, nil
}

View File

@@ -609,15 +609,15 @@ func (b *Bitmex) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submit
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Bitmex) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
func (b *Bitmex) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error) {
if err := action.Validate(); err != nil {
return order.Modify{}, err
return nil, err
}
var params OrderAmendParams
if math.Mod(action.Amount, 1) != 0 {
return order.Modify{}, errors.New("contract amount can not have decimals")
return nil, errors.New("contract amount can not have decimals")
}
params.OrderID = action.ID
@@ -626,17 +626,16 @@ func (b *Bitmex) ModifyOrder(ctx context.Context, action *order.Modify) (order.M
o, err := b.AmendOrder(ctx, &params)
if err != nil {
return order.Modify{}, err
return nil, err
}
return order.Modify{
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: o.OrderID,
Price: action.Price,
Amount: float64(params.OrderQty),
Price: action.Price,
Amount: float64(params.OrderQty),
}, nil
}

View File

@@ -561,8 +561,8 @@ func (b *Bitstamp) SubmitOrder(ctx context.Context, s *order.Submit) (order.Subm
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Bitstamp) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (b *Bitstamp) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -587,8 +587,8 @@ func (b *Bittrex) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submi
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Bittrex) ModifyOrder(_ context.Context, _ *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (b *Bittrex) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -21,6 +21,11 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
)
var (
errInvalidAmount = errors.New("cannot be less than or equal to zero")
errIDRequired = errors.New("id is required")
)
const (
btcMarketsAPIURL = "https://api.btcmarkets.net"
btcMarketsAPIVersion = "/v3"
@@ -464,8 +469,8 @@ func (b *BTCMarkets) CancelAllOpenOrdersByPairs(ctx context.Context, marketIDs [
}
// FetchOrder finds order based on the provided id
func (b *BTCMarkets) FetchOrder(ctx context.Context, id string) (OrderData, error) {
var resp OrderData
func (b *BTCMarkets) FetchOrder(ctx context.Context, id string) (*OrderData, error) {
var resp *OrderData
return resp, b.SendAuthenticatedRequest(ctx, http.MethodGet,
btcMarketsOrders+"/"+id,
nil,
@@ -483,6 +488,36 @@ func (b *BTCMarkets) RemoveOrder(ctx context.Context, id string) (CancelOrderRes
request.Auth)
}
// ReplaceOrder cancels an order and then places a new order.
func (b *BTCMarkets) ReplaceOrder(ctx context.Context, id, clientOrderID string, price, amount float64) (*OrderData, error) {
if price <= 0 {
return nil, fmt.Errorf("price %w", errInvalidAmount)
}
if amount <= 0 {
return nil, fmt.Errorf("amount %w", errInvalidAmount)
}
if id == "" {
return nil, errIDRequired
}
req := make(map[string]interface{}, 3)
req["price"] = strconv.FormatFloat(price, 'f', -1, 64)
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
if clientOrderID != "" {
req["clientOrderId"] = clientOrderID
}
var resp *OrderData
return resp, b.SendAuthenticatedRequest(ctx,
http.MethodPut,
btcMarketsOrders+"/"+id,
req,
&resp,
request.Auth)
}
// ListWithdrawals lists the withdrawal history
func (b *BTCMarkets) ListWithdrawals(ctx context.Context, before, after, limit int64) ([]TransferData, error) {
if (before > 0) && (after >= 0) {

View File

@@ -1041,6 +1041,60 @@ func TestGetTimeInForce(t *testing.T) {
}
}
func TestReplaceOrder(t *testing.T) {
t.Parallel()
_, err := b.ReplaceOrder(context.Background(), "", "bro", 0, 0)
if !errors.Is(err, errInvalidAmount) {
t.Fatalf("received: '%v' but expected: '%v'", err, errInvalidAmount)
}
_, err = b.ReplaceOrder(context.Background(), "", "bro", 1, 0)
if !errors.Is(err, errInvalidAmount) {
t.Fatalf("received: '%v' but expected: '%v'", err, errInvalidAmount)
}
_, err = b.ReplaceOrder(context.Background(), "", "bro", 1, 1)
if !errors.Is(err, errIDRequired) {
t.Fatalf("received: '%v' but expected: '%v'", err, errIDRequired)
}
if !areTestAPIKeysSet() || !canManipulateRealOrders {
t.Skip("skipping test, either api keys or manipulaterealorders isnt set correctly")
}
_, err = b.ReplaceOrder(context.Background(), "8207096301", "bruh", 100000, 0.001)
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
}
func TestWrapperModifyOrder(t *testing.T) {
t.Parallel()
_, err := b.ModifyOrder(context.Background(), &order.Modify{})
if !errors.Is(err, order.ErrPairIsEmpty) {
t.Fatalf("received: '%v' but expected: '%v'", err, order.ErrPairIsEmpty)
}
if !areTestAPIKeysSet() || !canManipulateRealOrders {
t.Skip("skipping test, either api keys or manipulaterealorders isnt set correctly")
}
mo, err := b.ModifyOrder(context.Background(), &order.Modify{
Pair: currency.NewPair(currency.BTC, currency.AUD),
AssetType: asset.Spot,
Price: 100000,
Amount: 0.001,
ID: "8207123461",
ClientOrderID: "bruh3",
})
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
if mo == nil {
t.Fatal("expected data return")
}
}
func TestUpdateOrderExecutionLimits(t *testing.T) {
t.Parallel()
err := b.UpdateOrderExecutionLimits(context.Background(), asset.Empty)

View File

@@ -90,6 +90,7 @@ func (b *BTCMarkets) SetDefaults() {
TradeFee: true,
FiatWithdrawalFee: true,
CryptoWithdrawalFee: true,
ModifyOrder: true,
},
WebsocketCapabilities: protocol.Features{
TickerFetching: true,
@@ -579,8 +580,41 @@ func (b *BTCMarkets) SubmitOrder(ctx context.Context, s *order.Submit) (order.Su
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *BTCMarkets) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (b *BTCMarkets) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error) {
if err := action.Validate(); err != nil {
return nil, err
}
resp, err := b.ReplaceOrder(ctx, action.ID, action.ClientOrderID, action.Price, action.Amount)
if err != nil {
return nil, err
}
pair, err := currency.NewPairFromString(resp.MarketID)
if err != nil {
return nil, err
}
side, err := order.StringToOrderSide(resp.Side)
if err != nil {
return nil, err
}
orderT, err := order.StringToOrderType(resp.Type)
if err != nil {
return nil, err
}
status, err := order.StringToOrderStatus(resp.Status)
if err != nil {
return nil, err
}
return &order.Modify{
ID: resp.OrderID,
Pair: pair,
Side: side,
Type: orderT,
Date: resp.CreationTime,
Price: resp.Price,
Amount: resp.Amount,
RemainingAmount: resp.OpenAmount,
Status: status,
}, nil
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -551,8 +551,8 @@ func (b *BTSE) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitRe
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *BTSE) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (b *BTSE) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -578,8 +578,8 @@ func (c *CoinbasePro) SubmitOrder(ctx context.Context, s *order.Submit) (order.S
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (c *CoinbasePro) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (c *CoinbasePro) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -679,8 +679,8 @@ func (c *COINUT) SubmitOrder(ctx context.Context, o *order.Submit) (order.Submit
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (c *COINUT) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (c *COINUT) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -500,8 +500,8 @@ func (e *EXMO) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitRe
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (e *EXMO) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (e *EXMO) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -682,9 +682,9 @@ func (f *FTX) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitRes
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error) {
if err := action.Validate(); err != nil {
return order.Modify{}, err
return nil, err
}
if action.TriggerPrice != 0 {
@@ -696,14 +696,13 @@ func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modi
action.Price,
0)
if err != nil {
return order.Modify{}, err
return nil, err
}
return order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: strconv.FormatInt(a.ID, 10),
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: strconv.FormatInt(a.ID, 10),
Price: action.Price,
Amount: action.Amount,
TriggerPrice: action.TriggerPrice,
@@ -719,7 +718,7 @@ func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modi
action.Price,
action.Amount)
if err != nil {
return order.Modify{}, err
return nil, err
}
} else {
o, err = f.ModifyPlacedOrder(ctx,
@@ -728,17 +727,16 @@ func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modi
action.Price,
action.Amount)
if err != nil {
return order.Modify{}, err
return nil, err
}
}
return order.Modify{
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: strconv.FormatInt(o.ID, 10),
Price: action.Price,
Amount: action.Amount,
Price: action.Price,
Amount: action.Amount,
}, err
}

View File

@@ -544,8 +544,8 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submit
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (g *Gateio) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (g *Gateio) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -573,8 +573,8 @@ func (g *Gemini) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submit
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (g *Gemini) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (g *Gemini) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -602,8 +602,8 @@ func (h *HitBTC) SubmitOrder(ctx context.Context, o *order.Submit) (order.Submit
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (h *HitBTC) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (h *HitBTC) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -999,8 +999,8 @@ func (h *HUOBI) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitR
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (h *HUOBI) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (h *HUOBI) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -52,17 +52,13 @@ type IBotExchange interface {
FormatWithdrawPermissions() string
SupportsWithdrawPermissions(permissions uint32) bool
GetFundingHistory(ctx context.Context) ([]FundHistory, error)
SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitResponse, error)
ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error)
CancelOrder(ctx context.Context, o *order.Cancel) error
CancelBatchOrders(ctx context.Context, o []order.Cancel) (order.CancelBatchResponse, error)
CancelAllOrders(ctx context.Context, orders *order.Cancel) (order.CancelAllResponse, error)
GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error)
OrderManagement
GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, accountID, chain string) (*deposit.Address, error)
GetAvailableTransferChains(ctx context.Context, cryptocurrency currency.Code) ([]string, error)
GetOrderHistory(ctx context.Context, getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)
GetWithdrawalsHistory(ctx context.Context, code currency.Code) ([]WithdrawalHistory, error)
GetActiveOrders(ctx context.Context, getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)
WithdrawCryptocurrencyFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)
WithdrawFiatFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)
WithdrawFiatFundsToInternationalBank(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)
@@ -101,6 +97,18 @@ type IBotExchange interface {
AccountManagement
}
// OrderManagement defines functionality for order management
type OrderManagement interface {
SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitResponse, error)
ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error)
CancelOrder(ctx context.Context, o *order.Cancel) error
CancelBatchOrders(ctx context.Context, o []order.Cancel) (order.CancelBatchResponse, error)
CancelAllOrders(ctx context.Context, orders *order.Cancel) (order.CancelAllResponse, error)
GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error)
GetActiveOrders(ctx context.Context, getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)
GetOrderHistory(ctx context.Context, getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)
}
// CurrencyStateManagement defines functionality for currency state management
type CurrencyStateManagement interface {
GetCurrencyStateSnapshot() ([]currencystate.Snapshot, error)

View File

@@ -431,8 +431,8 @@ func (i *ItBit) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitR
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (i *ItBit) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (i *ItBit) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -786,8 +786,8 @@ func (k *Kraken) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submit
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (k *Kraken) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (k *Kraken) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -485,8 +485,8 @@ func (l *Lbank) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitR
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (l *Lbank) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (l *Lbank) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -445,8 +445,8 @@ func (l *LocalBitcoins) SubmitOrder(ctx context.Context, s *order.Submit) (order
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (l *LocalBitcoins) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (l *LocalBitcoins) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -316,8 +316,8 @@ func (o *OKGroup) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submi
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (o *OKGroup) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (o *OKGroup) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -812,6 +812,9 @@ var stringsToOrderStatus = []struct {
{"cLosEd", Closed, nil},
{"cancellinG", Cancelling, nil},
{"woahMan", UnknownStatus, errUnrecognisedOrderStatus},
{"PLAcED", New, nil},
{"ACCePTED", New, nil},
{"FAILeD", Rejected, nil},
}
func TestStringToOrderStatus(t *testing.T) {

View File

@@ -919,7 +919,7 @@ func StringToOrderStatus(status string) (Status, error) {
switch status {
case AnyStatus.String():
return AnyStatus, nil
case New.String(), "PLACED":
case New.String(), "PLACED", "ACCEPTED":
return New, nil
case Active.String(), "STATUS_ACTIVE":
return Active, nil
@@ -937,7 +937,7 @@ func StringToOrderStatus(status string) (Status, error) {
return Cancelled, nil
case PendingCancel.String(), "PENDING CANCEL", "PENDING CANCELLATION":
return PendingCancel, nil
case Rejected.String():
case Rejected.String(), "FAILED":
return Rejected, nil
case Expired.String():
return Expired, nil

View File

@@ -567,14 +567,14 @@ func (p *Poloniex) SubmitOrder(ctx context.Context, s *order.Submit) (order.Subm
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (p *Poloniex) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
func (p *Poloniex) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error) {
if err := action.Validate(); err != nil {
return order.Modify{}, err
return nil, err
}
oID, err := strconv.ParseInt(action.ID, 10, 64)
if err != nil {
return order.Modify{}, err
return nil, err
}
resp, err := p.MoveOrder(ctx,
@@ -584,15 +584,14 @@ func (p *Poloniex) ModifyOrder(ctx context.Context, action *order.Modify) (order
action.PostOnly,
action.ImmediateOrCancel)
if err != nil {
return order.Modify{}, err
return nil, err
}
return order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: strconv.FormatInt(resp.OrderNumber, 10),
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: strconv.FormatInt(resp.OrderNumber, 10),
Price: action.Price,
Amount: action.Amount,
PostOnly: action.PostOnly,

View File

@@ -150,8 +150,8 @@ func (c *CustomEx) SubmitOrder(ctx context.Context, s *order.Submit) (order.Subm
return order.SubmitResponse{}, nil
}
func (c *CustomEx) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, nil
func (c *CustomEx) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, nil
}
func (c *CustomEx) CancelOrder(ctx context.Context, o *order.Cancel) error {

View File

@@ -439,8 +439,8 @@ func (y *Yobit) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitR
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (y *Yobit) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (y *Yobit) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number

View File

@@ -528,8 +528,8 @@ func (z *ZB) SubmitOrder(ctx context.Context, o *order.Submit) (order.SubmitResp
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (z *ZB) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error) {
return order.Modify{}, common.ErrFunctionNotSupported
func (z *ZB) ModifyOrder(_ context.Context, _ *order.Modify) (*order.Modify, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number