diff --git a/app/cronjob/trailingTrade/step/__tests__/ensure-grid-trade-order-executed.test.js b/app/cronjob/trailingTrade/step/__tests__/ensure-grid-trade-order-executed.test.js index 2144c655..d74448d7 100644 --- a/app/cronjob/trailingTrade/step/__tests__/ensure-grid-trade-order-executed.test.js +++ b/app/cronjob/trailingTrade/step/__tests__/ensure-grid-trade-order-executed.test.js @@ -20,6 +20,8 @@ describe('ensure-grid-trade-order-executed.js', () => { let mockGetGridTradeLastOrder; let mockDeleteGridTradeOrder; + let mockQueue; + describe('execute', () => { beforeEach(async () => { jest.clearAllMocks().resetModules(); @@ -31,6 +33,12 @@ describe('ensure-grid-trade-order-executed.js', () => { jest.requireActual('moment')(nextCheck || '2020-01-02T00:00:00+00:00') ); + mockQueue = { + executeFor: jest.fn().mockResolvedValue(true) + }; + + jest.mock('../../../trailingTradeHelper/queue', () => mockQueue); + const { slack, logger, PubSub } = require('../../../../helpers'); slackMock = slack; @@ -488,6 +496,10 @@ describe('ensure-grid-trade-order-executed.js', () => { ); }); + it('triggers queue.executeFor', () => { + expect(mockQueue.executeFor).toHaveBeenCalled(); + }); + it('triggers saveOrderStats', () => { expect(mockSaveOrderStats).toHaveBeenCalledWith(loggerMock, [ 'BTCUSDT', diff --git a/app/cronjob/trailingTrade/step/ensure-grid-trade-order-executed.js b/app/cronjob/trailingTrade/step/ensure-grid-trade-order-executed.js index 1753a398..7557a951 100644 --- a/app/cronjob/trailingTrade/step/ensure-grid-trade-order-executed.js +++ b/app/cronjob/trailingTrade/step/ensure-grid-trade-order-executed.js @@ -17,6 +17,7 @@ const { deleteGridTradeOrder, getGridTradeLastOrder } = require('../../trailingTradeHelper/order'); +const queue = require('../../trailingTradeHelper/queue'); /** * Remove last order from cache @@ -254,6 +255,13 @@ const execute = async (logger, rawData) => { }, temporaryDisableActionAfterConfirmingOrder ); + + // Queue other symbols to check if max. open trade is reached + symbols.map(async symbolToQueue => { + if (symbolToQueue !== symbol) { + queue.executeFor(logger, symbolToQueue); + } + }); } else if (removeStatuses.includes(lastBuyOrder.status)) { logger.info( {