mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
pkg/exchange: make the CTime and UTime to qualified name
This commit is contained in:
parent
4f94f7acc0
commit
cf527a6f05
|
@ -51,8 +51,8 @@ type OrderDetail struct {
|
||||||
// The value is json string, so we unmarshal it after unmarshal OrderDetail
|
// The value is json string, so we unmarshal it after unmarshal OrderDetail
|
||||||
FeeDetailRaw string `json:"feeDetail"`
|
FeeDetailRaw string `json:"feeDetail"`
|
||||||
OrderSource string `json:"orderSource"`
|
OrderSource string `json:"orderSource"`
|
||||||
CTime types.MillisecondTimestamp `json:"cTime"`
|
CreatedTime types.MillisecondTimestamp `json:"cTime"`
|
||||||
UTime types.MillisecondTimestamp `json:"uTime"`
|
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
|
||||||
|
|
||||||
FeeDetail FeeDetail
|
FeeDetail FeeDetail
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,8 @@ func TestOrderDetail_UnmarshalJSON(t *testing.T) {
|
||||||
EnterPointSource: "API",
|
EnterPointSource: "API",
|
||||||
FeeDetailRaw: "",
|
FeeDetailRaw: "",
|
||||||
OrderSource: "normal",
|
OrderSource: "normal",
|
||||||
CTime: types.NewMillisecondTimestampFromInt(1699021576683),
|
CreatedTime: types.NewMillisecondTimestampFromInt(1699021576683),
|
||||||
UTime: types.NewMillisecondTimestampFromInt(1699021649099),
|
UpdatedTime: types.NewMillisecondTimestampFromInt(1699021649099),
|
||||||
FeeDetail: FeeDetail{},
|
FeeDetail: FeeDetail{},
|
||||||
}, od)
|
}, od)
|
||||||
})
|
})
|
||||||
|
@ -98,8 +98,8 @@ func TestOrderDetail_UnmarshalJSON(t *testing.T) {
|
||||||
EnterPointSource: "API",
|
EnterPointSource: "API",
|
||||||
FeeDetailRaw: `{"newFees":{"c":0,"d":0,"deduction":false,"r":-0.0070005,"t":-0.0070005,"totalDeductionFee":0},"USDT":{"deduction":false,"feeCoinCode":"USDT","totalDeductionFee":0,"totalFee":-0.007000500000}}`,
|
FeeDetailRaw: `{"newFees":{"c":0,"d":0,"deduction":false,"r":-0.0070005,"t":-0.0070005,"totalDeductionFee":0},"USDT":{"deduction":false,"feeCoinCode":"USDT","totalDeductionFee":0,"totalFee":-0.007000500000}}`,
|
||||||
OrderSource: "normal",
|
OrderSource: "normal",
|
||||||
CTime: types.NewMillisecondTimestampFromInt(1699020564659),
|
CreatedTime: types.NewMillisecondTimestampFromInt(1699020564659),
|
||||||
UTime: types.NewMillisecondTimestampFromInt(1699020564688),
|
UpdatedTime: types.NewMillisecondTimestampFromInt(1699020564688),
|
||||||
FeeDetail: FeeDetail{
|
FeeDetail: FeeDetail{
|
||||||
NewFees: struct {
|
NewFees: struct {
|
||||||
DeductedByCoupon fixedpoint.Value `json:"c"`
|
DeductedByCoupon fixedpoint.Value `json:"c"`
|
||||||
|
|
|
@ -36,19 +36,19 @@ type TradeFee struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Trade struct {
|
type Trade struct {
|
||||||
UserId types.StrInt64 `json:"userId"`
|
UserId types.StrInt64 `json:"userId"`
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
OrderId types.StrInt64 `json:"orderId"`
|
OrderId types.StrInt64 `json:"orderId"`
|
||||||
TradeId types.StrInt64 `json:"tradeId"`
|
TradeId types.StrInt64 `json:"tradeId"`
|
||||||
OrderType OrderType `json:"orderType"`
|
OrderType OrderType `json:"orderType"`
|
||||||
Side SideType `json:"side"`
|
Side SideType `json:"side"`
|
||||||
PriceAvg fixedpoint.Value `json:"priceAvg"`
|
PriceAvg fixedpoint.Value `json:"priceAvg"`
|
||||||
Size fixedpoint.Value `json:"size"`
|
Size fixedpoint.Value `json:"size"`
|
||||||
Amount fixedpoint.Value `json:"amount"`
|
Amount fixedpoint.Value `json:"amount"`
|
||||||
FeeDetail TradeFee `json:"feeDetail"`
|
FeeDetail TradeFee `json:"feeDetail"`
|
||||||
TradeScope TradeScope `json:"tradeScope"`
|
TradeScope TradeScope `json:"tradeScope"`
|
||||||
CTime types.MillisecondTimestamp `json:"cTime"`
|
CreatedTime types.MillisecondTimestamp `json:"cTime"`
|
||||||
UTime types.MillisecondTimestamp `json:"uTime"`
|
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate GetRequest -url "/api/v2/spot/trade/fills" -type GetTradeFillsRequest -responseDataType []Trade
|
//go:generate GetRequest -url "/api/v2/spot/trade/fills" -type GetTradeFillsRequest -responseDataType []Trade
|
||||||
|
|
|
@ -27,8 +27,8 @@ type UnfilledOrder struct {
|
||||||
QuoteVolume fixedpoint.Value `json:"quoteVolume"`
|
QuoteVolume fixedpoint.Value `json:"quoteVolume"`
|
||||||
EnterPointSource string `json:"enterPointSource"`
|
EnterPointSource string `json:"enterPointSource"`
|
||||||
OrderSource string `json:"orderSource"`
|
OrderSource string `json:"orderSource"`
|
||||||
CTime types.MillisecondTimestamp `json:"cTime"`
|
CreatedTime types.MillisecondTimestamp `json:"cTime"`
|
||||||
UTime types.MillisecondTimestamp `json:"uTime"`
|
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate GetRequest -url "/api/v2/spot/trade/unfilled-orders" -type GetUnfilledOrdersRequest -responseDataType []UnfilledOrder
|
//go:generate GetRequest -url "/api/v2/spot/trade/unfilled-orders" -type GetUnfilledOrdersRequest -responseDataType []UnfilledOrder
|
||||||
|
|
|
@ -158,7 +158,7 @@ func toGlobalTrade(trade v2.Trade) (*types.Trade, error) {
|
||||||
Side: side,
|
Side: side,
|
||||||
IsBuyer: side == types.SideTypeBuy,
|
IsBuyer: side == types.SideTypeBuy,
|
||||||
IsMaker: isMaker,
|
IsMaker: isMaker,
|
||||||
Time: types.Time(trade.CTime),
|
Time: types.Time(trade.CreatedTime),
|
||||||
Fee: trade.FeeDetail.TotalFee.Abs(),
|
Fee: trade.FeeDetail.TotalFee.Abs(),
|
||||||
FeeCurrency: trade.FeeDetail.FeeCoin,
|
FeeCurrency: trade.FeeDetail.FeeCoin,
|
||||||
FeeDiscounted: isDiscount,
|
FeeDiscounted: isDiscount,
|
||||||
|
@ -211,8 +211,8 @@ func unfilledOrderToGlobalOrder(order v2.UnfilledOrder) (*types.Order, error) {
|
||||||
Status: status,
|
Status: status,
|
||||||
ExecutedQuantity: order.BaseVolume,
|
ExecutedQuantity: order.BaseVolume,
|
||||||
IsWorking: order.Status.IsWorking(),
|
IsWorking: order.Status.IsWorking(),
|
||||||
CreationTime: types.Time(order.CTime.Time()),
|
CreationTime: types.Time(order.CreatedTime.Time()),
|
||||||
UpdateTime: types.Time(order.UTime.Time()),
|
UpdateTime: types.Time(order.UpdatedTime.Time()),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,8 +262,8 @@ func toGlobalOrder(order v2.OrderDetail) (*types.Order, error) {
|
||||||
Status: status,
|
Status: status,
|
||||||
ExecutedQuantity: order.BaseVolume,
|
ExecutedQuantity: order.BaseVolume,
|
||||||
IsWorking: order.Status.IsWorking(),
|
IsWorking: order.Status.IsWorking(),
|
||||||
CreationTime: types.Time(order.CTime.Time()),
|
CreationTime: types.Time(order.CreatedTime.Time()),
|
||||||
UpdateTime: types.Time(order.UTime.Time()),
|
UpdateTime: types.Time(order.UpdatedTime.Time()),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,8 +443,8 @@ func (o *Order) toGlobalOrder() (types.Order, error) {
|
||||||
Status: status,
|
Status: status,
|
||||||
ExecutedQuantity: o.AccBaseVolume,
|
ExecutedQuantity: o.AccBaseVolume,
|
||||||
IsWorking: o.Status.IsWorking(),
|
IsWorking: o.Status.IsWorking(),
|
||||||
CreationTime: types.Time(o.CTime.Time()),
|
CreationTime: types.Time(o.CreatedTime.Time()),
|
||||||
UpdateTime: types.Time(o.UTime.Time()),
|
UpdateTime: types.Time(o.UpdatedTime.Time()),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,8 +222,8 @@ func Test_unfilledOrderToGlobalOrder(t *testing.T) {
|
||||||
QuoteVolume: fixedpoint.NewFromFloat(0),
|
QuoteVolume: fixedpoint.NewFromFloat(0),
|
||||||
EnterPointSource: "API",
|
EnterPointSource: "API",
|
||||||
OrderSource: "normal",
|
OrderSource: "normal",
|
||||||
CTime: types.NewMillisecondTimestampFromInt(1660704288118),
|
CreatedTime: types.NewMillisecondTimestampFromInt(1660704288118),
|
||||||
UTime: types.NewMillisecondTimestampFromInt(1660704288118),
|
UpdatedTime: types.NewMillisecondTimestampFromInt(1660704288118),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -296,8 +296,8 @@ func Test_toGlobalOrder(t *testing.T) {
|
||||||
EnterPointSource: "API",
|
EnterPointSource: "API",
|
||||||
FeeDetailRaw: `{\"newFees\":{\"c\":0,\"d\":0,\"deduction\":false,\"r\":-0.0070005,\"t\":-0.0070005,\"totalDeductionFee\":0},\"USDT\":{\"deduction\":false,\"feeCoinCode\":\"USDT\",\"totalDeductionFee\":0,\"totalFee\":-0.007000500000}}`,
|
FeeDetailRaw: `{\"newFees\":{\"c\":0,\"d\":0,\"deduction\":false,\"r\":-0.0070005,\"t\":-0.0070005,\"totalDeductionFee\":0},\"USDT\":{\"deduction\":false,\"feeCoinCode\":\"USDT\",\"totalDeductionFee\":0,\"totalFee\":-0.007000500000}}`,
|
||||||
OrderSource: "normal",
|
OrderSource: "normal",
|
||||||
CTime: types.NewMillisecondTimestampFromInt(1660704288118),
|
CreatedTime: types.NewMillisecondTimestampFromInt(1660704288118),
|
||||||
UTime: types.NewMillisecondTimestampFromInt(1660704288118),
|
UpdatedTime: types.NewMillisecondTimestampFromInt(1660704288118),
|
||||||
}
|
}
|
||||||
|
|
||||||
expOrder = &types.Order{
|
expOrder = &types.Order{
|
||||||
|
@ -558,9 +558,9 @@ func Test_toGlobalTrade(t *testing.T) {
|
||||||
TotalDeductionFee: fixedpoint.Zero,
|
TotalDeductionFee: fixedpoint.Zero,
|
||||||
TotalFee: fixedpoint.NewFromFloat(-0.0070005),
|
TotalFee: fixedpoint.NewFromFloat(-0.0070005),
|
||||||
},
|
},
|
||||||
TradeScope: v2.TradeTaker,
|
TradeScope: v2.TradeTaker,
|
||||||
CTime: types.NewMillisecondTimestampFromInt(1699020564676),
|
CreatedTime: types.NewMillisecondTimestampFromInt(1699020564676),
|
||||||
UTime: types.NewMillisecondTimestampFromInt(1699020564687),
|
UpdatedTime: types.NewMillisecondTimestampFromInt(1699020564687),
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := toGlobalTrade(trade)
|
res, err := toGlobalTrade(trade)
|
||||||
|
@ -597,7 +597,7 @@ func Test_toGlobalBalanceMap(t *testing.T) {
|
||||||
Frozen: fixedpoint.NewFromFloat(0.6),
|
Frozen: fixedpoint.NewFromFloat(0.6),
|
||||||
Locked: fixedpoint.NewFromFloat(0.7),
|
Locked: fixedpoint.NewFromFloat(0.7),
|
||||||
LimitAvailable: fixedpoint.Zero,
|
LimitAvailable: fixedpoint.Zero,
|
||||||
UTime: types.NewMillisecondTimestampFromInt(1699020564676),
|
UpdatedTime: types.NewMillisecondTimestampFromInt(1699020564676),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -773,8 +773,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
AccBaseVolume: fixedpoint.NewFromFloat(33.6558),
|
AccBaseVolume: fixedpoint.NewFromFloat(33.6558),
|
||||||
PriceAvg: fixedpoint.NewFromFloat(0.49016),
|
PriceAvg: fixedpoint.NewFromFloat(0.49016),
|
||||||
Status: v2.OrderStatusPartialFilled,
|
Status: v2.OrderStatusPartialFilled,
|
||||||
CTime: types.NewMillisecondTimestampFromInt(1699881902217),
|
CreatedTime: types.NewMillisecondTimestampFromInt(1699881902217),
|
||||||
UTime: types.NewMillisecondTimestampFromInt(1699881902248),
|
UpdatedTime: types.NewMillisecondTimestampFromInt(1699881902248),
|
||||||
FeeDetail: nil,
|
FeeDetail: nil,
|
||||||
EnterPointSource: "API",
|
EnterPointSource: "API",
|
||||||
}
|
}
|
||||||
|
@ -829,8 +829,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
Status: types.OrderStatusPartiallyFilled,
|
Status: types.OrderStatusPartiallyFilled,
|
||||||
ExecutedQuantity: newO.AccBaseVolume,
|
ExecutedQuantity: newO.AccBaseVolume,
|
||||||
IsWorking: newO.Status.IsWorking(),
|
IsWorking: newO.Status.IsWorking(),
|
||||||
CreationTime: types.Time(newO.CTime),
|
CreationTime: types.Time(newO.CreatedTime),
|
||||||
UpdateTime: types.Time(newO.UTime),
|
UpdateTime: types.Time(newO.UpdatedTime),
|
||||||
}, res)
|
}, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -886,8 +886,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
Status: types.OrderStatusPartiallyFilled,
|
Status: types.OrderStatusPartiallyFilled,
|
||||||
ExecutedQuantity: newO.AccBaseVolume,
|
ExecutedQuantity: newO.AccBaseVolume,
|
||||||
IsWorking: newO.Status.IsWorking(),
|
IsWorking: newO.Status.IsWorking(),
|
||||||
CreationTime: types.Time(newO.CTime),
|
CreationTime: types.Time(newO.CreatedTime),
|
||||||
UpdateTime: types.Time(newO.UTime),
|
UpdateTime: types.Time(newO.UpdatedTime),
|
||||||
}, res)
|
}, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -944,8 +944,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
Status: types.OrderStatusPartiallyFilled,
|
Status: types.OrderStatusPartiallyFilled,
|
||||||
ExecutedQuantity: newO.AccBaseVolume,
|
ExecutedQuantity: newO.AccBaseVolume,
|
||||||
IsWorking: newO.Status.IsWorking(),
|
IsWorking: newO.Status.IsWorking(),
|
||||||
CreationTime: types.Time(newO.CTime),
|
CreationTime: types.Time(newO.CreatedTime),
|
||||||
UpdateTime: types.Time(newO.UTime),
|
UpdateTime: types.Time(newO.UpdatedTime),
|
||||||
}, res)
|
}, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1002,8 +1002,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
|
||||||
Status: types.OrderStatusPartiallyFilled,
|
Status: types.OrderStatusPartiallyFilled,
|
||||||
ExecutedQuantity: newO.AccBaseVolume,
|
ExecutedQuantity: newO.AccBaseVolume,
|
||||||
IsWorking: newO.Status.IsWorking(),
|
IsWorking: newO.Status.IsWorking(),
|
||||||
CreationTime: types.Time(newO.CTime),
|
CreationTime: types.Time(newO.CreatedTime),
|
||||||
UpdateTime: types.Time(newO.UTime),
|
UpdateTime: types.Time(newO.UpdatedTime),
|
||||||
}, res)
|
}, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1088,8 +1088,8 @@ func TestOrder_toGlobalTrade(t *testing.T) {
|
||||||
AccBaseVolume: fixedpoint.NewFromFloat(33.6558),
|
AccBaseVolume: fixedpoint.NewFromFloat(33.6558),
|
||||||
PriceAvg: fixedpoint.NewFromFloat(0.49016),
|
PriceAvg: fixedpoint.NewFromFloat(0.49016),
|
||||||
Status: v2.OrderStatusPartialFilled,
|
Status: v2.OrderStatusPartialFilled,
|
||||||
CTime: types.NewMillisecondTimestampFromInt(1699881902217),
|
CreatedTime: types.NewMillisecondTimestampFromInt(1699881902217),
|
||||||
UTime: types.NewMillisecondTimestampFromInt(1699881902248),
|
UpdatedTime: types.NewMillisecondTimestampFromInt(1699881902248),
|
||||||
FeeDetail: nil,
|
FeeDetail: nil,
|
||||||
EnterPointSource: "API",
|
EnterPointSource: "API",
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,7 +394,7 @@ func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders [
|
||||||
return orders, nil
|
return orders, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryClosedOrders queries closed order by time range(`CTime`) and id. The order of the response is in descending order.
|
// QueryClosedOrders queries closed order by time range(`CreatedTime`) and id. The order of the response is in descending order.
|
||||||
// If you need to retrieve all data, please utilize the function pkg/exchange/batch.ClosedOrderBatchQuery.
|
// If you need to retrieve all data, please utilize the function pkg/exchange/batch.ClosedOrderBatchQuery.
|
||||||
//
|
//
|
||||||
// ** Since is inclusive, Until is exclusive. If you use a time range to query, you must provide both a start time and an end time. **
|
// ** Since is inclusive, Until is exclusive. If you use a time range to query, you must provide both a start time and an end time. **
|
||||||
|
@ -495,7 +495,7 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryTrades queries fill trades. The trade of the response is in descending order. The time-based query are typically
|
// QueryTrades queries fill trades. The trade of the response is in descending order. The time-based query are typically
|
||||||
// using (`CTime`) as the search criteria.
|
// using (`CreatedTime`) as the search criteria.
|
||||||
// If you need to retrieve all data, please utilize the function pkg/exchange/batch.TradeBatchQuery.
|
// If you need to retrieve all data, please utilize the function pkg/exchange/batch.TradeBatchQuery.
|
||||||
//
|
//
|
||||||
// ** StartTime is inclusive, EndTime is exclusive. If you use the EndTime, the StartTime is required. **
|
// ** StartTime is inclusive, EndTime is exclusive. If you use the EndTime, the StartTime is required. **
|
||||||
|
|
|
@ -452,7 +452,7 @@ type Balance struct {
|
||||||
Locked fixedpoint.Value `json:"locked"`
|
Locked fixedpoint.Value `json:"locked"`
|
||||||
// Restricted availability For spot copy trading
|
// Restricted availability For spot copy trading
|
||||||
LimitAvailable fixedpoint.Value `json:"limitAvailable"`
|
LimitAvailable fixedpoint.Value `json:"limitAvailable"`
|
||||||
UTime types.MillisecondTimestamp `json:"uTime"`
|
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountEvent struct {
|
type AccountEvent struct {
|
||||||
|
@ -495,8 +495,8 @@ type Order struct {
|
||||||
AccBaseVolume fixedpoint.Value `json:"accBaseVolume"`
|
AccBaseVolume fixedpoint.Value `json:"accBaseVolume"`
|
||||||
PriceAvg fixedpoint.Value `json:"priceAvg"`
|
PriceAvg fixedpoint.Value `json:"priceAvg"`
|
||||||
Status v2.OrderStatus `json:"status"`
|
Status v2.OrderStatus `json:"status"`
|
||||||
CTime types.MillisecondTimestamp `json:"cTime"`
|
CreatedTime types.MillisecondTimestamp `json:"cTime"`
|
||||||
UTime types.MillisecondTimestamp `json:"uTime"`
|
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
|
||||||
FeeDetail []struct {
|
FeeDetail []struct {
|
||||||
FeeCoin string `json:"feeCoin"`
|
FeeCoin string `json:"feeCoin"`
|
||||||
Fee string `json:"fee"`
|
Fee string `json:"fee"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user