mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
types: assign orderID to profit object
This commit is contained in:
parent
889318ddcb
commit
4c3334c482
|
@ -106,6 +106,7 @@ func (p *Position) NewProfit(trade Trade, profit, netProfit fixedpoint.Value) Pr
|
|||
NetProfitMargin: netProfit.Div(trade.QuoteQuantity),
|
||||
// trade related fields
|
||||
TradeID: trade.ID,
|
||||
OrderID: trade.OrderID,
|
||||
Side: trade.Side,
|
||||
IsBuyer: trade.IsBuyer,
|
||||
IsMaker: trade.IsMaker,
|
||||
|
|
|
@ -38,6 +38,7 @@ type Profit struct {
|
|||
// --------------------------------------------
|
||||
// TradeID is the exchange trade id of that trade
|
||||
TradeID uint64 `json:"tradeID" db:"trade_id"`
|
||||
OrderID uint64 `json:"orderID,omitempty"`
|
||||
Side SideType `json:"side" db:"side"`
|
||||
IsBuyer bool `json:"isBuyer" db:"is_buyer"`
|
||||
IsMaker bool `json:"isMaker" db:"is_maker"`
|
||||
|
|
|
@ -169,6 +169,8 @@ type TradeStats struct {
|
|||
Profits []fixedpoint.Value `json:"profits,omitempty" yaml:"profits,omitempty"`
|
||||
Losses []fixedpoint.Value `json:"losses,omitempty" yaml:"losses,omitempty"`
|
||||
|
||||
orderProfits map[uint64]*Profit
|
||||
|
||||
LargestProfitTrade fixedpoint.Value `json:"largestProfitTrade,omitempty" yaml:"largestProfitTrade"`
|
||||
LargestLossTrade fixedpoint.Value `json:"largestLossTrade,omitempty" yaml:"largestLossTrade"`
|
||||
AverageProfitTrade fixedpoint.Value `json:"averageProfitTrade" yaml:"averageProfitTrade"`
|
||||
|
@ -241,7 +243,12 @@ func (s *TradeStats) Add(profit *Profit) {
|
|||
return
|
||||
}
|
||||
|
||||
if s.orderProfits == nil {
|
||||
s.orderProfits = make(map[uint64]*Profit)
|
||||
}
|
||||
|
||||
s.add(profit.Profit)
|
||||
|
||||
for _, v := range s.IntervalProfits {
|
||||
v.Update(profit)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user