Skip to content

Commit

Permalink
liqmaker: fix actual orders printing
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Oct 28, 2024
1 parent 6004114 commit 2b0e4e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 19 additions & 2 deletions pkg/strategy/liquiditymaker/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestLiquidityOrderGenerator(t *testing.T) {
assert.InDelta(t, 1000.0, totalQuoteQuantity.Float64(), 1.0)

AssertOrdersPriceSideQuantityFromText(t, `
BUY,0.2899,65.41
BUY,0.2899,65.41
BUY,0.2868,68.61
BUY,0.2837,71.97
BUY,0.2806,75.5
Expand All @@ -136,6 +136,23 @@ func TestLiquidityOrderGenerator(t *testing.T) {
BUY,0.2589,105.5
BUY,0.2558,110.67
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)
})
}
6 changes: 4 additions & 2 deletions pkg/testing/testhelper/assert_priceside.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ func AssertOrdersPriceSideQuantityFromText(
) {
asserts := ParsePriceSideQuantityAssertions(text)
assert.Equalf(t, len(asserts), len(orders), "expecting %d orders", len(asserts))
actualInText := "Actual Orders:\n"
for i, a := range asserts {
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.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)

actualInText += fmt.Sprintf("%s,%s,%s\n", order.Side, order.Price.String(), order.Quantity.String())
}

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)
}
}
Expand Down

0 comments on commit 2b0e4e0

Please sign in to comment.