@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.
Files changed (119) hide show
  1. package/README.md +7 -2
  2. package/bin/tradejs-app.mjs +146 -2
  3. package/next.config.mjs +0 -14
  4. package/package.json +35 -19
  5. package/src/app/actions/backtest.ts +54 -0
  6. package/src/app/actions/kline.ts +10 -5
  7. package/src/app/actions/scanner.ts +8 -3
  8. package/src/app/actions/strategies.ts +39 -0
  9. package/src/app/api/ai/route.ts +5 -4
  10. package/src/app/api/auth/[...nextauth]/route.ts +1 -1
  11. package/src/app/api/backtest/configs/route.ts +25 -0
  12. package/src/app/api/backtest/files/route.ts +5 -2
  13. package/src/app/api/backtest/order-log/[strategy]/[name]/route.ts +26 -2
  14. package/src/app/api/backtest/result/[strategy]/[name]/route.ts +27 -2
  15. package/src/app/api/backtest/runs/[jobId]/route.ts +124 -0
  16. package/src/app/api/backtest/runs/route.ts +45 -0
  17. package/src/app/api/backtest/test/[strategy]/[name]/route.ts +19 -2
  18. package/src/app/api/derivatives/summary/route.ts +8 -1
  19. package/src/app/api/kline/[provider]/[universe]/[symbol]/[interval]/route.ts +1 -0
  20. package/src/app/api/kline/{[provider]/[symbol]/[interval]/route.ts → handler.ts} +61 -39
  21. package/src/app/api/scanner/[provider]/[universe]/route.ts +1 -0
  22. package/src/app/api/scanner/[provider]/route.ts +30 -12
  23. package/src/app/api/scanner/route.ts +3 -3
  24. package/src/app/api/signal/[symbol]/[signalId]/route.ts +4 -7
  25. package/src/app/api/strategies/ai/[cardId]/route.ts +22 -0
  26. package/src/app/api/strategies/ai/route.ts +139 -0
  27. package/src/app/api/strategies/replay/[cardId]/route.ts +18 -0
  28. package/src/app/api/strategies/replay/route.ts +44 -0
  29. package/src/app/api/strategies/runtime/route.ts +831 -0
  30. package/src/app/api/user/runtime-deployments/[deploymentId]/route.ts +25 -0
  31. package/src/app/api/user/runtime-deployments/route.ts +94 -0
  32. package/src/app/api/user/runtime-strategy-configs/route.ts +241 -0
  33. package/src/app/api/user/settings/route.ts +18 -1
  34. package/src/app/api/user/trading-accounts/[accountId]/route.ts +35 -0
  35. package/src/app/api/user/trading-accounts/route.ts +134 -0
  36. package/src/app/components/Backtest/CompareList/index.tsx +1 -1
  37. package/src/app/components/Backtest/ResultsPageClient.tsx +376 -0
  38. package/src/app/components/Backtest/TestCard/ActionsMenu/index.tsx +123 -0
  39. package/src/app/components/Backtest/TestCard/Chart/index.tsx +1 -1
  40. package/src/app/components/Backtest/TestCard/CompareButton/index.tsx +1 -1
  41. package/src/app/components/Backtest/TestCard/ConfigDrawer/index.tsx +28 -12
  42. package/src/app/components/Backtest/TestCard/DeleteButton/index.tsx +33 -17
  43. package/src/app/components/Backtest/TestCard/FavoriteIndicator/index.tsx +2 -2
  44. package/src/app/components/Backtest/TestCard/OpenDashboardButton/index.tsx +10 -1
  45. package/src/app/components/Backtest/TestCard/OrdersDrawer/index.tsx +128 -0
  46. package/src/app/components/Backtest/TestCard/Root/index.tsx +1 -1
  47. package/src/app/components/Backtest/TestCard/Stat/index.tsx +2 -0
  48. package/src/app/components/Backtest/TestCard/StatDrawer/index.tsx +66 -0
  49. package/src/app/components/Backtest/TestCard/index.ts +6 -2
  50. package/src/app/components/Backtest/TestList/index.tsx +4 -9
  51. package/src/app/components/Dashboard/AiDrawer/index.tsx +1 -1
  52. package/src/app/components/Dashboard/KlineChart/hooks/useBacktest.ts +1 -1
  53. package/src/app/components/Dashboard/KlineChart/hooks/useBbIndicator.ts +10 -5
  54. package/src/app/components/Dashboard/KlineChart/hooks/useBtcCorrelation.ts +1 -1
  55. package/src/app/components/Dashboard/KlineChart/hooks/useBtcIndicator.ts +4 -1
  56. package/src/app/components/Dashboard/KlineChart/hooks/useEmaIndicator.ts +3 -1
  57. package/src/app/components/Dashboard/KlineChart/hooks/usePluginIndicators.ts +1 -1
  58. package/src/app/components/Dashboard/KlineChart/hooks/useSetup.ts +1 -1
  59. package/src/app/components/Dashboard/KlineChart/hooks/useSignal.ts +1 -1
  60. package/src/app/components/Dashboard/KlineChart/hooks/useSpreadIndicator.ts +1 -1
  61. package/src/app/components/Dashboard/KlineChart/hooks/useTrendLine.ts +1 -1
  62. package/src/app/components/Dashboard/KlineChart/hooks/useWmaIndicator.ts +3 -1
  63. package/src/app/components/Dashboard/KlineChart/index.tsx +16 -6
  64. package/src/app/components/Dashboard/MainChart/index.tsx +3 -22
  65. package/src/app/components/Shared/AppShell.tsx +1 -1
  66. package/src/app/components/Shared/BulkSelection/index.tsx +140 -0
  67. package/src/app/components/Shared/BulkSelection/useBulkSelection.ts +97 -0
  68. package/src/app/components/Shared/BulkSelection/utils.ts +126 -0
  69. package/src/app/components/Shared/Filters/Backtest/index.tsx +33 -48
  70. package/src/app/components/Shared/Filters/FavoriteIndicator/index.tsx +5 -3
  71. package/src/app/components/Shared/Filters/Indicators/index.tsx +2 -2
  72. package/src/app/components/Shared/Filters/Interval/index.tsx +1 -1
  73. package/src/app/components/Shared/Filters/Provider/index.tsx +8 -2
  74. package/src/app/components/Shared/Filters/Symbol/index.tsx +4 -3
  75. package/src/app/components/Shared/Filters/Universe/index.tsx +36 -0
  76. package/src/app/components/Shared/Filters/index.ts +2 -0
  77. package/src/app/components/Shared/OrdersDrawer.tsx +629 -0
  78. package/src/app/components/Shared/Sidebar/AccountSettingsDrawer.tsx +55 -28
  79. package/src/app/components/Shared/Sidebar/TradingAccountsPanel.tsx +445 -0
  80. package/src/app/components/Shared/Sidebar/index.tsx +17 -3
  81. package/src/app/components/Strategies/AdvancedMetricsPanel.tsx +727 -0
  82. package/src/app/components/Strategies/RuntimeStrategyCard.tsx +2204 -0
  83. package/src/app/components/Strategies/RuntimeStrategyCardSkeleton.tsx +40 -0
  84. package/src/app/components/Strategies/RuntimeStrategyChart.tsx +121 -0
  85. package/src/app/components/Strategies/RuntimeStrategyConfigDrawer.tsx +458 -0
  86. package/src/app/components/Strategies/StrategySnapshotCard.tsx +2890 -0
  87. package/src/app/components/Strategies/StrategySnapshotChart.tsx +94 -0
  88. package/src/app/components/Strategies/StrategySnapshotList.tsx +82 -0
  89. package/src/app/components/UI/Segment/index.tsx +8 -1
  90. package/src/app/components/UI/Select/index.tsx +24 -13
  91. package/src/app/components/UI/SelectWithSearch/index.tsx +46 -5
  92. package/src/app/layout.tsx +1 -1
  93. package/src/app/lib/backtestJobs.ts +792 -0
  94. package/src/app/lib/cardPageLayout.ts +1 -0
  95. package/src/app/lib/connectorCreator.ts +28 -0
  96. package/src/app/lib/currentUser.ts +1 -1
  97. package/src/app/lib/errorMessage.ts +34 -0
  98. package/src/app/lib/marketDefaults.ts +12 -0
  99. package/src/app/lib/marketRoutes.ts +58 -0
  100. package/src/app/lib/runtimeStrategies.ts +1376 -0
  101. package/src/app/lib/runtimeStrategyConfigForm.ts +86 -0
  102. package/src/app/provider.tsx +1 -1
  103. package/src/app/routes/backtest/page.tsx +1051 -304
  104. package/src/app/routes/dashboard/{[provider]/[symbol]/[interval]/page.tsx → Dashboard.tsx} +35 -15
  105. package/src/app/routes/dashboard/[provider]/[universe]/[symbol]/[interval]/page.tsx +1 -0
  106. package/src/app/routes/dashboard/page.tsx +15 -3
  107. package/src/app/routes/derivatives/page.tsx +1222 -165
  108. package/src/app/routes/strategies/StrategiesPageClient.tsx +593 -0
  109. package/src/app/routes/strategies/[mode]/page.tsx +20 -0
  110. package/src/app/routes/strategies/page.tsx +7 -0
  111. package/src/app/store/ai.ts +1 -1
  112. package/src/app/store/data.ts +73 -17
  113. package/src/app/store/filters.ts +1 -0
  114. package/src/app/store/marketKlineStream.ts +87 -0
  115. package/src/app/store/tests.ts +1 -1
  116. package/src/app/store/tickers.ts +59 -22
  117. package/tsconfig.json +17 -12
  118. package/src/app/components/Backtest/TestCard/OpenReportButton/index.tsx +0 -24
  119. 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 '@store';
