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

@@ -312,13 +312,19 @@ func TestSubmitOrder(t *testing.T) {
t.Skip()
}
var p = currency.Pair{
Delimiter: "_",
Base: currency.LTC,
Quote: currency.BTC,
var orderSubmission = &exchange.OrderSubmission{
Pair: currency.Pair{
Delimiter: "_",
Base: currency.LTC,
Quote: currency.BTC,
},
OrderSide: exchange.BuyOrderSide,
OrderType: exchange.LimitOrderType,
Price: 1,
Amount: 1,
ClientID: "meowOrder",
}
response, err := g.SubmitOrder(p, exchange.BuyOrderSide,
exchange.LimitOrderType, 1, 10, "1234234")
response, err := g.SubmitOrder(orderSubmission)
if areTestAPIKeysSet() && (err != nil || !response.IsOrderPlaced) {
t.Errorf("Order failed to be placed: %v", err)
} else if !areTestAPIKeysSet() && err == nil {

View File

@@ -318,25 +318,31 @@ func (g *Gateio) GetExchangeHistory(p currency.Pair, assetType assets.AssetType)
// SubmitOrder submits a new order
// TODO: support multiple order types (IOC)
func (g *Gateio) SubmitOrder(p currency.Pair, side exchange.OrderSide, _ exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
func (g *Gateio) SubmitOrder(order *exchange.OrderSubmission) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var orderTypeFormat string
if order == nil {
return submitOrderResponse, exchange.ErrOrderSubmissionIsNil
}
if side == exchange.BuyOrderSide {
if err := order.Validate(); err != nil {
return submitOrderResponse, err
}
var orderTypeFormat string
if order.OrderSide == exchange.BuyOrderSide {
orderTypeFormat = exchange.BuyOrderSide.ToLower().ToString()
} else {
orderTypeFormat = exchange.SellOrderSide.ToLower().ToString()
}
var spotNewOrderRequestParams = SpotNewOrderRequestParams{
Amount: amount,
Price: price,
Symbol: p.String(),
Amount: order.Amount,
Price: order.Price,
Symbol: order.Pair.String(),
Type: orderTypeFormat,
}
response, err := g.SpotNewOrder(spotNewOrderRequestParams)
if response.OrderNumber > 0 {
submitOrderResponse.OrderID = fmt.Sprintf("%v", response.OrderNumber)
}