mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
move Time type to types.Time
This commit is contained in:
parent
4fde442722
commit
57a78777df
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
@ -237,7 +236,7 @@ func (m *SimplePriceMatching) newTradeFromOrder(order types.Order, isMaker bool)
|
||||||
Side: order.Side,
|
Side: order.Side,
|
||||||
IsBuyer: order.Side == types.SideTypeBuy,
|
IsBuyer: order.Side == types.SideTypeBuy,
|
||||||
IsMaker: isMaker,
|
IsMaker: isMaker,
|
||||||
Time: datatype.Time(m.CurrentTime),
|
Time: types.Time(m.CurrentTime),
|
||||||
Fee: fee,
|
Fee: fee,
|
||||||
FeeCurrency: feeCurrency,
|
FeeCurrency: feeCurrency,
|
||||||
}
|
}
|
||||||
|
@ -439,7 +438,7 @@ func (m *SimplePriceMatching) newOrder(o types.SubmitOrder, orderID uint64) type
|
||||||
Status: types.OrderStatusNew,
|
Status: types.OrderStatusNew,
|
||||||
ExecutedQuantity: 0,
|
ExecutedQuantity: 0,
|
||||||
IsWorking: true,
|
IsWorking: true,
|
||||||
CreationTime: datatype.Time(m.CurrentTime),
|
CreationTime: types.Time(m.CurrentTime),
|
||||||
UpdateTime: datatype.Time(m.CurrentTime),
|
UpdateTime: types.Time(m.CurrentTime),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"github.com/adshao/go-binance/v2"
|
"github.com/adshao/go-binance/v2"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
|
@ -150,8 +149,8 @@ func ToGlobalOrder(binanceOrder *binance.Order, isMargin bool) (*types.Order, er
|
||||||
OrderID: uint64(binanceOrder.OrderID),
|
OrderID: uint64(binanceOrder.OrderID),
|
||||||
Status: toGlobalOrderStatus(binanceOrder.Status),
|
Status: toGlobalOrderStatus(binanceOrder.Status),
|
||||||
ExecutedQuantity: util.MustParseFloat(binanceOrder.ExecutedQuantity),
|
ExecutedQuantity: util.MustParseFloat(binanceOrder.ExecutedQuantity),
|
||||||
CreationTime: datatype.Time(millisecondTime(binanceOrder.Time)),
|
CreationTime: types.Time(millisecondTime(binanceOrder.Time)),
|
||||||
UpdateTime: datatype.Time(millisecondTime(binanceOrder.UpdateTime)),
|
UpdateTime: types.Time(millisecondTime(binanceOrder.UpdateTime)),
|
||||||
IsMargin: isMargin,
|
IsMargin: isMargin,
|
||||||
IsIsolated: binanceOrder.IsIsolated,
|
IsIsolated: binanceOrder.IsIsolated,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -208,7 +207,7 @@ func ToGlobalTrade(t binance.TradeV3, isMargin bool) (*types.Trade, error) {
|
||||||
IsMaker: t.IsMaker,
|
IsMaker: t.IsMaker,
|
||||||
Fee: fee,
|
Fee: fee,
|
||||||
FeeCurrency: t.CommissionAsset,
|
FeeCurrency: t.CommissionAsset,
|
||||||
Time: datatype.Time(millisecondTime(t.Time)),
|
Time: types.Time(millisecondTime(t.Time)),
|
||||||
IsMargin: isMargin,
|
IsMargin: isMargin,
|
||||||
IsIsolated: t.IsIsolated,
|
IsIsolated: t.IsIsolated,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
|
@ -283,7 +282,7 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
|
||||||
txIDs[d.TxID] = struct{}{}
|
txIDs[d.TxID] = struct{}{}
|
||||||
allWithdraws = append(allWithdraws, types.Withdraw{
|
allWithdraws = append(allWithdraws, types.Withdraw{
|
||||||
Exchange: types.ExchangeBinance,
|
Exchange: types.ExchangeBinance,
|
||||||
ApplyTime: datatype.Time(time.Unix(0, d.ApplyTime*int64(time.Millisecond))),
|
ApplyTime: types.Time(time.Unix(0, d.ApplyTime*int64(time.Millisecond))),
|
||||||
Asset: d.Asset,
|
Asset: d.Asset,
|
||||||
Amount: d.Amount,
|
Amount: d.Amount,
|
||||||
Address: d.Address,
|
Address: d.Address,
|
||||||
|
@ -356,7 +355,7 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
||||||
txIDs[d.TxID] = struct{}{}
|
txIDs[d.TxID] = struct{}{}
|
||||||
allDeposits = append(allDeposits, types.Deposit{
|
allDeposits = append(allDeposits, types.Deposit{
|
||||||
Exchange: types.ExchangeBinance,
|
Exchange: types.ExchangeBinance,
|
||||||
Time: datatype.Time(time.Unix(0, d.InsertTime*int64(time.Millisecond))),
|
Time: types.Time(time.Unix(0, d.InsertTime*int64(time.Millisecond))),
|
||||||
Asset: d.Asset,
|
Asset: d.Asset,
|
||||||
Amount: d.Amount,
|
Amount: d.Amount,
|
||||||
Address: d.Address,
|
Address: d.Address,
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/adshao/go-binance/v2"
|
"github.com/adshao/go-binance/v2"
|
||||||
"github.com/valyala/fastjson"
|
"github.com/valyala/fastjson"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
|
@ -126,7 +125,7 @@ func (e *ExecutionReportEvent) Order() (*types.Order, error) {
|
||||||
OrderID: uint64(e.OrderID),
|
OrderID: uint64(e.OrderID),
|
||||||
Status: toGlobalOrderStatus(binance.OrderStatusType(e.CurrentOrderStatus)),
|
Status: toGlobalOrderStatus(binance.OrderStatusType(e.CurrentOrderStatus)),
|
||||||
ExecutedQuantity: util.MustParseFloat(e.CumulativeFilledQuantity),
|
ExecutedQuantity: util.MustParseFloat(e.CumulativeFilledQuantity),
|
||||||
CreationTime: datatype.Time(orderCreationTime),
|
CreationTime: types.Time(orderCreationTime),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ func (e *ExecutionReportEvent) Trade() (*types.Trade, error) {
|
||||||
QuoteQuantity: util.MustParseFloat(e.LastQuoteAssetTransactedQuantity),
|
QuoteQuantity: util.MustParseFloat(e.LastQuoteAssetTransactedQuantity),
|
||||||
IsBuyer: e.Side == "BUY",
|
IsBuyer: e.Side == "BUY",
|
||||||
IsMaker: e.IsMaker,
|
IsMaker: e.IsMaker,
|
||||||
Time: datatype.Time(tt),
|
Time: types.Time(tt),
|
||||||
Fee: util.MustParseFloat(e.CommissionAmount),
|
Fee: util.MustParseFloat(e.CommissionAmount),
|
||||||
FeeCurrency: e.CommissionAsset,
|
FeeCurrency: e.CommissionAsset,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
@ -52,8 +51,8 @@ func toGlobalOrder(r order) (types.Order, error) {
|
||||||
OrderID: uint64(r.ID),
|
OrderID: uint64(r.ID),
|
||||||
Status: "",
|
Status: "",
|
||||||
ExecutedQuantity: r.FilledSize,
|
ExecutedQuantity: r.FilledSize,
|
||||||
CreationTime: datatype.Time(r.CreatedAt.Time),
|
CreationTime: types.Time(r.CreatedAt.Time),
|
||||||
UpdateTime: datatype.Time(r.CreatedAt.Time),
|
UpdateTime: types.Time(r.CreatedAt.Time),
|
||||||
}
|
}
|
||||||
|
|
||||||
// `new` (accepted but not processed yet), `open`, or `closed` (filled or cancelled)
|
// `new` (accepted but not processed yet), `open`, or `closed` (filled or cancelled)
|
||||||
|
@ -93,7 +92,7 @@ func toGlobalDeposit(input depositHistory) (types.Deposit, error) {
|
||||||
d := types.Deposit{
|
d := types.Deposit{
|
||||||
GID: 0,
|
GID: 0,
|
||||||
Exchange: types.ExchangeFTX,
|
Exchange: types.ExchangeFTX,
|
||||||
Time: datatype.Time(t.Time),
|
Time: types.Time(t.Time),
|
||||||
Amount: input.Size,
|
Amount: input.Size,
|
||||||
Asset: toGlobalCurrency(input.Coin),
|
Asset: toGlobalCurrency(input.Coin),
|
||||||
TransactionID: input.TxID,
|
TransactionID: input.TxID,
|
||||||
|
@ -126,7 +125,7 @@ func toGlobalTrade(f fill) (types.Trade, error) {
|
||||||
Side: f.Side,
|
Side: f.Side,
|
||||||
IsBuyer: f.Side == types.SideTypeBuy,
|
IsBuyer: f.Side == types.SideTypeBuy,
|
||||||
IsMaker: f.Liquidity == "maker",
|
IsMaker: f.Liquidity == "maker",
|
||||||
Time: datatype.Time(f.Time.Time),
|
Time: types.Time(f.Time.Time),
|
||||||
Fee: f.Fee,
|
Fee: f.Fee,
|
||||||
FeeCurrency: f.FeeCurrency,
|
FeeCurrency: f.FeeCurrency,
|
||||||
IsMargin: false,
|
IsMargin: false,
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
@ -467,7 +466,7 @@ func TestExchange_QueryDepositHistory(t *testing.T) {
|
||||||
assert.Len(t, dh, 1)
|
assert.Len(t, dh, 1)
|
||||||
assert.Equal(t, types.Deposit{
|
assert.Equal(t, types.Deposit{
|
||||||
Exchange: types.ExchangeFTX,
|
Exchange: types.ExchangeFTX,
|
||||||
Time: datatype.Time(actualConfirmedTime),
|
Time: types.Time(actualConfirmedTime),
|
||||||
Amount: 99.0,
|
Amount: 99.0,
|
||||||
Asset: "TUSD",
|
Asset: "TUSD",
|
||||||
TransactionID: "0x8078356ae4b06a036d64747546c274af19581f1c78c510b60505798a7ffcaf1",
|
TransactionID: "0x8078356ae4b06a036d64747546c274af19581f1c78c510b60505798a7ffcaf1",
|
||||||
|
@ -610,7 +609,7 @@ func TestExchange_QueryTrades(t *testing.T) {
|
||||||
Side: types.SideTypeSell,
|
Side: types.SideTypeSell,
|
||||||
IsBuyer: false,
|
IsBuyer: false,
|
||||||
IsMaker: true,
|
IsMaker: true,
|
||||||
Time: datatype.Time(actualConfirmedTime),
|
Time: types.Time(actualConfirmedTime),
|
||||||
Fee: -0.0033625,
|
Fee: -0.0033625,
|
||||||
FeeCurrency: "USD",
|
FeeCurrency: "USD",
|
||||||
IsMargin: false,
|
IsMargin: false,
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,8 +54,8 @@ func Test_messageHandler_handleMessage(t *testing.T) {
|
||||||
OrderID: 36379,
|
OrderID: 36379,
|
||||||
Status: types.OrderStatusFilled,
|
Status: types.OrderStatusFilled,
|
||||||
ExecutedQuantity: 1.0,
|
ExecutedQuantity: 1.0,
|
||||||
CreationTime: datatype.Time(mustParseDatetime("2021-03-28T06:12:50.991447+00:00")),
|
CreationTime: types.Time(mustParseDatetime("2021-03-28T06:12:50.991447+00:00")),
|
||||||
UpdateTime: datatype.Time(mustParseDatetime("2021-03-28T06:12:50.991447+00:00")),
|
UpdateTime: types.Time(mustParseDatetime("2021-03-28T06:12:50.991447+00:00")),
|
||||||
}, order)
|
}, order)
|
||||||
})
|
})
|
||||||
h.handleMessage(input)
|
h.handleMessage(input)
|
||||||
|
@ -104,7 +103,7 @@ func Test_messageHandler_handleMessage(t *testing.T) {
|
||||||
Side: types.SideTypeBuy,
|
Side: types.SideTypeBuy,
|
||||||
IsBuyer: true,
|
IsBuyer: true,
|
||||||
IsMaker: false,
|
IsMaker: false,
|
||||||
Time: datatype.Time(mustParseDatetime("2021-03-28T06:12:34.702926+00:00")),
|
Time: types.Time(mustParseDatetime("2021-03-28T06:12:34.702926+00:00")),
|
||||||
Fee: 0.00153917575,
|
Fee: 0.00153917575,
|
||||||
FeeCurrency: "USD",
|
FeeCurrency: "USD",
|
||||||
IsMargin: false,
|
IsMargin: false,
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
"github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
@ -201,8 +200,8 @@ func toGlobalOrder(maxOrder max.Order) (*types.Order, error) {
|
||||||
OrderID: maxOrder.ID,
|
OrderID: maxOrder.ID,
|
||||||
Status: toGlobalOrderStatus(maxOrder.State, executedVolume, remainingVolume),
|
Status: toGlobalOrderStatus(maxOrder.State, executedVolume, remainingVolume),
|
||||||
ExecutedQuantity: executedVolume.Float64(),
|
ExecutedQuantity: executedVolume.Float64(),
|
||||||
CreationTime: datatype.Time(maxOrder.CreatedAt),
|
CreationTime: types.Time(maxOrder.CreatedAt),
|
||||||
UpdateTime: datatype.Time(maxOrder.CreatedAt),
|
UpdateTime: types.Time(maxOrder.CreatedAt),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +245,7 @@ func toGlobalTrade(t max.Trade) (*types.Trade, error) {
|
||||||
Fee: fee,
|
Fee: fee,
|
||||||
FeeCurrency: toGlobalCurrency(t.FeeCurrency),
|
FeeCurrency: toGlobalCurrency(t.FeeCurrency),
|
||||||
QuoteQuantity: quoteQuantity,
|
QuoteQuantity: quoteQuantity,
|
||||||
Time: datatype.Time(mts),
|
Time: types.Time(mts),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
maxapi "github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
maxapi "github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
@ -610,7 +609,7 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
|
||||||
txIDs[d.TxID] = struct{}{}
|
txIDs[d.TxID] = struct{}{}
|
||||||
withdraw := types.Withdraw{
|
withdraw := types.Withdraw{
|
||||||
Exchange: types.ExchangeMax,
|
Exchange: types.ExchangeMax,
|
||||||
ApplyTime: datatype.Time(time.Unix(d.CreatedAt, 0)),
|
ApplyTime: types.Time(time.Unix(d.CreatedAt, 0)),
|
||||||
Asset: toGlobalCurrency(d.Currency),
|
Asset: toGlobalCurrency(d.Currency),
|
||||||
Amount: util.MustParseFloat(d.Amount),
|
Amount: util.MustParseFloat(d.Amount),
|
||||||
Address: "",
|
Address: "",
|
||||||
|
@ -682,7 +681,7 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
||||||
|
|
||||||
allDeposits = append(allDeposits, types.Deposit{
|
allDeposits = append(allDeposits, types.Deposit{
|
||||||
Exchange: types.ExchangeMax,
|
Exchange: types.ExchangeMax,
|
||||||
Time: datatype.Time(time.Unix(d.CreatedAt, 0)),
|
Time: types.Time(time.Unix(d.CreatedAt, 0)),
|
||||||
Amount: util.MustParseFloat(d.Amount),
|
Amount: util.MustParseFloat(d.Amount),
|
||||||
Asset: toGlobalCurrency(d.Currency),
|
Asset: toGlobalCurrency(d.Currency),
|
||||||
Address: "", // not supported
|
Address: "", // not supported
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
@ -112,7 +111,7 @@ func (reward Reward) Reward() (*types.Reward, error) {
|
||||||
State: reward.State,
|
State: reward.State,
|
||||||
Note: reward.Note,
|
Note: reward.Note,
|
||||||
Spent: false,
|
Spent: false,
|
||||||
CreatedAt: datatype.Time(reward.CreatedAt),
|
CreatedAt: types.Time(reward.CreatedAt),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
max "github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
max "github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
@ -226,7 +225,7 @@ func convertWebSocketTrade(t max.TradeUpdate) (*types.Trade, error) {
|
||||||
Fee: fee,
|
Fee: fee,
|
||||||
FeeCurrency: toGlobalCurrency(t.FeeCurrency),
|
FeeCurrency: toGlobalCurrency(t.FeeCurrency),
|
||||||
QuoteQuantity: quoteQuantity,
|
QuoteQuantity: quoteQuantity,
|
||||||
Time: datatype.Time(mts),
|
Time: types.Time(mts),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +256,6 @@ func toGlobalOrderUpdate(u max.OrderUpdate) (*types.Order, error) {
|
||||||
OrderID: u.ID,
|
OrderID: u.ID,
|
||||||
Status: toGlobalOrderStatus(u.State, executedVolume, remainingVolume),
|
Status: toGlobalOrderStatus(u.State, executedVolume, remainingVolume),
|
||||||
ExecutedQuantity: executedVolume.Float64(),
|
ExecutedQuantity: executedVolume.Float64(),
|
||||||
CreationTime: datatype.Time(time.Unix(0, u.CreatedAtMs*int64(time.Millisecond))),
|
CreationTime: types.Time(time.Unix(0, u.CreatedAtMs*int64(time.Millisecond))),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,7 +23,7 @@ func TestDepositService(t *testing.T) {
|
||||||
|
|
||||||
err = service.Insert(types.Deposit{
|
err = service.Insert(types.Deposit{
|
||||||
Exchange: types.ExchangeMax,
|
Exchange: types.ExchangeMax,
|
||||||
Time: datatype.Time(time.Now()),
|
Time: types.Time(time.Now()),
|
||||||
Amount: 0.001,
|
Amount: 0.001,
|
||||||
Asset: "BTC",
|
Asset: "BTC",
|
||||||
Address: "test",
|
Address: "test",
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
@ -34,7 +33,7 @@ func TestRewardService_InsertAndQueryUnspent(t *testing.T) {
|
||||||
Quantity: 1,
|
Quantity: 1,
|
||||||
State: "done",
|
State: "done",
|
||||||
Spent: false,
|
Spent: false,
|
||||||
CreatedAt: datatype.Time(time.Now()),
|
CreatedAt: types.Time(time.Now()),
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ func TestRewardService_InsertAndQueryUnspent(t *testing.T) {
|
||||||
Quantity: 1000000,
|
Quantity: 1000000,
|
||||||
State: "done",
|
State: "done",
|
||||||
Spent: false,
|
Spent: false,
|
||||||
CreatedAt: datatype.Time(time.Now()),
|
CreatedAt: types.Time(time.Now()),
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
@ -99,7 +98,7 @@ func TestRewardService_AggregateUnspentCurrencyPosition(t *testing.T) {
|
||||||
Quantity: 1,
|
Quantity: 1,
|
||||||
State: "done",
|
State: "done",
|
||||||
Spent: false,
|
Spent: false,
|
||||||
CreatedAt: datatype.Time(now),
|
CreatedAt: types.Time(now),
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
@ -111,7 +110,7 @@ func TestRewardService_AggregateUnspentCurrencyPosition(t *testing.T) {
|
||||||
Quantity: 2,
|
Quantity: 2,
|
||||||
State: "done",
|
State: "done",
|
||||||
Spent: false,
|
Spent: false,
|
||||||
CreatedAt: datatype.Time(now),
|
CreatedAt: types.Time(now),
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
@ -123,7 +122,7 @@ func TestRewardService_AggregateUnspentCurrencyPosition(t *testing.T) {
|
||||||
Quantity: 1000000,
|
Quantity: 1000000,
|
||||||
State: "done",
|
State: "done",
|
||||||
Spent: false,
|
Spent: false,
|
||||||
CreatedAt: datatype.Time(now),
|
CreatedAt: types.Time(now),
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ func TestWithdrawService(t *testing.T) {
|
||||||
TransactionID: "01",
|
TransactionID: "01",
|
||||||
TransactionFee: 0.0001,
|
TransactionFee: 0.0001,
|
||||||
Network: "omni",
|
Network: "omni",
|
||||||
ApplyTime: datatype.Time(time.Now()),
|
ApplyTime: types.Time(time.Now()),
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@ package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DepositStatus string
|
type DepositStatus string
|
||||||
|
@ -26,7 +24,7 @@ const (
|
||||||
type Deposit struct {
|
type Deposit struct {
|
||||||
GID int64 `json:"gid" db:"gid"`
|
GID int64 `json:"gid" db:"gid"`
|
||||||
Exchange ExchangeName `json:"exchange" db:"exchange"`
|
Exchange ExchangeName `json:"exchange" db:"exchange"`
|
||||||
Time datatype.Time `json:"time" db:"time"`
|
Time Time `json:"time" db:"time"`
|
||||||
Amount float64 `json:"amount" db:"amount"`
|
Amount float64 `json:"amount" db:"amount"`
|
||||||
Asset string `json:"asset" db:"asset"`
|
Asset string `json:"asset" db:"asset"`
|
||||||
Address string `json:"address" db:"address"`
|
Address string `json:"address" db:"address"`
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/slack-go/slack"
|
"github.com/slack-go/slack"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -145,14 +144,14 @@ func (o *SubmitOrder) SlackAttachment() slack.Attachment {
|
||||||
type Order struct {
|
type Order struct {
|
||||||
SubmitOrder
|
SubmitOrder
|
||||||
|
|
||||||
Exchange ExchangeName `json:"exchange" db:"exchange"`
|
Exchange ExchangeName `json:"exchange" db:"exchange"`
|
||||||
GID uint64 `json:"gid" db:"gid"`
|
GID uint64 `json:"gid" db:"gid"`
|
||||||
OrderID uint64 `json:"orderID" db:"order_id"` // order id
|
OrderID uint64 `json:"orderID" db:"order_id"` // order id
|
||||||
Status OrderStatus `json:"status" db:"status"`
|
Status OrderStatus `json:"status" db:"status"`
|
||||||
ExecutedQuantity float64 `json:"executedQuantity" db:"executed_quantity"`
|
ExecutedQuantity float64 `json:"executedQuantity" db:"executed_quantity"`
|
||||||
IsWorking bool `json:"isWorking" db:"is_working"`
|
IsWorking bool `json:"isWorking" db:"is_working"`
|
||||||
CreationTime datatype.Time `json:"creationTime" db:"created_at"`
|
CreationTime Time `json:"creationTime" db:"created_at"`
|
||||||
UpdateTime datatype.Time `json:"updateTime" db:"updated_at"`
|
UpdateTime Time `json:"updateTime" db:"updated_at"`
|
||||||
|
|
||||||
IsMargin bool `json:"isMargin" db:"is_margin"`
|
IsMargin bool `json:"isMargin" db:"is_margin"`
|
||||||
IsIsolated bool `json:"isIsolated" db:"is_isolated"`
|
IsIsolated bool `json:"isIsolated" db:"is_isolated"`
|
||||||
|
|
|
@ -3,7 +3,6 @@ package types
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ type Reward struct {
|
||||||
Spent bool `json:"spent" db:"spent"`
|
Spent bool `json:"spent" db:"spent"`
|
||||||
|
|
||||||
// Unix timestamp in seconds
|
// Unix timestamp in seconds
|
||||||
CreatedAt datatype.Time `json:"created_at" db:"created_at"`
|
CreatedAt Time `json:"created_at" db:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RewardSlice []Reward
|
type RewardSlice []Reward
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package datatype
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
|
@ -9,7 +9,6 @@ import (
|
||||||
|
|
||||||
"github.com/slack-go/slack"
|
"github.com/slack-go/slack"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -59,12 +58,12 @@ type Trade struct {
|
||||||
QuoteQuantity float64 `json:"quoteQuantity" db:"quote_quantity"`
|
QuoteQuantity float64 `json:"quoteQuantity" db:"quote_quantity"`
|
||||||
Symbol string `json:"symbol" db:"symbol"`
|
Symbol string `json:"symbol" db:"symbol"`
|
||||||
|
|
||||||
Side SideType `json:"side" db:"side"`
|
Side SideType `json:"side" db:"side"`
|
||||||
IsBuyer bool `json:"isBuyer" db:"is_buyer"`
|
IsBuyer bool `json:"isBuyer" db:"is_buyer"`
|
||||||
IsMaker bool `json:"isMaker" db:"is_maker"`
|
IsMaker bool `json:"isMaker" db:"is_maker"`
|
||||||
Time datatype.Time `json:"tradedAt" db:"traded_at"`
|
Time Time `json:"tradedAt" db:"traded_at"`
|
||||||
Fee float64 `json:"fee" db:"fee"`
|
Fee float64 `json:"fee" db:"fee"`
|
||||||
FeeCurrency string `json:"feeCurrency" db:"fee_currency"`
|
FeeCurrency string `json:"feeCurrency" db:"fee_currency"`
|
||||||
|
|
||||||
IsMargin bool `json:"isMargin" db:"is_margin"`
|
IsMargin bool `json:"isMargin" db:"is_margin"`
|
||||||
IsIsolated bool `json:"isIsolated" db:"is_isolated"`
|
IsIsolated bool `json:"isIsolated" db:"is_isolated"`
|
||||||
|
|
|
@ -3,8 +3,6 @@ package types
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/datatype"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Withdraw struct {
|
type Withdraw struct {
|
||||||
|
@ -16,12 +14,12 @@ type Withdraw struct {
|
||||||
AddressTag string `json:"addressTag"`
|
AddressTag string `json:"addressTag"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
TransactionID string `json:"transactionID" db:"txn_id"`
|
TransactionID string `json:"transactionID" db:"txn_id"`
|
||||||
TransactionFee float64 `json:"transactionFee" db:"txn_fee"`
|
TransactionFee float64 `json:"transactionFee" db:"txn_fee"`
|
||||||
TransactionFeeCurrency string `json:"transactionFeeCurrency" db:"txn_fee_currency"`
|
TransactionFeeCurrency string `json:"transactionFeeCurrency" db:"txn_fee_currency"`
|
||||||
WithdrawOrderID string `json:"withdrawOrderId"`
|
WithdrawOrderID string `json:"withdrawOrderId"`
|
||||||
ApplyTime datatype.Time `json:"applyTime" db:"time"`
|
ApplyTime Time `json:"applyTime" db:"time"`
|
||||||
Network string `json:"network" db:"network"`
|
Network string `json:"network" db:"network"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w Withdraw) String() string {
|
func (w Withdraw) String() string {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user