mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +00:00
kucoin: implement QueryTrades
This commit is contained in:
parent
8c03147ff4
commit
e3181202db
|
@ -213,3 +213,23 @@ func toGlobalOrder(o kucoinapi.Order) types.Order {
|
||||||
}
|
}
|
||||||
return order
|
return order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func toGlobalTrade(fill kucoinapi.Fill) types.Trade {
|
||||||
|
var trade = types.Trade{
|
||||||
|
ID: hashStringID(fill.TradeId),
|
||||||
|
OrderID: hashStringID(fill.OrderId),
|
||||||
|
Exchange: types.ExchangeKucoin,
|
||||||
|
Price: fill.Price.Float64(),
|
||||||
|
Quantity: fill.Size.Float64(),
|
||||||
|
QuoteQuantity: fill.Funds.Float64(),
|
||||||
|
Symbol: toGlobalSymbol(fill.Symbol),
|
||||||
|
Side: toGlobalSide(string(fill.Side)),
|
||||||
|
IsBuyer: fill.Side == kucoinapi.SideTypeBuy,
|
||||||
|
IsMaker: fill.Liquidity == kucoinapi.LiquidityTypeMaker,
|
||||||
|
Time: types.Time{},
|
||||||
|
Fee: fill.Fee.Float64(),
|
||||||
|
FeeCurrency: toGlobalSymbol(fill.FeeCurrency),
|
||||||
|
}
|
||||||
|
return trade
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ type Exchange struct {
|
||||||
client *kucoinapi.RestClient
|
client *kucoinapi.RestClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func New(key, secret, passphrase string) *Exchange {
|
func New(key, secret, passphrase string) *Exchange {
|
||||||
client := kucoinapi.NewClient()
|
client := kucoinapi.NewClient()
|
||||||
|
|
||||||
|
@ -247,10 +246,26 @@ func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since,
|
||||||
return orders, err
|
return orders, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) ([]types.Trade, error) {
|
func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) (trades []types.Trade, err error) {
|
||||||
panic("implement me")
|
req := e.client.TradeService.NewGetFillsRequest()
|
||||||
}
|
req.Symbol(toLocalSymbol(symbol))
|
||||||
|
if options.StartTime != nil {
|
||||||
|
req.StartAt(*options.StartTime)
|
||||||
|
} else if options.EndTime != nil {
|
||||||
|
req.EndAt(*options.EndTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := req.Do(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return trades, err
|
||||||
|
}
|
||||||
|
for _, fill := range response.Items {
|
||||||
|
trade := toGlobalTrade(fill)
|
||||||
|
trades = append(trades, trade)
|
||||||
|
}
|
||||||
|
|
||||||
|
return trades, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (errs error) {
|
func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (errs error) {
|
||||||
for _, o := range orders {
|
for _, o := range orders {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user