mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-21 15:10:12 +00:00
Wrapper update modify order (#222)
* Changed IBotExchange interface ModifyOrder function paramater and return value to exchange type for easier addition or retraction of variables. * Function ModifyOrder for Binance not supported via API * Change to unsupported function for exchange ZB * Change to unsupported function for exchange Yobit * Add modify order support for Poloniex * Change to unsupported function for exchange Okex * Change to unsupported function for exchange Localbitcoins * Change to unsupported function for exchange Liqui * Change to unsupported function for exchange LakeBTC * Change to unsupported function for exchange Kraken * Change to unsupported function for exchange Itbit * Change to unsupported function for exchange HuobiHadax * Change to unsupported function for exchange Huobi * Change to unsupported function for exchange HitBTC * Change to unsupported function for exchange Gemini * Change to unsupported function for exchange GateIO * Change to unsupported function for exchange Exmo * Change to unsupported function for exchange Coinut * Change to unsupported function for exchange Coinbase * Change to unsupported function for exchange BTCMarkets * Change to unsupported function for exchange Bittrex * Change to unsupported function for exchange Bitstamp * Add modify order support for Bitmex * Add verbose header information in request package * Add modify order support for Bithumb exchange * Change to unsupported function for exchange Bitflyer * Change to unsupported function for exchange Bitfinex * Change to unsupported function for exchange ANX * Change interface function signature * Rm redundant code for authenticated requests in Bithumb * Add error check if decimal values supplied for create or modifying an order on Bitmex * Added test functions across the exchanges * Rm comment for modify order on Alphapoint exchange * Update tmpl file for exchange wrapper
This commit is contained in:
committed by
Adrian Gallagher
parent
2993ae17cf
commit
7c3134f35b
@@ -577,3 +577,13 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
a := &Alphapoint{}
|
||||
a.SetDefaults()
|
||||
|
||||
_, err := a.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,9 +125,8 @@ func (a *Alphapoint) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, o
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (a *Alphapoint) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
// return a.ModifyExistingOrder(p.Pair().String(), orderID, action)
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (a *Alphapoint) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -326,3 +326,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := a.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,8 +257,8 @@ func (a *ANX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderTyp
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (a *ANX) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (a *ANX) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -430,3 +430,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
t.Error("test failed - GetAccountInfo() error:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,15 @@ func (b *Binance) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the OKEX wrapper
|
||||
func (b *Binance) Run() {
|
||||
if b.Verbose {
|
||||
log.Printf("%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.Websocket.GetWebsocketURL())
|
||||
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
|
||||
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
|
||||
log.Printf("%s Websocket: %s. (url: %s).\n%s polling delay: %ds.\n%s %d currencies enabled: %s.\n",
|
||||
b.GetName(),
|
||||
common.IsEnabled(b.Websocket.IsEnabled()),
|
||||
b.Websocket.GetWebsocketURL(),
|
||||
b.GetName(),
|
||||
b.RESTPollingDelay,
|
||||
b.GetName(),
|
||||
len(b.EnabledPairs),
|
||||
b.EnabledPairs)
|
||||
}
|
||||
|
||||
symbols, err := b.GetExchangeValidCurrencyPairs()
|
||||
@@ -60,7 +66,6 @@ func (b *Binance) Run() {
|
||||
// UpdateTicker updates and returns the ticker for a currency pair
|
||||
func (b *Binance) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error) {
|
||||
var tickerPrice ticker.Price
|
||||
|
||||
tick, err := b.GetTickers()
|
||||
if err != nil {
|
||||
return tickerPrice, err
|
||||
@@ -154,7 +159,6 @@ func (b *Binance) GetAccountInfo() (exchange.AccountInfo, error) {
|
||||
|
||||
info.ExchangeName = b.GetName()
|
||||
info.Currencies = currencyBalance
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
@@ -168,7 +172,6 @@ func (b *Binance) GetFundingHistory() ([]exchange.FundHistory, error) {
|
||||
// GetExchangeHistory returns historic trade data since exchange opening.
|
||||
func (b *Binance) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) {
|
||||
var resp []exchange.TradeHistory
|
||||
|
||||
return resp, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
@@ -216,19 +219,20 @@ func (b *Binance) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orde
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *Binance) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (b *Binance) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
func (b *Binance) CancelOrder(order exchange.OrderCancellation) error {
|
||||
orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = b.CancelExistingOrder(exchange.FormatExchangeCurrency(b.Name, order.CurrencyPair).String(), orderIDInt, order.AccountID)
|
||||
_, err = b.CancelExistingOrder(exchange.FormatExchangeCurrency(b.Name, order.CurrencyPair).String(),
|
||||
orderIDInt,
|
||||
order.AccountID)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -806,3 +806,10 @@ func TestCancelAllExchangeOrdera(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,8 +198,8 @@ func (b *Bitfinex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, ord
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *Bitfinex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (b *Bitfinex) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -334,3 +334,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@ func (b *Bitflyer) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, ord
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *Bitflyer) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (b *Bitflyer) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -2,6 +2,7 @@ package bithumb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -247,15 +248,8 @@ func (b *Bithumb) GetAccountInformation(currency string) (Account, error) {
|
||||
val.Set("currency", currency)
|
||||
}
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateAccInfo, val, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateAccInfo, val, &response)
|
||||
}
|
||||
|
||||
// GetAccountBalance returns customer wallet information
|
||||
@@ -279,10 +273,6 @@ func (b *Bithumb) GetAccountBalance(c string) (FullBalance, error) {
|
||||
return fullBalance, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return fullBalance, errors.New(response.Message)
|
||||
}
|
||||
|
||||
// Added due to increasing of the usuable currencies on exchange, usually
|
||||
// without notificatation, so we dont need to update structs later on
|
||||
for tag, datum := range response.Data {
|
||||
@@ -331,30 +321,16 @@ func (b *Bithumb) GetWalletAddress(currency string) (WalletAddressRes, error) {
|
||||
params := url.Values{}
|
||||
params.Set("currency", common.StringToUpper(currency))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateWalletAdd, params, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateWalletAdd, params, &response)
|
||||
}
|
||||
|
||||
// GetLastTransaction returns customer last transaction
|
||||
func (b *Bithumb) GetLastTransaction() (LastTransactionTicker, error) {
|
||||
response := LastTransactionTicker{}
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateTicker, nil, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateTicker, nil, &response)
|
||||
}
|
||||
|
||||
// GetOrders returns order list
|
||||
@@ -374,30 +350,16 @@ func (b *Bithumb) GetOrders(orderID, transactionType, count, after, currency str
|
||||
params.Set("after", after)
|
||||
params.Set("currency", common.StringToUpper(currency))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateOrders, params, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateOrders, params, &response)
|
||||
}
|
||||
|
||||
// GetUserTransactions returns customer transactions
|
||||
func (b *Bithumb) GetUserTransactions() (UserTransactions, error) {
|
||||
response := UserTransactions{}
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateUserTrans, nil, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateUserTrans, nil, &response)
|
||||
}
|
||||
|
||||
// PlaceTrade executes a trade order
|
||||
@@ -417,15 +379,24 @@ func (b *Bithumb) PlaceTrade(orderCurrency, transactionType string, units float6
|
||||
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
|
||||
params.Set("price", strconv.FormatInt(price, 10))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privatePlaceTrade, params, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privatePlaceTrade, params, &response)
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
// ModifyTrade modifies an order already on the exchange books
|
||||
func (b *Bithumb) ModifyTrade(orderID, orderCurrency, transactionType string, units float64, price int64) (OrderPlace, error) {
|
||||
response := OrderPlace{}
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("order_currency", common.StringToUpper(orderCurrency))
|
||||
params.Set("Payment_currency", "KRW")
|
||||
params.Set("type", common.StringToUpper(transactionType))
|
||||
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
|
||||
params.Set("price", strconv.FormatInt(price, 10))
|
||||
params.Set("order_id", orderID)
|
||||
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privatePlaceTrade, params, &response)
|
||||
}
|
||||
|
||||
// GetOrderDetails returns specific order details
|
||||
@@ -442,15 +413,8 @@ func (b *Bithumb) GetOrderDetails(orderID, transactionType, currency string) (Or
|
||||
params.Set("type", common.StringToUpper(transactionType))
|
||||
params.Set("currency", common.StringToUpper(currency))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateOrderDetail, params, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateOrderDetail, params, &response)
|
||||
}
|
||||
|
||||
// CancelTrade cancels a customer purchase/sales transaction
|
||||
@@ -466,15 +430,8 @@ func (b *Bithumb) CancelTrade(transactionType, orderID, currency string) (Action
|
||||
params.Set("type", common.StringToUpper(transactionType))
|
||||
params.Set("currency", common.StringToUpper(currency))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateCancelTrade, nil, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateCancelTrade, nil, &response)
|
||||
}
|
||||
|
||||
// WithdrawCrypto withdraws a customer currency to an address
|
||||
@@ -494,15 +451,8 @@ func (b *Bithumb) WithdrawCrypto(address, destination, currency string, units fl
|
||||
params.Set("currency", common.StringToUpper(currency))
|
||||
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateBTCWithdraw, params, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateBTCWithdraw, params, &response)
|
||||
}
|
||||
|
||||
// RequestKRWDepositDetails returns Bithumb banking details for deposit
|
||||
@@ -510,15 +460,8 @@ func (b *Bithumb) WithdrawCrypto(address, destination, currency string, units fl
|
||||
func (b *Bithumb) RequestKRWDepositDetails() (KRWDeposit, error) {
|
||||
response := KRWDeposit{}
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateKRWDeposit, nil, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateKRWDeposit, nil, &response)
|
||||
}
|
||||
|
||||
// RequestKRWWithdraw allows a customer KRW withdrawal request
|
||||
@@ -534,15 +477,8 @@ func (b *Bithumb) RequestKRWWithdraw(bank, account string, price int64) (ActionS
|
||||
params.Set("account", account)
|
||||
params.Set("price", strconv.FormatInt(price, 10))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateKRWWithdraw, params, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateKRWWithdraw, params, &response)
|
||||
}
|
||||
|
||||
// MarketBuyOrder initiates a buy order through available order books
|
||||
@@ -557,15 +493,8 @@ func (b *Bithumb) MarketBuyOrder(currency string, units float64) (MarketBuy, err
|
||||
params.Set("currency", common.StringToUpper(currency))
|
||||
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateMarketBuy, params, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateMarketBuy, params, &response)
|
||||
}
|
||||
|
||||
// MarketSellOrder initiates a sell order through available order books
|
||||
@@ -580,15 +509,8 @@ func (b *Bithumb) MarketSellOrder(currency string, units float64) (MarketSell, e
|
||||
params.Set("currency", common.StringToUpper(currency))
|
||||
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequest(privateMarketSell, params, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return response, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
return response,
|
||||
b.SendAuthenticatedHTTPRequest(privateMarketSell, params, &response)
|
||||
}
|
||||
|
||||
// SendHTTPRequest sends an unauthenticated HTTP request
|
||||
@@ -615,7 +537,9 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(path string, params url.Values, r
|
||||
params.Set("endpoint", path)
|
||||
payload := params.Encode()
|
||||
hmacPayload := path + string(0) + payload + string(0) + b.Nonce.String()
|
||||
hmac := common.GetHMAC(common.HashSHA512, []byte(hmacPayload), []byte(b.APISecret))
|
||||
hmac := common.GetHMAC(common.HashSHA512,
|
||||
[]byte(hmacPayload),
|
||||
[]byte(b.APISecret))
|
||||
hmacStr := common.HexEncodeToString(hmac)
|
||||
|
||||
headers := make(map[string]string)
|
||||
@@ -624,7 +548,34 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(path string, params url.Values, r
|
||||
headers["Api-Nonce"] = b.Nonce.String()
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
|
||||
return b.SendPayload("POST", b.APIUrl+path, headers, bytes.NewBufferString(payload), result, true, b.Verbose)
|
||||
var intermediary json.RawMessage
|
||||
|
||||
errCapture := struct {
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
}{}
|
||||
|
||||
err := b.SendPayload("POST",
|
||||
b.APIUrl+path,
|
||||
headers,
|
||||
bytes.NewBufferString(payload),
|
||||
&intermediary,
|
||||
true,
|
||||
b.Verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = common.JSONDecode(intermediary, &errCapture)
|
||||
if err == nil {
|
||||
if errCapture.Status != "" && errCapture.Status != "0000" {
|
||||
return fmt.Errorf("SendAuthenticatedHTTPRequest error Code:%s Message:%s",
|
||||
errCapture.Status,
|
||||
errCode[errCapture.Status])
|
||||
}
|
||||
}
|
||||
|
||||
return common.JSONDecode(intermediary, result)
|
||||
}
|
||||
|
||||
// GetFee returns an estimate of fee based on type of transaction
|
||||
@@ -692,3 +643,14 @@ func getDepositFee(currency string, amount float64) float64 {
|
||||
func getWithdrawalFee(currency string) float64 {
|
||||
return WithdrawalFees[currency]
|
||||
}
|
||||
|
||||
var errCode = map[string]string{
|
||||
"5100": "Bad Request",
|
||||
"5200": "Not Member",
|
||||
"5300": "Invalid Apikey",
|
||||
"5302": "Method Not Allowed",
|
||||
"5400": "Database Fail",
|
||||
"5500": "Invalid Parameter",
|
||||
"5600": "CUSTOM NOTICE (상황별 에러 메시지 출력) usually means transaction not allowed",
|
||||
"5900": "Unknown Error",
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
"github.com/thrasher-/gocryptotrader/currency/pair"
|
||||
"github.com/thrasher-/gocryptotrader/currency/symbol"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges"
|
||||
)
|
||||
|
||||
// Please supply your own keys here for due diligence testing
|
||||
@@ -389,3 +389,15 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
curr := pair.NewCurrencyPairFromString("BTCUSD")
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{OrderID: "1337",
|
||||
Price: 100,
|
||||
Amount: 1000,
|
||||
OrderSide: exchange.Sell,
|
||||
Currency: curr})
|
||||
if err == nil {
|
||||
t.Error("Test Failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,8 +189,18 @@ func (b *Bithumb) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orde
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *Bithumb) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (b *Bithumb) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
order, err := b.ModifyTrade(action.OrderID,
|
||||
action.Currency.FirstCurrency.String(),
|
||||
common.StringToLower(action.OrderSide.ToString()),
|
||||
action.Amount,
|
||||
int64(action.Price))
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return order.Data[0].ContID, nil
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -403,13 +403,13 @@ func (b *Bitmex) GetOrders(params GenericRequestParams) ([]Order, error) {
|
||||
}
|
||||
|
||||
// AmendOrder amends the quantity or price of an open order
|
||||
func (b *Bitmex) AmendOrder(params OrderAmendParams) ([]Order, error) {
|
||||
var orders []Order
|
||||
func (b *Bitmex) AmendOrder(params OrderAmendParams) (Order, error) {
|
||||
var order Order
|
||||
|
||||
return orders, b.SendAuthenticatedHTTPRequest("PUT",
|
||||
return order, b.SendAuthenticatedHTTPRequest("PUT",
|
||||
bitmexEndpointOrder,
|
||||
params,
|
||||
&orders)
|
||||
&order)
|
||||
}
|
||||
|
||||
// CreateOrder creates a new order
|
||||
|
||||
@@ -5,10 +5,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
"github.com/thrasher-/gocryptotrader/currency/pair"
|
||||
"github.com/thrasher-/gocryptotrader/currency/symbol"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
)
|
||||
|
||||
// Please supply your own keys here for due diligence testing
|
||||
@@ -565,3 +566,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{OrderID: "1337"})
|
||||
if err == nil {
|
||||
t.Error("Test Failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package bitmex
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"math"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -164,6 +165,12 @@ func (b *Bitmex) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]ex
|
||||
// SubmitOrder submits a new order
|
||||
func (b *Bitmex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
|
||||
var submitOrderResponse exchange.SubmitOrderResponse
|
||||
|
||||
if math.Mod(amount, 1) != 0 {
|
||||
return submitOrderResponse,
|
||||
errors.New("contract amount can not have decimals")
|
||||
}
|
||||
|
||||
var orderNewParams = OrderNewParams{
|
||||
OrdType: side.ToString(),
|
||||
Symbol: p.Pair().String(),
|
||||
@@ -189,8 +196,23 @@ func (b *Bitmex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, order
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *Bitmex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (b *Bitmex) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
var params OrderAmendParams
|
||||
|
||||
if math.Mod(action.Amount, 1) != 0 {
|
||||
return "", errors.New("contract amount can not have decimals")
|
||||
}
|
||||
|
||||
params.OrderID = action.OrderID
|
||||
params.OrderQty = int32(action.Amount)
|
||||
params.Price = action.Price
|
||||
|
||||
order, err := b.AmendOrder(params)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return order.OrderID, nil
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -455,3 +455,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,8 +186,8 @@ func (b *Bitstamp) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, ord
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *Bitstamp) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (b *Bitstamp) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -420,3 +420,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,8 +198,8 @@ func (b *Bittrex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orde
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *Bittrex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (b *Bittrex) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -258,3 +258,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ func (b *BTCC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderTy
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *BTCC) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (b *BTCC) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -153,13 +153,6 @@ func TestGetFundingHistory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(1337, exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCancelOrder(t *testing.T) {
|
||||
|
||||
_, err := b.CancelExistingOrder([]int64{1337})
|
||||
@@ -384,3 +377,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := b.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,8 +172,8 @@ func (b *BTCMarkets) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, o
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (b *BTCMarkets) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrFunctionNotSupported
|
||||
func (b *BTCMarkets) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -494,3 +494,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := c.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ func (c *CoinbasePro) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide,
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (c *CoinbasePro) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (c *CoinbasePro) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -294,3 +294,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := c.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,8 +259,8 @@ func (c *COINUT) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, order
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (c *COINUT) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (c *COINUT) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -262,7 +262,7 @@ type IBotExchange interface {
|
||||
|
||||
GetFundingHistory() ([]FundHistory, error)
|
||||
SubmitOrder(p pair.CurrencyPair, side OrderSide, orderType OrderType, amount, price float64, clientID string) (SubmitOrderResponse, error)
|
||||
ModifyOrder(orderID int64, modify ModifyOrder) (int64, error)
|
||||
ModifyOrder(action ModifyOrder) (string, error)
|
||||
CancelOrder(order OrderCancellation) error
|
||||
CancelAllOrders(orders OrderCancellation) (CancelAllOrdersResponse, error)
|
||||
GetOrderInfo(orderID int64) (OrderDetail, error)
|
||||
@@ -728,10 +728,24 @@ func (e *Base) UpdateCurrencies(exchangeProducts []string, enabled, force bool)
|
||||
|
||||
// ModifyOrder is a an order modifyer
|
||||
type ModifyOrder struct {
|
||||
OrderID string
|
||||
OrderType
|
||||
OrderSide
|
||||
Price float64
|
||||
Amount float64
|
||||
Price float64
|
||||
Amount float64
|
||||
LimitPriceUpper float64
|
||||
LimitPriceLower float64
|
||||
Currency pair.CurrencyPair
|
||||
|
||||
ImmediateOrCancel bool
|
||||
HiddenOrder bool
|
||||
FillOrKill bool
|
||||
PostOnly bool
|
||||
}
|
||||
|
||||
// ModifyOrderResponse is an order modifying return type
|
||||
type ModifyOrderResponse struct {
|
||||
OrderID string
|
||||
}
|
||||
|
||||
// Format holds exchange formatting
|
||||
@@ -754,8 +768,9 @@ type OrderType string
|
||||
|
||||
// OrderType ...types
|
||||
const (
|
||||
Limit OrderType = "Limit"
|
||||
Market OrderType = "Market"
|
||||
Limit OrderType = "Limit"
|
||||
Market OrderType = "Market"
|
||||
ImmediateOrCancel OrderType = "IMMEDIATE_OR_CANCEL"
|
||||
)
|
||||
|
||||
// ToString changes the ordertype to the exchange standard and returns a string
|
||||
|
||||
@@ -335,3 +335,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := e.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,8 +207,8 @@ func (e *EXMO) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderTy
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (e *EXMO) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (e *EXMO) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -351,3 +351,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := g.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,8 +214,8 @@ func (g *Gateio) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, order
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (g *Gateio) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (g *Gateio) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -411,3 +411,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := Session[1].ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,8 +146,8 @@ func (g *Gemini) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, order
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (g *Gemini) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (g *Gemini) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -262,3 +262,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := h.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +173,8 @@ func (h *HitBTC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, order
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (h *HitBTC) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (h *HitBTC) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -499,3 +499,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := h.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,8 +279,8 @@ func (h *HUOBI) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderT
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (h *HUOBI) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (h *HUOBI) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -478,3 +478,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := h.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,8 +244,8 @@ func (h *HUOBIHADAX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, o
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (h *HUOBIHADAX) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (h *HUOBIHADAX) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -340,3 +340,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := i.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,8 +201,8 @@ func (i *ItBit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderT
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (i *ItBit) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (i *ItBit) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -431,3 +431,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := k.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,8 +195,8 @@ func (k *Kraken) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, order
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (k *Kraken) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (k *Kraken) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -335,3 +335,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := l.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ func (l *LakeBTC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orde
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (l *LakeBTC) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (l *LakeBTC) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -320,3 +320,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := l.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +166,8 @@ func (l *Liqui) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderT
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (l *Liqui) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (l *Liqui) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -285,3 +285,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := l.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,8 +209,8 @@ func (l *LocalBitcoins) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (l *LocalBitcoins) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (l *LocalBitcoins) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -235,3 +235,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := o.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,8 +227,8 @@ func (o *OKCoin) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, order
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (o *OKCoin) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (o *OKCoin) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -498,3 +498,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := o.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,8 +228,8 @@ func (o *OKEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderTy
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (o *OKEX) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (o *OKEX) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -544,18 +544,37 @@ func (p *Poloniex) CancelExistingOrder(orderID int64) (bool, error) {
|
||||
}
|
||||
|
||||
// MoveOrder moves an order
|
||||
func (p *Poloniex) MoveOrder(orderID int64, rate, amount float64) (MoveOrderResponse, error) {
|
||||
func (p *Poloniex) MoveOrder(orderID int64, rate, amount float64, postOnly, immediateOrCancel bool) (MoveOrderResponse, error) {
|
||||
result := MoveOrderResponse{}
|
||||
values := url.Values{}
|
||||
|
||||
if orderID == 0 {
|
||||
return result, errors.New("OrderID cannot be zero")
|
||||
}
|
||||
|
||||
if rate == 0 {
|
||||
return result, errors.New("Rate cannot be zero")
|
||||
}
|
||||
|
||||
values.Set("orderNumber", strconv.FormatInt(orderID, 10))
|
||||
values.Set("rate", strconv.FormatFloat(rate, 'f', -1, 64))
|
||||
|
||||
if postOnly {
|
||||
values.Set("postOnly", "true")
|
||||
}
|
||||
|
||||
if immediateOrCancel {
|
||||
values.Set("immediateOrCancel", "true")
|
||||
}
|
||||
|
||||
if amount != 0 {
|
||||
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
|
||||
}
|
||||
|
||||
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOrderMove, values, &result)
|
||||
|
||||
err := p.SendAuthenticatedHTTPRequest("POST",
|
||||
poloniexOrderMove,
|
||||
values,
|
||||
&result)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
"github.com/thrasher-/gocryptotrader/currency/pair"
|
||||
"github.com/thrasher-/gocryptotrader/currency/symbol"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges"
|
||||
)
|
||||
|
||||
var p Poloniex
|
||||
@@ -280,3 +280,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := p.ModifyOrder(exchange.ModifyOrder{OrderID: "1337", Price: 1337})
|
||||
if err == nil {
|
||||
t.Error("Test Failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +175,22 @@ func (p *Poloniex) SubmitOrder(currencyPair pair.CurrencyPair, side exchange.Ord
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (p *Poloniex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (p *Poloniex) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
oID, err := strconv.ParseInt(action.OrderID, 10, 64)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
resp, err := p.MoveOrder(oID,
|
||||
action.Price,
|
||||
action.Amount,
|
||||
action.PostOnly,
|
||||
action.ImmediateOrCancel)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strconv.FormatInt(resp.OrderNumber, 10), nil
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -258,6 +258,10 @@ func (r *Requester) checkRequest(method, path string, body io.Reader, headers ma
|
||||
func (r *Requester) DoRequest(req *http.Request, method, path string, headers map[string]string, body io.Reader, result interface{}, authRequest, verbose bool) error {
|
||||
if verbose {
|
||||
log.Printf("%s exchange request path: %s requires rate limiter: %v", r.Name, path, r.RequiresRateLimiter())
|
||||
for k, d := range headers {
|
||||
log.Printf("%s exchange request header [%s]: %s", r.Name, k, d)
|
||||
}
|
||||
log.Println(body)
|
||||
}
|
||||
|
||||
var timeoutError error
|
||||
|
||||
@@ -419,3 +419,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := w.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,8 +176,8 @@ func (w *WEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderTyp
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (w *WEX) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (w *WEX) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -399,3 +399,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := y.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,8 +158,8 @@ func (y *Yobit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderT
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (y *Yobit) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (y *Yobit) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -330,3 +330,10 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := z.ModifyOrder(exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,8 +194,8 @@ func (z *ZB) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func (z *ZB) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func (z *ZB) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrFunctionNotSupported
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
@@ -127,8 +127,8 @@ func ({{.Variable}} *{{.CapitalName}}) SubmitOrder(p pair.CurrencyPair, side exc
|
||||
|
||||
// ModifyOrder will allow of changing orderbook placement and limit to
|
||||
// market conversion
|
||||
func ({{.Variable}} *{{.CapitalName}}) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
func ({{.Variable}} *{{.CapitalName}}) ModifyOrder(action exchange.ModifyOrder) (string, error) {
|
||||
return "", common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
|
||||
Reference in New Issue
Block a user