mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
add more position tests
This commit is contained in:
parent
34148948ab
commit
169af63846
|
@ -15,11 +15,13 @@ func TestPosition(t *testing.T) {
|
||||||
Side: types.SideTypeBuy,
|
Side: types.SideTypeBuy,
|
||||||
Price: 1000.0,
|
Price: 1000.0,
|
||||||
Quantity: 0.01,
|
Quantity: 0.01,
|
||||||
|
QuoteQuantity: 1000.0 * 0.01,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Side: types.SideTypeBuy,
|
Side: types.SideTypeBuy,
|
||||||
Price: 2000.0,
|
Price: 2000.0,
|
||||||
Quantity: 0.03,
|
Quantity: 0.03,
|
||||||
|
QuoteQuantity: 2000.0 * 0.03,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +30,7 @@ func TestPosition(t *testing.T) {
|
||||||
pos.AddTrade(trade)
|
pos.AddTrade(trade)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, fixedpoint.NewFromFloat(-70.0), pos.Quote)
|
||||||
assert.Equal(t, fixedpoint.NewFromFloat(0.04), pos.Base)
|
assert.Equal(t, fixedpoint.NewFromFloat(0.04), pos.Base)
|
||||||
assert.Equal(t, fixedpoint.NewFromFloat((1000.0*0.01+2000.0*0.03)/0.04), pos.AverageCost)
|
assert.Equal(t, fixedpoint.NewFromFloat((1000.0*0.01+2000.0*0.03)/0.04), pos.AverageCost)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user