mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 23:16:52 +00:00
Engine improvements
This commit is contained in:
@@ -516,12 +516,18 @@ func TestSubmitOrder(t *testing.T) {
|
||||
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
|
||||
}
|
||||
|
||||
var p = currency.Pair{
|
||||
Delimiter: "",
|
||||
Base: currency.XBT,
|
||||
Quote: currency.USD,
|
||||
var orderSubmission = &exchange.OrderSubmission{
|
||||
Pair: currency.Pair{
|
||||
Base: currency.XBT,
|
||||
Quote: currency.USD,
|
||||
},
|
||||
OrderSide: exchange.BuyOrderSide,
|
||||
OrderType: exchange.LimitOrderType,
|
||||
Price: 1,
|
||||
Amount: 1,
|
||||
ClientID: "meowOrder",
|
||||
}
|
||||
response, err := b.SubmitOrder(p, exchange.BuyOrderSide, exchange.LimitOrderType, 1, 1, "clientId")
|
||||
response, err := b.SubmitOrder(orderSubmission)
|
||||
if areTestAPIKeysSet() && (err != nil || !response.IsOrderPlaced) {
|
||||
t.Errorf("Order failed to be placed: %v", err)
|
||||
} else if !areTestAPIKeysSet() && err == nil {
|
||||
|
||||
@@ -343,23 +343,30 @@ func (b *Bitmex) GetExchangeHistory(p currency.Pair, assetType assets.AssetType)
|
||||
}
|
||||
|
||||
// SubmitOrder submits a new order
|
||||
func (b *Bitmex) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
|
||||
func (b *Bitmex) SubmitOrder(order *exchange.OrderSubmission) (exchange.SubmitOrderResponse, error) {
|
||||
var submitOrderResponse exchange.SubmitOrderResponse
|
||||
if order == nil {
|
||||
return submitOrderResponse, exchange.ErrOrderSubmissionIsNil
|
||||
}
|
||||
|
||||
if math.Mod(amount, 1) != 0 {
|
||||
if err := order.Validate(); err != nil {
|
||||
return submitOrderResponse, err
|
||||
}
|
||||
|
||||
if math.Mod(order.Amount, 1) != 0 {
|
||||
return submitOrderResponse,
|
||||
errors.New("contract amount can not have decimals")
|
||||
errors.New("order contract amount can not have decimals")
|
||||
}
|
||||
|
||||
var orderNewParams = OrderNewParams{
|
||||
OrdType: side.ToString(),
|
||||
Symbol: p.String(),
|
||||
OrderQty: amount,
|
||||
Side: side.ToString(),
|
||||
OrdType: order.OrderSide.ToString(),
|
||||
Symbol: order.Pair.String(),
|
||||
OrderQty: order.Amount,
|
||||
Side: order.OrderSide.ToString(),
|
||||
}
|
||||
|
||||
if orderType == exchange.LimitOrderType {
|
||||
orderNewParams.Price = price
|
||||
if order.OrderType == exchange.LimitOrderType {
|
||||
orderNewParams.Price = order.Price
|
||||
}
|
||||
|
||||
response, err := b.CreateOrder(&orderNewParams)
|
||||
|
||||
Reference in New Issue
Block a user