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

@@ -373,12 +373,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.LTC,
var orderSubmission = &exchange.OrderSubmission{
Pair: currency.Pair{
Delimiter: "-",
Base: currency.BTC,
Quote: currency.LTC,
},
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 {

View File

@@ -288,20 +288,30 @@ func (b *Bittrex) GetExchangeHistory(p currency.Pair, assetType assets.AssetType
}
// SubmitOrder submits a new order
func (b *Bittrex) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
func (b *Bittrex) SubmitOrder(order *exchange.OrderSubmission) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
buy := side == exchange.BuyOrderSide
if order == nil {
return submitOrderResponse, exchange.ErrOrderSubmissionIsNil
}
if err := order.Validate(); err != nil {
return submitOrderResponse, err
}
buy := order.OrderSide == exchange.BuyOrderSide
var response UUID
var err error
if orderType != exchange.LimitOrderType {
return submitOrderResponse, errors.New("not supported on exchange")
if order.OrderType != exchange.LimitOrderType {
return submitOrderResponse, errors.New("limit order not supported on exchange")
}
if buy {
response, err = b.PlaceBuyLimit(p.String(), amount, price)
response, err = b.PlaceBuyLimit(order.Pair.String(), order.Amount,
order.Price)
} else {
response, err = b.PlaceSellLimit(p.String(), amount, price)
response, err = b.PlaceSellLimit(order.Pair.String(), order.Amount,
order.Price)
}
if response.Result.ID != "" {