From ef60ce242e3942b86e606f447a82e99dfdf39211 Mon Sep 17 00:00:00 2001 From: Dmytro Shcherbonos <81973123+dmytroshch@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:49:38 +0300 Subject: [PATCH] Hide Recurring for paper (#694) * processRecurringAO saga: pass not recurring aos * reset order history on mode change * improved getOrderHistory selector * save shown recurring atomics notifications * AlgoOrdersDetailsModal: improved UX - avoid blinking on close * update algo and indicators libs * rc4 * fix property name * fix trailing stop editing * fix stop limit editing * hide recurring for paper mode --- src/components/OrderForm/OrderForm.js | 6 ++-- .../OrderForm/OrderForm.orders.helpers.js | 29 +++++++++++-------- src/modals/EditOrderModal/EditOrderModal.js | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/components/OrderForm/OrderForm.js b/src/components/OrderForm/OrderForm.js index 444c1025a..2834b87fa 100644 --- a/src/components/OrderForm/OrderForm.js +++ b/src/components/OrderForm/OrderForm.js @@ -142,9 +142,10 @@ class OrderForm extends React.Component { aoParams, t, showAdvancedAlgos, + isPaperTrading, } = this.props const { currentMarket } = this.state - const algoOrders = getAOs(t, showAdvancedAlgos) + const algoOrders = getAOs(t, showAdvancedAlgos, false, isPaperTrading) const orders = getAtomicOrders(t) resetActiveAOParamsID() @@ -395,6 +396,7 @@ class OrderForm extends React.Component { t, showAdvancedAlgos, isAlgoWorkerStarted, + isPaperTrading, } = this.props const orders = getAtomicOrders(t) @@ -409,7 +411,7 @@ class OrderForm extends React.Component { isAlgoOrder, } = this.state - const algoOrders = getAOs(t, showAdvancedAlgos) + const algoOrders = getAOs(t, showAdvancedAlgos, false, isPaperTrading) const processedAOs = filterAOs(algoOrders, activeMarket) const apiClientConfigured = apiCredentials?.configured && apiCredentials?.valid diff --git a/src/components/OrderForm/OrderForm.orders.helpers.js b/src/components/OrderForm/OrderForm.orders.helpers.js index a36286743..11691c4bf 100644 --- a/src/components/OrderForm/OrderForm.orders.helpers.js +++ b/src/components/OrderForm/OrderForm.orders.helpers.js @@ -10,27 +10,32 @@ import memoizeOne from 'memoize-one' import _values from 'lodash/values' import _map from 'lodash/map' import _filter from 'lodash/filter' - import { isElectronApp } from '../../redux/config' import timeFrames from '../../util/time_frames' import rawOrders from '../../orders' -const DEV_ONLY_ALGO_ORDERS = [AccumulateDistribute, Recurring] - -const getAlgoOrdersForStandalone = (isBeta) => [ - ...(isBeta ? DEV_ONLY_ALGO_ORDERS : []), - PingPong, - Iceberg, - TWAP, - Bracket, -] +const getAlgoOrdersForStandalone = (isBeta, isPaperTrading) => { + const aos = [ + PingPong, + Iceberg, + TWAP, + Bracket, + ] + if (isBeta) { + if (!isPaperTrading) { + aos.unshift(Recurring) + } + aos.unshift(AccumulateDistribute) + } + return aos +} const HOSTED_ALGO_ORDERS = [Iceberg, TWAP] -const getAlgoOrders = (isBeta) => (isElectronApp ? getAlgoOrdersForStandalone(isBeta) : HOSTED_ALGO_ORDERS) +const getAlgoOrders = (isBeta, isPaperTrading) => (isElectronApp ? getAlgoOrdersForStandalone(isBeta, isPaperTrading) : HOSTED_ALGO_ORDERS) -export const getAOs = memoizeOne((t, isBeta, isEditMode = false) => _map(getAlgoOrders(isBeta), (ao) => ao.meta.getUIDef({ +export const getAOs = memoizeOne((t, isBeta, isEditMode, isPaperTrading = false) => _map(getAlgoOrders(isBeta, isPaperTrading), (ao) => ao.meta.getUIDef({ timeframes: timeFrames, i18n: { t, prefix: 'algoOrderForm.' }, isEditMode, diff --git a/src/modals/EditOrderModal/EditOrderModal.js b/src/modals/EditOrderModal/EditOrderModal.js index 8dcfac4d8..3f6a3651c 100644 --- a/src/modals/EditOrderModal/EditOrderModal.js +++ b/src/modals/EditOrderModal/EditOrderModal.js @@ -67,7 +67,7 @@ const EditOrderModal = ({ return } const updOrder = { ...order } - const algoOrders = getAOs(t, true, !isRelaunching) + const algoOrders = getAOs(t, true, !isRelaunching, false) let isAlgoOrder = true let uiDef = _find( algoOrders,