From 2b0e4e05124b920a8325941a7911073e821904bb Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 28 Oct 2024 14:52:13 +0800 Subject: [PATCH] liqmaker: fix actual orders printing --- pkg/strategy/liquiditymaker/generator_test.go | 21 +++++++++++++++++-- pkg/testing/testhelper/assert_priceside.go | 6 ++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pkg/strategy/liquiditymaker/generator_test.go b/pkg/strategy/liquiditymaker/generator_test.go index 4b67ab91d..a1113cf44 100644 --- a/pkg/strategy/liquiditymaker/generator_test.go +++ b/pkg/strategy/liquiditymaker/generator_test.go @@ -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 @@ -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) }) } diff --git a/pkg/testing/testhelper/assert_priceside.go b/pkg/testing/testhelper/assert_priceside.go index 592ed8c29..03e2fd7a1 100644 --- a/pkg/testing/testhelper/assert_priceside.go +++ b/pkg/testing/testhelper/assert_priceside.go @@ -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) } }