7
- import { Filters } from '@shared/Filters';
8
- import { MainChart } from '@app/components/Dashboard/MainChart';
9
- import { Interval, OnChangeFilters, Provider } from '@tradejs/types';
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 Dashboard = () => {
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
- const parts = window.location.pathname.split('/').filter(Boolean);
30
- return {
31
- provider: (parts[2] || filters.provider || 'bybit') as Provider,
32
- symbol: (parts[3] || filters.symbol) as string,
33
- interval: (parts[4] || filters.interval) as Interval,
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
- `/routes/dashboard/${nextProvider}/${nextSymbol}/${nextInterval}${search ? `?${search}` : ''}`,
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 Dashboard;
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 '@store';
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
- `/routes/dashboard/${filters.provider || 'bybit'}/${filters.symbol}/${filters.interval}`,
14
+ buildDashboardPath({
15
+ provider: filters.provider || 'bybit',
16
+ universe: filters.universe || 'crypto',
17
+ symbol: filters.symbol,
18
+ interval: filters.interval,
19
+ }),
14
20
  );
15
- }, [filters.interval, filters.provider, filters.symbol, router]);
21
+ }, [
22
+ filters.interval,
23
+ filters.provider,
24
+ filters.symbol,
25
+ filters.universe,
26
+ router,
27
+ ]);
16
28
 
17
29
  return null;
18
30
  };