mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-02 07:26:53 +00:00
Engine improvements
This commit is contained in:
@@ -259,13 +259,20 @@ func TestSubmitOrder(t *testing.T) {
|
||||
if areTestAPIKeysSet() && !canManipulateRealOrders {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
var p = currency.Pair{
|
||||
Delimiter: "_",
|
||||
Base: currency.BTC,
|
||||
Quote: currency.USD,
|
||||
|
||||
var orderSubmission = &exchange.OrderSubmission{
|
||||
Pair: currency.Pair{
|
||||
Delimiter: "_",
|
||||
Base: currency.BTC,
|
||||
Quote: currency.USD,
|
||||
},
|
||||
OrderSide: exchange.BuyOrderSide,
|
||||
OrderType: exchange.LimitOrderType,
|
||||
Price: 1,
|
||||
Amount: 1,
|
||||
ClientID: "meowOrder",
|
||||
}
|
||||
response, err := a.SubmitOrder(p,
|
||||
exchange.BuyOrderSide, exchange.LimitOrderType, 1, 1, "clientId")
|
||||
response, err := a.SubmitOrder(orderSubmission)
|
||||
if areTestAPIKeysSet() && (err != nil || !response.IsOrderPlaced) {
|
||||
t.Errorf("Order failed to be placed: %v", err)
|
||||
} else if !areTestAPIKeysSet() && err == nil {
|
||||
|
||||
@@ -339,26 +339,33 @@ func (a *ANX) GetExchangeHistory(p currency.Pair, assetType assets.AssetType) ([
|
||||
}
|
||||
|
||||
// SubmitOrder submits a new order
|
||||
func (a *ANX) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
|
||||
func (a *ANX) SubmitOrder(order *exchange.OrderSubmission) (exchange.SubmitOrderResponse, error) {
|
||||
var submitOrderResponse exchange.SubmitOrderResponse
|
||||
if order == nil {
|
||||
return submitOrderResponse, exchange.ErrOrderSubmissionIsNil
|
||||
}
|
||||
|
||||
if err := order.Validate(); err != nil {
|
||||
return submitOrderResponse, err
|
||||
}
|
||||
|
||||
var isBuying bool
|
||||
var limitPriceInSettlementCurrency float64
|
||||
|
||||
if side == exchange.BuyOrderSide {
|
||||
if order.OrderSide == exchange.BuyOrderSide {
|
||||
isBuying = true
|
||||
}
|
||||
|
||||
if orderType == exchange.LimitOrderType {
|
||||
limitPriceInSettlementCurrency = price
|
||||
if order.OrderType == exchange.LimitOrderType {
|
||||
limitPriceInSettlementCurrency = order.Price
|
||||
}
|
||||
|
||||
response, err := a.NewOrder(orderType.ToString(),
|
||||
response, err := a.NewOrder(order.OrderType.ToString(),
|
||||
isBuying,
|
||||
p.Base.String(),
|
||||
amount,
|
||||
p.Quote.String(),
|
||||
amount,
|
||||
order.Pair.Base.String(),
|
||||
order.Amount,
|
||||
order.Pair.Quote.String(),
|
||||
order.Amount,
|
||||
limitPriceInSettlementCurrency,
|
||||
false,
|
||||
"",
|
||||
|
||||
Reference in New Issue
Block a user