Skip to content

Commit

Permalink
Merge pull request #719 from dmytroshch/feature/beta
Browse files Browse the repository at this point in the history
(feature) Recurring, AccDist AOs and strategy editor are moved out from beta
  • Loading branch information
bhoomij authored Nov 14, 2024
2 parents 4cf25ce + c68e887 commit d64e9ac
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 117 deletions.
3 changes: 0 additions & 3 deletions src/components/HFUI/HFUI.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
getCurrentMode,
getShowAlgoPauseInfoSetting,
getThemeSetting,
getIsBetaVersion,
getIsStrategiesTabVisible,
SETTINGS_KEYS,
getIsFullscreen,
} from '../../redux/selectors/ui'
Expand All @@ -33,7 +31,6 @@ const mapStateToProps = (state = {}) => {
settingsShowAlgoPauseInfo: getShowAlgoPauseInfoSetting(state),
settingsTheme: getThemeSetting(state),
isBfxConnected: getIsBitfinexConnected(state),
showStrategies: getIsBetaVersion(state) || getIsStrategiesTabVisible(state),
isFullscreen: getIsFullscreen(state),
}
}
Expand Down
15 changes: 6 additions & 9 deletions src/components/HFUI/HFUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const HFUI = (props) => {
settingsShowAlgoPauseInfo,
settingsTheme,
isBfxConnected,
showStrategies,
getPastStrategies,
openAppSettingsModal,
setApplicationHiddenStatus,
Expand Down Expand Up @@ -167,12 +166,12 @@ const HFUI = (props) => {
render={() => <TradingPage />}
exact
/>
{showStrategies && Routes.strategyEditor && (
<Route
path={Routes.strategyEditor.path}
render={() => <StrategiesPage />}
/>
)}
(
<Route
path={Routes.strategyEditor.path}
render={() => <StrategiesPage />}
/>
)
<Route
path={Routes.marketData.path}
render={() => <MarketDataPage />}
Expand Down Expand Up @@ -212,7 +211,6 @@ HFUI.propTypes = {
settingsShowAlgoPauseInfo: PropTypes.bool,
settingsTheme: PropTypes.oneOf([THEMES.LIGHT, THEMES.DARK]),
isBfxConnected: PropTypes.bool,
showStrategies: PropTypes.bool,
openAppSettingsModal: PropTypes.func.isRequired,
setApplicationHiddenStatus: PropTypes.func.isRequired,
updateFullscreenState: PropTypes.func.isRequired,
Expand All @@ -224,7 +222,6 @@ HFUI.defaultProps = {
settingsShowAlgoPauseInfo: true,
settingsTheme: THEMES.DARK,
isBfxConnected: false,
showStrategies: false,
}

export default HFUI
12 changes: 4 additions & 8 deletions src/components/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ import LayoutSettings from './Navbar.LayoutSettings'
import APIBanner from './Navbar.APIBanner'
import AppSettings from './Navbar.AppSettings'
import RCDisclaimer from '../RCDisclaimer/RCDisclaimer'
import Routes, { strategyEditor } from '../../constants/routes'
import Routes from '../../constants/routes'
import { isElectronApp } from '../../redux/config'
import {
getThemeSetting,
THEMES,
getIsPaperTrading,
getIsBetaVersion,
getIsStrategiesTabVisible,
getUIState,
} from '../../redux/selectors/ui'
import { UI_MODAL_KEYS } from '../../redux/constants/modals'
Expand Down Expand Up @@ -60,11 +58,9 @@ const Navbar = () => {
const { t } = useTranslation()
const settingsTheme = useSelector(getThemeSetting)
const isPaperTrading = useSelector(getIsPaperTrading)
const isBetaVersion = useSelector(getIsBetaVersion)
const isStrategiesTabVisible = useSelector(getIsStrategiesTabVisible)
const showRCDisclaimer = useSelector((state) => getUIState(state, UI_KEYS.isRCDisclaimerShown),
)
const showStrategies = isBetaVersion || isStrategiesTabVisible

const leafOptions = useMemo(
() => getLeafDropdownOptions(settingsTheme),
[settingsTheme],
Expand All @@ -84,7 +80,7 @@ const Navbar = () => {
/>
<ul className='hfui-navbar__main-links'>
{_map(_values(Routes), ({ path, label }) => {
return showStrategies || path !== strategyEditor.path ? (
return (
<li key={path}>
<NavbarLink
route={path}
Expand All @@ -93,7 +89,7 @@ const Navbar = () => {
})}
/>
</li>
) : null
)
})}
</ul>
<div className='hfui-tradingpage__menu'>
Expand Down
5 changes: 0 additions & 5 deletions src/components/OrderForm/OrderForm.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ import {
getCurrentMode,
getIsPaperTrading,
getMaxOrderCounts,
getIsBetaVersion,
getUIState,
getServicesStatus,
getIsRecurringAOVisible,
} from '../../redux/selectors/ui'
import { getScope } from '../../util/scope'
import { UI_KEYS } from '../../redux/constants/ui_keys'
Expand Down Expand Up @@ -66,9 +64,6 @@ const mapStateToProps = (state = {}) => {
isOrderExecuting: getUIState(state, UI_KEYS.isOrderExecuting, false),
aoParams: getAOParams(state),
maxOrderCounts: getMaxOrderCounts(state),
isBetaVersion: getIsBetaVersion(state),
showAdvancedAlgos:
getIsRecurringAOVisible(state) || getIsBetaVersion(state),
isAlgoWorkerStarted: getServicesStatus(state)?.algoWorker,
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/components/OrderForm/OrderForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ class OrderForm extends React.Component {
getAlgoOrderParams,
aoParams,
t,
showAdvancedAlgos,
isPaperTrading,
} = this.props
const { currentMarket } = this.state
const algoOrders = getAOs(t, showAdvancedAlgos, false, isPaperTrading)
const algoOrders = getAOs({ t, isEditMode: false, isPaperTrading })
const orders = getAtomicOrders(t)
resetActiveAOParamsID()

Expand Down Expand Up @@ -394,7 +393,6 @@ class OrderForm extends React.Component {
isOrderExecuting,
activeMarket,
t,
showAdvancedAlgos,
isAlgoWorkerStarted,
isPaperTrading,
} = this.props
Expand All @@ -411,7 +409,7 @@ class OrderForm extends React.Component {
isAlgoOrder,
} = this.state

const algoOrders = getAOs(t, showAdvancedAlgos, false, isPaperTrading)
const algoOrders = getAOs({ t, isEditMode: false, isPaperTrading })
const processedAOs = filterAOs(algoOrders, activeMarket)

const apiClientConfigured = apiCredentials?.configured && apiCredentials?.valid
Expand Down Expand Up @@ -590,7 +588,6 @@ OrderForm.propTypes = {
isOrderExecuting: PropTypes.bool,
moveable: PropTypes.bool,
removeable: PropTypes.bool,
showAdvancedAlgos: PropTypes.bool,
t: PropTypes.func.isRequired,
atomicOrdersCount: PropTypes.number.isRequired,
atomicOrdersCountActiveMarket: PropTypes.number.isRequired,
Expand All @@ -609,7 +606,6 @@ OrderForm.defaultProps = {
apiCredentials: {},
onRemove: () => { },
authToken: null,
showAdvancedAlgos: false,
}

export default OrderForm
15 changes: 7 additions & 8 deletions src/components/OrderForm/OrderForm.orders.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@ import timeFrames from '../../util/time_frames'

import rawOrders from '../../orders'

const getAlgoOrdersForStandalone = (isBeta, isPaperTrading) => {
const getAlgoOrdersForStandalone = (isPaperTrading) => {
const aos = [
AccumulateDistribute,
PingPong,
Iceberg,
TWAP,
Bracket,
]
if (isBeta) {
if (!isPaperTrading) {
aos.unshift(Recurring)
}
aos.unshift(AccumulateDistribute)
if (!isPaperTrading) {
aos.unshift(Recurring)
}

return aos
}

const HOSTED_ALGO_ORDERS = [Iceberg, TWAP]

const getAlgoOrders = (isBeta, isPaperTrading) => (isElectronApp ? getAlgoOrdersForStandalone(isBeta, isPaperTrading) : HOSTED_ALGO_ORDERS)
const getAlgoOrders = (isPaperTrading) => (isElectronApp ? getAlgoOrdersForStandalone(isPaperTrading) : HOSTED_ALGO_ORDERS)

export const getAOs = memoizeOne((t, isBeta, isEditMode, isPaperTrading = false) => _map(getAlgoOrders(isBeta, isPaperTrading), (ao) => ao.meta.getUIDef({
export const getAOs = memoizeOne(({ t, isEditMode, isPaperTrading = false }) => _map(getAlgoOrders(isPaperTrading), (ao) => ao.meta.getUIDef({
timeframes: timeFrames,
i18n: { t, prefix: 'algoOrderForm.' },
isEditMode,
Expand Down
4 changes: 0 additions & 4 deletions src/components/StrategyEditor/StrategyEditor.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
import {
getThemeSetting,
getIsPaperTrading,
getStrategiesFeatureFlags,
getIsBetaVersion,
getCurrentMode,
getStrategyExecutionId,
getServicesStatus,
Expand All @@ -35,8 +33,6 @@ const mapStateToProps = (state = {}) => {
executionState: getCurrentStrategyExecutionState(state),
settingsTheme: getThemeSetting(state),
isPaperTrading: getIsPaperTrading(state),
flags: getStrategiesFeatureFlags(state),
isBetaVersion: getIsBetaVersion(state),
savedStrategies: getSavedStrategies(state),
currentMode: getCurrentMode(state),
executionId: getStrategyExecutionId(state),
Expand Down
89 changes: 39 additions & 50 deletions src/components/StrategyEditor/StrategyEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ const StrategyEditor = (props) => {
isPaperTrading,
dsExecuteBacktest,
showError,
flags,
isBetaVersion,
executionState,
sectionErrors,
savedStrategies,
Expand Down Expand Up @@ -663,23 +661,22 @@ const StrategyEditor = (props) => {
onRemoveStrategy={onRemoveStrategy}
isWideSidebar={isWideSidebar}
>
{(isBetaVersion || flags?.live_execution) && (
<StrategyTab
htmlKey='strategy'
sbtitle={sbtitleStrategy}
onOpenSaveStrategyAsModal={openSaveStrategyAsModal}
onOpenEditStrategyLabelModal={openEditStrategyLabelModal}
isPaperTrading={isPaperTrading}
stopExecution={stopExecution}
onSaveStrategy={onSaveStrategy}
saveStrategyOptions={saveStrategyOptions}
hasErrors={hasErrorsInIDE}
onCancelProcess={onCancelProcess}
{...props}
/>
)}

{isPaperTrading && (isBetaVersion || flags?.backtest) && (
<StrategyTab
htmlKey='strategy'
sbtitle={sbtitleStrategy}
onOpenSaveStrategyAsModal={openSaveStrategyAsModal}
onOpenEditStrategyLabelModal={openEditStrategyLabelModal}
isPaperTrading={isPaperTrading}
stopExecution={stopExecution}
onSaveStrategy={onSaveStrategy}
saveStrategyOptions={saveStrategyOptions}
hasErrors={hasErrorsInIDE}
onCancelProcess={onCancelProcess}
{...props}
/>

{isPaperTrading ? (
<BacktestTab
htmlKey='backtest'
sbtitle={sbtitleBacktest}
Expand All @@ -688,32 +685,30 @@ const StrategyEditor = (props) => {
onCancelProcess={onCancelProcess}
{...props}
/>
)}
{(isBetaVersion || flags?.docs) && !isPaperTrading && (
<IDETab
htmlKey='view_in_ide'
key='view_in_ide'
hasErrors={hasErrorsInIDE}
onSaveStrategy={onSaveStrategy}
onOpenSaveStrategyAsModal={openSaveStrategyAsModal}
sbtitle={sbtitleIDE}
setStrategyDirty={setStrategyDirty}
onDefineIndicatorsChange={onDefineIndicatorsChange}
evalSectionContent={evalSectionContent}
setSectionErrors={setSectionErrors}
sectionErrors={sectionErrors}
setStrategy={setStrategy}
strategy={strategy}
/>
)}
{(isBetaVersion || flags?.live_execution) && (
<div
htmlKey='settings'
key='settings'
sbtitle={sbtitleSettings}
onClick={openStrategySettingsModal}
/>
)}
)
: (
<IDETab
htmlKey='view_in_ide'
key='view_in_ide'
hasErrors={hasErrorsInIDE}
onSaveStrategy={onSaveStrategy}
onOpenSaveStrategyAsModal={openSaveStrategyAsModal}
sbtitle={sbtitleIDE}
setStrategyDirty={setStrategyDirty}
onDefineIndicatorsChange={onDefineIndicatorsChange}
evalSectionContent={evalSectionContent}
setSectionErrors={setSectionErrors}
sectionErrors={sectionErrors}
setStrategy={setStrategy}
strategy={strategy}
/>
)}
<div
htmlKey='settings'
key='settings'
sbtitle={sbtitleSettings}
onClick={openStrategySettingsModal}
/>
</StrategyEditorPanel>
<RemoveExistingStrategyModal
isOpen={isRemoveModalOpen}
Expand Down Expand Up @@ -811,12 +806,6 @@ StrategyEditor.propTypes = {
saveStrategy: PropTypes.func.isRequired,
isPaperTrading: PropTypes.bool.isRequired,
dsExecuteBacktest: PropTypes.func.isRequired,
isBetaVersion: PropTypes.bool.isRequired,
flags: PropTypes.shape({
docs: PropTypes.bool,
live_execution: PropTypes.bool,
backtest: PropTypes.bool,
}).isRequired,
showError: PropTypes.func.isRequired,
sectionErrors: PropTypes.objectOf(PropTypes.string).isRequired,
cancelProcess: PropTypes.func.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions src/modals/EditOrderModal/EditOrderModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const EditOrderModal = ({
return
}
const updOrder = { ...order }
const algoOrders = getAOs(t, true, !isRelaunching, false)
const algoOrders = getAOs({ t, isEditMode: !isRelaunching, isPaperTrading: false })
let isAlgoOrder = true
let uiDef = _find(
algoOrders,
Expand Down Expand Up @@ -110,7 +110,7 @@ const EditOrderModal = ({
setDiscardConfirmationVisible(false)

setTimeout(() => {
// clearing order data after modal close amination ends
// clearing order data after modal close animation ends
setLayout({})
setArgs({})
}, 600)
Expand Down
22 changes: 0 additions & 22 deletions src/redux/selectors/ui/get_feature_flags.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
import _get from 'lodash/get'
import _some from 'lodash/some'
import { createSelector } from 'reselect'
import { REDUCER_PATHS } from '../../config'

const path = REDUCER_PATHS.UI

export const getFeatureFlags = (state) => _get(state, `${path}.featureFlags`)

export const getStrategiesFeatureFlags = createSelector(
getFeatureFlags,
(allFlags) => allFlags?.strategy_editor,
)

export const getIsStrategiesLiveExecVisible = createSelector(
getStrategiesFeatureFlags,
(strategiesFlags) => strategiesFlags?.live_execution,
)

export const getIsStrategiesTabVisible = createSelector(
getStrategiesFeatureFlags,
(strategiesFlags) => _some(strategiesFlags, (flag) => flag === true),
)

export const getIsRecurringAOVisible = createSelector(
getFeatureFlags,
(flags) => flags?.recurring_AOs,
)

export default getFeatureFlags

0 comments on commit d64e9ac

Please sign in to comment.