Open xfoxawy opened 1 year ago
adding new orders in the same level does not add up the amount
I have unit tests that are failing to show the case
t.Run("test adding multiple bid quantities to the same level ", func(t *testing.T) { var err error engine := NewLocalMatchingEngine("BTCUSD") updatesChan, _, ob, err := engine.SubscribeToOrderBook(ctx, "USDEGP") if err != nil { t.Fatal(err) } // check that the subscription channel receives a snapshot snapshot := <-updatesChan assert.NotNil(t, snapshot) // add levels to local matching engine var price float64 = 112.32 res1, err := engine.CreateOrder(ctx, types.CreateOrderRequest{ ExternalAccountId: "test-1234", Side: types.BUY, Price: &price, Quantity: 2.14, }) if err != nil { t.Fatal(err) } assert.NotNil(t, <-updatesChan) assert.Equal(t, "OPEN", res1.Status) res2, err := engine.CreateOrder(ctx, types.CreateOrderRequest{ ExternalAccountId: "test-1235", Side: types.BUY, Price: &price, Quantity: 1.24, }) if err != nil { t.Fatal(err) } assert.NotNil(t, <-updatesChan) assert.Equal(t, "OPEN", res2.Status) assert.Equal(t, fpdecimal.FromFloat[float64](10000), ob.GetBestBid()) assert.Equal(t, 1, ob.GetDepth(orderbook.Bid)) assert.Equal(t, fpdecimal.FromFloat[float64](3.38), ob.GetBestVolume(orderbook.Bid)) assert.Equal(t, decimal.NewFromFloat32(3.38), engine.orderbook.Depth().Bids()[0].Amount()) })
adding new orders in the same level does not add up the amount
I have unit tests that are failing to show the case