reportify-sdk 0.3.33 → 0.3.35

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 CHANGED
@@ -120,11 +120,13 @@ const ohlcvBatch = await client.quant.ohlcvBatch({ symbols: ['000001', '600519']
120
120
  const result = await client.quant.backtest({
121
121
  startDate: '2023-01-01',
122
122
  endDate: '2024-01-01',
123
- symbol: '000001',
123
+ symbols: ['000001'],
124
124
  entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))',
125
125
  exitFormula: 'CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))'
126
126
  });
127
127
  console.log(`Total Return: ${(result.total_return_pct * 100).toFixed(2)}%`);
128
+ console.log(`Sharpe: ${result.sharpe_ratio.toFixed(3)}`);
129
+ console.log(`Alpha/Beta: ${result.alpha.toFixed(3)}/${result.beta.toFixed(3)}`);
128
130
  ```
129
131
 
130
132
  ### Concepts
package/dist/index.d.mts CHANGED
@@ -726,6 +726,7 @@ interface BacktestParams {
726
726
  symbols?: string[];
727
727
  filterFormula?: string;
728
728
  market?: StockMarket;
729
+ stockType?: 'stock' | 'etf' | 'index' | 'sw';
729
730
  entryFormula?: string;
730
731
  strategyCode?: string;
731
732
  exitFormula?: string;
@@ -742,6 +743,11 @@ interface BacktestParams {
742
743
  autoClose?: boolean;
743
744
  cheatOnOpen?: boolean;
744
745
  signalFactors?: Record<string, string>;
746
+ benchmark?: {
747
+ symbol: string;
748
+ market?: StockMarket;
749
+ stockType?: 'stock' | 'etf' | 'index' | 'sw';
750
+ };
745
751
  }
746
752
  interface KlineParams {
747
753
  symbol: string;
@@ -790,6 +796,11 @@ interface BacktestUploadParams {
790
796
  autoClose?: boolean;
791
797
  cheatOnOpen?: boolean;
792
798
  signalFactors?: Record<string, string>;
799
+ benchmark?: {
800
+ symbol: string;
801
+ market?: StockMarket;
802
+ stockType?: 'stock' | 'etf' | 'index' | 'sw';
803
+ };
793
804
  }
794
805
  interface BacktestResult {
795
806
  success: boolean;
@@ -817,6 +828,15 @@ interface BacktestResult {
817
828
  cumulative_pnl: number;
818
829
  }>;
819
830
  portfolio_value: Record<string, number>;
831
+ benchmark_value: Record<string, number>;
832
+ benchmark_return_pct: number;
833
+ sharpe_ratio: number;
834
+ alpha: number;
835
+ beta: number;
836
+ max_drawdown_start: string | null;
837
+ max_drawdown_end: string | null;
838
+ daily_returns: Record<string, number>;
839
+ drawdown_series: Record<string, number>;
820
840
  error_msg: string | null;
821
841
  }
822
842
  /**
@@ -849,7 +869,6 @@ interface BacktestResult {
849
869
  */
850
870
  declare class QuantModule {
851
871
  private client;
852
- private static readonly BACKTEST_TIMEOUT_MS;
853
872
  constructor(client: Reportify);
854
873
  /**
855
874
  * Get list of available factors (variables, functions, and indicators)
package/dist/index.d.ts CHANGED
@@ -726,6 +726,7 @@ interface BacktestParams {
726
726
  symbols?: string[];
727
727
  filterFormula?: string;
728
728
  market?: StockMarket;
729
+ stockType?: 'stock' | 'etf' | 'index' | 'sw';
729
730
  entryFormula?: string;
730
731
  strategyCode?: string;
731
732
  exitFormula?: string;
@@ -742,6 +743,11 @@ interface BacktestParams {
742
743
  autoClose?: boolean;
743
744
  cheatOnOpen?: boolean;
744
745
  signalFactors?: Record<string, string>;
746
+ benchmark?: {
747
+ symbol: string;
748
+ market?: StockMarket;
749
+ stockType?: 'stock' | 'etf' | 'index' | 'sw';
750
+ };
745
751
  }
746
752
  interface KlineParams {
747
753
  symbol: string;
@@ -790,6 +796,11 @@ interface BacktestUploadParams {
790
796
  autoClose?: boolean;
791
797
  cheatOnOpen?: boolean;
792
798
  signalFactors?: Record<string, string>;
799
+ benchmark?: {
800
+ symbol: string;
801
+ market?: StockMarket;
802
+ stockType?: 'stock' | 'etf' | 'index' | 'sw';
803
+ };
793
804
  }
794
805
  interface BacktestResult {
795
806
  success: boolean;
@@ -817,6 +828,15 @@ interface BacktestResult {
817
828
  cumulative_pnl: number;
818
829
  }>;
819
830
  portfolio_value: Record<string, number>;
831
+ benchmark_value: Record<string, number>;
832
+ benchmark_return_pct: number;
833
+ sharpe_ratio: number;
834
+ alpha: number;
835
+ beta: number;
836
+ max_drawdown_start: string | null;
837
+ max_drawdown_end: string | null;
838
+ daily_returns: Record<string, number>;
839
+ drawdown_series: Record<string, number>;
820
840
  error_msg: string | null;
821
841
  }
822
842
  /**
@@ -849,7 +869,6 @@ interface BacktestResult {
849
869
  */
850
870
  declare class QuantModule {
851
871
  private client;
852
- private static readonly BACKTEST_TIMEOUT_MS;
853
872
  constructor(client: Reportify);
854
873
  /**
855
874
  * Get list of available factors (variables, functions, and indicators)
package/dist/index.js CHANGED
@@ -614,11 +614,10 @@ var DocsModule = class {
614
614
  };
615
615
 
616
616
  // src/quant.ts
617
- var QuantModule = class _QuantModule {
617
+ var QuantModule = class {
618
618
  constructor(client) {
619
619
  this.client = client;
620
620
  }
621
- static BACKTEST_TIMEOUT_MS = 12e4;
622
621
  // ===========================================================================
623
622
  // Factors (includes technical indicators and fundamental factors)
624
623
  // ===========================================================================
@@ -959,6 +958,7 @@ var QuantModule = class _QuantModule {
959
958
  start_date: params.startDate,
960
959
  end_date: params.endDate,
961
960
  market: params.market || "cn",
961
+ stock_type: params.stockType || "stock",
962
962
  initial_cash: params.initialCash ?? 1e5,
963
963
  commission: params.commission ?? 0,
964
964
  buy_commission: params.buyCommission ?? 0,
@@ -996,9 +996,11 @@ var QuantModule = class _QuantModule {
996
996
  if (params.signalFactors !== void 0) {
997
997
  body.signal_factors = params.signalFactors;
998
998
  }
999
+ if (params.benchmark !== void 0) {
1000
+ body.benchmark = params.benchmark;
1001
+ }
999
1002
  return this.client.request("POST", "/v1/quant/backtest", {
1000
- body,
1001
- timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
1003
+ body
1002
1004
  });
1003
1005
  }
1004
1006
  /**
@@ -1084,9 +1086,11 @@ var QuantModule = class _QuantModule {
1084
1086
  if (params.signalFactors !== void 0) {
1085
1087
  formData.append("signal_factors", JSON.stringify(params.signalFactors));
1086
1088
  }
1089
+ if (params.benchmark !== void 0) {
1090
+ formData.append("benchmark", JSON.stringify(params.benchmark));
1091
+ }
1087
1092
  return this.client.request("POST", "/v1/quant/backtest/upload", {
1088
- formData,
1089
- timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
1093
+ formData
1090
1094
  });
1091
1095
  }
1092
1096
  };
package/dist/index.mjs CHANGED
@@ -570,11 +570,10 @@ var DocsModule = class {
570
570
  };
571
571
 
572
572
  // src/quant.ts
573
- var QuantModule = class _QuantModule {
573
+ var QuantModule = class {
574
574
  constructor(client) {
575
575
  this.client = client;
576
576
  }
577
- static BACKTEST_TIMEOUT_MS = 12e4;
578
577
  // ===========================================================================
579
578
  // Factors (includes technical indicators and fundamental factors)
580
579
  // ===========================================================================
@@ -915,6 +914,7 @@ var QuantModule = class _QuantModule {
915
914
  start_date: params.startDate,
916
915
  end_date: params.endDate,
917
916
  market: params.market || "cn",
917
+ stock_type: params.stockType || "stock",
918
918
  initial_cash: params.initialCash ?? 1e5,
919
919
  commission: params.commission ?? 0,
920
920
  buy_commission: params.buyCommission ?? 0,
@@ -952,9 +952,11 @@ var QuantModule = class _QuantModule {
952
952
  if (params.signalFactors !== void 0) {
953
953
  body.signal_factors = params.signalFactors;
954
954
  }
955
+ if (params.benchmark !== void 0) {
956
+ body.benchmark = params.benchmark;
957
+ }
955
958
  return this.client.request("POST", "/v1/quant/backtest", {
956
- body,
957
- timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
959
+ body
958
960
  });
959
961
  }
960
962
  /**
@@ -1040,9 +1042,11 @@ var QuantModule = class _QuantModule {
1040
1042
  if (params.signalFactors !== void 0) {
1041
1043
  formData.append("signal_factors", JSON.stringify(params.signalFactors));
1042
1044
  }
1045
+ if (params.benchmark !== void 0) {
1046
+ formData.append("benchmark", JSON.stringify(params.benchmark));
1047
+ }
1043
1048
  return this.client.request("POST", "/v1/quant/backtest/upload", {
1044
- formData,
1045
- timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
1049
+ formData
1046
1050
  });
1047
1051
  }
1048
1052
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reportify-sdk",
3
- "version": "0.3.33",
3
+ "version": "0.3.35",
4
4
  "description": "TypeScript SDK for Reportify API - Financial data and document search",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",