@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
|
@@ -3,16 +3,26 @@
|
|
|
3
3
|
import { useCallback, useEffect } from 'react';
|
|
4
4
|
import { useSearchParams } from 'next/navigation';
|
|
5
5
|
import { Box, Flex, ClientOnly } from '@chakra-ui/react';
|
|
6
|
-
import { useFilters, useTickers, useTestList } from '
|
|
7
|
-
import { Filters } from '
|
|
8
|
-
import { MainChart } from '
|
|
9
|
-
import {
|
|
6
|
+
import { useFilters, useTickers, useTestList } from '#store';
|
|
7
|
+
import { Filters } from '#shared/Filters';
|
|
8
|
+
import { MainChart } from '#app/components/Dashboard/MainChart';
|
|
9
|
+
import {
|
|
10
|
+
Interval,
|
|
11
|
+
MarketUniverse,
|
|
12
|
+
OnChangeFilters,
|
|
13
|
+
Provider,
|
|
14
|
+
} from '@tradejs/types';
|
|
15
|
+
import {
|
|
16
|
+
buildDashboardPath,
|
|
17
|
+
parseDashboardPath as parseMarketDashboardPath,
|
|
18
|
+
} from '#app/lib/marketRoutes';
|
|
10
19
|
|
|
11
|
-
const
|
|
20
|
+
const DashboardRoute = () => {
|
|
12
21
|
const searchParams = useSearchParams();
|
|
13
22
|
const { filters, setFilters } = useFilters();
|
|
14
23
|
const { tickers, ensureLoaded: ensureTickersLoaded } = useTickers(
|
|
15
24
|
filters.provider || 'bybit',
|
|
25
|
+
filters.universe ?? 'crypto',
|
|
16
26
|
{ enabled: false },
|
|
17
27
|
);
|
|
18
28
|
const { tests, ensureLoaded: ensureBacktestsLoaded } = useTestList({
|
|
@@ -26,18 +36,18 @@ const Dashboard = () => {
|
|
|
26
36
|
const isScreenshotMode = searchParams.get('screenshot') === '1';
|
|
27
37
|
|
|
28
38
|
const parseDashboardPath = useCallback(() => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
39
|
+
return parseMarketDashboardPath(window.location.pathname, {
|
|
40
|
+
provider: (filters.provider || 'bybit') as Provider,
|
|
41
|
+
symbol: filters.symbol,
|
|
42
|
+
interval: filters.interval as Interval,
|
|
43
|
+
});
|
|
35
44
|
}, [filters.interval, filters.provider, filters.symbol]);
|
|
36
45
|
|
|
37
46
|
useEffect(() => {
|
|
38
47
|
const parsed = parseDashboardPath();
|
|
39
48
|
setFilters({
|
|
40
49
|
provider: parsed.provider,
|
|
50
|
+
universe: parsed.universe,
|
|
41
51
|
symbol: parsed.symbol,
|
|
42
52
|
interval: parsed.interval,
|
|
43
53
|
...(hasBacktestId ? { backtestId } : {}),
|
|
@@ -59,14 +69,17 @@ const Dashboard = () => {
|
|
|
59
69
|
...filters,
|
|
60
70
|
...newFilters,
|
|
61
71
|
provider: (newFilters.provider || parsed.provider) as Provider,
|
|
72
|
+
universe: (newFilters.universe || parsed.universe) as MarketUniverse,
|
|
62
73
|
symbol: (newFilters.symbol || parsed.symbol) as string,
|
|
63
74
|
interval: (newFilters.interval || parsed.interval) as Interval,
|
|
64
75
|
};
|
|
65
76
|
setFilters(nextFilters);
|
|
66
77
|
const nextProvider = nextFilters.provider || 'bybit';
|
|
78
|
+
const nextUniverse = nextFilters.universe || 'crypto';
|
|
67
79
|
const nextSymbol = nextFilters.symbol;
|
|
68
80
|
const nextInterval = nextFilters.interval;
|
|
69
81
|
const params = new URLSearchParams(window.location.search);
|
|
82
|
+
params.delete('universe');
|
|
70
83
|
|
|
71
84
|
if (nextFilters.backtestId) {
|
|
72
85
|
params.set('backtestId', nextFilters.backtestId);
|
|
@@ -80,12 +93,18 @@ const Dashboard = () => {
|
|
|
80
93
|
params.delete('backtestStrategy');
|
|
81
94
|
}
|
|
82
95
|
|
|
83
|
-
const search = params.toString();
|
|
84
|
-
|
|
85
96
|
window.history.replaceState(
|
|
86
97
|
null,
|
|
87
98
|
'',
|
|
88
|
-
|
|
99
|
+
buildDashboardPath(
|
|
100
|
+
{
|
|
101
|
+
provider: nextProvider,
|
|
102
|
+
universe: nextUniverse,
|
|
103
|
+
symbol: nextSymbol,
|
|
104
|
+
interval: nextInterval,
|
|
105
|
+
},
|
|
106
|
+
params,
|
|
107
|
+
),
|
|
89
108
|
);
|
|
90
109
|
},
|
|
91
110
|
[filters, parseDashboardPath, setFilters],
|
|
@@ -114,6 +133,7 @@ const Dashboard = () => {
|
|
|
114
133
|
>
|
|
115
134
|
<Flex mb={2} gap={4} alignItems="center" flexDirection="row">
|
|
116
135
|
<Filters.SelectProvider />
|
|
136
|
+
{Filters.SelectUniverse ? <Filters.SelectUniverse /> : null}
|
|
117
137
|
<Filters.SelectSymbol />
|
|
118
138
|
<Filters.FavoriteIndicator />
|
|
119
139
|
<Filters.SelectInterval />
|
|
@@ -132,4 +152,4 @@ const Dashboard = () => {
|
|
|
132
152
|
);
|
|
133
153
|
};
|
|
134
154
|
|
|
135
|
-
export default
|
|
155
|
+
export default DashboardRoute;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../../../Dashboard';
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { useRouter } from 'next/navigation';
|
|
5
|
-
import { useFilters } from '
|
|
5
|
+
import { useFilters } from '#store';
|
|
6
|
+
import { buildDashboardPath } from '#app/lib/marketRoutes';
|
|
6
7
|
|
|
7
8
|
const DashboardIndex = () => {
|
|
8
9
|
const { filters } = useFilters();
|
|
@@ -10,9 +11,20 @@ const DashboardIndex = () => {
|
|
|
10
11
|
|
|
11
12
|
useEffect(() => {
|
|
12
13
|
router.replace(
|
|
13
|
-
|
|
14
|
+
buildDashboardPath({
|
|
15
|
+
provider: filters.provider || 'bybit',
|
|
16
|
+
universe: filters.universe || 'crypto',
|
|
17
|
+
symbol: filters.symbol,
|
|
18
|
+
interval: filters.interval,
|
|
19
|
+
}),
|
|
14
20
|
);
|
|
15
|
-
}, [
|
|
21
|
+
}, [
|
|
22
|
+
filters.interval,
|
|
23
|
+
filters.provider,
|
|
24
|
+
filters.symbol,
|
|
25
|
+
filters.universe,
|
|
26
|
+
router,
|
|
27
|
+
]);
|
|
16
28
|
|
|
17
29
|
return null;
|
|
18
30
|
};
|