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

@@ -682,12 +682,16 @@ func (f *FTX) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitRes
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Modify, error) {
func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (*order.ModifyResponse, error) {
if err := action.Validate(); err != nil {
return nil, err
}
if action.TriggerPrice != 0 {
var id string
var remainingAmount float64
switch {
case action.TriggerPrice != 0:
var a TriggerOrderData
a, err := f.ModifyTriggerOrder(ctx,
action.ID,
action.Type.String(),
@@ -698,21 +702,10 @@ func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Mod
if err != nil {
return nil, err
}
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: strconv.FormatInt(a.ID, 10),
Price: action.Price,
Amount: action.Amount,
TriggerPrice: action.TriggerPrice,
Type: action.Type,
}, err
}
var o OrderData
var err error
if action.ID == "" {
o, err = f.ModifyOrderByClientID(ctx,
id = strconv.FormatInt(a.ID, 10)
remainingAmount = a.Size - a.FilledSize
case action.ID == "":
o, err := f.ModifyOrderByClientID(ctx,
action.ClientOrderID,
action.ClientOrderID,
action.Price,
@@ -720,8 +713,10 @@ func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Mod
if err != nil {
return nil, err
}
} else {
o, err = f.ModifyPlacedOrder(ctx,
id = strconv.FormatInt(o.ID, 10)
remainingAmount = o.RemainingSize
default:
o, err := f.ModifyPlacedOrder(ctx,
action.ID,
action.ClientOrderID,
action.Price,
@@ -729,15 +724,16 @@ func (f *FTX) ModifyOrder(ctx context.Context, action *order.Modify) (*order.Mod
if err != nil {
return nil, err
}
id = strconv.FormatInt(o.ID, 10)
remainingAmount = o.RemainingSize
}
return &order.Modify{
Exchange: action.Exchange,
AssetType: action.AssetType,
Pair: action.Pair,
ID: strconv.FormatInt(o.ID, 10),
Price: action.Price,
Amount: action.Amount,
}, err
resp, err := action.DeriveModifyResponse()
if err != nil {
return nil, err
}
resp.OrderID = id
resp.RemainingAmount = remainingAmount
return resp, nil
}
// CancelOrder cancels an order by its corresponding ID number