mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
ignore selling trades from the beginning
This commit is contained in:
parent
062fe55b43
commit
35bb5bda06
13
bbgo/pnl.go
13
bbgo/pnl.go
|
@ -23,6 +23,19 @@ func CalculateCostAndProfit(trades []Trade, currentPrice float64) (averageBidPri
|
|||
var bidVolume = 0.0
|
||||
var bidAmount = 0.0
|
||||
var bidFee = 0.0
|
||||
|
||||
// find the first buy trade
|
||||
var firstBidIndex = -1
|
||||
for idx, t := range trades {
|
||||
if t.IsBuyer {
|
||||
firstBidIndex = idx
|
||||
break
|
||||
}
|
||||
}
|
||||
if firstBidIndex > 0 {
|
||||
trades = trades[firstBidIndex:]
|
||||
}
|
||||
|
||||
for _, t := range trades {
|
||||
if t.IsBuyer {
|
||||
bidVolume += t.Volume
|
||||
|
|
Loading…
Reference in New Issue
Block a user