1 line
153 KiB
JavaScript
1 line
153 KiB
JavaScript
"use strict";(self["webpackChunkvue_antd_pro"]=self["webpackChunkvue_antd_pro"]||[]).push([[79],{24079:function(t,e,a){a.r(e),a.d(e,{default:function(){return gt}});a(74423);var i=function(){var t,e=this,a=e._self._c;return a("div",{staticClass:"trading-assistant",class:{"theme-dark":e.isDarkTheme}},[a("a-row",{staticClass:"strategy-layout",attrs:{gutter:24}},[a("a-col",{staticClass:"strategy-list-col",attrs:{xs:24,sm:24,md:10,lg:8,xl:8}},[a("a-card",{staticClass:"strategy-list-card",attrs:{bordered:!1}},[a("div",{staticClass:"card-title",attrs:{slot:"title"},slot:"title"},[a("span",[e._v(e._s(e.$t("trading-assistant.strategyList")))]),a("a-button",{attrs:{type:"primary",size:"small"},on:{click:e.handleCreateStrategy}},[a("a-icon",{attrs:{type:"plus"}}),e._v(" "+e._s(e.$t("trading-assistant.createStrategy"))+" ")],1)],1),a("div",{staticClass:"group-mode-switch"},[a("span",{staticClass:"group-mode-label"},[e._v(e._s(e.$t("trading-assistant.groupBy"))+":")]),a("a-radio-group",{attrs:{size:"small","button-style":"solid"},model:{value:e.groupByMode,callback:function(t){e.groupByMode=t},expression:"groupByMode"}},[a("a-radio-button",{attrs:{value:"strategy"}},[a("a-icon",{attrs:{type:"folder"}}),e._v(" "+e._s(e.$t("trading-assistant.groupByStrategy"))+" ")],1),a("a-radio-button",{attrs:{value:"symbol"}},[a("a-icon",{attrs:{type:"stock"}}),e._v(" "+e._s(e.$t("trading-assistant.groupBySymbol"))+" ")],1)],1)],1),a("a-spin",{attrs:{spinning:e.loading}},[e.loading||0!==e.strategies.length?a("div",{staticClass:"strategy-grouped-list"},[e._l(e.groupedStrategies.groups,function(t){return a("div",{key:t.id,staticClass:"strategy-group"},[a("div",{staticClass:"strategy-group-header",on:{click:function(a){return e.toggleGroup(t.id)}}},[a("div",{staticClass:"group-header-left"},[a("a-icon",{staticClass:"collapse-icon",attrs:{type:e.collapsedGroups[t.id]?"right":"down"}}),a("a-icon",{staticClass:"group-icon",attrs:{type:"symbol"===e.groupByMode?"stock":"folder"}}),a("span",{staticClass:"group-name"},[e._v(e._s(t.baseName))]),a("a-tag",{attrs:{size:"small",color:"blue"}},[e._v(e._s(t.strategies.length)+" "+e._s("symbol"===e.groupByMode?e.$t("trading-assistant.strategyCount"):e.$t("trading-assistant.symbolCount")))])],1),a("div",{staticClass:"group-header-right",on:{click:function(t){t.stopPropagation()}}},[t.runningCount>0?a("span",{staticClass:"group-status running"},[e._v(" "+e._s(t.runningCount)+" "+e._s(e.$t("trading-assistant.status.running"))+" ")]):e._e(),t.stoppedCount>0?a("span",{staticClass:"group-status stopped"},[e._v(" "+e._s(t.stoppedCount)+" "+e._s(e.$t("trading-assistant.status.stopped"))+" ")]):e._e(),a("a-dropdown",{attrs:{getPopupContainer:e.getDropdownContainer,trigger:["click"]}},[a("a-menu",{attrs:{slot:"overlay"},on:{click:function(a){var i=a.key;return e.handleGroupMenuClick(i,t)}},slot:"overlay"},[a("a-menu-item",{key:"startAll"},[a("a-icon",{attrs:{type:"play-circle"}}),e._v(" "+e._s(e.$t("trading-assistant.startAll"))+" ")],1),a("a-menu-item",{key:"stopAll"},[a("a-icon",{attrs:{type:"pause-circle"}}),e._v(" "+e._s(e.$t("trading-assistant.stopAll"))+" ")],1),a("a-menu-divider"),a("a-menu-item",{key:"deleteAll",staticClass:"danger-item"},[a("a-icon",{attrs:{type:"delete"}}),e._v(" "+e._s(e.$t("trading-assistant.deleteAll"))+" ")],1)],1),a("a-button",{attrs:{type:"link",icon:"more",size:"small"}})],1)],1)]),a("div",{directives:[{name:"show",rawName:"v-show",value:!e.collapsedGroups[t.id],expression:"!collapsedGroups[group.id]"}],staticClass:"strategy-group-content"},e._l(t.strategies,function(t){return a("div",{key:t.id,class:["strategy-list-item",{active:e.selectedStrategy&&e.selectedStrategy.id===t.id}],on:{click:function(a){return e.handleSelectStrategy(t)}}},[a("div",{staticClass:"strategy-item-content"},[a("div",{staticClass:"strategy-item-header"},[a("div",{staticClass:"strategy-name-wrapper"},["strategy"===e.groupByMode?[t.trading_config&&t.trading_config.symbol?a("span",{staticClass:"info-item"},[a("a-icon",{attrs:{type:"dollar"}}),e._v(" "+e._s(t.trading_config.symbol)+" ")],1):e._e()]:[a("span",{staticClass:"info-item strategy-name-text"},[a("a-icon",{attrs:{type:"thunderbolt"}}),e._v(" "+e._s(t.displayInfo?t.displayInfo.strategyName:t.strategy_name)+" ")],1),t.displayInfo&&t.displayInfo.timeframe?a("a-tag",{attrs:{size:"small",color:"cyan"}},[a("a-icon",{staticStyle:{"margin-right":"2px"},attrs:{type:"clock-circle"}}),e._v(" "+e._s(t.displayInfo.timeframe)+" ")],1):e._e(),t.displayInfo&&t.displayInfo.indicatorName&&"-"!==t.displayInfo.indicatorName?a("a-tag",{attrs:{size:"small",color:"purple"}},[a("a-icon",{staticStyle:{"margin-right":"2px"},attrs:{type:"line-chart"}}),e._v(" "+e._s(t.displayInfo.indicatorName)+" ")],1):e._e()],"script"===t.strategy_mode?a("a-tag",{staticStyle:{"margin-left":"4px"},attrs:{size:"small",color:"green"}},[a("a-icon",{staticStyle:{"margin-right":"2px"},attrs:{type:"code"}}),e._v(e._s(e.$t("trading-assistant.strategyMode.script"))+" ")],1):e._e(),a("span",{staticClass:"status-label",class:[t.status?"status-".concat(t.status):"",{"status-stopped":"stopped"===t.status}]},[e._v(" "+e._s(e.getStatusText(t.status))+" ")])],2)])]),a("div",{staticClass:"strategy-item-actions",on:{click:function(t){t.stopPropagation()}}},[a("a-dropdown",{attrs:{getPopupContainer:e.getDropdownContainer,trigger:["click"]}},[a("a-menu",{attrs:{slot:"overlay"},on:{click:function(a){var i=a.key;return e.handleMenuClick(i,t)}},slot:"overlay"},["stopped"===t.status?a("a-menu-item",{key:"start"},[a("a-icon",{attrs:{type:"play-circle"}}),e._v(" "+e._s(e.$t("trading-assistant.startStrategy"))+" ")],1):e._e(),"running"===t.status?a("a-menu-item",{key:"stop"},[a("a-icon",{attrs:{type:"pause-circle"}}),e._v(" "+e._s(e.$t("trading-assistant.stopStrategy"))+" ")],1):e._e(),a("a-menu-divider"),a("a-menu-item",{key:"edit"},[a("a-icon",{attrs:{type:"edit"}}),e._v(" "+e._s(e.$t("trading-assistant.editStrategy"))+" ")],1),a("a-menu-divider"),a("a-menu-item",{key:"delete",staticClass:"danger-item"},[a("a-icon",{attrs:{type:"delete"}}),e._v(" "+e._s(e.$t("trading-assistant.deleteStrategy"))+" ")],1)],1),a("a-button",{attrs:{type:"link",icon:"more",size:"small"}})],1)],1)])}),0)])}),e._l(e.groupedStrategies.ungrouped,function(t){return a("div",{key:t.id,class:["strategy-list-item",{active:e.selectedStrategy&&e.selectedStrategy.id===t.id}],on:{click:function(a){return e.handleSelectStrategy(t)}}},[a("div",{staticClass:"strategy-item-content"},[a("div",{staticClass:"strategy-item-header"},[a("div",{staticClass:"strategy-name-wrapper"},[t.exchange_config&&t.exchange_config.exchange_id?a("a-tag",{staticClass:"exchange-tag",attrs:{color:e.getExchangeTagColor(t.exchange_config.exchange_id),size:"small"}},[a("a-icon",{staticStyle:{"margin-right":"4px"},attrs:{type:"bank"}}),e._v(" "+e._s(e.getExchangeDisplayName(t.exchange_config.exchange_id))+" ")],1):e._e(),a("span",{staticClass:"strategy-name"},[e._v(e._s(t.strategy_name))]),"PromptBasedStrategy"===t.strategy_type?a("a-tag",{staticClass:"strategy-type-tag",attrs:{color:"purple",size:"small"}},[a("a-icon",{staticStyle:{"margin-right":"2px"},attrs:{type:"robot"}}),e._v(" AI ")],1):e._e()],1)]),a("div",{staticClass:"strategy-item-info"},[t.trading_config&&t.trading_config.symbol?a("span",{staticClass:"info-item"},[a("a-icon",{attrs:{type:"dollar"}}),e._v(" "+e._s(t.trading_config.symbol)+" ")],1):e._e(),a("span",{staticClass:"status-label",class:[t.status?"status-".concat(t.status):"",{"status-stopped":"stopped"===t.status}]},[e._v(" "+e._s(e.getStatusText(t.status))+" ")])])]),a("div",{staticClass:"strategy-item-actions",on:{click:function(t){t.stopPropagation()}}},[a("a-dropdown",{attrs:{getPopupContainer:e.getDropdownContainer,trigger:["click"]}},[a("a-menu",{attrs:{slot:"overlay"},on:{click:function(a){var i=a.key;return e.handleMenuClick(i,t)}},slot:"overlay"},["stopped"===t.status?a("a-menu-item",{key:"start"},[a("a-icon",{attrs:{type:"play-circle"}}),e._v(" "+e._s(e.$t("trading-assistant.startStrategy"))+" ")],1):e._e(),"running"===t.status?a("a-menu-item",{key:"stop"},[a("a-icon",{attrs:{type:"pause-circle"}}),e._v(" "+e._s(e.$t("trading-assistant.stopStrategy"))+" ")],1):e._e(),a("a-menu-divider"),a("a-menu-item",{key:"edit"},[a("a-icon",{attrs:{type:"edit"}}),e._v(" "+e._s(e.$t("trading-assistant.editStrategy"))+" ")],1),a("a-menu-divider"),a("a-menu-item",{key:"delete",staticClass:"danger-item"},[a("a-icon",{attrs:{type:"delete"}}),e._v(" "+e._s(e.$t("trading-assistant.deleteStrategy"))+" ")],1)],1),a("a-button",{attrs:{type:"link",icon:"more",size:"small"}})],1)],1)])})],2):a("a-empty",{attrs:{description:e.$t("trading-assistant.noStrategy")}})],1)],1)],1),a("a-col",{staticClass:"strategy-detail-col",attrs:{xs:24,sm:24,md:14,lg:16,xl:16}},[e.selectedStrategy?a("div",{staticClass:"strategy-detail-panel"},[a("a-card",{staticClass:"strategy-header-card",attrs:{bordered:!1}},[a("div",{staticClass:"strategy-header"},[a("div",{staticClass:"header-left"},[a("div",{staticClass:"strategy-title-row"},[a("h3",{staticClass:"strategy-title"},[e._v(e._s(e.selectedStrategy.strategy_name))]),a("div",{staticClass:"status-badge",class:["status-".concat(e.selectedStrategy.status)]},[a("span",{staticClass:"status-dot"}),e._v(" "+e._s(e.getStatusText(e.selectedStrategy.status))+" ")])]),a("div",{staticClass:"key-stats-grid"},[e.selectedStrategy.initial_capital||e.selectedStrategy.trading_config&&e.selectedStrategy.trading_config.initial_capital?a("div",{staticClass:"stat-card"},[a("div",{staticClass:"stat-icon investment"},[a("a-icon",{attrs:{type:"wallet"}})],1),a("div",{staticClass:"stat-content"},[a("div",{staticClass:"stat-label"},[e._v(e._s(e.$t("trading-assistant.detail.totalInvestment")))]),a("div",{staticClass:"stat-value"},[e._v("$"+e._s(parseFloat(e.selectedStrategy.initial_capital||(null===(t=e.selectedStrategy.trading_config)||void 0===t?void 0:t.initial_capital)||0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})))])])]):e._e(),null!==e.currentEquity?a("div",{staticClass:"stat-card"},[a("div",{staticClass:"stat-icon equity"},[a("a-icon",{attrs:{type:"fund"}})],1),a("div",{staticClass:"stat-content"},[a("div",{staticClass:"stat-label"},[e._v(e._s(e.$t("trading-assistant.detail.currentEquity")))]),a("div",{staticClass:"stat-value",class:e.getEquityColorClass},[e._v(e._s(e.formatCurrency(e.currentEquity)))])])]):e._e(),null!==e.totalPnl?a("div",{staticClass:"stat-card pnl-card",class:{profit:e.totalPnl>0,loss:e.totalPnl<0}},[a("div",{staticClass:"stat-icon pnl"},[a("a-icon",{attrs:{type:e.totalPnl>=0?"rise":"fall"}})],1),a("div",{staticClass:"stat-content"},[a("div",{staticClass:"stat-label"},[e._v(e._s(e.$t("trading-assistant.detail.totalPnl")))]),a("div",{staticClass:"stat-value",class:e.getPnlColorClass},[e._v(" "+e._s(e.formatPnl(e.totalPnl))+" "),a("span",{staticClass:"pnl-percent"},[e._v("("+e._s(e.formatPnlPercent(e.totalPnlPercent))+")")])])])]):e._e()]),a("div",{staticClass:"strategy-tags"},[e.selectedStrategy.trading_config?a("div",{staticClass:"tag-item"},[a("a-icon",{attrs:{type:"stock"}}),a("span",[e._v(e._s(e.selectedStrategy.trading_config.symbol))])],1):e._e(),e.selectedStrategy.indicator_config&&e.selectedStrategy.indicator_config.indicator_name?a("div",{staticClass:"tag-item"},[a("a-icon",{attrs:{type:"line-chart"}}),a("span",[e._v(e._s(e.selectedStrategy.indicator_config.indicator_name))])],1):e._e(),e.selectedStrategy.trading_config?a("div",{staticClass:"tag-item"},[a("a-icon",{attrs:{type:"thunderbolt"}}),a("span",[e._v(e._s(e.selectedStrategy.trading_config.leverage||1)+"x")])],1):e._e(),e.selectedStrategy.trading_config&&e.selectedStrategy.trading_config.trade_direction?a("div",{staticClass:"tag-item"},[a("a-icon",{attrs:{type:"swap"}}),a("span",[e._v(e._s(e.getTradeDirectionText(e.selectedStrategy.trading_config.trade_direction)))])],1):e._e(),e.selectedStrategy.trading_config&&e.selectedStrategy.trading_config.timeframe?a("div",{staticClass:"tag-item"},[a("a-icon",{attrs:{type:"clock-circle"}}),a("span",[e._v(e._s(e.selectedStrategy.trading_config.timeframe))])],1):e._e()])]),a("div",{staticClass:"header-right"},["stopped"===e.selectedStrategy.status?a("a-button",{staticClass:"action-btn start-btn",attrs:{type:"primary",size:"large"},on:{click:function(t){return e.handleStartStrategy(e.selectedStrategy.id)}}},[a("a-icon",{attrs:{type:"play-circle"}}),e._v(" "+e._s(e.$t("trading-assistant.startStrategy"))+" ")],1):e._e(),"running"===e.selectedStrategy.status?a("a-button",{staticClass:"action-btn stop-btn",attrs:{type:"danger",size:"large"},on:{click:function(t){return e.handleStopStrategy(e.selectedStrategy.id)}}},[a("a-icon",{attrs:{type:"pause-circle"}}),e._v(" "+e._s(e.$t("trading-assistant.stopStrategy"))+" ")],1):e._e()],1)])]),a("a-card",{staticClass:"strategy-content-card",attrs:{bordered:!1}},[a("a-tabs",{attrs:{defaultActiveKey:"positions"}},[a("a-tab-pane",{key:"positions",attrs:{tab:e.$t("trading-assistant.tabs.positions")}},[a("position-records",{attrs:{"strategy-id":e.selectedStrategy.id,"market-type":e.selectedStrategy.trading_config&&e.selectedStrategy.trading_config.market_type||"swap",leverage:e.selectedStrategy.trading_config&&e.selectedStrategy.trading_config.leverage||1,loading:e.loadingRecords}})],1),a("a-tab-pane",{key:"trades",attrs:{tab:e.$t("trading-assistant.tabs.tradingRecords")}},[a("trading-records",{attrs:{"strategy-id":e.selectedStrategy.id,loading:e.loadingRecords}})],1),a("a-tab-pane",{key:"performance",attrs:{tab:e.$t("trading-assistant.tabs.performance")}},[a("performance-analysis",{attrs:{"strategy-id":e.selectedStrategy.id,"is-dark":e.isDarkTheme}})],1),a("a-tab-pane",{key:"logs",attrs:{tab:e.$t("trading-assistant.tabs.logs")}},[a("strategy-logs",{attrs:{"strategy-id":e.selectedStrategy.id,"is-dark":e.isDarkTheme}})],1)],1)],1)],1):a("div",{staticClass:"empty-detail"},[a("a-empty",{attrs:{description:e.$t("trading-assistant.selectStrategy")}})],1)])],1),a("a-modal",{staticClass:"mode-selector-modal",attrs:{visible:e.showModeSelector,title:e.$t("trading-assistant.selectMode"),width:e.isMobile?"95%":700,footer:null,maskClosable:!0,bodyStyle:{padding:"16px 24px"}},on:{cancel:function(t){e.showModeSelector=!1}}},[a("strategy-type-selector",{attrs:{selected:e.strategyMode,"is-dark":e.isDarkTheme},on:{select:e.handleModeSelect,"use-template":e.handleUseTemplate}})],1),a("a-modal",{attrs:{visible:e.showFormModal,title:e.editingStrategy?e.$t("trading-assistant.editStrategy"):e.$t("trading-assistant.createStrategy")+("script"===e.strategyMode?" - "+e.$t("trading-assistant.strategyMode.script"):""),width:e.isMobile?"95%":1100,confirmLoading:e.saving,maskClosable:!1,wrapClassName:e.isMobile?"mobile-modal":"",bodyStyle:{maxHeight:"70vh",overflowY:"auto"}},on:{ok:e.handleSubmit,cancel:e.handleCloseModal}},[a("a-spin",{attrs:{spinning:e.loadingIndicators}},[e.editingStrategy||"script"===e.strategyMode?e._e():a("div",{staticClass:"creation-mode-toggle"},[a("a-radio-group",{attrs:{size:"small","button-style":"solid"},model:{value:e.creationMode,callback:function(t){e.creationMode=t},expression:"creationMode"}},[a("a-radio-button",{attrs:{value:"simple"}},[a("a-icon",{attrs:{type:"rocket"}}),e._v(" "+e._s(e.$t("trading-assistant.form.simpleMode"))+" ")],1),a("a-radio-button",{attrs:{value:"advanced"}},[a("a-icon",{attrs:{type:"setting"}}),e._v(" "+e._s(e.$t("trading-assistant.form.advancedMode"))+" ")],1)],1),a("span",{staticClass:"mode-hint"},[e._v(e._s(e.isSimpleMode?e.$t("trading-assistant.form.simpleModeHint"):e.$t("trading-assistant.form.advancedModeHint")))])],1),a("a-steps",{staticClass:"steps-container",attrs:{current:e.displayCurrentStep}},["script"===e.strategyMode?[a("a-step",{attrs:{title:e.$t("trading-assistant.form.simpleStep1")}}),a("a-step",{attrs:{title:e.$t("trading-assistant.editor.title")}}),a("a-step",{attrs:{title:e.$t("trading-assistant.form.step3Signal")}})]:[a("a-step",{attrs:{title:e.isSimpleMode&&!e.editingStrategy?e.$t("trading-assistant.form.simpleStep1"):e.$t("trading-assistant.form.step1")}}),e.isAdvancedMode||e.editingStrategy?a("a-step",{attrs:{title:e.$t("trading-assistant.form.step2Params")}}):e._e(),a("a-step",{attrs:{title:e.isSimpleMode&&!e.editingStrategy?e.$t("trading-assistant.form.simpleStep2"):e.$t("trading-assistant.form.step3Signal")}})]],2),a("div",{staticClass:"form-container"},[a("div",{directives:[{name:"show",rawName:"v-show",value:0===e.currentStep,expression:"currentStep === 0"}],staticClass:"step-content"},["indicator"===e.strategyType&&"script"!==e.strategyMode?a("div",[a("a-form",{attrs:{form:e.form,layout:"vertical"}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.indicator")}},[a("a-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["indicator_id",{rules:[{required:!0,message:e.$t("trading-assistant.validation.indicatorRequired")}]}],expression:"['indicator_id', { rules: [{ required: true, message: $t('trading-assistant.validation.indicatorRequired') }] }]"}],attrs:{placeholder:e.$t("trading-assistant.placeholders.selectIndicator"),"show-search":"","filter-option":e.filterIndicatorOption,loading:e.loadingIndicators,getPopupContainer:function(t){return t.parentNode}},on:{focus:e.handleIndicatorSelectFocus,change:e.handleIndicatorChange}},e._l(e.availableIndicators,function(t){return a("a-select-option",{key:String(t.id),attrs:{value:String(t.id)}},[a("div",{staticClass:"indicator-option"},[a("span",{staticClass:"indicator-name"},[e._v(e._s(t.name))]),t.type?a("a-tag",{attrs:{size:"small",color:e.getIndicatorTypeColor(t.type)}},[e._v(" "+e._s(e.getIndicatorTypeName(t.type))+" ")]):e._e()],1)])}),1),a("div",{staticClass:"form-item-hint"},[e._v(" "+e._s(e.$t("trading-assistant.form.indicatorHint"))+" ")])],1),e.selectedIndicator?a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.indicatorDescription")}},[a("div",{staticClass:"indicator-description"},[e._v(" "+e._s(e.selectedIndicator.description||e.$t("trading-assistant.form.noDescription"))+" ")])]):e._e(),e.indicatorParams.length>0?a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.indicatorParams")}},[a("div",{staticClass:"indicator-params-form"},[a("a-row",{attrs:{gutter:16}},e._l(e.indicatorParams,function(t){return a("a-col",{key:t.name,attrs:{xs:24,sm:12,md:8}},[a("div",{staticClass:"param-item"},[a("label",{staticClass:"param-label"},[e._v(" "+e._s(t.name)+" "),t.description?a("a-tooltip",{attrs:{title:t.description}},[a("a-icon",{staticStyle:{"margin-left":"4px",color:"#999"},attrs:{type:"question-circle"}})],1):e._e()],1),"int"===t.type?a("a-input-number",{staticStyle:{width:"100%"},attrs:{precision:0,size:"small"},model:{value:e.indicatorParamValues[t.name],callback:function(a){e.$set(e.indicatorParamValues,t.name,a)},expression:"indicatorParamValues[param.name]"}}):"float"===t.type?a("a-input-number",{staticStyle:{width:"100%"},attrs:{precision:4,size:"small"},model:{value:e.indicatorParamValues[t.name],callback:function(a){e.$set(e.indicatorParamValues,t.name,a)},expression:"indicatorParamValues[param.name]"}}):"bool"===t.type?a("a-switch",{attrs:{size:"small"},model:{value:e.indicatorParamValues[t.name],callback:function(a){e.$set(e.indicatorParamValues,t.name,a)},expression:"indicatorParamValues[param.name]"}}):a("a-input",{attrs:{size:"small"},model:{value:e.indicatorParamValues[t.name],callback:function(a){e.$set(e.indicatorParamValues,t.name,a)},expression:"indicatorParamValues[param.name]"}})],1)])}),1),a("div",{staticClass:"form-item-hint",staticStyle:{"margin-top":"8px"}},[e._v(" "+e._s(e.$t("trading-assistant.form.indicatorParamsHint"))+" ")])],1)]):e._e(),a("a-divider"),a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.strategyName")}},[a("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["strategy_name",{rules:[{required:!0,message:e.$t("trading-assistant.validation.strategyNameRequired")}]}],expression:"['strategy_name', { rules: [{ required: true, message: $t('trading-assistant.validation.strategyNameRequired') }] }]"}],attrs:{placeholder:e.$t("trading-assistant.placeholders.inputStrategyName")}})],1),e.isSimpleMode&&!e.editingStrategy?a("div",{staticClass:"simple-defaults-summary"},[a("a-alert",{staticStyle:{"margin-bottom":"12px"},attrs:{type:"info","show-icon":""},scopedSlots:e._u([{key:"message",fn:function(){return[a("span",[e._v(e._s(e.$t("trading-assistant.form.simpleDefaultsHint")))])]},proxy:!0},{key:"description",fn:function(){return[a("span",[e._v(" "+e._s(e.$t("trading-assistant.form.klinePeriod"))+": "),a("b",[e._v("15m")]),e._v(" · "+e._s(e.$t("trading-assistant.form.leverage"))+": "),a("b",[e._v("5x")]),e._v(" · "+e._s(e.$t("trading-assistant.form.marketType"))+": "),a("b",[e._v(e._s(e.$t("trading-assistant.form.marketTypeFutures")))]),e._v(" · "+e._s(e.$t("dashboard.indicator.backtest.field.stopLossPct"))+": "),a("b",[e._v("3%")]),e._v(" · "+e._s(e.$t("dashboard.indicator.backtest.field.takeProfitPct"))+": "),a("b",[e._v("6%")])])]},proxy:!0}],null,!1,39555864)}),a("a-button",{staticStyle:{padding:"0","margin-bottom":"12px"},attrs:{type:"link",size:"small"},on:{click:function(t){e.showAdvancedSettings=!e.showAdvancedSettings}}},[a("a-icon",{attrs:{type:e.showAdvancedSettings?"up":"down"}}),e._v(" "+e._s(e.showAdvancedSettings?e.$t("trading-assistant.form.hideAdvancedSettings"):e.$t("trading-assistant.form.showAdvancedSettings"))+" ")],1)],1):e._e(),a("div",{directives:[{name:"show",rawName:"v-show",value:e.isAdvancedMode||e.editingStrategy||e.showAdvancedSettings,expression:"isAdvancedMode || editingStrategy || showAdvancedSettings"}]},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.strategyType")}},[a("a-radio-group",{directives:[{name:"decorator",rawName:"v-decorator",value:["cs_strategy_type",{initialValue:"single"}],expression:"['cs_strategy_type', { initialValue: 'single' }]"}],on:{change:e.handleStrategyTypeChange}},[a("a-radio",{attrs:{value:"single"}},[e._v(e._s(e.$t("trading-assistant.form.strategyTypeSingle")))]),a("a-radio",{attrs:{value:"cross_sectional"}},[e._v(e._s(e.$t("trading-assistant.form.strategyTypeCrossSectional")))])],1),a("div",{staticClass:"form-item-hint"},[e._v(" "+e._s(e.$t("trading-assistant.form.strategyTypeHint"))+" ")])],1)],1),"cross_sectional"===e.form.getFieldValue("cs_strategy_type")?[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.symbolList")}},[a("a-select",{attrs:{mode:"multiple",placeholder:e.$t("trading-assistant.placeholders.selectSymbols"),"show-search":"","filter-option":e.filterWatchlistOptionWithAdd,loading:e.loadingWatchlist,getPopupContainer:function(t){return t.parentNode},maxTagCount:5},on:{change:e.handleCrossSectionalSymbolChange},model:{value:e.crossSectionalSymbols,callback:function(t){e.crossSectionalSymbols=t},expression:"crossSectionalSymbols"}},[e._l(e.watchlist,function(t){return a("a-select-option",{key:"".concat(t.market,":").concat(t.symbol),attrs:{value:"".concat(t.market,":").concat(t.symbol)}},[a("div",{staticClass:"symbol-option"},[a("a-tag",{staticStyle:{"margin-right":"8px","margin-bottom":"0"},attrs:{color:e.getMarketColor(t.market)}},[e._v(" "+e._s(t.market)+" ")]),a("span",{staticClass:"symbol-name"},[e._v(e._s(t.symbol))]),t.name?a("span",{staticClass:"symbol-name-extra"},[e._v(e._s(t.name))]):e._e()],1)])}),a("a-select-option",{key:"__add_symbol_option__",staticClass:"add-symbol-option",attrs:{value:"__add_symbol_option__"}},[a("div",{staticStyle:{width:"100%","text-align":"center",padding:"4px 0",color:"#1890ff",cursor:"pointer"}},[a("a-icon",{staticStyle:{"margin-right":"4px"},attrs:{type:"plus"}}),a("span",[e._v(e._s(e.$t("trading-assistant.form.addSymbol")))])],1)])],2),a("div",{staticClass:"form-item-hint"},[e._v(" "+e._s(e.$t("trading-assistant.form.symbolListHint"))+" ")])],1),a("a-row",{attrs:{gutter:16}},[a("a-col",{attrs:{xs:24,sm:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.portfolioSize")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["portfolio_size",{initialValue:10,rules:[{required:!0,message:e.$t("trading-assistant.validation.portfolioSizeRequired")}]}],expression:"['portfolio_size', { initialValue: 10, rules: [{ required: true, message: $t('trading-assistant.validation.portfolioSizeRequired') }] }]"}],staticStyle:{width:"100%"},attrs:{min:1,max:100,step:1}}),a("div",{staticClass:"form-item-hint"},[e._v(" "+e._s(e.$t("trading-assistant.form.portfolioSizeHint"))+" ")])],1)],1),a("a-col",{attrs:{xs:24,sm:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.longRatio")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["long_ratio",{initialValue:.5,rules:[{required:!0,message:e.$t("trading-assistant.validation.longRatioRequired")}]}],expression:"['long_ratio', { initialValue: 0.5, rules: [{ required: true, message: $t('trading-assistant.validation.longRatioRequired') }] }]"}],staticStyle:{width:"100%"},attrs:{min:0,max:1,step:.1,precision:2}}),a("div",{staticClass:"form-item-hint"},[e._v(" "+e._s(e.$t("trading-assistant.form.longRatioHint"))+" ")])],1)],1)],1),a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.rebalanceFrequency")}},[a("a-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["rebalance_frequency",{initialValue:"daily"}],expression:"['rebalance_frequency', { initialValue: 'daily' }]"}],staticStyle:{width:"100%"}},[a("a-select-option",{attrs:{value:"daily"}},[e._v(e._s(e.$t("trading-assistant.form.rebalanceDaily")))]),a("a-select-option",{attrs:{value:"weekly"}},[e._v(e._s(e.$t("trading-assistant.form.rebalanceWeekly")))]),a("a-select-option",{attrs:{value:"monthly"}},[e._v(e._s(e.$t("trading-assistant.form.rebalanceMonthly")))])],1),a("div",{staticClass:"form-item-hint"},[e._v(" "+e._s(e.$t("trading-assistant.form.rebalanceFrequencyHint"))+" ")])],1)]:e._e(),"cross_sectional"!==e.form.getFieldValue("cs_strategy_type")?a("a-form-item",{attrs:{label:e.isEditMode?e.$t("trading-assistant.form.symbol"):e.$t("trading-assistant.form.symbols")}},[e.isEditMode?a("a-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["symbol",{rules:[{required:!0,message:e.$t("trading-assistant.validation.symbolRequired")}]}],expression:"['symbol', { rules: [{ required: true, message: $t('trading-assistant.validation.symbolRequired') }] }]"}],attrs:{placeholder:e.$t("trading-assistant.placeholders.selectSymbol"),"show-search":"","filter-option":e.filterWatchlistOption,loading:e.loadingWatchlist,getPopupContainer:function(t){return t.parentNode}},on:{change:e.handleWatchlistSymbolChange}},[e._l(e.watchlist,function(t){return a("a-select-option",{key:"".concat(t.market,":").concat(t.symbol),attrs:{value:"".concat(t.market,":").concat(t.symbol)}},[a("div",{staticClass:"symbol-option"},[a("a-tag",{staticStyle:{"margin-right":"8px","margin-bottom":"0"},attrs:{color:e.getMarketColor(t.market)}},[e._v(" "+e._s(t.market)+" ")]),a("span",{staticClass:"symbol-name"},[e._v(e._s(t.symbol))]),t.name?a("span",{staticClass:"symbol-name-extra"},[e._v(e._s(t.name))]):e._e()],1)])}),a("a-select-option",{key:"__add_symbol_option__",staticClass:"add-symbol-option",attrs:{value:"__add_symbol_option__"}},[a("div",{staticStyle:{width:"100%","text-align":"center",padding:"4px 0",color:"#1890ff",cursor:"pointer"}},[a("a-icon",{staticStyle:{"margin-right":"4px"},attrs:{type:"plus"}}),a("span",[e._v(e._s(e.$t("trading-assistant.form.addSymbol")))])],1)])],2):a("a-select",{attrs:{mode:"multiple",placeholder:e.$t("trading-assistant.placeholders.selectSymbols"),"show-search":"","filter-option":e.filterWatchlistOptionWithAdd,loading:e.loadingWatchlist,getPopupContainer:function(t){return t.parentNode},maxTagCount:3},on:{change:e.handleMultiSymbolChangeWithAdd},model:{value:e.selectedSymbols,callback:function(t){e.selectedSymbols=t},expression:"selectedSymbols"}},[e._l(e.watchlist,function(t){return a("a-select-option",{key:"".concat(t.market,":").concat(t.symbol),attrs:{value:"".concat(t.market,":").concat(t.symbol)}},[a("div",{staticClass:"symbol-option"},[a("a-tag",{staticStyle:{"margin-right":"8px","margin-bottom":"0"},attrs:{color:e.getMarketColor(t.market)}},[e._v(" "+e._s(t.market)+" ")]),a("span",{staticClass:"symbol-name"},[e._v(e._s(t.symbol))]),t.name?a("span",{staticClass:"symbol-name-extra"},[e._v(e._s(t.name))]):e._e()],1)])}),a("a-select-option",{key:"__add_symbol_option__",staticClass:"add-symbol-option",attrs:{value:"__add_symbol_option__"}},[a("div",{staticStyle:{width:"100%","text-align":"center",padding:"4px 0",color:"#1890ff",cursor:"pointer"}},[a("a-icon",{staticStyle:{"margin-right":"4px"},attrs:{type:"plus"}}),a("span",[e._v(e._s(e.$t("trading-assistant.form.addSymbol")))])],1)])],2),a("div",{staticClass:"form-item-hint"},[e._v(" "+e._s(e.isEditMode?e.$t("trading-assistant.form.symbolHintCrypto"):e.$t("trading-assistant.form.symbolsHint"))+" ")])],1):e._e(),a("div",{directives:[{name:"show",rawName:"v-show",value:e.isAdvancedMode||e.editingStrategy||e.showAdvancedSettings,expression:"isAdvancedMode || editingStrategy || showAdvancedSettings"}]},[a("a-row",{attrs:{gutter:16}},[a("a-col",{attrs:{xs:24,sm:24,md:12,lg:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.initialCapital")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["initial_capital",{rules:[{required:!0,message:e.$t("trading-assistant.validation.initialCapitalRequired")}],initialValue:1e3}],expression:"['initial_capital', { rules: [{ required: true, message: $t('trading-assistant.validation.initialCapitalRequired') }], initialValue: 1000 }]"}],staticStyle:{width:"100%"},attrs:{min:10,step:100,precision:2}})],1)],1),a("a-col",{attrs:{xs:24,sm:24,md:12,lg:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.marketType")}},[a("a-radio-group",{directives:[{name:"decorator",rawName:"v-decorator",value:["market_type",{initialValue:"swap"}],expression:"['market_type', { initialValue: 'swap' }]"}],on:{change:e.handleMarketTypeChange}},[a("a-radio",{attrs:{value:"swap"}},[e._v(e._s(e.$t("trading-assistant.form.marketTypeFutures")))]),a("a-radio",{attrs:{value:"spot"}},[e._v(e._s(e.$t("trading-assistant.form.marketTypeSpot")))])],1),a("div",{staticClass:"form-item-hint"},[e._v(" "+e._s(e.$t("trading-assistant.form.marketTypeHint"))+" ")])],1)],1)],1),a("a-row",{attrs:{gutter:16}},[a("a-col",{attrs:{xs:24,sm:24,md:12,lg:12}},[a("a-form-item",{attrs:{label:"".concat(e.$t("trading-assistant.form.leverage")," (x)")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["leverage",{initialValue:5,rules:[{required:!0,message:e.$t("trading-assistant.validation.leverageRequired")}]}],expression:"['leverage', { initialValue: 5, rules: [{ required: true, message: $t('trading-assistant.validation.leverageRequired') }] }]"}],staticStyle:{width:"100%"},attrs:{min:1,max:"spot"===e.form.getFieldValue("market_type")?1:125,step:1,disabled:"spot"===e.form.getFieldValue("market_type")}}),a("div",{staticClass:"form-item-hint"},["spot"===e.form.getFieldValue("market_type")?a("span",[e._v(" "+e._s(e.$t("trading-assistant.form.spotLeverageFixed"))+" ")]):a("span",[e._v(" "+e._s(e.$t("trading-assistant.form.leverageHint"))+" ")])])],1)],1),a("a-col",{attrs:{xs:24,sm:24,md:12,lg:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.tradeDirection")}},[a("a-radio-group",{directives:[{name:"decorator",rawName:"v-decorator",value:["trade_direction",{initialValue:"long"}],expression:"['trade_direction', { initialValue: 'long' }]"}],attrs:{disabled:"spot"===e.form.getFieldValue("market_type")}},[a("a-radio",{attrs:{value:"long"}},[e._v(e._s(e.$t("trading-assistant.form.tradeDirectionLong")))]),a("a-radio",{attrs:{value:"short",disabled:"spot"===e.form.getFieldValue("market_type")}},[e._v(" "+e._s(e.$t("trading-assistant.form.tradeDirectionShort"))+" ")]),a("a-radio",{attrs:{value:"both",disabled:"spot"===e.form.getFieldValue("market_type")}},[e._v(" "+e._s(e.$t("trading-assistant.form.tradeDirectionBoth"))+" ")])],1),"spot"===e.form.getFieldValue("market_type")?a("div",{staticClass:"form-item-hint",staticStyle:{color:"#ff9800"}},[e._v(" "+e._s(e.$t("trading-assistant.form.spotOnlyLongHint"))+" ")]):e._e()],1)],1)],1),a("a-row",{attrs:{gutter:16}},[a("a-col",{attrs:{xs:24,sm:24,md:12,lg:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.klinePeriod")}},[a("a-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["timeframe",{initialValue:"15m",rules:[{required:!0}]}],expression:"['timeframe', { initialValue: '15m', rules: [{ required: true }] }]"}],attrs:{placeholder:e.$t("trading-assistant.placeholders.selectKlinePeriod"),getPopupContainer:function(t){return t.parentNode}}},[a("a-select-option",{attrs:{value:"1m"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe1m")))]),a("a-select-option",{attrs:{value:"5m"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe5m")))]),a("a-select-option",{attrs:{value:"15m"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe15m")))]),a("a-select-option",{attrs:{value:"30m"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe30m")))]),a("a-select-option",{attrs:{value:"1H"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe1H")))]),a("a-select-option",{attrs:{value:"4H"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe4H")))]),a("a-select-option",{attrs:{value:"1D"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe1D")))])],1)],1)],1),a("a-col",{attrs:{xs:24,sm:24,md:12,lg:12}})],1)],1)],2)],1):e._e(),"script"===e.strategyMode?a("div",[a("a-form",{attrs:{form:e.form,layout:"vertical"}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.strategyName")}},[a("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["strategy_name",{rules:[{required:!0,message:e.$t("trading-assistant.validation.strategyNameRequired")}]}],expression:"['strategy_name', { rules: [{ required: true, message: $t('trading-assistant.validation.strategyNameRequired') }] }]"}],attrs:{placeholder:e.$t("trading-assistant.placeholders.inputStrategyName")}})],1),a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.symbol")}},[a("a-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["symbol",{rules:[{required:!0,message:e.$t("trading-assistant.validation.symbolRequired")}]}],expression:"['symbol', { rules: [{ required: true, message: $t('trading-assistant.validation.symbolRequired') }] }]"}],attrs:{placeholder:e.$t("trading-assistant.placeholders.selectSymbol"),"show-search":"","filter-option":e.filterWatchlistOption,loading:e.loadingWatchlist,getPopupContainer:function(t){return t.parentNode}},on:{change:e.handleWatchlistSymbolChange}},e._l(e.watchlist,function(t){return a("a-select-option",{key:"".concat(t.market,":").concat(t.symbol),attrs:{value:"".concat(t.market,":").concat(t.symbol)}},[a("div",{staticClass:"symbol-option"},[a("a-tag",{staticStyle:{"margin-right":"8px","margin-bottom":"0"},attrs:{color:e.getMarketColor(t.market)}},[e._v(" "+e._s(t.market)+" ")]),a("span",{staticClass:"symbol-name"},[e._v(e._s(t.symbol))]),t.name?a("span",{staticClass:"symbol-name-extra"},[e._v(e._s(t.name))]):e._e()],1)])}),1)],1),a("a-row",{attrs:{gutter:16}},[a("a-col",{attrs:{xs:24,sm:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.initialCapital")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["initial_capital",{initialValue:1e3,rules:[{required:!0}]}],expression:"['initial_capital', { initialValue: 1000, rules: [{ required: true }] }]"}],staticStyle:{width:"100%"},attrs:{min:10,step:100,precision:2}})],1)],1),a("a-col",{attrs:{xs:24,sm:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.klinePeriod")}},[a("a-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["timeframe",{initialValue:"15m",rules:[{required:!0}]}],expression:"['timeframe', { initialValue: '15m', rules: [{ required: true }] }]"}],attrs:{getPopupContainer:function(t){return t.parentNode}}},[a("a-select-option",{attrs:{value:"1m"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe1m")))]),a("a-select-option",{attrs:{value:"5m"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe5m")))]),a("a-select-option",{attrs:{value:"15m"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe15m")))]),a("a-select-option",{attrs:{value:"30m"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe30m")))]),a("a-select-option",{attrs:{value:"1H"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe1H")))]),a("a-select-option",{attrs:{value:"4H"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe4H")))]),a("a-select-option",{attrs:{value:"1D"}},[e._v(e._s(e.$t("trading-assistant.form.timeframe1D")))])],1)],1)],1)],1),a("a-row",{attrs:{gutter:16}},[a("a-col",{attrs:{xs:24,sm:12}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.marketType")}},[a("a-radio-group",{directives:[{name:"decorator",rawName:"v-decorator",value:["market_type",{initialValue:"swap"}],expression:"['market_type', { initialValue: 'swap' }]"}]},[a("a-radio",{attrs:{value:"swap"}},[e._v(e._s(e.$t("trading-assistant.form.marketTypeFutures")))]),a("a-radio",{attrs:{value:"spot"}},[e._v(e._s(e.$t("trading-assistant.form.marketTypeSpot")))])],1)],1)],1),a("a-col",{attrs:{xs:24,sm:12}},[a("a-form-item",{attrs:{label:"".concat(e.$t("trading-assistant.form.leverage")," (x)")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["leverage",{initialValue:5}],expression:"['leverage', { initialValue: 5 }]"}],staticStyle:{width:"100%"},attrs:{min:1,max:125,step:1}})],1)],1)],1)],1)],1):e._e()]),"script"===e.strategyMode?a("div",{directives:[{name:"show",rawName:"v-show",value:1===e.currentStep,expression:"currentStep === 1"}],staticClass:"step-content"},[a("strategy-editor",{ref:"strategyEditor",attrs:{"is-dark":e.isDarkTheme,"user-id":1},model:{value:e.strategyCode,callback:function(t){e.strategyCode=t},expression:"strategyCode"}})],1):e._e(),a("div",{directives:[{name:"show",rawName:"v-show",value:"script"!==e.strategyMode&&(1===e.currentStep||e.isSimpleMode&&0===e.currentStep&&e.showAdvancedSettings),expression:"strategyMode !== 'script' && (currentStep === 1 || (isSimpleMode && currentStep === 0 && showAdvancedSettings))"}],staticClass:"step-content"},["indicator"===e.strategyType?a("div",[a("a-form",{attrs:{form:e.form,layout:"vertical"}},[a("a-collapse",{staticStyle:{background:"#fafafa"},attrs:{bordered:!1},model:{value:e.backtestCollapseKeys,callback:function(t){e.backtestCollapseKeys=t},expression:"backtestCollapseKeys"}},[a("a-collapse-panel",{key:"risk",attrs:{header:e.$t("dashboard.indicator.backtest.panel.risk")}},[a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.stopLossPct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["stop_loss_pct",{initialValue:3}],expression:"['stop_loss_pct', { initialValue: 3 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:100,step:.01,precision:4}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.takeProfitPct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["take_profit_pct",{initialValue:6}],expression:"['take_profit_pct', { initialValue: 6 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:1e3,step:.01,precision:4}})],1)],1)],1),a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trailingEnabled")}},[a("a-switch",{directives:[{name:"decorator",rawName:"v-decorator",value:["trailing_enabled",{valuePropName:"checked",initialValue:!1}],expression:"['trailing_enabled', { valuePropName: 'checked', initialValue: false }]"}],on:{change:e.onTrailingToggle}})],1)],1),a("a-col",{attrs:{span:12}})],1),e.trailingEnabledUi?[a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trailingStopPct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["trailing_stop_pct",{initialValue:0}],expression:"['trailing_stop_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:100,step:.01,precision:4}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trailingActivationPct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["trailing_activation_pct",{initialValue:0}],expression:"['trailing_activation_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:1e3,step:.01,precision:4}})],1)],1)],1)]:e._e()],2),a("a-collapse-panel",{key:"scale",attrs:{header:e.$t("dashboard.indicator.backtest.panel.scale")}},[a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trendAddEnabled")}},[a("a-switch",{directives:[{name:"decorator",rawName:"v-decorator",value:["trend_add_enabled",{valuePropName:"checked",initialValue:!1}],expression:"['trend_add_enabled', { valuePropName: 'checked', initialValue: false }]"}],on:{change:e.onTrendAddToggle}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.dcaAddEnabled")}},[a("a-switch",{directives:[{name:"decorator",rawName:"v-decorator",value:["dca_add_enabled",{valuePropName:"checked",initialValue:!1}],expression:"['dca_add_enabled', { valuePropName: 'checked', initialValue: false }]"}],on:{change:e.onDcaAddToggle}})],1)],1)],1),a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trendAddStepPct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["trend_add_step_pct",{initialValue:0}],expression:"['trend_add_step_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:1e3,step:.01,precision:4},on:{change:e.onScaleParamsChange}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.dcaAddStepPct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["dca_add_step_pct",{initialValue:0}],expression:"['dca_add_step_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:1e3,step:.01,precision:4},on:{change:e.onScaleParamsChange}})],1)],1)],1),a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trendAddSizePct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["trend_add_size_pct",{initialValue:0}],expression:"['trend_add_size_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:100,step:.1,precision:4},on:{change:e.onScaleParamsChange}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.dcaAddSizePct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["dca_add_size_pct",{initialValue:0}],expression:"['dca_add_size_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:100,step:.1,precision:4},on:{change:e.onScaleParamsChange}})],1)],1)],1),a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trendAddMaxTimes")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["trend_add_max_times",{initialValue:0}],expression:"['trend_add_max_times', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:50,step:1,precision:0},on:{change:e.onScaleParamsChange}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.dcaAddMaxTimes")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["dca_add_max_times",{initialValue:0}],expression:"['dca_add_max_times', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:50,step:1,precision:0},on:{change:e.onScaleParamsChange}})],1)],1)],1)],1),a("a-collapse-panel",{key:"reduce",attrs:{header:e.$t("dashboard.indicator.backtest.panel.reduce")}},[a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trendReduceEnabled")}},[a("a-switch",{directives:[{name:"decorator",rawName:"v-decorator",value:["trend_reduce_enabled",{valuePropName:"checked",initialValue:!1}],expression:"['trend_reduce_enabled', { valuePropName: 'checked', initialValue: false }]"}]})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.adverseReduceEnabled")}},[a("a-switch",{directives:[{name:"decorator",rawName:"v-decorator",value:["adverse_reduce_enabled",{valuePropName:"checked",initialValue:!1}],expression:"['adverse_reduce_enabled', { valuePropName: 'checked', initialValue: false }]"}]})],1)],1)],1),a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trendReduceStepPct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["trend_reduce_step_pct",{initialValue:0}],expression:"['trend_reduce_step_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:1e3,step:.01,precision:4}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.adverseReduceStepPct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["adverse_reduce_step_pct",{initialValue:0}],expression:"['adverse_reduce_step_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:1e3,step:.01,precision:4}})],1)],1)],1),a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trendReduceSizePct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["trend_reduce_size_pct",{initialValue:0}],expression:"['trend_reduce_size_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:100,step:.1,precision:4}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.adverseReduceSizePct")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["adverse_reduce_size_pct",{initialValue:0}],expression:"['adverse_reduce_size_pct', { initialValue: 0 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:100,step:.1,precision:4}})],1)],1)],1),a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.trendReduceMaxTimes")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["trend_reduce_max_times",{initialValue:0}],expression:"['trend_reduce_max_times', { initialValue: 0 }]"}],staticStyle:{width:"100%"},attrs:{min:0,max:50,step:1,precision:0}})],1)],1),a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.adverseReduceMaxTimes")}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["adverse_reduce_max_times",{initialValue:0}],expression:"['adverse_reduce_max_times', { initialValue: 0 }]"}],staticStyle:{width:"100%"},attrs:{min:0,max:50,step:1,precision:0}})],1)],1)],1)],1),a("a-collapse-panel",{key:"position",attrs:{header:e.$t("dashboard.indicator.backtest.panel.position")}},[a("a-row",{attrs:{gutter:24}},[a("a-col",{attrs:{span:12}},[a("a-form-item",{attrs:{label:e.$t("dashboard.indicator.backtest.field.entryPct"),help:e.$t("dashboard.indicator.backtest.hint.entryPctMax",{maxPct:Number(e.entryPctMaxUi||0).toFixed(0)})}},[a("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["entry_pct",{initialValue:100}],expression:"['entry_pct', { initialValue: 100 }]"}],staticStyle:{width:"220px"},attrs:{min:0,max:e.entryPctMaxUi,step:.1,precision:4},on:{change:e.onEntryPctChange}})],1)],1),a("a-col",{attrs:{span:12}})],1)],1)],1),a("div",{staticClass:"ai-filter-box"},[a("div",{staticClass:"ai-filter-header"},[a("div",{staticClass:"ai-filter-title"},[a("a-icon",{attrs:{type:"robot"}}),a("span",[e._v(e._s(e.$t("trading-assistant.form.enableAiFilter")))])],1),a("a-switch",{attrs:{checked:e.aiFilterEnabledUi},on:{change:e.onAiFilterToggle}})],1),a("div",{staticClass:"ai-filter-hint"},[e._v(e._s(e.$t("trading-assistant.form.enableAiFilterHint")))])])],1)],1):e._e()]),a("div",{directives:[{name:"show",rawName:"v-show",value:2===e.currentStep,expression:"currentStep === 2"}],staticClass:"step-content"},[a("a-form",{attrs:{form:e.form,layout:"vertical",autocomplete:"off"}},[a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.executionMode")}},[a("a-radio-group",{directives:[{name:"decorator",rawName:"v-decorator",value:["execution_mode",{initialValue:"signal"}],expression:"['execution_mode', { initialValue: 'signal' }]"}],attrs:{disabled:!e.canUseLiveTrading},on:{change:e.onExecutionModeChange}},[a("a-radio",{attrs:{value:"signal"}},[e._v(e._s(e.$t("trading-assistant.form.executionModeSignal")))]),a("a-radio",{attrs:{value:"live",disabled:!e.canUseLiveTrading}},[e._v(e._s(e.$t("trading-assistant.form.executionModeLive")))])],1),e.canUseLiveTrading?e._e():a("div",{staticClass:"form-item-hint",staticStyle:{color:"#ff9800"}},[e._v(" "+e._s(e.$t("trading-assistant.form.liveTradingNotSupportedHint"))+" ")])],1),"live"===e.executionModeUi&&e.canUseLiveTrading?a("a-form-item",{staticClass:"live-disclaimer-item"},[a("a-alert",{staticStyle:{"margin-bottom":"8px"},attrs:{type:"warning",showIcon:"",message:e.$t("trading-assistant.liveDisclaimer.title"),description:e.$t("trading-assistant.liveDisclaimer.content")}}),a("a-checkbox",{directives:[{name:"decorator",rawName:"v-decorator",value:["live_disclaimer_ack",{valuePropName:"checked",initialValue:!1}],expression:"['live_disclaimer_ack', { valuePropName: 'checked', initialValue: false }]"}],on:{change:e.onLiveDisclaimerAckChange}},[e._v(" "+e._s(e.$t("trading-assistant.liveDisclaimer.agree"))+" ")])],1):e._e(),a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.notifyChannels")}},[a("a-checkbox-group",{directives:[{name:"decorator",rawName:"v-decorator",value:["notify_channels",{initialValue:["browser"]}],expression:"['notify_channels', { initialValue: ['browser'] }]"}],on:{change:e.onNotifyChannelsChange}},[a("a-checkbox",{attrs:{value:"browser"}},[e._v(e._s(e.$t("trading-assistant.notify.browser")))]),a("a-checkbox",{attrs:{value:"email"}},[e._v(e._s(e.$t("trading-assistant.notify.email")))]),a("a-checkbox",{attrs:{value:"telegram"}},[e._v(e._s(e.$t("trading-assistant.notify.telegram")))]),a("a-checkbox",{attrs:{value:"discord"}},[e._v(e._s(e.$t("trading-assistant.notify.discord")))]),a("a-checkbox",{attrs:{value:"webhook"}},[e._v(e._s(e.$t("trading-assistant.notify.webhook")))]),a("a-checkbox",{attrs:{value:"phone"}},[e._v(e._s(e.$t("trading-assistant.notify.phone")))])],1),a("div",{staticClass:"form-item-hint"},[e._v(e._s(e.$t("trading-assistant.form.notifyChannelsHint")))])],1),e.unconfiguredChannels.length>0?a("a-alert",{staticStyle:{"margin-bottom":"16px"},attrs:{type:"warning",showIcon:""},scopedSlots:e._u([{key:"message",fn:function(){return[a("span",[e._v(" "+e._s(e.$t("trading-assistant.form.notificationConfigMissing",{channels:e.unconfiguredChannels.join(", ")}))+" "),a("router-link",{staticStyle:{"margin-left":"8px"},attrs:{to:"/profile"}},[a("a-icon",{attrs:{type:"setting"}}),e._v(" "+e._s(e.$t("trading-assistant.form.goToProfile"))+" ")],1)],1)]},proxy:!0}],null,!1,2930252607)}):e.notifyChannelsUi.length>0&&!e.notifyChannelsUi.includes("browser")||e.notifyChannelsUi.length>1?a("a-alert",{staticStyle:{"margin-bottom":"16px"},attrs:{type:"info",showIcon:""},scopedSlots:e._u([{key:"message",fn:function(){return[a("span",[e._v(" "+e._s(e.$t("trading-assistant.form.notificationFromProfile"))+" "),a("router-link",{staticStyle:{"margin-left":"8px"},attrs:{to:"/profile"}},[a("a-icon",{attrs:{type:"setting"}}),e._v(" "+e._s(e.$t("trading-assistant.form.goToProfile"))+" ")],1)],1)]},proxy:!0}])}):e._e(),"live"===e.executionModeUi&&e.canUseLiveTrading?a("a-divider"):e._e(),"live"===e.executionModeUi&&e.canUseLiveTrading&&!e.liveDisclaimerAckUi?a("a-alert",{staticStyle:{"margin-bottom":"12px"},attrs:{type:"warning",showIcon:"",message:e.$t("trading-assistant.liveDisclaimer.blockTitle"),description:e.$t("trading-assistant.liveDisclaimer.blockDesc")}}):e._e(),"live"===e.executionModeUi&&e.canUseLiveTrading&&e.liveDisclaimerAckUi?a("div",[a("a-alert",{staticStyle:{"margin-bottom":"12px"},attrs:{type:"info","show-icon":"",message:e.$t("trading-assistant.form.liveTradingConfigTitle"),description:e.$t("trading-assistant.form.liveTradingConfigHint")}}),a("a-form-item",{attrs:{label:e.$t("trading-assistant.form.savedCredential")}},[a("a-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["credential_id",{rules:[{required:!0,message:e.$t("profile.exchange.noCredentialHint")}],getValueFromEvent:function(t){return t||void 0}}],expression:"['credential_id', {\n rules: [{ required: true, message: $t('profile.exchange.noCredentialHint') }],\n getValueFromEvent: (val) => val || undefined\n }]"}],attrs:{placeholder:e.$t("trading-assistant.placeholders.selectSavedCredential"),"allow-clear":"","show-search":"","option-filter-prop":"children",loading:e.loadingExchangeCredentials},on:{change:e.handleCredentialSelectChange}},e._l(e.filteredExchangeCredentials,function(t){return a("a-select-option",{key:t.id,attrs:{value:t.id}},[e._v(" "+e._s(e.formatCredentialLabel(t))+" ")])}),1),a("div",{staticClass:"form-item-hint",staticStyle:{"margin-top":"6px"}},[a("router-link",{attrs:{to:"/profile?tab=exchange"}},[a("a-icon",{staticStyle:{"margin-right":"4px"},attrs:{type:"setting"}}),e._v(e._s(e.$t("profile.exchange.goToManage"))+" ")],1)],1)],1)],1):e._e()],1)],1)])],1),a("template",{slot:"footer"},[a("a-button",{on:{click:e.handleCloseModal}},[e._v(e._s(e.$t("trading-assistant.form.cancel")))]),a("a-button",{directives:[{name:"show",rawName:"v-show",value:e.currentStep>0,expression:"currentStep > 0"}],on:{click:e.handlePrev}},[e._v(" "+e._s(e.$t("trading-assistant.form.prev"))+" ")]),a("a-button",{directives:[{name:"show",rawName:"v-show",value:e.currentStep<2,expression:"currentStep < 2"}],attrs:{type:"primary",loading:e.saving},on:{click:e.handleNext}},[e._v(" "+e._s(e.$t("trading-assistant.form.next"))+" ")]),a("a-button",{directives:[{name:"show",rawName:"v-show",value:2===e.currentStep,expression:"currentStep === 2"}],attrs:{type:"primary",loading:e.saving},on:{click:e.handleSubmit}},[e._v(" "+e._s(e.editingStrategy?e.$t("trading-assistant.form.confirmEdit"):e.$t("trading-assistant.form.confirmCreate"))+" ")])],1)],2),a("a-modal",{attrs:{title:e.$t("trading-assistant.form.addSymbolTitle"),visible:e.showAddSymbolModal,confirmLoading:e.addingSymbol,width:"600px",okText:e.$t("trading-assistant.form.confirmAdd"),cancelText:e.$t("trading-assistant.form.cancel"),maskClosable:!1,keyboard:!1},on:{ok:e.handleConfirmAddSymbol,cancel:e.handleCloseAddSymbolModal}},[a("div",{staticClass:"add-symbol-modal-content"},[a("a-tabs",{staticClass:"market-tabs",on:{change:e.handleAddSymbolMarketChange},model:{value:e.addSymbolMarket,callback:function(t){e.addSymbolMarket=t},expression:"addSymbolMarket"}},e._l(e.addSymbolMarketTypes,function(t){return a("a-tab-pane",{key:t.value,attrs:{tab:e.$t(t.i18nKey||"dashboard.analysis.market.".concat(t.value))}})}),1),a("div",{staticClass:"symbol-search-section"},[a("a-input-search",{attrs:{placeholder:e.$t("dashboard.analysis.modal.addStock.searchOrInputPlaceholder"),loading:e.searchingSymbol,size:"large","allow-clear":""},on:{search:e.handleSearchSymbol,change:e.handleSymbolSearchInputChange},model:{value:e.addSymbolKeyword,callback:function(t){e.addSymbolKeyword=t},expression:"addSymbolKeyword"}},[a("a-button",{attrs:{slot:"enterButton",type:"primary",icon:"search"},slot:"enterButton"},[e._v(" "+e._s(e.$t("dashboard.analysis.modal.addStock.search"))+" ")])],1)],1),e.symbolSearchResults.length>0?a("div",{staticClass:"search-results-section"},[a("div",{staticClass:"section-title"},[a("a-icon",{staticStyle:{"margin-right":"4px"},attrs:{type:"search"}}),e._v(" "+e._s(e.$t("dashboard.analysis.modal.addStock.searchResults"))+" ")],1),a("a-list",{staticClass:"symbol-list",attrs:{"data-source":e.symbolSearchResults,loading:e.searchingSymbol,size:"small"},scopedSlots:e._u([{key:"renderItem",fn:function(t){return a("a-list-item",{staticClass:"symbol-list-item",on:{click:function(a){return e.handleSelectAddSymbol(t)}}},[a("a-list-item-meta",[a("template",{slot:"title"},[a("div",{staticClass:"symbol-item-content"},[a("span",{staticClass:"symbol-code"},[e._v(e._s(t.symbol))]),a("span",{staticClass:"symbol-name"},[e._v(e._s(t.name))]),t.exchange?a("a-tag",{staticStyle:{"margin-left":"8px"},attrs:{size:"small",color:"blue"}},[e._v(" "+e._s(t.exchange)+" ")]):e._e()],1)])],2)],1)}}],null,!1,2801225082)})],1):e._e(),a("div",{staticClass:"hot-symbols-section"},[a("div",{staticClass:"section-title"},[a("a-icon",{staticStyle:{color:"#ff4d4f","margin-right":"4px"},attrs:{type:"fire"}}),e._v(" "+e._s(e.$t("dashboard.analysis.modal.addStock.hotSymbols"))+" ")],1),a("a-spin",{attrs:{spinning:e.loadingHotSymbols}},[e.hotSymbols.length>0?a("a-list",{staticClass:"symbol-list",attrs:{"data-source":e.hotSymbols,size:"small"},scopedSlots:e._u([{key:"renderItem",fn:function(t){return a("a-list-item",{staticClass:"symbol-list-item",on:{click:function(a){return e.handleSelectAddSymbol(t)}}},[a("a-list-item-meta",[a("template",{slot:"title"},[a("div",{staticClass:"symbol-item-content"},[a("span",{staticClass:"symbol-code"},[e._v(e._s(t.symbol))]),a("span",{staticClass:"symbol-name"},[e._v(e._s(t.name))]),t.exchange?a("a-tag",{staticStyle:{"margin-left":"8px"},attrs:{size:"small",color:"orange"}},[e._v(" "+e._s(t.exchange)+" ")]):e._e()],1)])],2)],1)}}],null,!1,3959834868)}):a("a-empty",{attrs:{description:e.$t("dashboard.analysis.modal.addStock.noHotSymbols"),image:!1}})],1)],1),e.selectedAddSymbol?a("div",{staticClass:"selected-symbol-section"},[a("div",{staticClass:"section-title"},[a("a-icon",{staticStyle:{color:"#52c41a","margin-right":"4px"},attrs:{type:"check-circle"}}),e._v(" "+e._s(e.$t("dashboard.analysis.modal.addStock.selectedSymbol"))+" ")],1),a("div",{staticClass:"selected-symbol-info"},[a("a-tag",{staticStyle:{"margin-right":"8px"},attrs:{color:e.getMarketColor(e.addSymbolMarket)}},[e._v(e._s(e.addSymbolMarket))]),a("span",{staticClass:"symbol-code"},[e._v(e._s(e.selectedAddSymbol.symbol))]),e.selectedAddSymbol.name?a("span",{staticClass:"symbol-name"},[e._v(e._s(e.selectedAddSymbol.name))]):e._e()],1)]):e._e()],1)])],1)},s=[],r=a(15863),n=a(44735),o=a(81127),l=a(56252),c=a(2403),d=a(57532),u=a(76338),m=a(36911),g=a(35038),p=a(42430),_=a(84841),h=a(55434),y=a(75769),f=function(){var t=this,e=t._self._c;return e("div",{staticClass:"trading-records"},[0!==t.records.length||t.loading?e("a-table",{attrs:{columns:t.columns,"data-source":t.records,loading:t.loading,pagination:{pageSize:10},size:"small",rowKey:"id",scroll:{x:800}},scopedSlots:t._u([{key:"type",fn:function(a){return[e("a-tag",{attrs:{color:t.getTradeTypeColor(a)}},[t._v(" "+t._s(t.getTradeTypeText(a))+" ")])]}},{key:"price",fn:function(e){return[t._v(" $"+t._s(parseFloat(e).toFixed(4))+" ")]}},{key:"amount",fn:function(e){return[t._v(" "+t._s(parseFloat(e).toFixed(4))+" ")]}},{key:"value",fn:function(e){return[t._v(" $"+t._s(parseFloat(e).toFixed(2))+" ")]}},{key:"profit",fn:function(a,i){return[e("span",{style:{color:a>0?"#52c41a":a<0?"#f5222d":"#666"}},[t._v(" "+t._s(t.formatProfit(a,i))+" ")])]}},{key:"commission",fn:function(e){return[t._v(" "+t._s(t.formatCommission(e))+" ")]}},{key:"time",fn:function(e,a){return[t._v(" "+t._s(t.formatTime(a.created_at||e))+" ")]}}])}):e("div",{staticClass:"empty-state"},[e("a-empty",{attrs:{description:t.$t("trading-assistant.table.noPositions")}})],1)],1)},v=[],b={name:"TradingRecords",props:{strategyId:{type:Number,required:!0},loading:{type:Boolean,default:!1}},computed:{columns:function(){return[{title:this.$t("trading-assistant.table.time"),dataIndex:"created_at",key:"created_at",width:180,scopedSlots:{customRender:"time"}},{title:this.$t("dashboard.indicator.backtest.tradeType"),dataIndex:"type",key:"type",width:140,scopedSlots:{customRender:"type"}},{title:this.$t("trading-assistant.table.price"),dataIndex:"price",key:"price",width:120,scopedSlots:{customRender:"price"}},{title:this.$t("trading-assistant.table.amount"),dataIndex:"amount",key:"amount",width:120,scopedSlots:{customRender:"amount"}},{title:this.$t("trading-assistant.table.value"),dataIndex:"value",key:"value",width:120,scopedSlots:{customRender:"value"}},{title:this.$t("dashboard.indicator.backtest.profit"),dataIndex:"profit",key:"profit",width:120,scopedSlots:{customRender:"profit"}},{title:this.$t("trading-assistant.table.commission"),dataIndex:"commission",key:"commission",width:100,scopedSlots:{customRender:"commission"}}]}},data:function(){return{records:[]}},watch:{strategyId:{handler:function(t){t&&this.loadRecords()},immediate:!0}},methods:{loadRecords:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(t.strategyId){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,(0,m.tq)(t.strategyId);case 2:a=e.v,1===a.code?t.records=(a.data.trades||[]).map(function(t){return(0,u.A)((0,u.A)({},t),{},{time:t.created_at||t.time})}):t.$message.error(a.msg||t.$t("trading-assistant.messages.loadTradesFailed")),e.n=4;break;case 3:e.p=3,e.v;case 4:return e.a(2)}},e,null,[[1,3]])}))()},formatTime:function(t){if(!t)return"--";try{var e;if("number"===typeof t){var a=t<1e12?1e3*t:t;e=new Date(a)}else{if("string"!==typeof t)return"--";if(/^\d+$/.test(t)){var i=parseInt(t,10),s=i<1e12?1e3*i:i;e=new Date(s)}else e=new Date(t)}if(isNaN(e.getTime()))return"--";var r=this.$i18n.locale||"zh-CN",n={"zh-CN":"zh-CN","zh-TW":"zh-TW","en-US":"en-US"};return e.toLocaleString(n[r]||"zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch(o){return"--"}},getTradeTypeColor:function(t){var e={buy:"green",sell:"red",liquidation:"orange",open_long:"green",add_long:"cyan",close_long:"orange",close_long_stop:"red",close_long_profit:"lime",open_short:"red",add_short:"magenta",close_short:"blue",close_short_stop:"red",close_short_profit:"cyan"};return e[t]||"default"},getTradeTypeText:function(t){var e={buy:this.$t("dashboard.indicator.backtest.buy"),sell:this.$t("dashboard.indicator.backtest.sell"),liquidation:this.$t("dashboard.indicator.backtest.liquidation"),open_long:this.$t("dashboard.indicator.backtest.openLong"),add_long:this.$t("dashboard.indicator.backtest.addLong"),close_long:this.$t("dashboard.indicator.backtest.closeLong"),close_long_stop:this.$t("dashboard.indicator.backtest.closeLongStop"),close_long_profit:this.$t("dashboard.indicator.backtest.closeLongProfit"),open_short:this.$t("dashboard.indicator.backtest.openShort"),add_short:this.$t("dashboard.indicator.backtest.addShort"),close_short:this.$t("dashboard.indicator.backtest.closeShort"),close_short_stop:this.$t("dashboard.indicator.backtest.closeShortStop"),close_short_profit:this.$t("dashboard.indicator.backtest.closeShortProfit")};return e[t]||t},formatMoney:function(t){if(null===t||void 0===t)return"--";var e=t>=0?"+":"-";return"".concat(e,"$").concat(Math.abs(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}))},formatProfit:function(t,e){if(null===t||void 0===t)return"--";var a=parseFloat(t),i=["open_long","open_short","add_long","add_short"];return 0===a&&e&&i.includes(e.type)?"--":Math.abs(a)<1e-6?e&&i.includes(e.type)?"--":"$0.00":this.formatMoney(a)},formatCommission:function(t){if(null===t||void 0===t)return"--";var e=parseFloat(t);return isNaN(e)||Math.abs(e)<1e-6?"--":"$".concat(e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:6}))}}},k=b,S=a(845),x=(0,S.A)(k,f,v,!1,null,"a5bdef7e",null),C=x.exports,w=function(){var t=this,e=t._self._c;return e("div",{staticClass:"position-records"},[0!==t.positions.length||t.loading?e("a-table",{attrs:{columns:t.columns,"data-source":t.positions,loading:t.loading,pagination:!1,size:"small",rowKey:"id",scroll:{x:800}},scopedSlots:t._u([{key:"symbol",fn:function(a,i){return[e("strong",[t._v(t._s(i.symbol||a))])]}},{key:"side",fn:function(a,i){return[e("a-tag",{attrs:{color:"long"===(i.side||a)?"green":"red"}},[t._v(" "+t._s("long"===(i.side||a)?t.$t("trading-assistant.table.long"):t.$t("trading-assistant.table.short"))+" ")])]}},{key:"entryPrice",fn:function(a,i){return[t.hasValidPrice(i.entry_price||a)?e("span",[t._v(" $"+t._s(parseFloat(i.entry_price||a).toFixed(4))+" ")]):e("span",[t._v("--")])]}},{key:"currentPrice",fn:function(e,a){return[t._v(" $"+t._s(parseFloat(a.current_price||e||0).toFixed(4))+" ")]}},{key:"size",fn:function(e,a){return[t._v(" "+t._s(parseFloat(a.size||e||0).toFixed(4))+" ")]}},{key:"unrealizedPnl",fn:function(a,i){return[e("span",{class:{profit:parseFloat(i.unrealized_pnl||a||0)>0,loss:parseFloat(i.unrealized_pnl||a||0)<0}},[t._v(" $"+t._s(parseFloat(i.unrealized_pnl||a||0).toFixed(2))+" ")])]}},{key:"pnlPercent",fn:function(a,i){return[e("span",{class:{profit:parseFloat(i.pnl_percent||a||0)>0,loss:parseFloat(i.pnl_percent||a||0)<0}},[t._v(" "+t._s(parseFloat(i.pnl_percent||a||0).toFixed(2))+"% ")])]}}])}):e("div",{staticClass:"empty-state"},[e("a-empty",{attrs:{description:t.$t("trading-assistant.table.noPositions")}})],1)],1)},$=[],A={name:"PositionRecords",props:{strategyId:{type:Number,required:!0},marketType:{type:String,default:"swap"},leverage:{type:[Number,String],default:1},loading:{type:Boolean,default:!1}},data:function(){return{positions:[]}},computed:{columns:function(){return[{title:this.$t("trading-assistant.table.symbol"),dataIndex:"symbol",key:"symbol",width:120,scopedSlots:{customRender:"symbol"}},{title:this.$t("trading-assistant.table.side"),dataIndex:"side",key:"side",width:80,scopedSlots:{customRender:"side"}},{title:this.$t("trading-assistant.table.size"),dataIndex:"size",key:"size",width:120,scopedSlots:{customRender:"size"}},{title:this.$t("trading-assistant.table.entryPrice"),dataIndex:"entry_price",key:"entry_price",width:120,scopedSlots:{customRender:"entryPrice"}},{title:this.$t("trading-assistant.table.currentPrice"),dataIndex:"current_price",key:"current_price",width:120,scopedSlots:{customRender:"currentPrice"}},{title:this.$t("trading-assistant.table.unrealizedPnl"),dataIndex:"unrealized_pnl",key:"unrealized_pnl",width:120,scopedSlots:{customRender:"unrealizedPnl"}},{title:this.$t("trading-assistant.table.pnlPercent"),dataIndex:"pnl_percent",key:"pnl_percent",width:100,scopedSlots:{customRender:"pnlPercent"}}]}},watch:{strategyId:{handler:function(t){t?(this.loadPositions(),this.startPolling()):this.stopPolling()},immediate:!0}},beforeDestroy:function(){this.stopPolling()},methods:{loadPositions:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a,i;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(t.strategyId){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,(0,m.oK)(t.strategyId);case 2:a=e.v,1===a.code?(i=a.data.positions||[],t.positions=i.map(function(e,a){var i=String(t.marketType||"swap").toLowerCase(),s=parseFloat(t.leverage);(!isFinite(s)||s<=0)&&(s=1),"spot"===i&&(s=1);var r=parseFloat(e.entry_price||e.entryPrice||0),n=parseFloat(e.size||"0")||0,o=parseFloat(e.unrealized_pnl||e.unrealizedPnl||"0")||0,l=parseFloat(e.pnl_percent||e.pnlPercent||"0")||0;r>0&&n>0?l=o/(r*n)*100*s:"spot"!==i&&(l*=s);var c={id:e.id||a,symbol:e.symbol||"",side:e.side||"long",size:n>0?n.toString():"0",entry_price:r>0?r.toString():"0",current_price:e.current_price||e.currentPrice||"0",unrealized_pnl:e.unrealized_pnl||e.unrealizedPnl||"0",pnl_percent:l,updated_at:e.updated_at||e.updatedAt||""};return c})):t.positions=[],e.n=4;break;case 3:e.p=3,e.v,t.positions=[];case 4:return e.a(2)}},e,null,[[1,3]])}))()},hasValidPrice:function(t){var e=parseFloat(t);return Number.isFinite(e)&&e>0},startPolling:function(){var t=this;this.stopPolling(),this.pollingTimer=setInterval(function(){t.loadPositions()},5e3)},stopPolling:function(){this.pollingTimer&&(clearInterval(this.pollingTimer),this.pollingTimer=null)}}},M=A,P=(0,S.A)(M,w,$,!1,null,"2abcf4f1",null),T=P.exports,F=function(){var t=this,e=t._self._c;return e("div",{staticClass:"strategy-type-selector",class:{"theme-dark":t.isDark}},[e("div",{staticClass:"selector-header"},[e("h3",[t._v(t._s(t.$t("trading-assistant.selectMode")))]),e("p",{staticClass:"selector-hint"},[t._v(t._s(t.$t("trading-assistant.selectModeHint")))])]),e("div",{staticClass:"mode-cards"},[e("div",{staticClass:"mode-card",class:{selected:"signal"===t.selected},on:{click:function(e){return t.$emit("select","signal")}}},[e("div",{staticClass:"card-icon signal-icon"},[e("a-icon",{attrs:{type:"line-chart"}})],1),e("div",{staticClass:"card-body"},[e("h4",[t._v(t._s(t.$t("trading-assistant.strategyMode.signal")))]),e("p",{staticClass:"card-desc"},[t._v(t._s(t.$t("trading-assistant.strategyMode.signalDesc")))]),e("ul",{staticClass:"card-features"},[e("li",[e("a-icon",{attrs:{type:"check"}}),t._v(" "+t._s(t.$t("trading-assistant.strategyMode.signalFeature1")))],1),e("li",[e("a-icon",{attrs:{type:"check"}}),t._v(" "+t._s(t.$t("trading-assistant.strategyMode.signalFeature2")))],1),e("li",[e("a-icon",{attrs:{type:"check"}}),t._v(" "+t._s(t.$t("trading-assistant.strategyMode.signalFeature3")))],1)])]),e("a-button",{staticClass:"card-btn",attrs:{type:"primary",ghost:""},on:{click:function(e){return e.stopPropagation(),t.$emit("select","signal")}}},[t._v(" "+t._s(t.$t("trading-assistant.useThisMode"))+" ")])],1),e("div",{staticClass:"mode-card",class:{selected:"script"===t.selected},on:{click:function(e){return t.$emit("select","script")}}},[e("div",{staticClass:"card-icon script-icon"},[e("a-icon",{attrs:{type:"code"}})],1),e("div",{staticClass:"card-body"},[e("h4",[t._v(t._s(t.$t("trading-assistant.strategyMode.script")))]),e("p",{staticClass:"card-desc"},[t._v(t._s(t.$t("trading-assistant.strategyMode.scriptDesc")))]),e("ul",{staticClass:"card-features"},[e("li",[e("a-icon",{attrs:{type:"check"}}),t._v(" "+t._s(t.$t("trading-assistant.strategyMode.scriptFeature1")))],1),e("li",[e("a-icon",{attrs:{type:"check"}}),t._v(" "+t._s(t.$t("trading-assistant.strategyMode.scriptFeature2")))],1),e("li",[e("a-icon",{attrs:{type:"check"}}),t._v(" "+t._s(t.$t("trading-assistant.strategyMode.scriptFeature3")))],1)])]),e("a-button",{staticClass:"card-btn",attrs:{type:"primary",ghost:""},on:{click:function(e){return e.stopPropagation(),t.$emit("select","script")}}},[t._v(" "+t._s(t.$t("trading-assistant.useThisMode"))+" ")])],1)]),e("div",{staticClass:"template-quick-start"},[e("a-divider",[e("span",{staticClass:"divider-text"},[t._v(t._s(t.$t("trading-assistant.fromTemplate")))])]),e("div",{staticClass:"template-tags"},t._l(t.templates,function(a){return e("a-tag",{key:a.key,staticClass:"template-tag",on:{click:function(e){return t.$emit("use-template",a.key)}}},[e("span",{staticClass:"tpl-icon"},[t._v(t._s(a.icon))]),t._v(" "+t._s(t.$t("trading-assistant.template.".concat(a.key)))+" ")])}),1)],1)])},I=[],V={name:"StrategyTypeSelector",props:{selected:{type:String,default:""},isDark:{type:Boolean,default:!1}},data:function(){return{templates:[{key:"trendFollowing",icon:"📈"},{key:"martingale",icon:"🔥"},{key:"grid",icon:"📐"},{key:"dca",icon:"💰"},{key:"meanReversion",icon:"🔄"},{key:"breakout",icon:"⚡"}]}}},N=V,D=(0,S.A)(N,F,I,!1,null,"2344f311",null),U=D.exports,E=function(){var t=this,e=t._self._c;return e("div",{staticClass:"strategy-editor",class:{"theme-dark":t.isDark}},[e("a-row",{staticClass:"editor-layout",attrs:{gutter:16}},[e("a-col",{staticClass:"code-col",attrs:{xs:24,md:16}},[e("div",{staticClass:"code-section"},[e("div",{staticClass:"section-header"},[e("span",{staticClass:"section-title"},[e("a-icon",{attrs:{type:"code"}}),t._v(" "+t._s(t.$t("trading-assistant.editor.title"))+" ")],1),e("div",{staticClass:"section-actions"},[e("a-button",{staticStyle:{color:"#52c41a","font-weight":"600"},attrs:{type:"link",size:"small",loading:t.verifying},on:{click:t.handleVerify}},[e("a-icon",{attrs:{type:"check-circle"}}),t._v(" "+t._s(t.$t("trading-assistant.editor.verify"))+" ")],1)],1)]),e("div",{ref:"editorContainer",staticClass:"code-editor-container"})])]),e("a-col",{staticClass:"side-col",attrs:{xs:24,md:8}},[e("a-tabs",{staticClass:"side-tabs",attrs:{size:"small"},model:{value:t.activeTab,callback:function(e){t.activeTab=e},expression:"activeTab"}},[e("a-tab-pane",{key:"templates",attrs:{tab:t.$t("trading-assistant.editor.templateTab")}},[e("div",{staticClass:"template-list"},t._l(t.templates,function(a){return e("div",{key:a.key,staticClass:"template-item",on:{click:function(e){return t.loadTemplate(a.key)}}},[e("div",{staticClass:"tpl-header"},[e("span",{staticClass:"tpl-icon"},[t._v(t._s(a.icon))]),e("span",{staticClass:"tpl-name"},[t._v(t._s(t.$t("trading-assistant.template.".concat(a.key))))])]),e("p",{staticClass:"tpl-desc"},[t._v(t._s(t.$t("trading-assistant.template.".concat(a.key,"Desc"))))]),e("a-button",{staticClass:"tpl-use-btn",attrs:{type:"link",size:"small"}},[t._v(" "+t._s(t.$t("trading-assistant.template.useTemplate"))+" "),e("a-icon",{attrs:{type:"arrow-right"}})],1)],1)}),0)]),e("a-tab-pane",{key:"ai",attrs:{tab:t.$t("trading-assistant.editor.aiTab")}},[e("div",{staticClass:"ai-panel"},[e("div",{staticClass:"ai-panel-title"},[e("a-icon",{attrs:{type:"robot"}}),e("span",[t._v(t._s(t.$t("trading-assistant.editor.aiGenerate")))])],1),e("a-textarea",{attrs:{placeholder:t.$t("trading-assistant.editor.aiPromptPlaceholder"),rows:10,"auto-size":{minRows:8,maxRows:16}},model:{value:t.aiPrompt,callback:function(e){t.aiPrompt=e},expression:"aiPrompt"}}),e("a-button",{staticStyle:{"margin-top":"10px"},attrs:{type:"primary",block:"",loading:t.aiGenerating,size:"large"},on:{click:t.handleAIGenerate}},[e("a-icon",{attrs:{type:"thunderbolt"}}),t._v(" "+t._s(t.$t("trading-assistant.editor.aiGenerateBtn"))+" ")],1),t.aiGenerating?e("div",{staticClass:"ai-status"},[e("a-icon",{attrs:{type:"loading",spin:""}}),t._v(" "+t._s(t.$t("trading-assistant.editor.generating"))+" ")],1):t._e()],1)]),e("a-tab-pane",{key:"docs",attrs:{tab:t.$t("trading-assistant.editor.docsTab")}},[e("div",{staticClass:"docs-panel"},[e("div",{staticClass:"docs-content",domProps:{innerHTML:t._s(t.apiDocsHtml)}})])])],1)],1)],1)],1)},q=[],R=(a(6011),a(18787)),z=a(15237),L=a.n(z),K=(a(74806),a(55218),a(97923),a(50436),{trendFollowing:"\"\"\"\nTrend Following Strategy\nUses EMA crossover with dynamic stop-loss\n\"\"\"\n\ndef on_init(ctx):\n ctx.fast_period = ctx.param('fast_period', 12)\n ctx.slow_period = ctx.param('slow_period', 26)\n ctx.stop_pct = ctx.param('stop_pct', 0.03)\n\ndef on_bar(ctx, bar):\n bars = ctx.bars(ctx.slow_period + 5)\n if len(bars) < ctx.slow_period:\n return\n\n closes = [b['close'] for b in bars]\n fast_ema = _ema(closes, ctx.fast_period)\n slow_ema = _ema(closes, ctx.slow_period)\n\n if fast_ema > slow_ema and not ctx.position:\n ctx.buy(bar['close'], ctx.equity * 0.95 / bar['close'])\n ctx.log(f\"BUY at {bar['close']:.2f}\")\n\n elif fast_ema < slow_ema and ctx.position and ctx.position['side'] == 'long':\n ctx.close_position()\n ctx.log(f\"SELL at {bar['close']:.2f}\")\n\n if ctx.position and ctx.position['side'] == 'long':\n entry = ctx.position['entry_price']\n if bar['close'] < entry * (1 - ctx.stop_pct):\n ctx.close_position()\n ctx.log(f\"STOP LOSS at {bar['close']:.2f}\")\n\ndef _ema(data, period):\n k = 2 / (period + 1)\n ema = data[0]\n for price in data[1:]:\n ema = price * k + ema * (1 - k)\n return ema\n",martingale:"\"\"\"\nMartingale Strategy\nDouble position on each loss, with max layer control\n\"\"\"\n\ndef on_init(ctx):\n ctx.base_amount = ctx.param('base_amount', 100)\n ctx.max_layers = ctx.param('max_layers', 5)\n ctx.multiplier = ctx.param('multiplier', 2.0)\n ctx.take_profit_pct = ctx.param('take_profit_pct', 0.02)\n ctx.current_layer = 0\n\ndef on_bar(ctx, bar):\n if not ctx.position:\n amount = ctx.base_amount * (ctx.multiplier ** ctx.current_layer)\n if amount <= ctx.balance:\n qty = amount / bar['close']\n ctx.buy(bar['close'], qty)\n ctx.log(f\"Layer {ctx.current_layer}: BUY {qty:.4f} at {bar['close']:.2f}\")\n else:\n entry = ctx.position['entry_price']\n pnl_pct = (bar['close'] - entry) / entry\n\n if pnl_pct >= ctx.take_profit_pct:\n ctx.close_position()\n ctx.current_layer = 0\n ctx.log(f\"TAKE PROFIT at {bar['close']:.2f}, reset layers\")\n\n elif pnl_pct <= -ctx.take_profit_pct:\n ctx.close_position()\n if ctx.current_layer < ctx.max_layers:\n ctx.current_layer += 1\n ctx.log(f\"LOSS, escalate to layer {ctx.current_layer}\")\n else:\n ctx.current_layer = 0\n ctx.log(f\"Max layers reached, reset\")\n",grid:'"""\nGrid Trading Strategy\nPlaces buy/sell orders at equal intervals within a price range\n"""\n\ndef on_init(ctx):\n ctx.grid_upper = ctx.param(\'grid_upper\', 70000)\n ctx.grid_lower = ctx.param(\'grid_lower\', 60000)\n ctx.grid_levels = ctx.param(\'grid_levels\', 10)\n ctx.order_amount = ctx.param(\'order_amount\', 100)\n ctx.filled_grids = set()\n\n spacing = (ctx.grid_upper - ctx.grid_lower) / ctx.grid_levels\n ctx.grid_prices = [ctx.grid_lower + i * spacing for i in range(ctx.grid_levels + 1)]\n\ndef on_bar(ctx, bar):\n price = bar[\'close\']\n if price < ctx.grid_lower or price > ctx.grid_upper:\n return\n\n for i, gp in enumerate(ctx.grid_prices[:-1]):\n upper_gp = ctx.grid_prices[i + 1]\n grid_id = f"grid_{i}"\n\n if price <= gp and grid_id not in ctx.filled_grids:\n qty = ctx.order_amount / price\n ctx.buy(price, qty)\n ctx.filled_grids.add(grid_id)\n ctx.log(f"Grid BUY at {price:.2f} (level {i})")\n\n elif price >= upper_gp and grid_id in ctx.filled_grids:\n qty = ctx.order_amount / price\n ctx.sell(price, qty)\n ctx.filled_grids.discard(grid_id)\n ctx.log(f"Grid SELL at {price:.2f} (level {i})")\n',dca:'"""\nDCA (Dollar Cost Averaging) Strategy\nPeriodic purchases with optional dip-buying\n"""\n\ndef on_init(ctx):\n ctx.buy_amount = ctx.param(\'buy_amount\', 100)\n ctx.dip_threshold = ctx.param(\'dip_threshold\', 0.05)\n ctx.dip_multiplier = ctx.param(\'dip_multiplier\', 2.0)\n ctx.bar_count = 0\n ctx.buy_interval = ctx.param(\'buy_interval\', 24)\n ctx.last_buy_price = None\n\ndef on_bar(ctx, bar):\n ctx.bar_count += 1\n price = bar[\'close\']\n\n is_dip = False\n if ctx.last_buy_price and price < ctx.last_buy_price * (1 - ctx.dip_threshold):\n is_dip = True\n\n if ctx.bar_count % ctx.buy_interval == 0 or is_dip:\n amount = ctx.buy_amount * (ctx.dip_multiplier if is_dip else 1.0)\n if amount <= ctx.balance:\n qty = amount / price\n ctx.buy(price, qty)\n ctx.last_buy_price = price\n tag = " (DIP BUY)" if is_dip else ""\n ctx.log(f"DCA BUY {qty:.6f} at {price:.2f}{tag}")\n',meanReversion:"\"\"\"\nMean Reversion Strategy\nBollinger Bands based: buy at lower band, sell at upper band\n\"\"\"\n\ndef on_init(ctx):\n ctx.period = ctx.param('period', 20)\n ctx.std_mult = ctx.param('std_mult', 2.0)\n ctx.position_pct = ctx.param('position_pct', 0.5)\n\ndef on_bar(ctx, bar):\n bars = ctx.bars(ctx.period + 5)\n if len(bars) < ctx.period:\n return\n\n closes = [b['close'] for b in bars[-ctx.period:]]\n mean = sum(closes) / len(closes)\n std = (sum((c - mean) ** 2 for c in closes) / len(closes)) ** 0.5\n\n upper = mean + ctx.std_mult * std\n lower = mean - ctx.std_mult * std\n price = bar['close']\n\n if price <= lower and not ctx.position:\n qty = (ctx.equity * ctx.position_pct) / price\n ctx.buy(price, qty)\n ctx.log(f\"BUY at {price:.2f} (below lower band {lower:.2f})\")\n\n elif price >= upper and ctx.position and ctx.position['side'] == 'long':\n ctx.close_position()\n ctx.log(f\"SELL at {price:.2f} (above upper band {upper:.2f})\")\n\n elif price >= mean and ctx.position and ctx.position['side'] == 'long':\n pnl_pct = (price - ctx.position['entry_price']) / ctx.position['entry_price']\n if pnl_pct > 0.01:\n ctx.close_position()\n ctx.log(f\"CLOSE at mean {price:.2f}, profit {pnl_pct:.2%}\")\n",breakout:"\"\"\"\nBreakout Strategy\nEnter when price breaks key resistance/support with volume confirmation\n\"\"\"\n\ndef on_init(ctx):\n ctx.lookback = ctx.param('lookback', 20)\n ctx.volume_mult = ctx.param('volume_mult', 1.5)\n ctx.stop_pct = ctx.param('stop_pct', 0.02)\n\ndef on_bar(ctx, bar):\n bars = ctx.bars(ctx.lookback + 5)\n if len(bars) < ctx.lookback:\n return\n\n recent = bars[-ctx.lookback:]\n high = max(b['high'] for b in recent[:-1])\n low = min(b['low'] for b in recent[:-1])\n avg_vol = sum(b['volume'] for b in recent[:-1]) / (len(recent) - 1)\n price = bar['close']\n vol = bar['volume']\n\n if price > high and vol > avg_vol * ctx.volume_mult and not ctx.position:\n qty = (ctx.equity * 0.9) / price\n ctx.buy(price, qty)\n ctx.log(f\"BREAKOUT BUY at {price:.2f} (prev high: {high:.2f})\")\n\n elif price < low and ctx.position and ctx.position['side'] == 'long':\n ctx.close_position()\n ctx.log(f\"BREAK DOWN, close at {price:.2f}\")\n\n if ctx.position and ctx.position['side'] == 'long':\n entry = ctx.position['entry_price']\n if price < entry * (1 - ctx.stop_pct):\n ctx.close_position()\n ctx.log(f\"STOP LOSS at {price:.2f}\")\n"}),B='\n<h4>Strategy API Reference</h4>\n<h5>Lifecycle Functions</h5>\n<pre><code>def on_init(ctx):\n """Called once when strategy starts"""\n\ndef on_bar(ctx, bar):\n """Called on each new K-line bar"""\n # bar: { open, high, low, close, volume, timestamp }\n\ndef on_order_filled(ctx, order):\n """Called when an order is filled"""\n\ndef on_stop(ctx):\n """Called when strategy stops"""</code></pre>\n\n<h5>Trading Actions</h5>\n<pre><code>ctx.buy(price, amount) # Buy / Go long\nctx.sell(price, amount) # Sell / Go short\nctx.close_position() # Close current position\nctx.cancel_all_orders() # Cancel pending orders</code></pre>\n\n<h5>Context Properties</h5>\n<pre><code>ctx.position # { side, amount, entry_price, unrealized_pnl }\nctx.balance # Available balance\nctx.equity # Total equity\nctx.current_price # Current market price\nctx.symbol # Trading symbol\nctx.timeframe # K-line timeframe</code></pre>\n\n<h5>Data Access</h5>\n<pre><code>ctx.bars(n=100) # Get last N bars\nctx.param(name, default) # Get strategy parameter\nctx.indicator(id, params) # Call existing indicator\nctx.log(message) # Log a message</code></pre>\n',O={name:"StrategyEditor",props:{value:{type:String,default:""},isDark:{type:Boolean,default:!1},userId:{type:[Number,String],default:1}},data:function(){return{activeTab:"templates",aiPrompt:"",aiGenerating:!1,verifying:!1,editor:null,apiDocsHtml:B,templates:[{key:"trendFollowing",icon:"📈"},{key:"martingale",icon:"🔥"},{key:"grid",icon:"📐"},{key:"dca",icon:"💰"},{key:"meanReversion",icon:"🔄"},{key:"breakout",icon:"⚡"}]}},mounted:function(){var t=this;this.$nextTick(function(){return t.initEditor()})},beforeDestroy:function(){this.editor&&("function"===typeof this.editor.toTextArea&&this.editor.toTextArea(),this.editor=null)},watch:{value:function(t){this.editor&&this.editor.getValue()!==t&&this.editor.setValue(t||"")},isDark:function(){this.editor&&this.editor.setOption("theme",this.isDark?"monokai":"eclipse")}},methods:{initEditor:function(){var t=this;this.$refs.editorContainer&&(this.editor=L()(this.$refs.editorContainer,{value:this.value||this._getDefaultCode(),mode:"python",theme:this.isDark?"monokai":"eclipse",lineNumbers:!0,autoCloseBrackets:!0,matchBrackets:!0,styleActiveLine:!0,tabSize:4,indentUnit:4,indentWithTabs:!1,lineWrapping:!0,viewportMargin:1/0}),this.editor.on("change",function(){t.$emit("input",t.editor.getValue())}))},_getDefaultCode:function(){return'"""\nMy Custom Strategy\n"""\n\ndef on_init(ctx):\n # Initialize strategy parameters\n pass\n\ndef on_bar(ctx, bar):\n # Core trading logic, called on each K-line bar\n # bar: { open, high, low, close, volume, timestamp }\n price = bar[\'close\']\n\n # Example: simple moving average\n bars = ctx.bars(20)\n if len(bars) < 20:\n return\n\n avg = sum(b[\'close\'] for b in bars) / len(bars)\n\n if price > avg and not ctx.position:\n ctx.buy(price, ctx.equity * 0.9 / price)\n ctx.log(f"BUY at {price}")\n\n elif price < avg and ctx.position:\n ctx.close_position()\n ctx.log(f"SELL at {price}")\n'},loadTemplate:function(t){var e=K[t];e&&(this.editor&&this.editor.setValue(e),this.$emit("input",e),this.activeTab="ai")},getCode:function(){return this.editor?this.editor.getValue():this.value},setCode:function(t){this.editor&&this.editor.setValue(t),this.$emit("input",t)},handleVerify:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a,i,s;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return t.verifying=!0,e.p=1,a=t.getCode(),e.n=2,(0,y.Ay)({url:"/api/strategies/verify-code",method:"post",data:{code:a,user_id:t.userId}});case 2:i=e.v,i&&i.success?R.A.success(t.$t("trading-assistant.editor.verifySuccess")):R.A.error(i&&i.message||t.$t("trading-assistant.editor.verifyFailed")),e.n=4;break;case 3:e.p=3,s=e.v,R.A.error(t.$t("trading-assistant.editor.verifyFailed")+": "+(s.message||""));case 4:return e.p=4,t.verifying=!1,e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}))()},handleAIGenerate:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a,i;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(t.aiPrompt.trim()){e.n=1;break}return e.a(2);case 1:return t.aiGenerating=!0,e.p=2,e.n=3,(0,y.Ay)({url:"/api/strategies/ai-generate",method:"post",data:{prompt:t.aiPrompt,user_id:t.userId}});case 3:a=e.v,a&&a.code&&(t.setCode(a.code),R.A.success("OK")),e.n=5;break;case 4:e.p=4,i=e.v,R.A.error("AI generation failed: "+(i.message||""));case 5:return e.p=5,t.aiGenerating=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}))()}}},H=O,W=(0,S.A)(H,E,q,!1,null,"767abf73",null),G=W.exports,Y=function(){var t=this,e=t._self._c;return e("div",{staticClass:"performance-analysis",class:{"theme-dark":t.isDark}},[e("a-spin",{attrs:{spinning:t.loading}},[t.hasData?e("div",[e("div",{staticClass:"metrics-grid"},[e("div",{staticClass:"metric-card",class:t.getMetricClass(t.metrics.totalReturn)},[e("div",{staticClass:"metric-label"},[t._v(t._s(t.$t("trading-assistant.performance.totalReturn")))]),e("div",{staticClass:"metric-value"},[t._v(t._s(t.formatPercent(t.metrics.totalReturn)))])]),e("div",{staticClass:"metric-card",class:t.getMetricClass(t.metrics.annualReturn)},[e("div",{staticClass:"metric-label"},[t._v(t._s(t.$t("trading-assistant.performance.annualReturn")))]),e("div",{staticClass:"metric-value"},[t._v(t._s(t.formatPercent(t.metrics.annualReturn)))])]),e("div",{staticClass:"metric-card negative"},[e("div",{staticClass:"metric-label"},[t._v(t._s(t.$t("trading-assistant.performance.maxDrawdown")))]),e("div",{staticClass:"metric-value"},[t._v(t._s(t.formatPercent(t.metrics.maxDrawdown)))])]),e("div",{staticClass:"metric-card"},[e("div",{staticClass:"metric-label"},[t._v(t._s(t.$t("trading-assistant.performance.sharpe")))]),e("div",{staticClass:"metric-value"},[t._v(t._s((t.metrics.sharpe||0).toFixed(2)))])]),e("div",{staticClass:"metric-card"},[e("div",{staticClass:"metric-label"},[t._v(t._s(t.$t("trading-assistant.performance.winRate")))]),e("div",{staticClass:"metric-value"},[t._v(t._s(t.formatPercent(t.metrics.winRate)))])]),e("div",{staticClass:"metric-card",class:t.getMetricClass((t.metrics.profitFactor||0)-1)},[e("div",{staticClass:"metric-label"},[t._v(t._s(t.$t("trading-assistant.performance.profitFactor")))]),e("div",{staticClass:"metric-value"},[t._v(t._s((t.metrics.profitFactor||0).toFixed(2)))])]),e("div",{staticClass:"metric-card"},[e("div",{staticClass:"metric-label"},[t._v(t._s(t.$t("trading-assistant.performance.totalTrades")))]),e("div",{staticClass:"metric-value"},[t._v(t._s(t.metrics.totalTrades||0))])]),e("div",{staticClass:"metric-card"},[e("div",{staticClass:"metric-label"},[t._v(t._s(t.$t("trading-assistant.performance.runningDays")))]),e("div",{staticClass:"metric-value"},[t._v(t._s(t.metrics.runningDays||0))])])]),e("div",{staticClass:"chart-section"},[e("div",{staticClass:"chart-title"},[t._v(t._s(t.$t("trading-assistant.performance.equityCurve")))]),e("div",{ref:"equityChart",staticClass:"chart-container"})]),e("div",{staticClass:"chart-section"},[e("div",{staticClass:"chart-title"},[t._v(t._s(t.$t("trading-assistant.performance.dailyReturns")))]),e("div",{ref:"dailyChart",staticClass:"chart-container",staticStyle:{height:"250px"}})])]):t.loading?t._e():e("a-empty",{staticStyle:{padding:"60px 0"},attrs:{description:t.$t("trading-assistant.performance.noData")}})],1)],1)},j=[],Q={name:"PerformanceAnalysis",props:{strategyId:{type:[Number,String],default:null},isDark:{type:Boolean,default:!1}},data:function(){return{loading:!1,metrics:{},equityData:[],dailyReturns:[],equityChartInstance:null,dailyChartInstance:null}},computed:{hasData:function(){return this.equityData.length>0}},watch:{strategyId:{handler:function(t){t&&this.loadData()},immediate:!0},isDark:function(){var t=this;this.disposeCharts(),this.$nextTick(function(){return t.renderCharts()})}},beforeDestroy:function(){this.disposeCharts()},methods:{loadData:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(t.strategyId){e.n=1;break}return e.a(2);case 1:return t.loading=!0,e.p=2,e.n=3,(0,m.Yx)(t.strategyId);case 3:a=e.v,a&&a.data&&(t.equityData=a.data.equity_curve||a.data||[],t.computeMetrics(),t.$nextTick(function(){return t.renderCharts()})),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.p=5,t.loading=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}))()},computeMetrics:function(){var t=this.equityData;if(t.length){for(var e=t.map(function(t){return t.equity||t.value||t.y||0}),a=e[0]||1,i=e[e.length-1]||a,s=(i-a)/a,r=e[0],n=0,o=[],l=1;l<e.length;l++){e[l]>r&&(r=e[l]);var c=(e[l]-r)/r;c<n&&(n=c),o.push((e[l]-e[l-1])/e[l-1])}this.dailyReturns=o;var d=t.length,u=365/Math.max(d,1),m=o.length?o.reduce(function(t,e){return t+e},0)/o.length:0,g=o.length>1?Math.sqrt(o.reduce(function(t,e){return t+Math.pow(e-m,2)},0)/(o.length-1)):0,p=t.filter(function(t){return t.trade_count}).reduce(function(t,e){return t+e.trade_count},0)||0,_=t.filter(function(t){return t.win_count}).reduce(function(t,e){return t+e.win_count},0)||0,h=t.filter(function(t){return t.gross_profit}).reduce(function(t,e){return t+e.gross_profit},0),y=Math.abs(t.filter(function(t){return t.gross_loss}).reduce(function(t,e){return t+e.gross_loss},0));this.metrics={totalReturn:s,annualReturn:Math.pow(1+s,u)-1,maxDrawdown:n,sharpe:g>0?m/g*Math.sqrt(252):0,winRate:p>0?_/p:0,profitFactor:y>0?h/y:h>0?999:0,totalTrades:p,runningDays:d}}else this.metrics={}},renderCharts:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a;return(0,o.A)().w(function(e){while(1)switch(e.n){case 0:return e.n=1,t.getEcharts();case 1:if(a=e.v,a){e.n=2;break}return e.a(2);case 2:t.renderEquityChart(a),t.renderDailyChart(a);case 3:return e.a(2)}},e)}))()},getEcharts:function(){return(0,l.A)((0,o.A)().m(function t(){var e;return(0,o.A)().w(function(t){while(1)switch(t.p=t.n){case 0:if(!window.echarts){t.n=1;break}return t.a(2,window.echarts);case 1:return t.p=1,t.n=2,a.e(362).then(a.bind(a,29362));case 2:return e=t.v,window.echarts=e.default||e,t.a(2,window.echarts);case 3:return t.p=3,t.v,t.a(2,null)}},t,null,[[1,3]])}))()},renderEquityChart:function(t){if(this.$refs.equityChart){this.equityChartInstance=t.init(this.$refs.equityChart,this.isDark?"dark":null);var e=this.equityData.map(function(t){return t.date||t.timestamp||t.x||""}),a=this.equityData.map(function(t){return t.equity||t.value||t.y||0});this.equityChartInstance.setOption({tooltip:{trigger:"axis"},grid:{left:60,right:20,top:20,bottom:30},xAxis:{type:"category",data:e,axisLabel:{fontSize:10}},yAxis:{type:"value",axisLabel:{fontSize:10}},series:[{type:"line",data:a,smooth:!0,lineStyle:{width:2,color:"#1890ff"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(24,144,255,0.3)"},{offset:1,color:"rgba(24,144,255,0.02)"}]}},itemStyle:{color:"#1890ff"},showSymbol:!1}]})}},renderDailyChart:function(t){this.$refs.dailyChart&&this.dailyReturns.length&&(this.dailyChartInstance=t.init(this.$refs.dailyChart,this.isDark?"dark":null),this.dailyChartInstance.setOption({tooltip:{trigger:"axis",formatter:function(t){return"".concat((100*t[0].value).toFixed(2),"%")}},grid:{left:60,right:20,top:10,bottom:30},xAxis:{type:"category",data:this.dailyReturns.map(function(t,e){return e+1}),show:!1},yAxis:{type:"value",axisLabel:{formatter:function(t){return(100*t).toFixed(1)+"%"},fontSize:10}},series:[{type:"bar",data:this.dailyReturns.map(function(t){return{value:t,itemStyle:{color:t>=0?"#52c41a":"#ff4d4f"}}}),barMaxWidth:6}]}))},disposeCharts:function(){this.equityChartInstance&&(this.equityChartInstance.dispose(),this.equityChartInstance=null),this.dailyChartInstance&&(this.dailyChartInstance.dispose(),this.dailyChartInstance=null)},formatPercent:function(t){return void 0===t||null===t?"--":(t>=0?"+":"")+(100*t).toFixed(2)+"%"},getMetricClass:function(t){return t?t>0?"positive":t<0?"negative":"":""}}},X=Q,J=(0,S.A)(X,Y,j,!1,null,"192d71db",null),Z=J.exports,tt=function(){var t=this,e=t._self._c;return e("div",{staticClass:"strategy-logs",class:{"theme-dark":t.isDark}},[e("div",{staticClass:"logs-toolbar"},[e("div",{staticClass:"toolbar-left"},[e("a-radio-group",{attrs:{size:"small","button-style":"solid"},model:{value:t.filterLevel,callback:function(e){t.filterLevel=e},expression:"filterLevel"}},[e("a-radio-button",{attrs:{value:"all"}},[t._v("All")]),e("a-radio-button",{attrs:{value:"trade"}},[e("a-badge",{attrs:{count:t.countByLevel("trade"),"overflow-count":99,offset:[6,-2]}},[t._v(" "+t._s(t.$t("trading-assistant.logs.level.trade"))+" ")])],1),e("a-radio-button",{attrs:{value:"signal"}},[t._v(t._s(t.$t("trading-assistant.logs.level.signal")))]),e("a-radio-button",{attrs:{value:"error"}},[t._v(t._s(t.$t("trading-assistant.logs.level.error")))])],1)],1),e("div",{staticClass:"toolbar-right"},[e("a-switch",{attrs:{checked:t.autoRefresh,size:"small"},on:{change:t.toggleAutoRefresh}}),e("span",{staticClass:"auto-refresh-label"},[t._v(t._s(t.$t("trading-assistant.logs.autoRefresh")))])],1)]),e("div",{ref:"logsContainer",staticClass:"logs-container custom-scrollbar"},[0===t.filteredLogs.length?e("div",{staticClass:"logs-empty"},[e("a-icon",{staticStyle:{"font-size":"32px",color:"#ccc"},attrs:{type:"file-text"}}),e("p",[t._v(t._s(t.$t("trading-assistant.logs.noLogs")))])],1):t._e(),t._l(t.filteredLogs,function(a,i){return e("div",{key:i,staticClass:"log-entry",class:"level-"+a.level},[e("span",{staticClass:"log-time"},[t._v(t._s(t.formatTime(a.timestamp)))]),e("a-tag",{staticClass:"log-level",attrs:{color:t.getLevelColor(a.level),size:"small"}},[t._v(" "+t._s(t.getLevelText(a.level))+" ")]),e("span",{staticClass:"log-message"},[t._v(t._s(a.message))])],1)})],2)])},et=[],at={name:"StrategyLogs",props:{strategyId:{type:[Number,String],default:null},isDark:{type:Boolean,default:!1}},data:function(){return{logs:[],filterLevel:"all",autoRefresh:!1,refreshTimer:null,loading:!1}},computed:{filteredLogs:function(){var t=this;return"all"===this.filterLevel?this.logs:this.logs.filter(function(e){return e.level===t.filterLevel})}},watch:{strategyId:{handler:function(t){t&&this.loadLogs()},immediate:!0}},beforeDestroy:function(){this.stopAutoRefresh()},methods:{loadLogs:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(t.strategyId){e.n=1;break}return e.a(2);case 1:return t.loading=!0,e.p=2,e.n=3,(0,y.Ay)({url:"/api/strategies/logs",method:"get",params:{id:t.strategyId,limit:200}});case 3:a=e.v,a&&a.data&&(t.logs=a.data,t.$nextTick(function(){return t.scrollToBottom()})),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.p=5,t.loading=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}))()},toggleAutoRefresh:function(t){var e=this;this.autoRefresh=t,t?this.refreshTimer=setInterval(function(){return e.loadLogs()},5e3):this.stopAutoRefresh()},stopAutoRefresh:function(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null)},scrollToBottom:function(){var t=this.$refs.logsContainer;t&&(t.scrollTop=t.scrollHeight)},countByLevel:function(t){return this.logs.filter(function(e){return e.level===t}).length},formatTime:function(t){if(!t)return"";try{var e=new Date(t);return e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch(a){return t}},getLevelColor:function(t){var e={info:"blue",warn:"orange",error:"red",trade:"green",signal:"purple"};return e[t]||"default"},getLevelText:function(t){var e="trading-assistant.logs.level.".concat(t),a=this.$t(e);return a!==e?a:t}}},it=at,st=(0,S.A)(it,tt,et,!1,null,"129fed65",null),rt=st.exports,nt=["BTC/USDT","ETH/USDT","BNB/USDT","SOL/USDT","ADA/USDT","XRP/USDT","DOGE/USDT","DOT/USDT","MATIC/USDT","AVAX/USDT","LINK/USDT","UNI/USDT","LTC/USDT","ATOM/USDT","ETC/USDT"],ot=[{value:"binance",labelKey:"binance"},{value:"okx",labelKey:"okx"},{value:"bitget",labelKey:"bitget"},{value:"bybit",labelKey:"bybit"},{value:"coinbaseexchange",labelKey:"coinbaseexchange"},{value:"kraken",labelKey:"kraken"},{value:"kucoin",labelKey:"kucoin"},{value:"gate",labelKey:"gate"},{value:"bitfinex",labelKey:"bitfinex"},{value:"deepcoin",labelKey:"deepcoin"}],lt=[{value:"ibkr",labelKey:"ibkr",name:"Interactive Brokers"}],ct=[{value:"mt5",labelKey:"mt5",name:"MetaTrader 5"}],dt={name:"TradingAssistant",mixins:[h.t],components:{TradingRecords:C,PositionRecords:T,StrategyTypeSelector:U,StrategyEditor:G,PerformanceAnalysis:Z,StrategyLogs:rt},computed:{isAdvancedMode:function(){return"advanced"===this.creationMode},isSimpleMode:function(){return"simple"===this.creationMode},displayCurrentStep:function(){return"script"===this.strategyMode?this.currentStep:this.isSimpleMode&&!this.editingStrategy?0===this.currentStep?0:1:this.currentStep},isDarkTheme:function(){return"dark"===this.navTheme||"realdark"===this.navTheme},needsPassphrase:function(){return["okx","okex","coinbaseexchange","kucoin","bitget","deepcoin"].includes(this.currentExchangeId)},isIBKRMarket:function(){return"USStock"===this.selectedMarketCategory},isMT5Market:function(){return"Forex"===this.selectedMarketCategory},isBrokerMarket:function(){return this.isIBKRMarket||this.isMT5Market},filteredExchangeCredentials:function(){var t=this;return this.exchangeCredentials&&Array.isArray(this.exchangeCredentials)?this.exchangeCredentials.filter(function(e){return t.isCredentialCompatible(e)}):[]},formattedExchangeOptions:function(){var t=this;return ot.map(function(e){var a="";try{if(e.labelKey){var i="trading-assistant.exchangeNames.".concat(e.labelKey),s=t.$t(i);s!==i&&(a=s)}}catch(r){}return a||(a=e.value.charAt(0).toUpperCase()+e.value.slice(1)),(0,u.A)((0,u.A)({},e),{},{displayName:a})})},totalPnl:function(){return null!==this.currentEquity&&this.selectedStrategy&&this.selectedStrategy.initial_capital?this.currentEquity-(this.selectedStrategy.initial_capital||0):null},totalPnlPercent:function(){return null!==this.totalPnl&&this.selectedStrategy&&this.selectedStrategy.initial_capital?0===this.selectedStrategy.initial_capital?0:this.totalPnl/this.selectedStrategy.initial_capital*100:null},getEquityColorClass:function(){return null===this.totalPnl?"":this.totalPnl>=0?"text-success":"text-danger"},getPnlColorClass:function(){return null===this.totalPnl?"":this.totalPnl>=0?"text-success":"text-danger"},isCryptoMarket:function(){var t=this.selectedMarketCategory||"Crypto";return"crypto"===String(t).toLowerCase()},canUseLiveTrading:function(){var t=this.selectedMarketCategory||"Crypto";return"crypto"===String(t).toLowerCase()||("USStock"===t||"Forex"===t)},isLiveTradingAvailable:function(){var t=this.selectedMarketCategory||"Crypto",e=this.currentExchangeId||"";return"crypto"===String(t).toLowerCase()?["binance","okx","bitget","bybit","coinbaseexchange","kraken","kucoin","gate","bitfinex"].includes(e):"USStock"===t?"ibkr"===this.currentBrokerId:"Forex"===t&&"mt5"===this.currentBrokerId},showDemoTradingSwitch:function(){return this.currentExchangeId&&"binance"===this.currentExchangeId.toLowerCase()},brokerOptions:function(){var t=this;return lt.map(function(e){var a="";try{var i="trading-assistant.brokerNames.".concat(e.labelKey),s=t.$t(i);s!==i&&(a=s)}catch(r){}return a||(a=e.name||e.value.toUpperCase()),(0,u.A)((0,u.A)({},e),{},{displayName:a})})},forexBrokerOptions:function(){var t=this;return ct.map(function(e){var a="";try{var i="trading-assistant.brokerNames.".concat(e.labelKey),s=t.$t(i);s!==i&&(a=s)}catch(r){}return a||(a=e.name||e.value.toUpperCase()),(0,u.A)((0,u.A)({},e),{},{displayName:a})})},cryptoExchangeOptions:function(){var t=this;return ot.map(function(e){var a="";try{if(e.labelKey){var i="trading-assistant.exchangeNames.".concat(e.labelKey),s=t.$t(i);s!==i&&(a=s)}}catch(r){}return a||(a=e.value.charAt(0).toUpperCase()+e.value.slice(1)),(0,u.A)((0,u.A)({},e),{},{displayName:a})})},groupedStrategies:function(){return"symbol"===this.groupByMode?this.groupedBySymbol:this.groupedByStrategy},groupedByStrategy:function(){var t,e={},a=[],i=(0,d.A)(this.strategies);try{for(i.s();!(t=i.n()).done;){var s=t.value,r=s.strategy_group_id;r&&r.trim()?(e[r]||(e[r]={id:r,baseName:s.group_base_name||s.strategy_name.split("-")[0],strategies:[],runningCount:0,stoppedCount:0}),e[r].strategies.push(s),"running"===s.status?e[r].runningCount++:e[r].stoppedCount++):a.push(s)}}catch(o){i.e(o)}finally{i.f()}var n=Object.values(e).sort(function(t,e){var a=Math.max.apply(Math,(0,c.A)(t.strategies.map(function(t){return t.created_at||0}))),i=Math.max.apply(Math,(0,c.A)(e.strategies.map(function(t){return t.created_at||0})));return i-a});return{groups:n,ungrouped:a}},groupedBySymbol:function(){var t,e={},a=[],i=(0,d.A)(this.strategies);try{for(i.s();!(t=i.n()).done;){var s=t.value,r=s.trading_config||{},n=r.symbol;if(n&&n.trim()){e[n]||(e[n]={id:"symbol_".concat(n),baseName:n,strategies:[],runningCount:0,stoppedCount:0});var o=(0,u.A)((0,u.A)({},s),{},{displayInfo:{strategyName:s.strategy_name||s.group_base_name||"Unnamed",timeframe:r.timeframe||"-",indicatorName:s.indicator_name||s.indicator_config&&s.indicator_config.name||"-"}});e[n].strategies.push(o),"running"===s.status?e[n].runningCount++:e[n].stoppedCount++}else a.push(s)}}catch(c){i.e(c)}finally{i.f()}var l=Object.values(e).sort(function(t,e){return t.baseName.localeCompare(e.baseName)});return{groups:l,ungrouped:a}},unconfiguredChannels:function(){var t=[];return this.notifyChannelsUi.includes("telegram")&&(this.userNotificationSettings.telegram_bot_token||this.userNotificationSettings.telegram_chat_id||t.push("Telegram")),this.notifyChannelsUi.includes("email")&&(this.userNotificationSettings.email||t.push("Email")),this.notifyChannelsUi.includes("discord")&&(this.userNotificationSettings.discord_webhook||t.push("Discord")),this.notifyChannelsUi.includes("webhook")&&(this.userNotificationSettings.webhook_url||t.push("Webhook")),t}},data:function(){return{loading:!1,loadingRecords:!1,strategies:[],selectedStrategy:null,showFormModal:!1,creationMode:"simple",showAdvancedSettings:!1,strategyMode:"",strategyCode:"",showModeSelector:!1,strategyType:"indicator",selectedMarketCategory:"Crypto",currentStep:0,saving:!1,loadingIndicators:!1,availableIndicators:[],selectedIndicator:null,indicatorParams:[],indicatorParamValues:{},cryptoSymbols:nt,loadingWatchlist:!1,watchlist:[],exchangeOptions:ot,currentExchangeId:"",currentBrokerId:"ibkr",connectionTestResult:null,indicatorsLoaded:!1,editingStrategy:null,currentEquity:null,equityPollingTimer:null,backtestCollapseKeys:["risk"],trailingEnabledUi:!1,entryPctMaxUi:100,aiFilterEnabledUi:!1,isEditMode:!1,supportedIPs:[],executionModeUi:"signal",liveDisclaimerAckUi:!1,notifyChannelsUi:["browser"],userNotificationSettings:{default_channels:["browser"],telegram_bot_token:"",telegram_chat_id:"",email:"",phone:"",discord_webhook:"",webhook_url:"",webhook_token:""},loadingExchangeCredentials:!1,exchangeCredentials:[],saveCredentialUi:!1,suppressApiClearOnce:!1,selectedSymbols:[],crossSectionalSymbols:[],collapsedGroups:{},groupByMode:"strategy",showAddSymbolModal:!1,addSymbolMarket:"Crypto",addSymbolMarketTypes:[{value:"Crypto",i18nKey:"dashboard.analysis.market.Crypto"},{value:"USStock",i18nKey:"dashboard.analysis.market.USStock"},{value:"Forex",i18nKey:"dashboard.analysis.market.Forex"},{value:"Futures",i18nKey:"dashboard.analysis.market.Futures"}],addSymbolKeyword:"",searchingSymbol:!1,symbolSearchResults:[],selectedAddSymbol:null,hasSearchedSymbol:!1,addingSymbol:!1,hotSymbols:[],loadingHotSymbols:!1,searchTimer:null}},beforeCreate:function(){this.form=this.$form.createForm(this)},mounted:function(){var t=this;this.loadStrategies(),this.loadUserNotificationSettings(),"create"===this.$route.query.mode&&this.$nextTick(function(){var e=t.$route.query.indicator_id;e?(t.strategyMode="signal",t._openCreateModal(),t.$nextTick(function(){try{t.form.setFieldsValue({indicator_id:parseInt(e)})}catch(a){}})):t.handleCreateStrategy()})},beforeDestroy:function(){this.stopEquityPolling()},methods:{loadUserNotificationSettings:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return e.p=0,e.n=1,(0,_.vF)();case 1:a=e.v,1===a.code&&a.data&&(t.userNotificationSettings={default_channels:a.data.default_channels||["browser"],telegram_bot_token:a.data.telegram_bot_token||"",telegram_chat_id:a.data.telegram_chat_id||"",email:a.data.email||"",phone:a.data.phone||"",discord_webhook:a.data.discord_webhook||"",webhook_url:a.data.webhook_url||"",webhook_token:a.data.webhook_token||""}),e.n=3;break;case 2:e.p=2,e.v;case 3:return e.a(2)}},e,null,[[0,2]])}))()},loadWatchlist:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return t.loadingWatchlist=!0,e.p=1,e.n=2,(0,g.Qo)({userid:1});case 2:a=e.v,a&&1===a.code?t.watchlist=Array.isArray(a.data)?a.data:[]:t.watchlist=[],e.n=4;break;case 3:e.p=3,e.v,t.watchlist=[];case 4:return e.p=4,t.loadingWatchlist=!1,e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}))()},handleCloseAddSymbolModal:function(){this.showAddSymbolModal=!1,this.addSymbolKeyword="",this.symbolSearchResults=[],this.selectedAddSymbol=null,this.hasSearchedSymbol=!1},handleAddSymbolMarketChange:function(t){this.addSymbolMarket=t,this.addSymbolKeyword="",this.symbolSearchResults=[],this.selectedAddSymbol=null,this.hasSearchedSymbol=!1,this.loadHotSymbols(t)},handleSymbolSearchInputChange:function(t){var e=this,a=t.target.value;if(this.addSymbolKeyword=a,this.searchTimer&&clearTimeout(this.searchTimer),!a||""===a.trim())return this.symbolSearchResults=[],this.hasSearchedSymbol=!1,void(this.selectedAddSymbol=null);this.searchTimer=setTimeout(function(){e.searchSymbolsInModal(a)},500)},handleSearchSymbol:function(t){var e=this;return(0,l.A)((0,o.A)().m(function a(){return(0,o.A)().w(function(a){while(1)switch(a.n){case 0:if(t&&t.trim()){a.n=1;break}return a.a(2);case 1:if(e.addSymbolMarket){a.n=2;break}return e.$message.warning(e.$t("dashboard.analysis.modal.addStock.pleaseSelectMarket")),a.a(2);case 2:if(!(e.symbolSearchResults.length>0)){a.n=3;break}return a.a(2);case 3:e.hasSearchedSymbol&&0===e.symbolSearchResults.length?e.handleDirectAdd():e.searchSymbolsInModal(t);case 4:return a.a(2)}},a)}))()},searchSymbolsInModal:function(t){var e=this;return(0,l.A)((0,o.A)().m(function a(){var i;return(0,o.A)().w(function(a){while(1)switch(a.p=a.n){case 0:if(t&&""!==t.trim()){a.n=1;break}return e.symbolSearchResults=[],e.hasSearchedSymbol=!1,a.a(2);case 1:if(e.addSymbolMarket){a.n=2;break}return a.a(2);case 2:return e.searchingSymbol=!0,e.hasSearchedSymbol=!0,a.p=3,a.n=4,(0,g._3)({market:e.addSymbolMarket,keyword:t.trim()});case 4:i=a.v,i&&1===i.code&&Array.isArray(i.data)?e.symbolSearchResults=i.data:e.symbolSearchResults=[],a.n=6;break;case 5:a.p=5,a.v,e.symbolSearchResults=[];case 6:return a.p=6,e.searchingSymbol=!1,a.f(6);case 7:return a.a(2)}},a,null,[[3,5,6,7]])}))()},handleDirectAdd:function(){this.addSymbolKeyword&&this.addSymbolKeyword.trim()?this.addSymbolMarket?this.selectedAddSymbol={market:this.addSymbolMarket,symbol:this.addSymbolKeyword.trim().toUpperCase(),name:""}:this.$message.warning(this.$t("dashboard.analysis.modal.addStock.pleaseSelectMarket")):this.$message.warning(this.$t("dashboard.analysis.modal.addStock.pleaseEnterSymbol"))},handleSelectAddSymbol:function(t){this.selectedAddSymbol={market:this.addSymbolMarket,symbol:t.symbol,name:t.name||""}},loadHotSymbols:function(t){var e=this;return(0,l.A)((0,o.A)().m(function a(){var i;return(0,o.A)().w(function(a){while(1)switch(a.p=a.n){case 0:if(t||(t=e.addSymbolMarket||"Crypto"),t){a.n=1;break}return a.a(2);case 1:return e.loadingHotSymbols=!0,a.p=2,a.n=3,(0,g.z6)({market:t,limit:10});case 3:i=a.v,i&&1===i.code&&i.data?e.hotSymbols=i.data:e.hotSymbols=[],a.n=5;break;case 4:a.p=4,a.v,e.hotSymbols=[];case 5:return a.p=5,e.loadingHotSymbols=!1,a.f(5);case 6:return a.a(2)}},a,null,[[2,4,5,6]])}))()},handleConfirmAddSymbol:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a,i,s,r,n,l,d;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(a="",i="",!t.selectedAddSymbol){e.n=1;break}a=t.selectedAddSymbol.market,i=t.selectedAddSymbol.symbol.toUpperCase(),e.n=4;break;case 1:if(!t.addSymbolKeyword||!t.addSymbolKeyword.trim()){e.n=3;break}if(t.addSymbolMarket){e.n=2;break}return t.$message.warning(t.$t("dashboard.analysis.modal.addStock.pleaseSelectMarket")),e.a(2);case 2:a=t.addSymbolMarket,i=t.addSymbolKeyword.trim().toUpperCase(),e.n=4;break;case 3:return t.$message.warning(t.$t("dashboard.analysis.modal.addStock.pleaseSelectOrEnterSymbol")),e.a(2);case 4:return t.addingSymbol=!0,e.p=5,e.n=6,(0,g.dp)({userid:1,market:a,symbol:i});case 6:if(s=e.v,!s||1!==s.code){e.n=8;break}return t.$message.success(t.$t("dashboard.analysis.message.addStockSuccess")),e.n=7,t.loadWatchlist();case 7:r="".concat(a,":").concat(i),t.isEditMode?(t.form.setFieldsValue({symbol:r}),t.handleWatchlistSymbolChange(r)):(t.selectedSymbols.includes(r)||(t.selectedSymbols=[].concat((0,c.A)(t.selectedSymbols),[r])),t.handleMultiSymbolChange(t.selectedSymbols)),t.handleCloseAddSymbolModal(),e.n=9;break;case 8:t.$message.error((null===s||void 0===s?void 0:s.msg)||t.$t("dashboard.analysis.message.addStockFailed"));case 9:e.n=11;break;case 10:e.p=10,d=e.v,l=(null===d||void 0===d||null===(n=d.response)||void 0===n||null===(n=n.data)||void 0===n?void 0:n.msg)||(null===d||void 0===d?void 0:d.message)||t.$t("dashboard.analysis.message.addStockFailed"),t.$message.error(l);case 11:return e.p=11,t.addingSymbol=!1,e.f(11);case 12:return e.a(2)}},e,null,[[5,10,11,12]])}))()},filterWatchlistOption:function(t,e){var a,i=(null===(a=e.componentOptions)||void 0===a||null===(a=a.propsData)||void 0===a?void 0:a.value)||"";return"__add_symbol_option__"===i||String(i).toLowerCase().includes(String(t||"").toLowerCase())},filterWatchlistOptionWithAdd:function(t,e){var a,i=(null===(a=e.componentOptions)||void 0===a||null===(a=a.propsData)||void 0===a?void 0:a.value)||"";return"__add_symbol_option__"===i||String(i).toLowerCase().includes(String(t||"").toLowerCase())},handleMultiSymbolChangeWithAdd:function(t){if(t&&t.includes("__add_symbol_option__"))return this.selectedSymbols=t.filter(function(t){return"__add_symbol_option__"!==t}),this.showAddSymbolModal=!0,void this.loadHotSymbols(this.addSymbolMarket);this.handleMultiSymbolChange(t)},handleStrategyTypeChange:function(t){var e=t.target.value;"single"===e&&(this.crossSectionalSymbols=[])},handleCrossSectionalSymbolChange:function(t){if(t&&t.includes("__add_symbol_option__"))return this.crossSectionalSymbols=t.filter(function(t){return"__add_symbol_option__"!==t}),this.showAddSymbolModal=!0,void this.loadHotSymbols(this.addSymbolMarket);if(this.crossSectionalSymbols=t||[],t&&t.length>0){var e=t[0];if("string"===typeof e&&e.includes(":")){var a=e.indexOf(":"),i=e.slice(0,a);this.selectedMarketCategory=i||"Crypto"}}},getMarketColor:function(t){var e={USStock:"green",Crypto:"purple",Forex:"gold",Futures:"cyan"};return e[t]||"default"},handleWatchlistSymbolChange:function(t){var e=this;if("__add_symbol_option__"===t)return this.$nextTick(function(){e.form.setFieldsValue({symbol:void 0})}),this.showAddSymbolModal=!0,void this.loadHotSymbols(this.addSymbolMarket);if(t&&"string"===typeof t&&t.includes(":")){var a=t.indexOf(":"),i=t.slice(0,a);if(this.selectedMarketCategory=i||"Crypto","Forex"===this.selectedMarketCategory){this.currentBrokerId="mt5";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({forex_broker_id:"mt5"})}catch(r){}}else if("USStock"===this.selectedMarketCategory){this.currentBrokerId="ibkr";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({broker_id:"ibkr"})}catch(r){}}var s=["Crypto","USStock","Forex"].includes(this.selectedMarketCategory);if(!s){this.executionModeUi="signal";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({execution_mode:"signal"})}catch(r){}}this.currentExchangeId="";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({exchange_id:void 0})}catch(r){}}},handleMultiSymbolChange:function(t){if(this.selectedSymbols=t||[],t&&t.length>0){var e=t[0];if("string"===typeof e&&e.includes(":")){var a=e.indexOf(":"),i=e.slice(0,a);this.selectedMarketCategory=i||"Crypto"}}if("Forex"===this.selectedMarketCategory){this.currentBrokerId="mt5";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({forex_broker_id:"mt5"})}catch(r){}}else if("USStock"===this.selectedMarketCategory){this.currentBrokerId="ibkr";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({broker_id:"ibkr"})}catch(r){}}var s=["Crypto","USStock","Forex"].includes(this.selectedMarketCategory);if(!s){this.executionModeUi="signal";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({execution_mode:"signal"})}catch(r){}}this.currentExchangeId="";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({exchange_id:void 0})}catch(r){}},loadExchangeCredentials:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return t.loadingExchangeCredentials=!0,e.p=1,e.n=2,(0,p.IA)({user_id:1});case 2:a=e.v,a&&1===a.code?t.exchangeCredentials=a.data&&a.data.items||[]:(t.exchangeCredentials=[],t.$message.warning((null===a||void 0===a?void 0:a.msg)||t.$t("trading-assistant.messages.loadFailed"))),e.n=4;break;case 3:e.p=3,e.v,t.exchangeCredentials=[],t.$message.warning(t.$t("trading-assistant.exchange.testFailed"));case 4:return e.p=4,t.loadingExchangeCredentials=!1,e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}))()},formatCredentialLabel:function(t){if(!t)return"";var e=(t.name||"").trim(),a=t.exchange_id||"",i=t.api_key_hint||"";return e?"".concat(a.toUpperCase()," - ").concat(e," (").concat(i,")"):"".concat(a.toUpperCase()," (").concat(i,")")},isCredentialCompatible:function(t){if(!t||!t.exchange_id)return!0;var e=(t.exchange_id||"").toLowerCase(),a=this.selectedMarketCategory||"Crypto";if("mt5"===e)return"Forex"===a;if("ibkr"===e)return"USStock"===a;var i=["binance","okx","bitget","bybit","coinbaseexchange","kraken","kucoin","gate","bitfinex","deepcoin"];return!i.includes(e)||"Crypto"===a},handleCredentialSelectChange:function(t){var e=this;return(0,l.A)((0,o.A)().m(function a(){var i,s,r;return(0,o.A)().w(function(a){while(1)switch(a.n){case 0:if(t){a.n=1;break}return e.currentExchangeId="",e.connectionTestResult=null,a.a(2);case 1:if(i=e.exchangeCredentials.find(function(e){return String(e.id)===String(t)}),!i){a.n=5;break}if(s=(i.exchange_id||"").toLowerCase(),"mt5"!==s||"Forex"===e.selectedMarketCategory){a.n=2;break}e.$message.error(e.$t("trading-assistant.validation.mt5OnlyForForex"));try{e.form&&e.form.setFieldsValue&&e.form.setFieldsValue({credential_id:void 0})}catch(n){}return e.currentExchangeId="",e.connectionTestResult=null,a.a(2);case 2:if("ibkr"!==s||"USStock"===e.selectedMarketCategory){a.n=3;break}e.$message.error(e.$t("trading-assistant.validation.ibkrOnlyForUSStock"));try{e.form&&e.form.setFieldsValue&&e.form.setFieldsValue({credential_id:void 0})}catch(n){}return e.currentExchangeId="",e.connectionTestResult=null,a.a(2);case 3:if(r=["binance","okx","bitget","bybit","coinbaseexchange","kraken","kucoin","gate","bitfinex"],!r.includes(s)||"Crypto"===e.selectedMarketCategory){a.n=4;break}e.$message.error(e.$t("trading-assistant.validation.cryptoExchangeOnlyForCrypto"));try{e.form&&e.form.setFieldsValue&&e.form.setFieldsValue({credential_id:void 0})}catch(n){}return e.currentExchangeId="",e.connectionTestResult=null,a.a(2);case 4:e.currentExchangeId=i.exchange_id||"";case 5:e.connectionTestResult=null;case 6:return a.a(2)}},a)}))()},onSaveCredentialChange:function(t){var e=!!(t&&t.target&&t.target.checked);this.saveCredentialUi=e;try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({save_credential:e})}catch(a){}},onExecutionModeChange:function(t){var e=t&&t.target?t.target.value:t;this.executionModeUi=e||"signal",this.liveDisclaimerAckUi=!1;try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({live_disclaimer_ack:!1})}catch(a){}if(!this.canUseLiveTrading&&"signal"!==this.executionModeUi){this.executionModeUi="signal";try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({execution_mode:"signal"})}catch(a){}}},onLiveDisclaimerAckChange:function(t){var e=!!(t&&t.target&&t.target.checked);this.liveDisclaimerAckUi=e;try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({live_disclaimer_ack:e})}catch(a){}},onNotifyChannelsChange:function(t){this.notifyChannelsUi=Array.isArray(t)?t:[]},formatCurrency:function(t){return null===t||void 0===t?"-":"$"+t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})},formatPnl:function(t){if(null===t||void 0===t)return"-";var e=t>=0?"+":"";return e+"$"+Math.abs(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})},formatPnlPercent:function(t){if(null===t||void 0===t)return"-";var e=t>=0?"+":"";return e+Math.abs(t).toFixed(2)+"%"},loadStrategies:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a,i,s;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return t.loading=!0,e.p=1,e.n=2,(0,m.EM)();case 2:a=e.v,1===a.code?(i=a.data.strategies||[],t.strategies=i,t.selectedStrategy&&(s=t.strategies.find(function(e){return e.id===t.selectedStrategy.id}),t.selectedStrategy=s||null)):t.$message.error(a.msg||t.$t("trading-assistant.messages.loadFailed")),e.n=4;break;case 3:e.p=3,e.v,t.$message.error(t.$t("trading-assistant.messages.loadFailed"));case 4:return e.p=4,t.loading=!1,e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}))()},handleCreateStrategy:function(){this.isEditMode=!1,this.editingStrategy=null,this.strategyMode="",this.strategyCode="",this.showModeSelector=!0,this.showFormModal=!1},handleModeSelect:function(t){this.strategyMode=t,this.showModeSelector=!1,this._openCreateModal()},handleUseTemplate:function(t){var e=this;this.strategyMode="script",this.showModeSelector=!1,this._openCreateModal(),this.$nextTick(function(){var a=e.$refs.strategyEditor;a&&a.loadTemplate&&a.loadTemplate(t)})},_openCreateModal:function(){var t=this;this.strategyType="indicator",this.currentStep=0,this.currentExchangeId="",this.currentBrokerId="ibkr",this.selectedIndicator=null,this.connectionTestResult=null,this.executionModeUi="signal",this.notifyChannelsUi=["browser"],this.saveCredentialUi=!1,this.backtestCollapseKeys=["risk"],this.trailingEnabledUi=!1,this.entryPctMaxUi=100,this.aiFilterEnabledUi=!1,this.selectedMarketCategory="Crypto",this.selectedSymbols=[],this.showAdvancedSettings=!1,this.form.resetFields(),this.form.setFieldsValue({execution_mode:"signal",notify_channels:["browser"],save_credential:!1,live_disclaimer_ack:!1}),this.liveDisclaimerAckUi=!1,this.showFormModal=!0,this.$nextTick(function(){t.loadWatchlist(),t.loadIndicators(),t.loadExchangeCredentials()})},handleEditStrategy:function(t){var e=this;"running"!==t.status?(this.strategyType="indicator",this.strategyMode=t.strategy_mode||"signal",this.strategyCode=t.strategy_code||"",this.isEditMode=!0,this.editingStrategy=t,this.currentStep=0,this.currentExchangeId="",this.selectedIndicator=null,this.connectionTestResult=null,this.form.resetFields(),this.backtestCollapseKeys=["risk"],this.trailingEnabledUi=!1,this.entryPctMaxUi=100,this.aiFilterEnabledUi=!1,this.showFormModal=!0,this.$nextTick((0,l.A)((0,o.A)().m(function a(){return(0,o.A)().w(function(a){while(1)switch(a.n){case 0:return e.loadWatchlist(),e.loadIndicators(),e.loadExchangeCredentials(),a.n=1,e.loadStrategyDataToForm(t);case 1:return a.a(2)}},a)})))):this.$message.warning(this.$t("trading-assistant.messages.runningWarning"))},loadStrategyDataToForm:function(t){var e=this;return(0,l.A)((0,o.A)().m(function a(){var i,s,r,l,c,d,u,m,g,p,_,h,y,f,v,b,k,S,x,C,w,$,A,M,P,T,F,I,V,N,D,U,E,q,R,z,L,K,B,O,H,W;return(0,o.A)().w(function(a){while(1)switch(a.n){case 0:if(e.indicatorsLoaded){a.n=1;break}return a.n=1,e.loadIndicators();case 1:return a.n=2,e.$nextTick();case 2:return e.selectedMarketCategory=t.market_category||"Crypto",d=t.execution_mode||"signal",e.executionModeUi=d,e.liveDisclaimerAckUi="live"===d,u=t.notification_config&&t.notification_config.channels||["browser"],e.notifyChannelsUi=Array.isArray(u)?u:["browser"],m=!1,g=!1,t.trading_config&&(f=t.trading_config||{},v=f.trailing&&"object"===(0,n.A)(f.trailing)?f.trailing:null,m=void 0!==f.trailing_enabled?!!f.trailing_enabled:!(!v||!v.enabled),b=f.enable_ai_filter,g=!0===b||"true"===b||1===b||"1"===b,k=f.scale&&"object"===(0,n.A)(f.scale)?f.scale:null,S=f.position&&"object"===(0,n.A)(f.position)?f.position:null,x=new Set(["risk"]),(f.trend_add_enabled||f.dca_add_enabled||k&&(null!==(p=k.trendAdd)&&void 0!==p&&p.enabled||null!==(_=k.dcaAdd)&&void 0!==_&&_.enabled))&&x.add("scale"),(f.trend_reduce_enabled||f.adverse_reduce_enabled||k&&(null!==(h=k.trendReduce)&&void 0!==h&&h.enabled||null!==(y=k.adverseReduce)&&void 0!==y&&y.enabled))&&x.add("reduce"),(void 0!==f.entry_pct||S&&void 0!==S.entryPct)&&x.add("position"),e.backtestCollapseKeys=Array.from(x)),e.trailingEnabledUi=m,e.aiFilterEnabledUi=g,a.n=3,e.$nextTick();case 3:return e.form.setFieldsValue({enable_ai_filter:g}),a.n=4,e.$nextTick();case 4:if(e.form.setFieldsValue({execution_mode:e.executionModeUi,live_disclaimer_ack:e.liveDisclaimerAckUi,notify_channels:e.notifyChannelsUi,notify_email:(null===(i=t.notification_config)||void 0===i||null===(i=i.targets)||void 0===i?void 0:i.email)||"",notify_phone:(null===(s=t.notification_config)||void 0===s||null===(s=s.targets)||void 0===s?void 0:s.phone)||"",notify_telegram:(null===(r=t.notification_config)||void 0===r||null===(r=r.targets)||void 0===r?void 0:r.telegram)||"",notify_discord:(null===(l=t.notification_config)||void 0===l||null===(l=l.targets)||void 0===l?void 0:l.discord)||"",notify_webhook:(null===(c=t.notification_config)||void 0===c||null===(c=c.targets)||void 0===c?void 0:c.webhook)||""}),!t.indicator_config||!t.indicator_config.indicator_id){a.n=7;break}if(C=t.indicator_config.indicator_id,w=e.availableIndicators.find(function(t){return String(t.id)===String(C)}),!w){a.n=6;break}return A=String(w.id),e.form.setFieldsValue({indicator_id:A}),a.n=5,e.handleIndicatorChange(A);case 5:M=null===($=t.trading_config)||void 0===$?void 0:$.indicator_params,M&&"object"===(0,n.A)(M)&&Object.keys(M).forEach(function(t){t in e.indicatorParamValues&&e.$set(e.indicatorParamValues,t,M[t])}),a.n=7;break;case 6:e.form.setFieldsValue({indicator_id:String(C)});case 7:if(!t.exchange_config){a.n=11;break}if(P=t.exchange_config.exchange_id||"",T="live"===e.executionModeUi,F=["Crypto","USStock","Forex"].includes(e.selectedMarketCategory),I="USStock"===e.selectedMarketCategory,V="Forex"===e.selectedMarketCategory,!T||!F){a.n=10;break}if(!I){a.n=8;break}e.currentBrokerId=P||"ibkr",e.form.setFieldsValue({broker_id:P||"ibkr",ibkr_host:t.exchange_config.ibkr_host||"127.0.0.1",ibkr_port:t.exchange_config.ibkr_port||7497,ibkr_client_id:t.exchange_config.ibkr_client_id||1,ibkr_account:t.exchange_config.ibkr_account||""}),a.n=10;break;case 8:if(!V){a.n=9;break}e.currentBrokerId=P||"mt5",e.form.setFieldsValue({forex_broker_id:P||"mt5",mt5_server:t.exchange_config.mt5_server||"",mt5_login:t.exchange_config.mt5_login||"",mt5_password:t.exchange_config.mt5_password||"",mt5_terminal_path:t.exchange_config.mt5_terminal_path||""}),a.n=10;break;case 9:if(e.currentExchangeId=P||t.exchange_config.exchange_id||"",N=t.exchange_config.credential_id,!N){a.n=10;break}return e.form.setFieldsValue({credential_id:N}),a.n=10,e.handleCredentialSelectChange(N);case 10:I||V?e.currentBrokerId=P||(V?"mt5":"ibkr"):e.currentExchangeId=P;case 11:if(t.trading_config){if(D=t.trading_config||{},U=D.trailing&&"object"===(0,n.A)(D.trailing)?D.trailing:null,E=D.scale&&"object"===(0,n.A)(D.scale)?D.scale:null,q=D.position&&"object"===(0,n.A)(D.position)?D.position:null,R=D.strategy_type||t.strategy_type||"single","cross_sectional"===R)if(e.form.setFieldsValue({cs_strategy_type:"cross_sectional",portfolio_size:D.portfolio_size||10,long_ratio:D.long_ratio||.5,rebalance_frequency:D.rebalance_frequency||"daily"}),D.symbol_list&&Array.isArray(D.symbol_list))e.crossSectionalSymbols=D.symbol_list;else if(t.symbol_list)try{z="string"===typeof t.symbol_list?JSON.parse(t.symbol_list):t.symbol_list,Array.isArray(z)&&(e.crossSectionalSymbols=z)}catch(o){e.crossSectionalSymbols=[]}else e.crossSectionalSymbols=[];else e.form.setFieldsValue({cs_strategy_type:"single"}),e.crossSectionalSymbols=[];L=E&&E.trendAdd?E.trendAdd:null,K=E&&E.dcaAdd?E.dcaAdd:null,B=E&&E.trendReduce?E.trendReduce:null,O=E&&E.adverseReduce?E.adverseReduce:null,H=D.symbol,W="string"===typeof H&&H.includes(":")?H:"".concat(e.selectedMarketCategory,":").concat(H),e.form.setFieldsValue({strategy_name:t.strategy_name,symbol:W,initial_capital:D.initial_capital,leverage:D.leverage,trade_direction:D.trade_direction||"long",timeframe:D.timeframe||"1H",market_type:"futures"===D.market_type?"swap":D.market_type||"swap",take_profit_pct:D.take_profit_pct||0,stop_loss_pct:D.stop_loss_pct||0,trailing_enabled:m,trailing_stop_pct:void 0!==D.trailing_stop_pct?D.trailing_stop_pct||0:U&&U.pct||0,trailing_activation_pct:void 0!==D.trailing_activation_pct?D.trailing_activation_pct||0:U&&U.activationPct||0,trend_add_enabled:void 0!==D.trend_add_enabled?!!D.trend_add_enabled:!(!L||!L.enabled),trend_add_step_pct:void 0!==D.trend_add_step_pct?D.trend_add_step_pct||0:L&&L.stepPct||0,trend_add_size_pct:void 0!==D.trend_add_size_pct?D.trend_add_size_pct||0:L&&L.sizePct||0,trend_add_max_times:void 0!==D.trend_add_max_times?D.trend_add_max_times||0:L&&L.maxTimes||0,dca_add_enabled:void 0!==D.dca_add_enabled?!!D.dca_add_enabled:!(!K||!K.enabled),dca_add_step_pct:void 0!==D.dca_add_step_pct?D.dca_add_step_pct||0:K&&K.stepPct||0,dca_add_size_pct:void 0!==D.dca_add_size_pct?D.dca_add_size_pct||0:K&&K.sizePct||0,dca_add_max_times:void 0!==D.dca_add_max_times?D.dca_add_max_times||0:K&&K.maxTimes||0,trend_reduce_enabled:void 0!==D.trend_reduce_enabled?!!D.trend_reduce_enabled:!(!B||!B.enabled),trend_reduce_step_pct:void 0!==D.trend_reduce_step_pct?D.trend_reduce_step_pct||0:B&&B.stepPct||0,trend_reduce_size_pct:void 0!==D.trend_reduce_size_pct?D.trend_reduce_size_pct||0:B&&B.sizePct||0,trend_reduce_max_times:void 0!==D.trend_reduce_max_times?D.trend_reduce_max_times||0:B&&B.maxTimes||0,adverse_reduce_enabled:void 0!==D.adverse_reduce_enabled?!!D.adverse_reduce_enabled:!(!O||!O.enabled),adverse_reduce_step_pct:void 0!==D.adverse_reduce_step_pct?D.adverse_reduce_step_pct||0:O&&O.stepPct||0,adverse_reduce_size_pct:void 0!==D.adverse_reduce_size_pct?D.adverse_reduce_size_pct||0:O&&O.sizePct||0,adverse_reduce_max_times:void 0!==D.adverse_reduce_max_times?D.adverse_reduce_max_times||0:O&&O.maxTimes||0,entry_pct:0===D.entry_pct||D.entry_pct?D.entry_pct:q&&q.entryPct?q.entryPct:100,enable_ai_filter:g}),e.$nextTick(function(){e.recalcEntryPctMaxUi(),e.normalizeEntryPct()})}case 12:return a.a(2)}},a)}))()},handleSelectStrategy:function(t){this.selectedStrategy=t,this.currentEquity=null,this.loadStrategyDetails(),this.startEquityPolling()},loadStrategyDetails:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a,i,s,n,l,c,u,g,p,_,h,y,f;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(t.selectedStrategy){e.n=1;break}return e.a(2,Promise.resolve());case 1:return e.p=1,e.n=2,Promise.all([(0,m.Yx)(t.selectedStrategy.id),(0,m.oK)(t.selectedStrategy.id)]);case 2:if(a=e.v,i=(0,r.A)(a,2),s=i[0],n=i[1],l=null,1===s.code&&s.data&&(Array.isArray(s.data)&&s.data.length>0?(c=s.data[s.data.length-1],l=c.equity):(g=(null===(u=t.selectedStrategy.trading_config)||void 0===u?void 0:u.initial_capital)||t.selectedStrategy.initial_capital,l=g||null)),p=0,1===n.code&&n.data){_=n.data.positions||n.data.items||[],h=(0,d.A)(_);try{for(h.s();!(y=h.n()).done;)f=y.value,p+=parseFloat(f.unrealized_pnl||f.unrealizedPnl||0)}catch(o){h.e(o)}finally{h.f()}}t.currentEquity=null!==l?l+p:null,e.n=4;break;case 3:e.p=3,e.v;case 4:return e.a(2)}},e,null,[[1,3]])}))()},startEquityPolling:function(){var t=this;this.stopEquityPolling(),this.selectedStrategy&&(this.loadStrategyDetails(),this.equityPollingTimer=setInterval(function(){t.loadStrategyDetails()},1e4))},stopEquityPolling:function(){this.equityPollingTimer&&(clearInterval(this.equityPollingTimer),this.equityPollingTimer=null)},handleCloseModal:function(){this.showFormModal=!1,this.editingStrategy=null,this.isEditMode=!1,this.strategyType="indicator",this.strategyMode="",this.strategyCode="",this.currentStep=0,this.currentExchangeId="",this.selectedIndicator=null,this.connectionTestResult=null,this.indicatorsLoaded=!1,this.availableIndicators=[],this.backtestCollapseKeys=["risk"],this.trailingEnabledUi=!1,this.entryPctMaxUi=100,this.aiFilterEnabledUi=!1,this.showAdvancedSettings=!1,this.executionModeUi="signal",this.liveDisclaimerAckUi=!1,this.form.resetFields()},handleRefresh:function(){this.loadStrategies(),this.showFormModal=!1},handleMenuClick:function(t,e){switch(t){case"start":this.handleStartStrategy(e.id);break;case"stop":this.handleStopStrategy(e.id);break;case"edit":this.handleEditStrategy(e);break;case"delete":this.handleDeleteStrategy(e);break}},toggleGroup:function(t){this.$set(this.collapsedGroups,t,!this.collapsedGroups[t])},handleGroupMenuClick:function(t,e){var a=this;return(0,l.A)((0,o.A)().m(function i(){var s,r;return(0,o.A)().w(function(i){while(1)switch(i.n){case 0:s=e.strategies.map(function(t){return t.id}),r=t,i.n="startAll"===r?1:"stopAll"===r?3:"deleteAll"===r?5:7;break;case 1:return i.n=2,a.handleBatchStartStrategies(s,e.baseName);case 2:return i.a(3,7);case 3:return i.n=4,a.handleBatchStopStrategies(s,e.baseName);case 4:return i.a(3,7);case 5:return i.n=6,a.handleBatchDeleteStrategies(s,e.baseName);case 6:return i.a(3,7);case 7:return i.a(2)}},i)}))()},handleBatchStartStrategies:function(t,e){var a=this;return(0,l.A)((0,o.A)().m(function e(){var i,s,r;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return e.p=0,e.n=1,(0,m.UH)({strategy_ids:t});case 1:i=e.v,1===i.code?(r=(null===(s=i.data)||void 0===s||null===(s=s.success_ids)||void 0===s?void 0:s.length)||t.length,a.$message.success(a.$t("trading-assistant.messages.batchStartSuccess",{count:r})),a.loadStrategies()):a.$message.error(i.msg||a.$t("trading-assistant.messages.batchStartFailed")),e.n=3;break;case 2:e.p=2,e.v,a.$message.error(a.$t("trading-assistant.messages.batchStartFailed"));case 3:return e.a(2)}},e,null,[[0,2]])}))()},handleBatchStopStrategies:function(t,e){var a=this;return(0,l.A)((0,o.A)().m(function e(){var i,s,r;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return e.p=0,e.n=1,(0,m.GF)({strategy_ids:t});case 1:i=e.v,1===i.code?(r=(null===(s=i.data)||void 0===s||null===(s=s.success_ids)||void 0===s?void 0:s.length)||t.length,a.$message.success(a.$t("trading-assistant.messages.batchStopSuccess",{count:r})),a.loadStrategies()):a.$message.error(i.msg||a.$t("trading-assistant.messages.batchStopFailed")),e.n=3;break;case 2:e.p=2,e.v,a.$message.error(a.$t("trading-assistant.messages.batchStopFailed"));case 3:return e.a(2)}},e,null,[[0,2]])}))()},handleBatchDeleteStrategies:function(t,e){var a=this;return(0,l.A)((0,o.A)().m(function i(){var s;return(0,o.A)().w(function(i){while(1)switch(i.n){case 0:s=a.$t("trading-assistant.messages.batchDeleteConfirm",{count:t.length,name:e}),a.$confirm({title:a.$t("trading-assistant.deleteAll"),content:s,okText:a.$t("trading-assistant.deleteAll"),okType:"danger",cancelText:a.$t("trading-assistant.form.cancel"),onOk:function(){var e=(0,l.A)((0,o.A)().m(function e(){var i,s,r;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return e.p=0,e.n=1,(0,m.xQ)({strategy_ids:t});case 1:i=e.v,1===i.code?(r=(null===(s=i.data)||void 0===s||null===(s=s.success_ids)||void 0===s?void 0:s.length)||t.length,a.$message.success(a.$t("trading-assistant.messages.batchDeleteSuccess",{count:r})),a.selectedStrategy&&t.includes(a.selectedStrategy.id)&&(a.selectedStrategy=null,a.stopEquityPolling()),a.loadStrategies()):a.$message.error(i.msg||a.$t("trading-assistant.messages.batchDeleteFailed")),e.n=3;break;case 2:e.p=2,e.v,a.$message.error(a.$t("trading-assistant.messages.batchDeleteFailed"));case 3:return e.a(2)}},e,null,[[0,2]])}));function i(){return e.apply(this,arguments)}return i}()});case 1:return i.a(2)}},i)}))()},handleStartStrategy:function(t){var e=this;return(0,l.A)((0,o.A)().m(function a(){var i;return(0,o.A)().w(function(a){while(1)switch(a.p=a.n){case 0:return a.p=0,a.n=1,(0,m.mV)(t);case 1:i=a.v,1===i.code?(e.$message.success(e.$t("trading-assistant.messages.startSuccess")),e.loadStrategies(),e.selectedStrategy&&e.selectedStrategy.id===t&&(e.selectedStrategy.status="running")):e.$message.error(i.msg||e.$t("trading-assistant.messages.startFailed")),a.n=3;break;case 2:a.p=2,a.v,e.$message.error(e.$t("trading-assistant.messages.startFailed"));case 3:return a.a(2)}},a,null,[[0,2]])}))()},handleStopStrategy:function(t){var e=this;return(0,l.A)((0,o.A)().m(function a(){var i;return(0,o.A)().w(function(a){while(1)switch(a.p=a.n){case 0:return a.p=0,a.n=1,(0,m.Ke)(t);case 1:i=a.v,1===i.code?(e.$message.success(e.$t("trading-assistant.messages.stopSuccess")),e.loadStrategies(),e.selectedStrategy&&e.selectedStrategy.id===t&&(e.selectedStrategy.status="stopped")):e.$message.error(i.msg||e.$t("trading-assistant.messages.stopFailed")),a.n=3;break;case 2:a.p=2,a.v,e.$message.error(e.$t("trading-assistant.messages.stopFailed"));case 3:return a.a(2)}},a,null,[[0,2]])}))()},handleDeleteStrategy:function(t){var e=this,a=this.$t("trading-assistant.messages.deleteConfirmWithName",{name:t.strategy_name});this.$confirm({title:this.$t("trading-assistant.deleteStrategy"),content:a,okText:this.$t("trading-assistant.deleteStrategy"),okType:"danger",cancelText:this.$t("trading-assistant.form.cancel"),onOk:function(){var a=(0,l.A)((0,o.A)().m(function a(){var i;return(0,o.A)().w(function(a){while(1)switch(a.p=a.n){case 0:return a.p=0,a.n=1,(0,m.v_)(t.id);case 1:i=a.v,1===i.code?(e.$message.success(e.$t("trading-assistant.messages.deleteSuccess")),e.selectedStrategy&&e.selectedStrategy.id===t.id&&(e.selectedStrategy=null,e.stopEquityPolling()),e.loadStrategies()):e.$message.error(i.msg||e.$t("trading-assistant.messages.deleteFailed")),a.n=3;break;case 2:a.p=2,a.v,e.$message.error(e.$t("trading-assistant.messages.deleteFailed"));case 3:return a.a(2)}},a,null,[[0,2]])}));function i(){return a.apply(this,arguments)}return i}()})},getStatusColor:function(t){var e={running:"green",stopped:"default",error:"red"};return e[t]||"default"},getStatusText:function(t){return this.$t("trading-assistant.status.".concat(t))||t},getStrategyTypeText:function(t){return this.$t("trading-assistant.strategyType.".concat(t))||t},getTradeDirectionText:function(t){if(!t)return"";var e={long:this.$t("trading-assistant.form.tradeDirectionLong")||"做多",short:this.$t("trading-assistant.form.tradeDirectionShort")||"做空",both:this.$t("trading-assistant.form.tradeDirectionBoth")||"双向"};return e[t]||t},handleIndicatorSelectFocus:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){return(0,o.A)().w(function(e){while(1)switch(e.n){case 0:if(t.indicatorsLoaded||t.loadingIndicators){e.n=1;break}return e.n=1,t.loadIndicators();case 1:return e.a(2)}},e)}))()},loadIndicators:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){var a,i,s,r;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(!t.loadingIndicators){e.n=1;break}return e.a(2,new Promise(function(e){var a=setInterval(function(){t.loadingIndicators||(clearInterval(a),e())},100)}));case 1:if(!t.indicatorsLoaded){e.n=2;break}return e.a(2,Promise.resolve());case 2:return a=t.$store.getters.userInfo||{},i=a.id||1,t.loadingIndicators=!0,e.p=3,e.n=4,(0,y.Ay)({url:"/api/indicator/getIndicators",method:"get",params:{userid:i}});case 4:s=e.v,1===s.code&&s.data?(r=s.data.map(function(t){return{id:t.id,name:t.name,description:t.description,type:t.indicator_type||t.indicatorType||"python",code:t.code,is_buy:t.is_buy,source:1===t.is_buy?"bought":"custom"}}),t.availableIndicators=r,t.indicatorsLoaded=!0):(t.availableIndicators=[],t.$message.warning(s.msg||t.$t("trading-assistant.messages.loadIndicatorsFailed"))),e.n=6;break;case 5:e.p=5,e.v,t.availableIndicators=[],t.$message.warning(t.$t("trading-assistant.messages.loadIndicatorsFailed"));case 6:return e.p=6,t.loadingIndicators=!1,e.f(6);case 7:return e.a(2)}},e,null,[[3,5,6,7]])}))()},handleIndicatorChange:function(t){var e=this;return(0,l.A)((0,o.A)().m(function a(){var i,s,r;return(0,o.A)().w(function(a){while(1)switch(a.p=a.n){case 0:if(i=String(t),e.selectedIndicator=e.availableIndicators.find(function(t){return String(t.id)===i}),e.indicatorParams=[],e.indicatorParamValues={},!t){a.n=4;break}return a.p=1,a.n=2,e.$http.get("/api/indicator/getIndicatorParams",{params:{indicator_id:t}});case 2:s=a.v,s&&1===s.code&&Array.isArray(s.data)&&(e.indicatorParams=s.data,r={},s.data.forEach(function(t){r[t.name]=t.default}),e.indicatorParamValues=r),a.n=4;break;case 3:a.p=3,a.v;case 4:return a.a(2)}},a,null,[[1,3]])}))()},handleMarketTypeChange:function(t){var e=t.target.value;"spot"===e&&this.form.setFieldsValue({trade_direction:"long",leverage:1})},recalcEntryPctMaxUi:function(){if(this.form){var t=!!this.form.getFieldValue("trend_add_enabled"),e=!!this.form.getFieldValue("dca_add_enabled"),a=Number(this.form.getFieldValue("trend_add_max_times")||0),i=Number(this.form.getFieldValue("dca_add_max_times")||0),s=Number(this.form.getFieldValue("trend_add_size_pct")||0),r=Number(this.form.getFieldValue("dca_add_size_pct")||0),n=(t?a*s:0)+(e?i*r:0),o=Math.max(0,Math.min(100,100-n));this.entryPctMaxUi=o}else this.entryPctMaxUi=100},normalizeEntryPct:function(){if(this.form){var t=Number(this.form.getFieldValue("entry_pct")||0),e=Number(this.entryPctMaxUi||100);t>e&&this.form.setFieldsValue({entry_pct:e})}},onTrendAddToggle:function(t){var e=this;this.form&&(t&&this.form.setFieldsValue({dca_add_enabled:!1}),this.$nextTick(function(){e.recalcEntryPctMaxUi(),e.normalizeEntryPct()}))},onDcaAddToggle:function(t){var e=this;this.form&&(t&&this.form.setFieldsValue({trend_add_enabled:!1}),this.$nextTick(function(){e.recalcEntryPctMaxUi(),e.normalizeEntryPct()}))},onScaleParamsChange:function(){var t=this;this.$nextTick(function(){t.recalcEntryPctMaxUi(),t.normalizeEntryPct()})},onEntryPctChange:function(){var t=this;this.$nextTick(function(){return t.normalizeEntryPct()})},onTrailingToggle:function(t){this.form&&(this.trailingEnabledUi=!!t,t||this.form.setFieldsValue({trailing_stop_pct:0,trailing_activation_pct:0}))},onAiFilterToggle:function(t){this.aiFilterEnabledUi=!!t;try{this.form&&this.form.setFieldsValue&&this.form.setFieldsValue({enable_ai_filter:!!t})}catch(e){}},filterIndicatorOption:function(t,e){var a=e.componentOptions.children[0].children[0].text;return a.toLowerCase().indexOf(t.toLowerCase())>=0},filterSymbolOption:function(t,e){return e.componentOptions.children[0].text.toLowerCase().indexOf(t.toLowerCase())>=0},getIndicatorTypeColor:function(t){var e={trend:"blue",momentum:"green",volatility:"orange",volume:"purple",custom:"default"};return e[t]||"default"},getIndicatorTypeName:function(t){return this.$t("trading-assistant.indicatorType.".concat(t))||t},getExchangeName:function(t){if(t.labelKey){var e="trading-assistant.exchangeNames.".concat(t.labelKey),a=this.$t(e);return a===e?t.value.charAt(0).toUpperCase()+t.value.slice(1):a}return t.label||t.value},getExchangeDisplayName:function(t){if(!t)return"";var e=this.exchangeOptions.find(function(e){return e.value===t});return e?this.getExchangeName(e):t.charAt(0).toUpperCase()+t.slice(1)},getExchangeTagColor:function(t){var e={binance:"gold",okx:"blue",coinbaseexchange:"cyan",kraken:"purple",bitfinex:"geekblue",huobi:"orange",gate:"green",mexc:"lime",kucoin:"volcano",bybit:"red",bitget:"magenta",bitmex:"red",deribit:"blue",phemex:"cyan",bitmart:"geekblue",bitstamp:"purple",bittrex:"orange",poloniex:"green",gemini:"lime",cryptocom:"volcano",blockchaincom:"magenta",bitflyer:"red",upbit:"blue",bithumb:"cyan",coinone:"purple",zb:"geekblue",lbank:"orange",bibox:"green",bigone:"lime",bitrue:"volcano",coinex:"magenta",ftx:"red",ftxus:"blue",binanceus:"gold",binancecoinm:"gold",binanceusdm:"gold",ibkr:"green"};return e[t]||"default"},handleApiConfigChange:function(){this.connectionTestResult=null},getModalPopupContainer:function(){return window.document.body},handleBrokerSelectChange:function(t){this.currentBrokerId=t||"ibkr",this.connectionTestResult=null},handleForexBrokerSelectChange:function(t){this.currentBrokerId=t||"mt5",this.connectionTestResult=null},handleExchangeSelectChange:function(t){var e=this;this.currentExchangeId=t||"",this.connectionTestResult=null,this.suppressApiClearOnce?this.suppressApiClearOnce=!1:this.$nextTick(function(){var t={api_key:void 0,secret_key:void 0,passphrase:void 0,enable_demo_trading:!1};setTimeout(function(){e.form.setFieldsValue(t)},100)})},getPlaceholder:function(t){var e={okx:{api_key:"请输入API Key",secret_key:"请输入Secret Key",passphrase:"请输入Passphrase(创建API时设置)"},okex:{api_key:"请输入API Key",secret_key:"请输入Secret Key",passphrase:"请输入Passphrase(创建API时设置)"},binance:{api_key:"请输入API Key",secret_key:"请输入Secret Key"},coinbaseexchange:{api_key:"请输入API Key(或Key Name)",secret_key:"请输入API Secret(或Private Key)",passphrase:"请输入Passphrase(Legacy Pro API需要)"},kucoin:{api_key:"请输入API Key",secret_key:"请输入Secret Key",passphrase:"请输入Passphrase"},gate:{api_key:"请输入API Key",secret_key:"请输入Secret Key"},mexc:{api_key:"请输入Access Key",secret_key:"请输入Secret Key"},kraken:{api_key:"请输入API Key",secret_key:"请输入Secret Key"},bitfinex:{api_key:"请输入API Key",secret_key:"请输入Secret Key"},bybit:{api_key:"请输入API Key",secret_key:"请输入Secret Key"},bitget:{api_key:"请输入API Key",secret_key:"请输入Secret Key",passphrase:"请输入Passphrase(Legacy Pro API需要)"}},a=e[this.currentExchangeId]||{};if(a[t])return a[t];var i={api_key:this.$t("trading-assistant.placeholders.inputApiKey"),secret_key:this.$t("trading-assistant.placeholders.inputSecretKey"),passphrase:this.$t("trading-assistant.placeholders.inputPassphrase")};return i[t]||this.$t("trading-assistant.placeholders.inputApiKey")},handleNext:function(){var t=this;if("script"!==this.strategyMode){if(0===this.currentStep){var e=["indicator_id","strategy_name"];(this.isAdvancedMode||this.editingStrategy)&&e.push("initial_capital","market_type","leverage","trade_direction","timeframe"),this.isEditMode&&e.push("symbol"),this.form.validateFields(e,function(e,a){if(!e){if(!t.isEditMode){var i=t.form.getFieldValue("cs_strategy_type")||"single";if("cross_sectional"===i){if(!t.crossSectionalSymbols||0===t.crossSectionalSymbols.length)return void t.$message.warning(t.$t("trading-assistant.validation.symbolsRequired"))}else if(!t.selectedSymbols||0===t.selectedSymbols.length)return void t.$message.warning(t.$t("trading-assistant.validation.symbolsRequired"))}try{var s=a&&a.market_type||t.form.getFieldValue("market_type");"spot"===s&&t.form.setFieldsValue({leverage:1,trade_direction:"long"})}catch(r){}t.backtestCollapseKeys=["risk"];try{t.trailingEnabledUi=!!t.form.getFieldValue("trailing_enabled")}catch(r){t.trailingEnabledUi=!1}t.$nextTick(function(){t.recalcEntryPctMaxUi(),t.normalizeEntryPct()}),t.isSimpleMode&&!t.editingStrategy?t.currentStep=2:t.currentStep++}})}else if(1===this.currentStep){try{var a=this.form.getFieldValue("execution_mode")||"signal";this.executionModeUi=a;var i=this.form.getFieldValue("notify_channels")||["browser"];this.notifyChannelsUi=Array.isArray(i)?i:["browser"]}catch(o){}this.currentStep++}}else if(0===this.currentStep){var s=["strategy_name","symbol","initial_capital","timeframe"];this.form.validateFields(s,function(e){e||(t.currentStep=1)})}else if(1===this.currentStep){if(!this.strategyCode||this.strategyCode.trim().length<20)return void this.$message.warning(this.$t("trading-assistant.editor.codeHint"));try{var r=this.form.getFieldValue("execution_mode")||"signal";this.executionModeUi=r;var n=this.form.getFieldValue("notify_channels")||["browser"];this.notifyChannelsUi=Array.isArray(n)?n:["browser"]}catch(o){}this.currentStep=2}},handlePrev:function(){if(this.currentStep>0){if("script"===this.strategyMode)return void this.currentStep--;this.isSimpleMode&&!this.editingStrategy&&2===this.currentStep?this.currentStep=0:this.currentStep--}},handleSubmit:function(){var t=this;return(0,l.A)((0,o.A)().m(function e(){return(0,o.A)().w(function(e){while(1)switch(e.n){case 0:t.form.validateFields(function(){var e=(0,l.A)((0,o.A)().m(function e(a,i){var s,r,n,l,c,d,u,g,p,_,h,y,f,v,b,k,S,x,C,w,$,A,M;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(a){e.n=16;break}if(e.p=1,t.saving=!0,"script"!==t.strategyMode||t.editingStrategy){e.n=3;break}return s={channels:i.notify_channels||["browser"],targets:{email:t.userNotificationSettings.email||"",phone:t.userNotificationSettings.phone||"",telegram:t.userNotificationSettings.telegram_chat_id||"",telegram_bot_token:t.userNotificationSettings.telegram_bot_token||"",discord:t.userNotificationSettings.discord_webhook||"",webhook:t.userNotificationSettings.webhook_url||"",webhook_token:t.userNotificationSettings.webhook_token||""}},r=i.symbol||"",n="Crypto","string"===typeof r&&r.includes(":")&&(l=r.indexOf(":"),n=r.slice(0,l)||"Crypto",r=r.slice(l+1)),c={user_id:1,strategy_name:i.strategy_name,strategy_type:"ScriptStrategy",strategy_mode:"script",strategy_code:t.strategyCode,market_category:n,execution_mode:i.execution_mode||"signal",notification_config:s,trading_config:{initial_capital:i.initial_capital||1e3,leverage:i.leverage||1,timeframe:i.timeframe||"15m",market_type:i.market_type||"swap",symbol:r}},e.n=2,(0,m.WM)(c);case 2:return d=e.v,1===d.code?(t.$message.success(t.$t("trading-assistant.messages.createSuccess")),t.handleRefresh()):t.$message.error(d.msg||t.$t("trading-assistant.messages.createFailed")),t.saving=!1,t.showFormModal=!1,e.a(2);case 3:if(u=t.canUseLiveTrading&&"live"===i.execution_mode,!u||i.live_disclaimer_ack){e.n=4;break}return t.$message.warning(t.$t("trading-assistant.liveDisclaimer.required")),t.saving=!1,e.a(2);case 4:if(!u){e.n=5;break}if(g=i.credential_id,g){e.n=5;break}return t.$message.warning(t.$t("trading-assistant.validation.credentialRequired")),t.saving=!1,e.a(2);case 5:if(p={channels:i.notify_channels||[],targets:{email:t.userNotificationSettings.email||"",phone:t.userNotificationSettings.phone||"",telegram:t.userNotificationSettings.telegram_chat_id||"",telegram_bot_token:t.userNotificationSettings.telegram_bot_token||"",discord:t.userNotificationSettings.discord_webhook||"",webhook:t.userNotificationSettings.webhook_url||"",webhook_token:t.userNotificationSettings.webhook_token||""}},p.channels&&0!==p.channels.length){e.n=6;break}return t.$message.warning(t.$t("trading-assistant.validation.notifyChannelRequired")),t.saving=!1,e.a(2);case 6:if(_=String(i.indicator_id),h=t.availableIndicators.find(function(t){return String(t.id)===_}),h){e.n=7;break}return t.$message.error(t.$t("trading-assistant.validation.indicatorRequired")),t.saving=!1,e.a(2);case 7:if(y=!!t.aiFilterEnabledUi,f="futures"===i.market_type?"swap":i.market_type||"swap",v=i.leverage||1,b=i.trade_direction||"long","spot"===f?(v=1,b="long",t.$message.info(t.$t("trading-assistant.messages.spotLimitations"))):(v<1&&(v=1),v>125&&(v=125)),k={strategy_name:i.strategy_name,market_category:t.selectedMarketCategory||"Crypto",execution_mode:i.execution_mode||"signal",notification_config:p,indicator_config:{indicator_id:h.id,indicator_name:h.name,indicator_code:h.code||""},exchange_config:u?t.isIBKRMarket?{exchange_id:i.broker_id||t.currentBrokerId||"ibkr",ibkr_host:i.ibkr_host||"127.0.0.1",ibkr_port:i.ibkr_port||7497,ibkr_client_id:i.ibkr_client_id||1,ibkr_account:i.ibkr_account||""}:t.isMT5Market?{exchange_id:i.forex_broker_id||t.currentBrokerId||"mt5",mt5_server:i.mt5_server||"",mt5_login:i.mt5_login||"",mt5_password:i.mt5_password||"",mt5_terminal_path:i.mt5_terminal_path||""}:{credential_id:i.credential_id,exchange_id:t.currentExchangeId||void 0}:void 0,trading_config:{initial_capital:i.initial_capital,leverage:v,trade_direction:b,timeframe:i.timeframe,market_type:f,margin_mode:"cross",signal_mode:"confirmed",take_profit_pct:i.take_profit_pct||0,stop_loss_pct:i.stop_loss_pct||0,trailing_enabled:!!i.trailing_enabled,trailing_stop_pct:i.trailing_stop_pct||0,trailing_activation_pct:i.trailing_activation_pct||0,trend_add_enabled:!!i.trend_add_enabled,trend_add_step_pct:i.trend_add_step_pct||0,trend_add_size_pct:i.trend_add_size_pct||0,trend_add_max_times:i.trend_add_max_times||0,dca_add_enabled:!!i.dca_add_enabled,dca_add_step_pct:i.dca_add_step_pct||0,dca_add_size_pct:i.dca_add_size_pct||0,dca_add_max_times:i.dca_add_max_times||0,trend_reduce_enabled:!!i.trend_reduce_enabled,trend_reduce_step_pct:i.trend_reduce_step_pct||0,trend_reduce_size_pct:i.trend_reduce_size_pct||0,trend_reduce_max_times:i.trend_reduce_max_times||0,adverse_reduce_enabled:!!i.adverse_reduce_enabled,adverse_reduce_step_pct:i.adverse_reduce_step_pct||0,adverse_reduce_size_pct:i.adverse_reduce_size_pct||0,adverse_reduce_max_times:i.adverse_reduce_max_times||0,entry_pct:0===i.entry_pct||i.entry_pct?i.entry_pct:100,commission:i.commission||0,slippage:i.slippage||0,enable_ai_filter:y,indicator_params:t.indicatorParamValues,strategy_type:i.cs_strategy_type||"single",symbol_list:"cross_sectional"===i.cs_strategy_type?t.crossSectionalSymbols:void 0,portfolio_size:"cross_sectional"===i.cs_strategy_type?i.portfolio_size||10:void 0,long_ratio:"cross_sectional"===i.cs_strategy_type?i.long_ratio||.5:void 0,rebalance_frequency:"cross_sectional"===i.cs_strategy_type?i.rebalance_frequency||"daily":void 0}},!t.editingStrategy){e.n=9;break}return x=i.symbol,"string"===typeof x&&x.includes(":")&&(C=x.indexOf(":"),k.market_category=x.slice(0,C)||k.market_category,x=x.slice(C+1)),k.trading_config.symbol=x,e.n=8,(0,m.P7)(t.editingStrategy.id,k);case 8:S=e.v,e.n=13;break;case 9:if(k.user_id=1,k.strategy_type="IndicatorStrategy","cross_sectional"!==i.cs_strategy_type){e.n=11;break}return k.strategy_type="IndicatorStrategy",k.trading_config.symbol=null,e.n=10,(0,m.WM)(k);case 10:S=e.v,e.n=13;break;case 11:return k.symbols=t.selectedSymbols,e.n=12,(0,m.Ox)(k);case 12:S=e.v;case 13:1===S.code?(t.isEditMode?t.$message.success(t.$t("trading-assistant.messages.updateSuccess")):($=i.cs_strategy_type||"single",A="cross_sectional"===$?t.crossSectionalSymbols.length:t.selectedSymbols.length,M=(null===(w=S.data)||void 0===w?void 0:w.total_created)||A,t.$message.success(t.$t("trading-assistant.messages.batchCreateSuccess",{count:M}))),t.handleRefresh()):t.$message.error(S.msg||(t.isEditMode?t.$t("trading-assistant.messages.updateFailed"):t.$t("trading-assistant.messages.createFailed"))),e.n=15;break;case 14:e.p=14,e.v,t.$message.error(t.isEditMode?t.$t("trading-assistant.messages.updateFailed"):t.$t("trading-assistant.messages.createFailed"));case 15:return e.p=15,t.saving=!1,e.f(15);case 16:return e.a(2)}},e,null,[[1,14,15,16]])}));return function(t,a){return e.apply(this,arguments)}}());case 1:return e.a(2)}},e)}))()},getFormValues:function(){var t=this;return new Promise(function(e,a){t.form.validateFields(function(t,i){t?a(t):e(i)})})},getDropdownContainer:function(t){return document.body}}},ut=dt,mt=(0,S.A)(ut,i,s,!1,null,"69d6d8ef",null),gt=mt.exports},84841:function(t,e,a){a.d(e,{DK:function(){return v},E$:function(){return d},Gl:function(){return g},O0:function(){return c},TK:function(){return n},aU:function(){return s},cw:function(){return l},d$:function(){return k},hG:function(){return o},hl:function(){return p},kg:function(){return r},nY:function(){return f},r7:function(){return u},rx:function(){return h},v9:function(){return _},vF:function(){return m},vi:function(){return b},wq:function(){return y}});var i=a(75769);function s(t){return(0,i.Ay)({url:"/api/users/list",method:"get",params:t})}function r(t){return(0,i.Ay)({url:"/api/users/create",method:"post",data:t})}function n(t,e){return(0,i.Ay)({url:"/api/users/update",method:"put",params:{id:t},data:e})}function o(t){return(0,i.Ay)({url:"/api/users/delete",method:"delete",params:{id:t}})}function l(t){return(0,i.Ay)({url:"/api/users/reset-password",method:"post",data:t})}function c(){return(0,i.Ay)({url:"/api/users/roles",method:"get"})}function d(){return(0,i.Ay)({url:"/api/users/profile",method:"get"})}function u(t){return(0,i.Ay)({url:"/api/users/profile/update",method:"put",data:t})}function m(){return(0,i.Ay)({url:"/api/users/notification-settings",method:"get"})}function g(t){return(0,i.Ay)({url:"/api/users/notification-settings",method:"put",data:t})}function p(){return(0,i.Ay)({url:"/api/users/notification-settings/test",method:"post",data:{}})}function _(t){return(0,i.Ay)({url:"/api/users/my-credits-log",method:"get",params:t})}function h(t){return(0,i.Ay)({url:"/api/users/my-referrals",method:"get",params:t})}function y(t){return(0,i.Ay)({url:"/api/users/set-credits",method:"post",data:t})}function f(t){return(0,i.Ay)({url:"/api/users/set-vip",method:"post",data:t})}function v(t){return(0,i.Ay)({url:"/api/users/system-strategies",method:"get",params:t})}function b(t){return(0,i.Ay)({url:"/api/users/admin-orders",method:"get",params:t})}function k(t){return(0,i.Ay)({url:"/api/users/admin-ai-stats",method:"get",params:t})}}}]); |