Skip to content

Commit

Permalink
feat: Set limit on order book size (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
gazbert committed Nov 24, 2024
1 parent b8095c6 commit 9f4f1ba
Show file tree
Hide file tree
Showing 4 changed files with 422 additions and 7,613 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;

import com.gazbert.bxbot.exchange.api.AuthenticationConfig;
import com.gazbert.bxbot.exchange.api.ExchangeAdapter;
Expand Down Expand Up @@ -92,8 +93,8 @@ public void testPublicApiCalls() throws Exception {
exchangeAdapter.init(exchangeConfig);

final MarketOrderBook orderBook = exchangeAdapter.getMarketOrders(MARKET_ID);
assertFalse(orderBook.getBuyOrders().isEmpty());
assertFalse(orderBook.getSellOrders().isEmpty());
assertEquals(100, orderBook.getBuyOrders().size());
assertEquals(100, orderBook.getSellOrders().size());

verify(authenticationConfig, networkConfig, otherConfig, exchangeConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class CoinbaseExchangeAdapter extends AbstractExchangeAdapter

private static final String PRODUCT_BOOK = "/market/product_book";
private static final String PRODUCT_ID_PARAM = "product_id";
private static final String PRODUCT_BOOK_LIMIT_PARAM = "limit";
private static final int PRODUCT_BOOK_LIMIT_VALUE = 100;

private static final String UNEXPECTED_ERROR_MSG =
"Unexpected error has occurred in Coinbase Advanced Trade Exchange Adapter. ";
Expand Down Expand Up @@ -122,6 +124,7 @@ public MarketOrderBook getMarketOrders(String marketId)
try {
final Map<String, String> params = createRequestParamMap();
params.put(PRODUCT_ID_PARAM, marketId);
params.put(PRODUCT_BOOK_LIMIT_PARAM, String.valueOf(PRODUCT_BOOK_LIMIT_VALUE));

final ExchangeHttpResponse response = sendPublicRequestToExchange(PRODUCT_BOOK, params);

Expand Down
Loading

0 comments on commit 9f4f1ba

Please sign in to comment.