pkg/exchange: make the CTime and UTime to qualified name

This commit is contained in:
Edwin 2023-11-15 10:46:18 +08:00
parent 4f94f7acc0
commit cf527a6f05
8 changed files with 53 additions and 53 deletions

View File

@ -51,8 +51,8 @@ type OrderDetail struct {
// The value is json string, so we unmarshal it after unmarshal OrderDetail
FeeDetailRaw string `json:"feeDetail"`
OrderSource string `json:"orderSource"`
CTime types.MillisecondTimestamp `json:"cTime"`
UTime types.MillisecondTimestamp `json:"uTime"`
CreatedTime types.MillisecondTimestamp `json:"cTime"`
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
FeeDetail FeeDetail
}

View File

@ -53,8 +53,8 @@ func TestOrderDetail_UnmarshalJSON(t *testing.T) {
EnterPointSource: "API",
FeeDetailRaw: "",
OrderSource: "normal",
CTime: types.NewMillisecondTimestampFromInt(1699021576683),
UTime: types.NewMillisecondTimestampFromInt(1699021649099),
CreatedTime: types.NewMillisecondTimestampFromInt(1699021576683),
UpdatedTime: types.NewMillisecondTimestampFromInt(1699021649099),
FeeDetail: FeeDetail{},
}, od)
})
@ -98,8 +98,8 @@ func TestOrderDetail_UnmarshalJSON(t *testing.T) {
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}}`,
OrderSource: "normal",
CTime: types.NewMillisecondTimestampFromInt(1699020564659),
UTime: types.NewMillisecondTimestampFromInt(1699020564688),
CreatedTime: types.NewMillisecondTimestampFromInt(1699020564659),
UpdatedTime: types.NewMillisecondTimestampFromInt(1699020564688),
FeeDetail: FeeDetail{
NewFees: struct {
DeductedByCoupon fixedpoint.Value `json:"c"`

View File

@ -36,19 +36,19 @@ type TradeFee struct {
}
type Trade struct {
UserId types.StrInt64 `json:"userId"`
Symbol string `json:"symbol"`
OrderId types.StrInt64 `json:"orderId"`
TradeId types.StrInt64 `json:"tradeId"`
OrderType OrderType `json:"orderType"`
Side SideType `json:"side"`
PriceAvg fixedpoint.Value `json:"priceAvg"`
Size fixedpoint.Value `json:"size"`
Amount fixedpoint.Value `json:"amount"`
FeeDetail TradeFee `json:"feeDetail"`
TradeScope TradeScope `json:"tradeScope"`
CTime types.MillisecondTimestamp `json:"cTime"`
UTime types.MillisecondTimestamp `json:"uTime"`
UserId types.StrInt64 `json:"userId"`
Symbol string `json:"symbol"`
OrderId types.StrInt64 `json:"orderId"`
TradeId types.StrInt64 `json:"tradeId"`
OrderType OrderType `json:"orderType"`
Side SideType `json:"side"`
PriceAvg fixedpoint.Value `json:"priceAvg"`
Size fixedpoint.Value `json:"size"`
Amount fixedpoint.Value `json:"amount"`
FeeDetail TradeFee `json:"feeDetail"`
TradeScope TradeScope `json:"tradeScope"`
CreatedTime types.MillisecondTimestamp `json:"cTime"`
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
}
//go:generate GetRequest -url "/api/v2/spot/trade/fills" -type GetTradeFillsRequest -responseDataType []Trade

View File

@ -27,8 +27,8 @@ type UnfilledOrder struct {
QuoteVolume fixedpoint.Value `json:"quoteVolume"`
EnterPointSource string `json:"enterPointSource"`
OrderSource string `json:"orderSource"`
CTime types.MillisecondTimestamp `json:"cTime"`
UTime types.MillisecondTimestamp `json:"uTime"`
CreatedTime types.MillisecondTimestamp `json:"cTime"`
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
}
//go:generate GetRequest -url "/api/v2/spot/trade/unfilled-orders" -type GetUnfilledOrdersRequest -responseDataType []UnfilledOrder

View File

@ -158,7 +158,7 @@ func toGlobalTrade(trade v2.Trade) (*types.Trade, error) {
Side: side,
IsBuyer: side == types.SideTypeBuy,
IsMaker: isMaker,
Time: types.Time(trade.CTime),
Time: types.Time(trade.CreatedTime),
Fee: trade.FeeDetail.TotalFee.Abs(),
FeeCurrency: trade.FeeDetail.FeeCoin,
FeeDiscounted: isDiscount,
@ -211,8 +211,8 @@ func unfilledOrderToGlobalOrder(order v2.UnfilledOrder) (*types.Order, error) {
Status: status,
ExecutedQuantity: order.BaseVolume,
IsWorking: order.Status.IsWorking(),
CreationTime: types.Time(order.CTime.Time()),
UpdateTime: types.Time(order.UTime.Time()),
CreationTime: types.Time(order.CreatedTime.Time()),
UpdateTime: types.Time(order.UpdatedTime.Time()),
}, nil
}
@ -262,8 +262,8 @@ func toGlobalOrder(order v2.OrderDetail) (*types.Order, error) {
Status: status,
ExecutedQuantity: order.BaseVolume,
IsWorking: order.Status.IsWorking(),
CreationTime: types.Time(order.CTime.Time()),
UpdateTime: types.Time(order.UTime.Time()),
CreationTime: types.Time(order.CreatedTime.Time()),
UpdateTime: types.Time(order.UpdatedTime.Time()),
}, nil
}
@ -443,8 +443,8 @@ func (o *Order) toGlobalOrder() (types.Order, error) {
Status: status,
ExecutedQuantity: o.AccBaseVolume,
IsWorking: o.Status.IsWorking(),
CreationTime: types.Time(o.CTime.Time()),
UpdateTime: types.Time(o.UTime.Time()),
CreationTime: types.Time(o.CreatedTime.Time()),
UpdateTime: types.Time(o.UpdatedTime.Time()),
}, nil
}

View File

@ -222,8 +222,8 @@ func Test_unfilledOrderToGlobalOrder(t *testing.T) {
QuoteVolume: fixedpoint.NewFromFloat(0),
EnterPointSource: "API",
OrderSource: "normal",
CTime: types.NewMillisecondTimestampFromInt(1660704288118),
UTime: types.NewMillisecondTimestampFromInt(1660704288118),
CreatedTime: types.NewMillisecondTimestampFromInt(1660704288118),
UpdatedTime: types.NewMillisecondTimestampFromInt(1660704288118),
}
)
@ -296,8 +296,8 @@ func Test_toGlobalOrder(t *testing.T) {
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}}`,
OrderSource: "normal",
CTime: types.NewMillisecondTimestampFromInt(1660704288118),
UTime: types.NewMillisecondTimestampFromInt(1660704288118),
CreatedTime: types.NewMillisecondTimestampFromInt(1660704288118),
UpdatedTime: types.NewMillisecondTimestampFromInt(1660704288118),
}
expOrder = &types.Order{
@ -558,9 +558,9 @@ func Test_toGlobalTrade(t *testing.T) {
TotalDeductionFee: fixedpoint.Zero,
TotalFee: fixedpoint.NewFromFloat(-0.0070005),
},
TradeScope: v2.TradeTaker,
CTime: types.NewMillisecondTimestampFromInt(1699020564676),
UTime: types.NewMillisecondTimestampFromInt(1699020564687),
TradeScope: v2.TradeTaker,
CreatedTime: types.NewMillisecondTimestampFromInt(1699020564676),
UpdatedTime: types.NewMillisecondTimestampFromInt(1699020564687),
}
res, err := toGlobalTrade(trade)
@ -597,7 +597,7 @@ func Test_toGlobalBalanceMap(t *testing.T) {
Frozen: fixedpoint.NewFromFloat(0.6),
Locked: fixedpoint.NewFromFloat(0.7),
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),
PriceAvg: fixedpoint.NewFromFloat(0.49016),
Status: v2.OrderStatusPartialFilled,
CTime: types.NewMillisecondTimestampFromInt(1699881902217),
UTime: types.NewMillisecondTimestampFromInt(1699881902248),
CreatedTime: types.NewMillisecondTimestampFromInt(1699881902217),
UpdatedTime: types.NewMillisecondTimestampFromInt(1699881902248),
FeeDetail: nil,
EnterPointSource: "API",
}
@ -829,8 +829,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
Status: types.OrderStatusPartiallyFilled,
ExecutedQuantity: newO.AccBaseVolume,
IsWorking: newO.Status.IsWorking(),
CreationTime: types.Time(newO.CTime),
UpdateTime: types.Time(newO.UTime),
CreationTime: types.Time(newO.CreatedTime),
UpdateTime: types.Time(newO.UpdatedTime),
}, res)
})
@ -886,8 +886,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
Status: types.OrderStatusPartiallyFilled,
ExecutedQuantity: newO.AccBaseVolume,
IsWorking: newO.Status.IsWorking(),
CreationTime: types.Time(newO.CTime),
UpdateTime: types.Time(newO.UTime),
CreationTime: types.Time(newO.CreatedTime),
UpdateTime: types.Time(newO.UpdatedTime),
}, res)
})
@ -944,8 +944,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
Status: types.OrderStatusPartiallyFilled,
ExecutedQuantity: newO.AccBaseVolume,
IsWorking: newO.Status.IsWorking(),
CreationTime: types.Time(newO.CTime),
UpdateTime: types.Time(newO.UTime),
CreationTime: types.Time(newO.CreatedTime),
UpdateTime: types.Time(newO.UpdatedTime),
}, res)
})
@ -1002,8 +1002,8 @@ func TestOrder_toGlobalOrder(t *testing.T) {
Status: types.OrderStatusPartiallyFilled,
ExecutedQuantity: newO.AccBaseVolume,
IsWorking: newO.Status.IsWorking(),
CreationTime: types.Time(newO.CTime),
UpdateTime: types.Time(newO.UTime),
CreationTime: types.Time(newO.CreatedTime),
UpdateTime: types.Time(newO.UpdatedTime),
}, res)
})
@ -1088,8 +1088,8 @@ func TestOrder_toGlobalTrade(t *testing.T) {
AccBaseVolume: fixedpoint.NewFromFloat(33.6558),
PriceAvg: fixedpoint.NewFromFloat(0.49016),
Status: v2.OrderStatusPartialFilled,
CTime: types.NewMillisecondTimestampFromInt(1699881902217),
UTime: types.NewMillisecondTimestampFromInt(1699881902248),
CreatedTime: types.NewMillisecondTimestampFromInt(1699881902217),
UpdatedTime: types.NewMillisecondTimestampFromInt(1699881902248),
FeeDetail: nil,
EnterPointSource: "API",
}

View File

@ -394,7 +394,7 @@ func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders [
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.
//
// ** 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
// 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.
//
// ** StartTime is inclusive, EndTime is exclusive. If you use the EndTime, the StartTime is required. **

View File

@ -452,7 +452,7 @@ type Balance struct {
Locked fixedpoint.Value `json:"locked"`
// Restricted availability For spot copy trading
LimitAvailable fixedpoint.Value `json:"limitAvailable"`
UTime types.MillisecondTimestamp `json:"uTime"`
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
}
type AccountEvent struct {
@ -495,8 +495,8 @@ type Order struct {
AccBaseVolume fixedpoint.Value `json:"accBaseVolume"`
PriceAvg fixedpoint.Value `json:"priceAvg"`
Status v2.OrderStatus `json:"status"`
CTime types.MillisecondTimestamp `json:"cTime"`
UTime types.MillisecondTimestamp `json:"uTime"`
CreatedTime types.MillisecondTimestamp `json:"cTime"`
UpdatedTime types.MillisecondTimestamp `json:"uTime"`
FeeDetail []struct {
FeeCoin string `json:"feeCoin"`
Fee string `json:"fee"`