From bfa68bed5af9239750c31e697c67538bc3915c08 Mon Sep 17 00:00:00 2001 From: via Date: Mon, 22 Apr 2024 16:09:14 +0800 Subject: [PATCH] add go mod and fix tests --- .gitignore | 1 + go.mod | 8 ++++++++ go.sum | 4 ++++ orderbook_test.go | 8 ++++---- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..33dd18b --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module orderbook + +go 1.22.1 + +require ( + github.com/emirpasic/gods v1.18.1 + github.com/shopspring/decimal v1.4.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3c33ec2 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= +github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= diff --git a/orderbook_test.go b/orderbook_test.go index bddb6a4..84abc2d 100644 --- a/orderbook_test.go +++ b/orderbook_test.go @@ -240,7 +240,7 @@ func TestPriceCalculation(t *testing.T) { addDepth(ob, "15-", decimal.New(10, 0)) t.Log(ob) - price, err := ob.CalculateMarketPrice(Buy, decimal.New(115, 0)) + price, _, err := ob.CalculateMarketPrice(Buy, decimal.New(115, 0)) if err != nil { t.Fatal(err) } @@ -249,7 +249,7 @@ func TestPriceCalculation(t *testing.T) { t.Fatal("invalid price", price) } - price, err = ob.CalculateMarketPrice(Buy, decimal.New(200, 0)) + price, _, err = ob.CalculateMarketPrice(Buy, decimal.New(200, 0)) if err == nil { t.Fatal("invalid quantity count") } @@ -260,7 +260,7 @@ func TestPriceCalculation(t *testing.T) { // ------- - price, err = ob.CalculateMarketPrice(Sell, decimal.New(115, 0)) + price, _, err = ob.CalculateMarketPrice(Sell, decimal.New(115, 0)) if err != nil { t.Fatal(err) } @@ -269,7 +269,7 @@ func TestPriceCalculation(t *testing.T) { t.Fatal("invalid price", price) } - price, err = ob.CalculateMarketPrice(Sell, decimal.New(200, 0)) + price, _, err = ob.CalculateMarketPrice(Sell, decimal.New(200, 0)) if err == nil { t.Fatal("invalid quantity count") }