mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix position test for net profit
This commit is contained in:
parent
cca3284140
commit
0a908e5dda
|
@ -38,7 +38,7 @@ func TestPosition_ExchangeFeeRate_Short(t *testing.T) {
|
|||
FeeCurrency: "BNB",
|
||||
})
|
||||
|
||||
profit, _, madeProfit := pos.AddTrade(types.Trade{
|
||||
_, netProfit, madeProfit := pos.AddTrade(types.Trade{
|
||||
Exchange: types.ExchangeBinance,
|
||||
Price: 2000.0,
|
||||
Quantity: 10.0,
|
||||
|
@ -51,7 +51,7 @@ func TestPosition_ExchangeFeeRate_Short(t *testing.T) {
|
|||
|
||||
expectedProfit := (averageCost-2000.0)*10.0 - (2000.0 * 10.0 * feeRate)
|
||||
assert.True(t, madeProfit)
|
||||
assert.Equal(t, fixedpoint.NewFromFloat(expectedProfit), profit)
|
||||
assert.Equal(t, fixedpoint.NewFromFloat(expectedProfit), netProfit)
|
||||
}
|
||||
|
||||
func TestPosition_ExchangeFeeRate_Long(t *testing.T) {
|
||||
|
@ -83,7 +83,7 @@ func TestPosition_ExchangeFeeRate_Long(t *testing.T) {
|
|||
FeeCurrency: "BNB",
|
||||
})
|
||||
|
||||
profit, _, madeProfit := pos.AddTrade(types.Trade{
|
||||
_, netProfit, madeProfit := pos.AddTrade(types.Trade{
|
||||
Exchange: types.ExchangeBinance,
|
||||
Price: 4000.0,
|
||||
Quantity: 10.0,
|
||||
|
@ -96,7 +96,7 @@ func TestPosition_ExchangeFeeRate_Long(t *testing.T) {
|
|||
|
||||
expectedProfit := (4000.0-averageCost)*10.0 - (4000.0 * 10.0 * feeRate)
|
||||
assert.True(t, madeProfit)
|
||||
assert.Equal(t, fixedpoint.NewFromFloat(expectedProfit), profit)
|
||||
assert.Equal(t, fixedpoint.NewFromFloat(expectedProfit), netProfit)
|
||||
}
|
||||
|
||||
func TestPosition(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user