risk: fix margin level prec assertion

This commit is contained in:
c9s 2022-07-22 15:06:10 +08:00
parent 4b7126ce41
commit a609c0606a
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -150,5 +150,9 @@ func TestNewAccountValueCalculator_MarginLevel(t *testing.T) {
ctx := context.Background()
marginLevel, err := cal.MarginLevel(ctx)
assert.NoError(t, err)
assert.Equal(t, "1.10195728", marginLevel.String()) // 21000 / 19000 * 1.003
// expected (21000 / 19000 * 1.003)
assert.Equal(t,
fixedpoint.NewFromFloat(21000.0).Div(fixedpoint.NewFromFloat(19000.0).Mul(fixedpoint.NewFromFloat(1.003))).FormatString(6),
marginLevel.FormatString(6))
}