orders: Add derive modify struct method from order.Detail (#948)

* orders: Add derive modify struct method to order.Detail and then subsequent method to derive and standardize response details

* exchanges: call modify method in wrappers

* linter: fixes

* engine/wsroutineman: remove print summary

* glorious: nits, removed modifyOrder functionality for Bithumb. There are not docs to support this.

* Update exchanges/order/orders.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2022-05-30 14:38:21 +10:00
committed by GitHub
parent 293d6104ed
commit a63aa6b616
42 changed files with 298 additions and 427 deletions

View File

@@ -313,7 +313,7 @@ func (b *Bitmex) wsHandleData(respRaw []byte) error {
Err: err,
}
}
b.Websocket.DataHandler <- &order.Modify{
b.Websocket.DataHandler <- &order.Detail{
Exchange: b.Name,
ID: response.Data[i].OrderID,
AccountID: strconv.FormatInt(response.Data[i].Account, 10),
@@ -424,7 +424,7 @@ func (b *Bitmex) wsHandleData(respRaw []byte) error {
Err: err,
}
}
b.Websocket.DataHandler <- &order.Modify{
b.Websocket.DataHandler <- &order.Detail{
Price: response.Data[x].Price,
Amount: response.Data[x].OrderQuantity,
Exchange: b.Name,

View File

@@ -609,34 +609,32 @@ func (b *Bitmex) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submit
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Bitmex) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error) {
func (b *Bitmex) ModifyOrder(ctx context.Context, action *order.Modify) (*order.ModifyResponse, error) {
if err := action.Validate(); err != nil {
return nil, err
}
var params OrderAmendParams
if math.Mod(action.Amount, 1) != 0 {
return nil, errors.New("contract amount can not have decimals")
}
params.OrderID = action.ID
params.OrderQty = int32(action.Amount)
params.Price = action.Price
o, err := b.AmendOrder(ctx, &params)
o, err := b.AmendOrder(ctx, &OrderAmendParams{
OrderID: action.ID,
OrderQty: int32(action.Amount),
Price: action.Price})
if err != nil {
return nil, err
}
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: o.OrderID,
Price: action.Price,
Amount: float64(params.OrderQty),
}, nil
resp, err := action.DeriveModifyResponse()
if err != nil {
return nil, err
}
resp.OrderID = o.OrderID
resp.RemainingAmount = o.OrderQty
resp.LastUpdated = o.TransactTime
return resp, nil
}
// CancelOrder cancels an order by its corresponding ID number