mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-02 07:26:53 +00:00
Implementation of Exchange GetOrder through GRPC for Coinbase (#453)
* fix 440: SubmitOrder and CB-ACCESS-TIMESTAMP value * removed gctcli executable and added it to gitignore * implemented GetOrderInfo * getOrder also has trades attached to an order * getOrder also has trades attached to an order * fix 440: SubmitOrder and CB-ACCESS-TIMESTAMP value * removed gctcli executable and added it to gitignore * fix 440: SubmitOrder and CB-ACCESS-TIMESTAMP value * removed gctcli executable and added it to gitignore * minor * go lint fixes * removed clutter * fixed Amount, Executed Amount, Remaining Amount * removed default value declarations * removed useless nil chceck * iteration rewritten go style from java style * returning error if GetFills fails * returning error if GetOrderInfo fails * ExecutedAmont value is FilledSize * added TODO to fix asset type * chnages after merging #446 * range without copy value, using index * removed useless slice initialisation * couple of nits from code review * fix indentation * Update rpc.proto Fixes indentation Co-authored-by: Adrian Gallagher <thrasher@addictionsoftware.com>
This commit is contained in:
@@ -749,7 +749,43 @@ func (s *RPCServer) GetOrders(ctx context.Context, r *gctrpc.GetOrdersRequest) (
|
||||
|
||||
// GetOrder returns order information based on exchange and order ID
|
||||
func (s *RPCServer) GetOrder(ctx context.Context, r *gctrpc.GetOrderRequest) (*gctrpc.OrderDetails, error) {
|
||||
return &gctrpc.OrderDetails{}, common.ErrNotYetImplemented
|
||||
exch := GetExchangeByName(r.Exchange)
|
||||
if exch == nil {
|
||||
return nil, errors.New("exchange is not loaded/doesn't exist")
|
||||
}
|
||||
result, err := exch.GetOrderInfo(r.OrderId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error whilst trying to retrieve info for order %s: %s", r.OrderId, err)
|
||||
}
|
||||
var trades []*gctrpc.TradeHistory
|
||||
for i := range result.Trades {
|
||||
trades = append(trades, &gctrpc.TradeHistory{
|
||||
CreationTime: result.Trades[i].Timestamp.Unix(),
|
||||
Id: result.Trades[i].TID,
|
||||
Price: result.Trades[i].Price,
|
||||
Amount: result.Trades[i].Amount,
|
||||
Exchange: result.Trades[i].Exchange,
|
||||
AssetType: result.Trades[i].Type.String(),
|
||||
OrderSide: result.Trades[i].Side.String(),
|
||||
Fee: result.Trades[i].Fee,
|
||||
})
|
||||
}
|
||||
return &gctrpc.OrderDetails{
|
||||
Exchange: result.Exchange,
|
||||
Id: result.ID,
|
||||
BaseCurrency: result.Pair.Base.String(),
|
||||
QuoteCurrency: result.Pair.Quote.String(),
|
||||
AssetType: result.AssetType.String(),
|
||||
OrderSide: result.Side.String(),
|
||||
OrderType: result.Type.String(),
|
||||
CreationTime: result.Date.Unix(),
|
||||
Status: result.Status.String(),
|
||||
Price: result.Price,
|
||||
Amount: result.Amount,
|
||||
OpenVolume: result.RemainingAmount,
|
||||
Fee: result.Fee,
|
||||
Trades: trades,
|
||||
}, err
|
||||
}
|
||||
|
||||
// SubmitOrder submits an order specified by exchange, currency pair and asset
|
||||
|
||||
Reference in New Issue
Block a user