@tradejs/app 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/bin/tradejs-app.mjs +146 -2
- package/next.config.mjs +0 -14
- package/package.json +35 -19
- package/src/app/actions/backtest.ts +54 -0
- package/src/app/actions/kline.ts +10 -5
- package/src/app/actions/scanner.ts +8 -3
- package/src/app/actions/strategies.ts +39 -0
- package/src/app/api/ai/route.ts +5 -4
- package/src/app/api/auth/[...nextauth]/route.ts +1 -1
- package/src/app/api/backtest/configs/route.ts +25 -0
- package/src/app/api/backtest/files/route.ts +5 -2
- package/src/app/api/backtest/order-log/[strategy]/[name]/route.ts +26 -2
- package/src/app/api/backtest/result/[strategy]/[name]/route.ts +27 -2
- package/src/app/api/backtest/runs/[jobId]/route.ts +124 -0
- package/src/app/api/backtest/runs/route.ts +45 -0
- package/src/app/api/backtest/test/[strategy]/[name]/route.ts +19 -2
- package/src/app/api/derivatives/summary/route.ts +8 -1
- package/src/app/api/kline/[provider]/[universe]/[symbol]/[interval]/route.ts +1 -0
- package/src/app/api/kline/{[provider]/[symbol]/[interval]/route.ts → handler.ts} +61 -39
- package/src/app/api/scanner/[provider]/[universe]/route.ts +1 -0
- package/src/app/api/scanner/[provider]/route.ts +30 -12
- package/src/app/api/scanner/route.ts +3 -3
- package/src/app/api/signal/[symbol]/[signalId]/route.ts +4 -7
- package/src/app/api/strategies/ai/[cardId]/route.ts +22 -0
- package/src/app/api/strategies/ai/route.ts +139 -0
- package/src/app/api/strategies/replay/[cardId]/route.ts +18 -0
- package/src/app/api/strategies/replay/route.ts +44 -0
- package/src/app/api/strategies/runtime/route.ts +831 -0
- package/src/app/api/user/runtime-deployments/[deploymentId]/route.ts +25 -0
- package/src/app/api/user/runtime-deployments/route.ts +94 -0
- package/src/app/api/user/runtime-strategy-configs/route.ts +241 -0
- package/src/app/api/user/settings/route.ts +18 -1
- package/src/app/api/user/trading-accounts/[accountId]/route.ts +35 -0
- package/src/app/api/user/trading-accounts/route.ts +134 -0
- package/src/app/components/Backtest/CompareList/index.tsx +1 -1
- package/src/app/components/Backtest/ResultsPageClient.tsx +376 -0
- package/src/app/components/Backtest/TestCard/ActionsMenu/index.tsx +123 -0
- package/src/app/components/Backtest/TestCard/Chart/index.tsx +1 -1
- package/src/app/components/Backtest/TestCard/CompareButton/index.tsx +1 -1
- package/src/app/components/Backtest/TestCard/ConfigDrawer/index.tsx +28 -12
- package/src/app/components/Backtest/TestCard/DeleteButton/index.tsx +33 -17
- package/src/app/components/Backtest/TestCard/FavoriteIndicator/index.tsx +2 -2
- package/src/app/components/Backtest/TestCard/OpenDashboardButton/index.tsx +10 -1
- package/src/app/components/Backtest/TestCard/OrdersDrawer/index.tsx +128 -0
- package/src/app/components/Backtest/TestCard/Root/index.tsx +1 -1
- package/src/app/components/Backtest/TestCard/Stat/index.tsx +2 -0
- package/src/app/components/Backtest/TestCard/StatDrawer/index.tsx +66 -0
- package/src/app/components/Backtest/TestCard/index.ts +6 -2
- package/src/app/components/Backtest/TestList/index.tsx +4 -9
- package/src/app/components/Dashboard/AiDrawer/index.tsx +1 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useBacktest.ts +1 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useBbIndicator.ts +10 -5
- package/src/app/components/Dashboard/KlineChart/hooks/useBtcCorrelation.ts +1 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useBtcIndicator.ts +4 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useEmaIndicator.ts +3 -1
- package/src/app/components/Dashboard/KlineChart/hooks/usePluginIndicators.ts +1 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useSetup.ts +1 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useSignal.ts +1 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useSpreadIndicator.ts +1 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useTrendLine.ts +1 -1
- package/src/app/components/Dashboard/KlineChart/hooks/useWmaIndicator.ts +3 -1
- package/src/app/components/Dashboard/KlineChart/index.tsx +16 -6
- package/src/app/components/Dashboard/MainChart/index.tsx +3 -22
- package/src/app/components/Shared/AppShell.tsx +1 -1
- package/src/app/components/Shared/BulkSelection/index.tsx +140 -0
- package/src/app/components/Shared/BulkSelection/useBulkSelection.ts +97 -0
- package/src/app/components/Shared/BulkSelection/utils.ts +126 -0
- package/src/app/components/Shared/Filters/Backtest/index.tsx +33 -48
- package/src/app/components/Shared/Filters/FavoriteIndicator/index.tsx +5 -3
- package/src/app/components/Shared/Filters/Indicators/index.tsx +2 -2
- package/src/app/components/Shared/Filters/Interval/index.tsx +1 -1
- package/src/app/components/Shared/Filters/Provider/index.tsx +8 -2
- package/src/app/components/Shared/Filters/Symbol/index.tsx +4 -3
- package/src/app/components/Shared/Filters/Universe/index.tsx +36 -0
- package/src/app/components/Shared/Filters/index.ts +2 -0
- package/src/app/components/Shared/OrdersDrawer.tsx +629 -0
- package/src/app/components/Shared/Sidebar/AccountSettingsDrawer.tsx +55 -28
- package/src/app/components/Shared/Sidebar/TradingAccountsPanel.tsx +445 -0
- package/src/app/components/Shared/Sidebar/index.tsx +17 -3
- package/src/app/components/Strategies/AdvancedMetricsPanel.tsx +727 -0
- package/src/app/components/Strategies/RuntimeStrategyCard.tsx +2204 -0
- package/src/app/components/Strategies/RuntimeStrategyCardSkeleton.tsx +40 -0
- package/src/app/components/Strategies/RuntimeStrategyChart.tsx +121 -0
- package/src/app/components/Strategies/RuntimeStrategyConfigDrawer.tsx +458 -0
- package/src/app/components/Strategies/StrategySnapshotCard.tsx +2890 -0
- package/src/app/components/Strategies/StrategySnapshotChart.tsx +94 -0
- package/src/app/components/Strategies/StrategySnapshotList.tsx +82 -0
- package/src/app/components/UI/Segment/index.tsx +8 -1
- package/src/app/components/UI/Select/index.tsx +24 -13
- package/src/app/components/UI/SelectWithSearch/index.tsx +46 -5
- package/src/app/layout.tsx +1 -1
- package/src/app/lib/backtestJobs.ts +792 -0
- package/src/app/lib/cardPageLayout.ts +1 -0
- package/src/app/lib/connectorCreator.ts +28 -0
- package/src/app/lib/currentUser.ts +1 -1
- package/src/app/lib/errorMessage.ts +34 -0
- package/src/app/lib/marketDefaults.ts +12 -0
- package/src/app/lib/marketRoutes.ts +58 -0
- package/src/app/lib/runtimeStrategies.ts +1376 -0
- package/src/app/lib/runtimeStrategyConfigForm.ts +86 -0
- package/src/app/provider.tsx +1 -1
- package/src/app/routes/backtest/page.tsx +1051 -304
- package/src/app/routes/dashboard/{[provider]/[symbol]/[interval]/page.tsx → Dashboard.tsx} +35 -15
- package/src/app/routes/dashboard/[provider]/[universe]/[symbol]/[interval]/page.tsx +1 -0
- package/src/app/routes/dashboard/page.tsx +15 -3
- package/src/app/routes/derivatives/page.tsx +1222 -165
- package/src/app/routes/strategies/StrategiesPageClient.tsx +593 -0
- package/src/app/routes/strategies/[mode]/page.tsx +20 -0
- package/src/app/routes/strategies/page.tsx +7 -0
- package/src/app/store/ai.ts +1 -1
- package/src/app/store/data.ts +73 -17
- package/src/app/store/filters.ts +1 -0
- package/src/app/store/marketKlineStream.ts +87 -0
- package/src/app/store/tests.ts +1 -1
- package/src/app/store/tickers.ts +59 -22
- package/tsconfig.json +17 -12
- package/src/app/components/Backtest/TestCard/OpenReportButton/index.tsx +0 -24
- package/src/app/routes/backtest/[test]/page.tsx +0 -33
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { StrategyConfig } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
export type RuntimeStrategyManagedParameters = {
|
|
4
|
+
maxLossValue: number;
|
|
5
|
+
aiEnabled: boolean;
|
|
6
|
+
aiMode: 'gate' | 'llm';
|
|
7
|
+
minAiQuality: number;
|
|
8
|
+
mlEnabled: boolean;
|
|
9
|
+
mlThreshold: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const DEFAULT_RUNTIME_STRATEGY_MANAGED_PARAMETERS: RuntimeStrategyManagedParameters =
|
|
13
|
+
{
|
|
14
|
+
maxLossValue: 1,
|
|
15
|
+
aiEnabled: true,
|
|
16
|
+
aiMode: 'gate',
|
|
17
|
+
minAiQuality: 4,
|
|
18
|
+
mlEnabled: false,
|
|
19
|
+
mlThreshold: 0.1,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const FORM_FIELDS = new Set([
|
|
23
|
+
'ENABLE',
|
|
24
|
+
'INTERVAL',
|
|
25
|
+
'UNIVERSE',
|
|
26
|
+
'ACCOUNT_ID',
|
|
27
|
+
'MAX_LOSS_VALUE',
|
|
28
|
+
'AI_ENABLED',
|
|
29
|
+
'AI_MODE',
|
|
30
|
+
'MIN_AI_QUALITY',
|
|
31
|
+
'ML_ENABLED',
|
|
32
|
+
'ML_THRESHOLD',
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
const readNumber = (value: unknown, fallback: number) => {
|
|
36
|
+
const parsed = Number(value);
|
|
37
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const readBoolean = (value: unknown, fallback: boolean) =>
|
|
41
|
+
typeof value === 'boolean' ? value : fallback;
|
|
42
|
+
|
|
43
|
+
export const splitRuntimeStrategyConfig = (config: StrategyConfig | null) => ({
|
|
44
|
+
managed: {
|
|
45
|
+
maxLossValue: readNumber(
|
|
46
|
+
config?.MAX_LOSS_VALUE,
|
|
47
|
+
DEFAULT_RUNTIME_STRATEGY_MANAGED_PARAMETERS.maxLossValue,
|
|
48
|
+
),
|
|
49
|
+
aiEnabled: readBoolean(
|
|
50
|
+
config?.AI_ENABLED,
|
|
51
|
+
DEFAULT_RUNTIME_STRATEGY_MANAGED_PARAMETERS.aiEnabled,
|
|
52
|
+
),
|
|
53
|
+
aiMode:
|
|
54
|
+
config?.AI_MODE === 'llm' || config?.AI_MODE === 'gate'
|
|
55
|
+
? config.AI_MODE
|
|
56
|
+
: DEFAULT_RUNTIME_STRATEGY_MANAGED_PARAMETERS.aiMode,
|
|
57
|
+
minAiQuality: readNumber(
|
|
58
|
+
config?.MIN_AI_QUALITY,
|
|
59
|
+
DEFAULT_RUNTIME_STRATEGY_MANAGED_PARAMETERS.minAiQuality,
|
|
60
|
+
),
|
|
61
|
+
mlEnabled: readBoolean(
|
|
62
|
+
config?.ML_ENABLED,
|
|
63
|
+
DEFAULT_RUNTIME_STRATEGY_MANAGED_PARAMETERS.mlEnabled,
|
|
64
|
+
),
|
|
65
|
+
mlThreshold: readNumber(
|
|
66
|
+
config?.ML_THRESHOLD,
|
|
67
|
+
DEFAULT_RUNTIME_STRATEGY_MANAGED_PARAMETERS.mlThreshold,
|
|
68
|
+
),
|
|
69
|
+
} satisfies RuntimeStrategyManagedParameters,
|
|
70
|
+
parameters: Object.fromEntries(
|
|
71
|
+
Object.entries(config ?? {}).filter(([key]) => !FORM_FIELDS.has(key)),
|
|
72
|
+
),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const mergeRuntimeStrategyManagedParameters = (
|
|
76
|
+
parameters: Record<string, unknown>,
|
|
77
|
+
managed: RuntimeStrategyManagedParameters,
|
|
78
|
+
) => ({
|
|
79
|
+
...parameters,
|
|
80
|
+
MAX_LOSS_VALUE: managed.maxLossValue,
|
|
81
|
+
AI_ENABLED: managed.aiEnabled,
|
|
82
|
+
AI_MODE: managed.aiMode,
|
|
83
|
+
MIN_AI_QUALITY: managed.minAiQuality,
|
|
84
|
+
ML_ENABLED: managed.mlEnabled,
|
|
85
|
+
ML_THRESHOLD: managed.mlThreshold,
|
|
86
|
+
});
|
package/src/app/provider.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
defineConfig,
|
|
8
8
|
} from '@chakra-ui/react';
|
|
9
9
|
import { SessionProvider } from 'next-auth/react';
|
|
10
|
-
import { AppToaster, ColorModeProvider } from '
|
|
10
|
+
import { AppToaster, ColorModeProvider } from '#ui';
|
|
11
11
|
|
|
12
12
|
const config = defineConfig({
|
|
13
13
|
theme: {
|