From 5e0cdc50d7d35981e31ef23890c99c746eedf875 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Fri, 11 Mar 2022 12:00:46 +1100 Subject: [PATCH] ftx: Add filter for negative orderbook values on bear tokens [REST] (#898) * ftx: Add filter for negative values on bear tokens * ftx: string comparison after issue found --- exchanges/ftx/ftx_test.go | 12 ++++++++++++ exchanges/ftx/ftx_wrapper.go | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/exchanges/ftx/ftx_test.go b/exchanges/ftx/ftx_test.go index 9b24791c..d36326e6 100644 --- a/exchanges/ftx/ftx_test.go +++ b/exchanges/ftx/ftx_test.go @@ -1042,6 +1042,18 @@ func TestUpdateOrderbook(t *testing.T) { if err != nil { t.Error(err) } + + cp = currency.NewPairWithDelimiter("ALGOBEAR", currency.USD.String(), "/") + _, err = f.UpdateOrderbook(context.Background(), cp, asset.Spot) + if err != nil { + t.Error(err) + } + + cp = currency.NewPairWithDelimiter("ASDBEAR", currency.USD.String(), "/") + _, err = f.UpdateOrderbook(context.Background(), cp, asset.Spot) + if err != nil { + t.Error(err) + } } func TestUpdateTicker(t *testing.T) { diff --git a/exchanges/ftx/ftx_wrapper.go b/exchanges/ftx/ftx_wrapper.go index 31b29952..db10affc 100644 --- a/exchanges/ftx/ftx_wrapper.go +++ b/exchanges/ftx/ftx_wrapper.go @@ -430,12 +430,21 @@ func (f *FTX) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType as if err != nil { return book, err } + for x := range tempResp.Bids { + // Bear tokens have illiquid books and contain negative place holders. + if tempResp.Bids[x].Size < 0 && strings.Contains(p.String(), "BEAR") { + continue + } book.Bids = append(book.Bids, orderbook.Item{ Amount: tempResp.Bids[x].Size, Price: tempResp.Bids[x].Price}) } for y := range tempResp.Asks { + // Bear tokens have illiquid books and contain negative place holders. + if tempResp.Asks[y].Size < 0 && strings.Contains(p.String(), "BEAR") { + continue + } book.Asks = append(book.Asks, orderbook.Item{ Amount: tempResp.Asks[y].Size, Price: tempResp.Asks[y].Price})