mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +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),
|
NetProfitMargin: netProfit.Div(trade.QuoteQuantity),
|
||||||
// trade related fields
|
// trade related fields
|
||||||
TradeID: trade.ID,
|
TradeID: trade.ID,
|
||||||
|
OrderID: trade.OrderID,
|
||||||
Side: trade.Side,
|
Side: trade.Side,
|
||||||
IsBuyer: trade.IsBuyer,
|
IsBuyer: trade.IsBuyer,
|
||||||
IsMaker: trade.IsMaker,
|
IsMaker: trade.IsMaker,
|
||||||
|
|
|
@ -38,6 +38,7 @@ type Profit struct {
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
// TradeID is the exchange trade id of that trade
|
// TradeID is the exchange trade id of that trade
|
||||||
TradeID uint64 `json:"tradeID" db:"trade_id"`
|
TradeID uint64 `json:"tradeID" db:"trade_id"`
|
||||||
|
OrderID uint64 `json:"orderID,omitempty"`
|
||||||
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"`
|
||||||
|
|
|
@ -169,6 +169,8 @@ type TradeStats struct {
|
||||||
Profits []fixedpoint.Value `json:"profits,omitempty" yaml:"profits,omitempty"`
|
Profits []fixedpoint.Value `json:"profits,omitempty" yaml:"profits,omitempty"`
|
||||||
Losses []fixedpoint.Value `json:"losses,omitempty" yaml:"losses,omitempty"`
|
Losses []fixedpoint.Value `json:"losses,omitempty" yaml:"losses,omitempty"`
|
||||||
|
|
||||||
|
orderProfits map[uint64]*Profit
|
||||||
|
|
||||||
LargestProfitTrade fixedpoint.Value `json:"largestProfitTrade,omitempty" yaml:"largestProfitTrade"`
|
LargestProfitTrade fixedpoint.Value `json:"largestProfitTrade,omitempty" yaml:"largestProfitTrade"`
|
||||||
LargestLossTrade fixedpoint.Value `json:"largestLossTrade,omitempty" yaml:"largestLossTrade"`
|
LargestLossTrade fixedpoint.Value `json:"largestLossTrade,omitempty" yaml:"largestLossTrade"`
|
||||||
AverageProfitTrade fixedpoint.Value `json:"averageProfitTrade" yaml:"averageProfitTrade"`
|
AverageProfitTrade fixedpoint.Value `json:"averageProfitTrade" yaml:"averageProfitTrade"`
|
||||||
|
@ -241,7 +243,12 @@ func (s *TradeStats) Add(profit *Profit) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.orderProfits == nil {
|
||||||
|
s.orderProfits = make(map[uint64]*Profit)
|
||||||
|
}
|
||||||
|
|
||||||
s.add(profit.Profit)
|
s.add(profit.Profit)
|
||||||
|
|
||||||
for _, v := range s.IntervalProfits {
|
for _, v := range s.IntervalProfits {
|
||||||
v.Update(profit)
|
v.Update(profit)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user