reportify-sdk 0.3.32 → 0.3.34

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
@@ -817,6 +817,15 @@ interface BacktestResult {
817
817
  cumulative_pnl: number;
818
818
  }>;
819
819
  portfolio_value: Record<string, number>;
820
+ benchmark_value: Record<string, number>;
821
+ benchmark_return_pct: number;
822
+ sharpe_ratio: number;
823
+ alpha: number;
824
+ beta: number;
825
+ max_drawdown_start: string | null;
826
+ max_drawdown_end: string | null;
827
+ daily_returns: Record<string, number>;
828
+ drawdown_series: Record<string, number>;
820
829
  error_msg: string | null;
821
830
  }
822
831
  /**
@@ -849,7 +858,6 @@ interface BacktestResult {
849
858
  */
850
859
  declare class QuantModule {
851
860
  private client;
852
- private static readonly BACKTEST_TIMEOUT_MS;
853
861
  constructor(client: Reportify);
854
862
  /**
855
863
  * Get list of available factors (variables, functions, and indicators)
@@ -864,11 +872,13 @@ declare class QuantModule {
864
872
  * - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, AMOUNT
865
873
  * - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
866
874
  *
875
+ * @param market - Stock market ("cn", "hk", "us"), default "cn"
867
876
  * @returns Array of factor definitions with name, type, level, description, and optional fields
868
877
  *
869
878
  * @example
870
879
  * ```typescript
871
880
  * const factors = await client.quant.factors();
881
+ * const hkFactors = await client.quant.factors('hk');
872
882
  * factors.forEach(f => {
873
883
  * console.log(`${f.name} (${f.type}, level ${f.level})`);
874
884
  * if (f.fields) {
@@ -877,7 +887,7 @@ declare class QuantModule {
877
887
  * });
878
888
  * ```
879
889
  */
880
- factors(): Promise<FactorMeta[]>;
890
+ factors(market?: StockMarket): Promise<FactorMeta[]>;
881
891
  /**
882
892
  * Compute factor values for given symbols
883
893
  *
package/dist/index.d.ts CHANGED
@@ -817,6 +817,15 @@ interface BacktestResult {
817
817
  cumulative_pnl: number;
818
818
  }>;
819
819
  portfolio_value: Record<string, number>;
820
+ benchmark_value: Record<string, number>;
821
+ benchmark_return_pct: number;
822
+ sharpe_ratio: number;
823
+ alpha: number;
824
+ beta: number;
825
+ max_drawdown_start: string | null;
826
+ max_drawdown_end: string | null;
827
+ daily_returns: Record<string, number>;
828
+ drawdown_series: Record<string, number>;
820
829
  error_msg: string | null;
821
830
  }
822
831
  /**
@@ -849,7 +858,6 @@ interface BacktestResult {
849
858
  */
850
859
  declare class QuantModule {
851
860
  private client;
852
- private static readonly BACKTEST_TIMEOUT_MS;
853
861
  constructor(client: Reportify);
854
862
  /**
855
863
  * Get list of available factors (variables, functions, and indicators)
@@ -864,11 +872,13 @@ declare class QuantModule {
864
872
  * - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, AMOUNT
865
873
  * - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
866
874
  *
875
+ * @param market - Stock market ("cn", "hk", "us"), default "cn"
867
876
  * @returns Array of factor definitions with name, type, level, description, and optional fields
868
877
  *
869
878
  * @example
870
879
  * ```typescript
871
880
  * const factors = await client.quant.factors();
881
+ * const hkFactors = await client.quant.factors('hk');
872
882
  * factors.forEach(f => {
873
883
  * console.log(`${f.name} (${f.type}, level ${f.level})`);
874
884
  * if (f.fields) {
@@ -877,7 +887,7 @@ declare class QuantModule {
877
887
  * });
878
888
  * ```
879
889
  */
880
- factors(): Promise<FactorMeta[]>;
890
+ factors(market?: StockMarket): Promise<FactorMeta[]>;
881
891
  /**
882
892
  * Compute factor values for given symbols
883
893
  *
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
  // ===========================================================================
@@ -635,11 +634,13 @@ var QuantModule = class _QuantModule {
635
634
  * - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, AMOUNT
636
635
  * - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
637
636
  *
637
+ * @param market - Stock market ("cn", "hk", "us"), default "cn"
638
638
  * @returns Array of factor definitions with name, type, level, description, and optional fields
639
639
  *
640
640
  * @example
641
641
  * ```typescript
642
642
  * const factors = await client.quant.factors();
643
+ * const hkFactors = await client.quant.factors('hk');
643
644
  * factors.forEach(f => {
644
645
  * console.log(`${f.name} (${f.type}, level ${f.level})`);
645
646
  * if (f.fields) {
@@ -648,8 +649,8 @@ var QuantModule = class _QuantModule {
648
649
  * });
649
650
  * ```
650
651
  */
651
- async factors() {
652
- return this.client.get("/v1/quant/factors");
652
+ async factors(market = "cn") {
653
+ return this.client.get("/v1/quant/factors", { market });
653
654
  }
654
655
  /**
655
656
  * Compute factor values for given symbols
@@ -995,8 +996,7 @@ var QuantModule = class _QuantModule {
995
996
  body.signal_factors = params.signalFactors;
996
997
  }
997
998
  return this.client.request("POST", "/v1/quant/backtest", {
998
- body,
999
- timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
999
+ body
1000
1000
  });
1001
1001
  }
1002
1002
  /**
@@ -1083,8 +1083,7 @@ var QuantModule = class _QuantModule {
1083
1083
  formData.append("signal_factors", JSON.stringify(params.signalFactors));
1084
1084
  }
1085
1085
  return this.client.request("POST", "/v1/quant/backtest/upload", {
1086
- formData,
1087
- timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
1086
+ formData
1088
1087
  });
1089
1088
  }
1090
1089
  };
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
  // ===========================================================================
@@ -591,11 +590,13 @@ var QuantModule = class _QuantModule {
591
590
  * - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, AMOUNT
592
591
  * - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
593
592
  *
593
+ * @param market - Stock market ("cn", "hk", "us"), default "cn"
594
594
  * @returns Array of factor definitions with name, type, level, description, and optional fields
595
595
  *
596
596
  * @example
597
597
  * ```typescript
598
598
  * const factors = await client.quant.factors();
599
+ * const hkFactors = await client.quant.factors('hk');
599
600
  * factors.forEach(f => {
600
601
  * console.log(`${f.name} (${f.type}, level ${f.level})`);
601
602
  * if (f.fields) {
@@ -604,8 +605,8 @@ var QuantModule = class _QuantModule {
604
605
  * });
605
606
  * ```
606
607
  */
607
- async factors() {
608
- return this.client.get("/v1/quant/factors");
608
+ async factors(market = "cn") {
609
+ return this.client.get("/v1/quant/factors", { market });
609
610
  }
610
611
  /**
611
612
  * Compute factor values for given symbols
@@ -951,8 +952,7 @@ var QuantModule = class _QuantModule {
951
952
  body.signal_factors = params.signalFactors;
952
953
  }
953
954
  return this.client.request("POST", "/v1/quant/backtest", {
954
- body,
955
- timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
955
+ body
956
956
  });
957
957
  }
958
958
  /**
@@ -1039,8 +1039,7 @@ var QuantModule = class _QuantModule {
1039
1039
  formData.append("signal_factors", JSON.stringify(params.signalFactors));
1040
1040
  }
1041
1041
  return this.client.request("POST", "/v1/quant/backtest/upload", {
1042
- formData,
1043
- timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
1042
+ formData
1044
1043
  });
1045
1044
  }
1046
1045
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reportify-sdk",
3
- "version": "0.3.32",
3
+ "version": "0.3.34",
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",