mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-23 23:16:49 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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, ¶ms)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user