mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
add more position tests
This commit is contained in:
parent
34148948ab
commit
169af63846
|
@ -12,14 +12,16 @@ import (
|
|||
func TestPosition(t *testing.T) {
|
||||
trades := []types.Trade{
|
||||
{
|
||||
Side: types.SideTypeBuy,
|
||||
Price: 1000.0,
|
||||
Quantity: 0.01,
|
||||
Side: types.SideTypeBuy,
|
||||
Price: 1000.0,
|
||||
Quantity: 0.01,
|
||||
QuoteQuantity: 1000.0 * 0.01,
|
||||
},
|
||||
{
|
||||
Side: types.SideTypeBuy,
|
||||
Price: 2000.0,
|
||||
Quantity: 0.03,
|
||||
Side: types.SideTypeBuy,
|
||||
Price: 2000.0,
|
||||
Quantity: 0.03,
|
||||
QuoteQuantity: 2000.0 * 0.03,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -28,6 +30,7 @@ func TestPosition(t *testing.T) {
|
|||
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((1000.0*0.01+2000.0*0.03)/0.04), pos.AverageCost)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user