diff --git a/src/components/StrategyEditor/StrategyEditor.container.js b/src/components/StrategyEditor/StrategyEditor.container.js index 98586b4ca..49760a874 100644 --- a/src/components/StrategyEditor/StrategyEditor.container.js +++ b/src/components/StrategyEditor/StrategyEditor.container.js @@ -104,6 +104,9 @@ const mapDispatchToProps = (dispatch) => ({ constraints, label, id, + leverageSettings, + stopOrderSettings, + margin, } = data const processedStrategy = _omitBy(strategyContent, _isEmpty) const sync = true @@ -125,9 +128,12 @@ const mapDispatchToProps = (dispatch) => ({ trades, candleSeed, sync, + margin, processedStrategy, uuidv4(), constraints, + leverageSettings, + stopOrderSettings, ], ], }), diff --git a/src/components/StrategyEditor/StrategyEditor.helpers.js b/src/components/StrategyEditor/StrategyEditor.helpers.js index c49889955..bf1691e96 100644 --- a/src/components/StrategyEditor/StrategyEditor.helpers.js +++ b/src/components/StrategyEditor/StrategyEditor.helpers.js @@ -149,13 +149,20 @@ export const prepareStrategyBacktestingArgs = (strategy) => { maxDrawdownPerc, startDate, endDate, + margin, + useMaxLeverage, + increaseLeverage, + leverage, + addStopOrder, + stopOrderPercent, }, strategyContent, id, } = strategy - return { + const args = { symbol: symbol?.wsID, + label, startNum: new Date(startDate).getTime(), endNum: new Date(endDate).getTime(), [STRATEGY_OPTIONS_KEYS.TIMEFRAME]: timeframe, @@ -164,13 +171,30 @@ export const prepareStrategyBacktestingArgs = (strategy) => { id, [STRATEGY_OPTIONS_KEYS.CANDLES]: candles, [STRATEGY_OPTIONS_KEYS.CANDLE_SEED]: candleSeed, + [STRATEGY_OPTIONS_KEYS.MARGIN]: margin, constraints: { [STRATEGY_OPTIONS_KEYS.CAPITAL_ALLOCATION]: Number(capitalAllocation), [STRATEGY_OPTIONS_KEYS.STOP_LOSS_PERC]: Number(stopLossPerc), [STRATEGY_OPTIONS_KEYS.MAX_DRAWDOWN_PERC]: Number(maxDrawdownPerc), }, - label, + leverageSettings: {}, + stopOrderSettings: { + addStopOrder, + }, + } + + if (margin) { + args.leverageSettings.useMaxLeverage = useMaxLeverage + if (!useMaxLeverage) { + args.leverageSettings.leverage = Number(leverage) + args.leverageSettings.increaseLeverage = increaseLeverage + } } + if (addStopOrder && stopOrderPercent) { + args.stopOrderSettings.stopOrderPercent = Number(stopOrderPercent) + } + + return args } export const prepareStrategyToLoad = (strategyToLoad, markets, strategies) => {