Engine improvements

This commit is contained in:
Adrian Gallagher
2019-06-10 20:02:09 +10:00
parent 04c7c4895f
commit f777e68716
88 changed files with 2037 additions and 1413 deletions

View File

@@ -306,13 +306,19 @@ func TestSubmitOrder(t *testing.T) {
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 := e.SubmitOrder(p, exchange.BuyOrderSide,
exchange.LimitOrderType, 1, 10, "1234234")
response, err := e.SubmitOrder(orderSubmission)
if areTestAPIKeysSet() && (err != nil || !response.IsOrderPlaced) {
t.Errorf("Order failed to be placed: %v", err)
} else if !areTestAPIKeysSet() && err == nil {

View File

@@ -298,24 +298,29 @@ func (e *EXMO) GetExchangeHistory(p currency.Pair, assetType assets.AssetType) (
}
// SubmitOrder submits a new order
func (e *EXMO) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
func (e *EXMO) SubmitOrder(order *exchange.OrderSubmission) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var oT string
if order == nil {
return submitOrderResponse, exchange.ErrOrderSubmissionIsNil
}
switch orderType {
if err := order.Validate(); err != nil {
return submitOrderResponse, err
}
var oT string
switch order.OrderType {
case exchange.LimitOrderType:
return submitOrderResponse, errors.New("unsupported order type")
case exchange.MarketOrderType:
oT = "market_buy"
if side == exchange.SellOrderSide {
if order.OrderSide == exchange.SellOrderSide {
oT = "market_sell"
}
default:
return submitOrderResponse, errors.New("unsupported order type")
}
response, err := e.CreateOrder(p.String(), oT, price, amount)
response, err := e.CreateOrder(order.Pair.String(), oT, order.Price,
order.Amount)
if response > 0 {
submitOrderResponse.OrderID = fmt.Sprintf("%v", response)
}