liqmaker: fix actual orders printing

This commit is contained in:
c9s 2024-10-28 14:52:13 +08:00
parent 6004114696
commit 2b0e4e0512
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 23 additions and 4 deletions

View File

@ -136,6 +136,23 @@ func TestLiquidityOrderGenerator(t *testing.T) {
BUY,0.2589,105.5 BUY,0.2589,105.5
BUY,0.2558,110.67 BUY,0.2558,110.67
BUY,0.2527,116.09 BUY,0.2527,116.09
`, orders[0:13]) BUY,0.2496,121.77
BUY,0.2465,127.74
BUY,0.2434,133.99
BUY,0.2403,140.55
BUY,0.2372,147.44
BUY,0.2341,154.65
BUY,0.231,162.23
BUY,0.2279,170.17
BUY,0.2248,178.5
BUY,0.2217,187.24
BUY,0.2186,196.41
BUY,0.2155,206.03
BUY,0.2124,216.12
BUY,0.2093,226.7
BUY,0.2062,237.8
BUY,0.2031,249.44
BUY,0.2,261.66
`, orders)
}) })
} }

View File

@ -62,17 +62,19 @@ func AssertOrdersPriceSideQuantityFromText(
) { ) {
asserts := ParsePriceSideQuantityAssertions(text) asserts := ParsePriceSideQuantityAssertions(text)
assert.Equalf(t, len(asserts), len(orders), "expecting %d orders", len(asserts)) assert.Equalf(t, len(asserts), len(orders), "expecting %d orders", len(asserts))
actualInText := "Actual Orders:\n"
for i, a := range asserts { for i, a := range asserts {
order := orders[i] order := orders[i]
assert.Equalf(t, a.Price.Float64(), order.Price.Float64(), "order #%d price should be %f", i+1, a.Price.Float64()) assert.Equalf(t, a.Price.Float64(), order.Price.Float64(), "order #%d price should be %f", i+1, a.Price.Float64())
assert.Equalf(t, a.Quantity.Float64(), order.Quantity.Float64(), "order #%d quantity should be %f", i+1, a.Quantity.Float64()) assert.Equalf(t, a.Quantity.Float64(), order.Quantity.Float64(), "order #%d quantity should be %f", i+1, a.Quantity.Float64())
assert.Equalf(t, a.Side, orders[i].Side, "order at price %f should be %s", a.Price.Float64(), a.Side) assert.Equalf(t, a.Side, orders[i].Side, "order at price %f should be %s", a.Price.Float64(), a.Side)
actualInText += fmt.Sprintf("%s,%s,%s\n", order.Side, order.Price.String(), order.Quantity.String())
} }
if t.Failed() { if t.Failed() {
actualInText := "Actual Orders:\n"
for _, order := range orders {
actualInText += fmt.Sprintf("%s,%s,%s\n", order.Side, order.Price.String(), order.Quantity.String())
}
t.Log(actualInText) t.Log(actualInText)
} }
} }