reportify-sdk 0.3.2 → 0.3.4
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 +3 -3
- package/dist/index.d.mts +55 -8
- package/dist/index.d.ts +55 -8
- package/dist/index.js +57 -10
- package/dist/index.mjs +57 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ const macd = await client.quant.computeIndicators({
|
|
|
114
114
|
|
|
115
115
|
// Screen stocks by formula
|
|
116
116
|
const oversold = await client.quant.screen({ formula: 'RSI(14) < 30' });
|
|
117
|
-
const goldenCross = await client.quant.screen({ formula: 'CROSS(MA(5), MA(20))' });
|
|
117
|
+
const goldenCross = await client.quant.screen({ formula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))' });
|
|
118
118
|
|
|
119
119
|
// Get OHLCV data
|
|
120
120
|
const ohlcv = await client.quant.ohlcv({ symbol: '000001', startDate: '2024-01-01' });
|
|
@@ -125,8 +125,8 @@ const result = await client.quant.backtest({
|
|
|
125
125
|
startDate: '2023-01-01',
|
|
126
126
|
endDate: '2024-01-01',
|
|
127
127
|
symbol: '000001',
|
|
128
|
-
entryFormula: 'CROSS(MA(5), MA(20))',
|
|
129
|
-
exitFormula: 'CROSSDOWN(MA(5), MA(20))'
|
|
128
|
+
entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))',
|
|
129
|
+
exitFormula: 'CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))'
|
|
130
130
|
});
|
|
131
131
|
console.log(`Total Return: ${(result.total_return_pct * 100).toFixed(2)}%`);
|
|
132
132
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -800,6 +800,8 @@ declare class QuantModule {
|
|
|
800
800
|
/**
|
|
801
801
|
* Get list of available technical indicators
|
|
802
802
|
*
|
|
803
|
+
* All indicators are functions and require parentheses when used (e.g., MA(CLOSE, 20), RSI(14), MACD()).
|
|
804
|
+
*
|
|
803
805
|
* @returns Array of indicator definitions
|
|
804
806
|
*
|
|
805
807
|
* @example
|
|
@@ -815,6 +817,10 @@ declare class QuantModule {
|
|
|
815
817
|
/**
|
|
816
818
|
* Compute indicator values for given symbols
|
|
817
819
|
*
|
|
820
|
+
* Variables vs Functions:
|
|
821
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME (aliases: C, O, H, L, V, VOL)
|
|
822
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), RSI(14), MACD(), etc.
|
|
823
|
+
*
|
|
818
824
|
* @param params - Indicator computation parameters
|
|
819
825
|
* @returns Array of indicator data
|
|
820
826
|
*
|
|
@@ -831,12 +837,22 @@ declare class QuantModule {
|
|
|
831
837
|
* symbols: ['000001'],
|
|
832
838
|
* formula: 'MACD()'
|
|
833
839
|
* });
|
|
840
|
+
*
|
|
841
|
+
* // Standard deviation
|
|
842
|
+
* const data = await client.quant.computeIndicators({
|
|
843
|
+
* symbols: ['000001'],
|
|
844
|
+
* formula: 'STD(CLOSE, 20)'
|
|
845
|
+
* });
|
|
834
846
|
* ```
|
|
835
847
|
*/
|
|
836
848
|
computeIndicators(params: IndicatorComputeParams): Promise<IndicatorData[]>;
|
|
837
849
|
/**
|
|
838
850
|
* Get list of available factors (variables and functions)
|
|
839
851
|
*
|
|
852
|
+
* Variables vs Functions:
|
|
853
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, PE_TTM, ROE_TTM, etc.
|
|
854
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
855
|
+
*
|
|
840
856
|
* @returns Array of factor definitions organized by level
|
|
841
857
|
*/
|
|
842
858
|
listFactors(): Promise<FactorMeta[]>;
|
|
@@ -845,6 +861,10 @@ declare class QuantModule {
|
|
|
845
861
|
*
|
|
846
862
|
* Uses Mai-language syntax compatible with TongDaXin/TongHuaShun.
|
|
847
863
|
*
|
|
864
|
+
* Variables vs Functions:
|
|
865
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
866
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
867
|
+
*
|
|
848
868
|
* @param params - Factor computation parameters
|
|
849
869
|
* @returns Array of factor data
|
|
850
870
|
*
|
|
@@ -865,7 +885,13 @@ declare class QuantModule {
|
|
|
865
885
|
* // Close above 20-day MA
|
|
866
886
|
* const data = await client.quant.computeFactors({
|
|
867
887
|
* symbols: ['000001'],
|
|
868
|
-
* formula: 'CLOSE > MA(20)'
|
|
888
|
+
* formula: 'CLOSE > MA(CLOSE, 20)'
|
|
889
|
+
* });
|
|
890
|
+
*
|
|
891
|
+
* // Fundamental factors (note: functions require parentheses)
|
|
892
|
+
* const data = await client.quant.computeFactors({
|
|
893
|
+
* symbols: ['000001'],
|
|
894
|
+
* formula: 'PE()'
|
|
869
895
|
* });
|
|
870
896
|
* ```
|
|
871
897
|
*/
|
|
@@ -873,6 +899,10 @@ declare class QuantModule {
|
|
|
873
899
|
/**
|
|
874
900
|
* Screen stocks based on factor formula
|
|
875
901
|
*
|
|
902
|
+
* Variables vs Functions:
|
|
903
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
904
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
905
|
+
*
|
|
876
906
|
* @param params - Screening parameters
|
|
877
907
|
* @returns Array of stocks that passed the filter
|
|
878
908
|
*
|
|
@@ -885,12 +915,17 @@ declare class QuantModule {
|
|
|
885
915
|
*
|
|
886
916
|
* // Golden cross
|
|
887
917
|
* const stocks = await client.quant.screen({
|
|
888
|
-
* formula: 'CROSS(MA(5), MA(10))'
|
|
918
|
+
* formula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 10))'
|
|
889
919
|
* });
|
|
890
920
|
*
|
|
891
921
|
* // Uptrend
|
|
892
922
|
* const stocks = await client.quant.screen({
|
|
893
|
-
* formula: '(CLOSE > MA(20)) & (MA(20) > MA(60))'
|
|
923
|
+
* formula: '(CLOSE > MA(CLOSE, 20)) & (MA(CLOSE, 20) > MA(CLOSE, 60))'
|
|
924
|
+
* });
|
|
925
|
+
*
|
|
926
|
+
* // Fundamental screening (note: functions require parentheses)
|
|
927
|
+
* const stocks = await client.quant.screen({
|
|
928
|
+
* formula: '(PE() < 20) & (ROE() > 0.15)'
|
|
894
929
|
* });
|
|
895
930
|
* ```
|
|
896
931
|
*/
|
|
@@ -928,6 +963,10 @@ declare class QuantModule {
|
|
|
928
963
|
/**
|
|
929
964
|
* Execute strategy backtest
|
|
930
965
|
*
|
|
966
|
+
* Variables vs Functions:
|
|
967
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
968
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
969
|
+
*
|
|
931
970
|
* @param params - Backtest parameters
|
|
932
971
|
* @returns Backtest results
|
|
933
972
|
*
|
|
@@ -938,7 +977,7 @@ declare class QuantModule {
|
|
|
938
977
|
* startDate: '2023-01-01',
|
|
939
978
|
* endDate: '2024-01-01',
|
|
940
979
|
* symbol: '000001',
|
|
941
|
-
* entryFormula: 'CROSS(MA(5), MA(20))', // Buy when MA5 crosses above MA20
|
|
980
|
+
* entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))', // Buy when MA5 crosses above MA20
|
|
942
981
|
* initialCash: 100000
|
|
943
982
|
* });
|
|
944
983
|
*
|
|
@@ -951,18 +990,26 @@ declare class QuantModule {
|
|
|
951
990
|
* startDate: '2023-01-01',
|
|
952
991
|
* endDate: '2024-01-01',
|
|
953
992
|
* symbol: '000001',
|
|
954
|
-
* entryFormula: 'CROSS(MA(5), MA(20))', // Buy signal
|
|
955
|
-
* exitFormula: 'CROSSDOWN(MA(5), MA(20))' // Sell signal
|
|
993
|
+
* entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))', // Buy signal
|
|
994
|
+
* exitFormula: 'CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))' // Sell signal
|
|
956
995
|
* });
|
|
957
996
|
*
|
|
958
|
-
* //
|
|
997
|
+
* // Fundamental screening backtest (note: functions require parentheses)
|
|
959
998
|
* const result3 = await client.quant.backtest({
|
|
960
999
|
* startDate: '2023-01-01',
|
|
961
1000
|
* endDate: '2024-01-01',
|
|
962
1001
|
* symbol: '000001',
|
|
1002
|
+
* entryFormula: '(PE() < 20) & (ROE() > 0.15)'
|
|
1003
|
+
* });
|
|
1004
|
+
*
|
|
1005
|
+
* // With custom labels for analysis
|
|
1006
|
+
* const result4 = await client.quant.backtest({
|
|
1007
|
+
* startDate: '2023-01-01',
|
|
1008
|
+
* endDate: '2024-01-01',
|
|
1009
|
+
* symbol: '000001',
|
|
963
1010
|
* entryFormula: 'RSI(14) < 30',
|
|
964
1011
|
* exitFormula: 'RSI(14) > 70',
|
|
965
|
-
* labels: { rsi: 'RSI(14)', ma20: 'MA(20)' }
|
|
1012
|
+
* labels: { rsi: 'RSI(14)', ma20: 'MA(CLOSE, 20)' }
|
|
966
1013
|
* });
|
|
967
1014
|
* ```
|
|
968
1015
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -800,6 +800,8 @@ declare class QuantModule {
|
|
|
800
800
|
/**
|
|
801
801
|
* Get list of available technical indicators
|
|
802
802
|
*
|
|
803
|
+
* All indicators are functions and require parentheses when used (e.g., MA(CLOSE, 20), RSI(14), MACD()).
|
|
804
|
+
*
|
|
803
805
|
* @returns Array of indicator definitions
|
|
804
806
|
*
|
|
805
807
|
* @example
|
|
@@ -815,6 +817,10 @@ declare class QuantModule {
|
|
|
815
817
|
/**
|
|
816
818
|
* Compute indicator values for given symbols
|
|
817
819
|
*
|
|
820
|
+
* Variables vs Functions:
|
|
821
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME (aliases: C, O, H, L, V, VOL)
|
|
822
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), RSI(14), MACD(), etc.
|
|
823
|
+
*
|
|
818
824
|
* @param params - Indicator computation parameters
|
|
819
825
|
* @returns Array of indicator data
|
|
820
826
|
*
|
|
@@ -831,12 +837,22 @@ declare class QuantModule {
|
|
|
831
837
|
* symbols: ['000001'],
|
|
832
838
|
* formula: 'MACD()'
|
|
833
839
|
* });
|
|
840
|
+
*
|
|
841
|
+
* // Standard deviation
|
|
842
|
+
* const data = await client.quant.computeIndicators({
|
|
843
|
+
* symbols: ['000001'],
|
|
844
|
+
* formula: 'STD(CLOSE, 20)'
|
|
845
|
+
* });
|
|
834
846
|
* ```
|
|
835
847
|
*/
|
|
836
848
|
computeIndicators(params: IndicatorComputeParams): Promise<IndicatorData[]>;
|
|
837
849
|
/**
|
|
838
850
|
* Get list of available factors (variables and functions)
|
|
839
851
|
*
|
|
852
|
+
* Variables vs Functions:
|
|
853
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, PE_TTM, ROE_TTM, etc.
|
|
854
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
855
|
+
*
|
|
840
856
|
* @returns Array of factor definitions organized by level
|
|
841
857
|
*/
|
|
842
858
|
listFactors(): Promise<FactorMeta[]>;
|
|
@@ -845,6 +861,10 @@ declare class QuantModule {
|
|
|
845
861
|
*
|
|
846
862
|
* Uses Mai-language syntax compatible with TongDaXin/TongHuaShun.
|
|
847
863
|
*
|
|
864
|
+
* Variables vs Functions:
|
|
865
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
866
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
867
|
+
*
|
|
848
868
|
* @param params - Factor computation parameters
|
|
849
869
|
* @returns Array of factor data
|
|
850
870
|
*
|
|
@@ -865,7 +885,13 @@ declare class QuantModule {
|
|
|
865
885
|
* // Close above 20-day MA
|
|
866
886
|
* const data = await client.quant.computeFactors({
|
|
867
887
|
* symbols: ['000001'],
|
|
868
|
-
* formula: 'CLOSE > MA(20)'
|
|
888
|
+
* formula: 'CLOSE > MA(CLOSE, 20)'
|
|
889
|
+
* });
|
|
890
|
+
*
|
|
891
|
+
* // Fundamental factors (note: functions require parentheses)
|
|
892
|
+
* const data = await client.quant.computeFactors({
|
|
893
|
+
* symbols: ['000001'],
|
|
894
|
+
* formula: 'PE()'
|
|
869
895
|
* });
|
|
870
896
|
* ```
|
|
871
897
|
*/
|
|
@@ -873,6 +899,10 @@ declare class QuantModule {
|
|
|
873
899
|
/**
|
|
874
900
|
* Screen stocks based on factor formula
|
|
875
901
|
*
|
|
902
|
+
* Variables vs Functions:
|
|
903
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
904
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
905
|
+
*
|
|
876
906
|
* @param params - Screening parameters
|
|
877
907
|
* @returns Array of stocks that passed the filter
|
|
878
908
|
*
|
|
@@ -885,12 +915,17 @@ declare class QuantModule {
|
|
|
885
915
|
*
|
|
886
916
|
* // Golden cross
|
|
887
917
|
* const stocks = await client.quant.screen({
|
|
888
|
-
* formula: 'CROSS(MA(5), MA(10))'
|
|
918
|
+
* formula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 10))'
|
|
889
919
|
* });
|
|
890
920
|
*
|
|
891
921
|
* // Uptrend
|
|
892
922
|
* const stocks = await client.quant.screen({
|
|
893
|
-
* formula: '(CLOSE > MA(20)) & (MA(20) > MA(60))'
|
|
923
|
+
* formula: '(CLOSE > MA(CLOSE, 20)) & (MA(CLOSE, 20) > MA(CLOSE, 60))'
|
|
924
|
+
* });
|
|
925
|
+
*
|
|
926
|
+
* // Fundamental screening (note: functions require parentheses)
|
|
927
|
+
* const stocks = await client.quant.screen({
|
|
928
|
+
* formula: '(PE() < 20) & (ROE() > 0.15)'
|
|
894
929
|
* });
|
|
895
930
|
* ```
|
|
896
931
|
*/
|
|
@@ -928,6 +963,10 @@ declare class QuantModule {
|
|
|
928
963
|
/**
|
|
929
964
|
* Execute strategy backtest
|
|
930
965
|
*
|
|
966
|
+
* Variables vs Functions:
|
|
967
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
968
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
969
|
+
*
|
|
931
970
|
* @param params - Backtest parameters
|
|
932
971
|
* @returns Backtest results
|
|
933
972
|
*
|
|
@@ -938,7 +977,7 @@ declare class QuantModule {
|
|
|
938
977
|
* startDate: '2023-01-01',
|
|
939
978
|
* endDate: '2024-01-01',
|
|
940
979
|
* symbol: '000001',
|
|
941
|
-
* entryFormula: 'CROSS(MA(5), MA(20))', // Buy when MA5 crosses above MA20
|
|
980
|
+
* entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))', // Buy when MA5 crosses above MA20
|
|
942
981
|
* initialCash: 100000
|
|
943
982
|
* });
|
|
944
983
|
*
|
|
@@ -951,18 +990,26 @@ declare class QuantModule {
|
|
|
951
990
|
* startDate: '2023-01-01',
|
|
952
991
|
* endDate: '2024-01-01',
|
|
953
992
|
* symbol: '000001',
|
|
954
|
-
* entryFormula: 'CROSS(MA(5), MA(20))', // Buy signal
|
|
955
|
-
* exitFormula: 'CROSSDOWN(MA(5), MA(20))' // Sell signal
|
|
993
|
+
* entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))', // Buy signal
|
|
994
|
+
* exitFormula: 'CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))' // Sell signal
|
|
956
995
|
* });
|
|
957
996
|
*
|
|
958
|
-
* //
|
|
997
|
+
* // Fundamental screening backtest (note: functions require parentheses)
|
|
959
998
|
* const result3 = await client.quant.backtest({
|
|
960
999
|
* startDate: '2023-01-01',
|
|
961
1000
|
* endDate: '2024-01-01',
|
|
962
1001
|
* symbol: '000001',
|
|
1002
|
+
* entryFormula: '(PE() < 20) & (ROE() > 0.15)'
|
|
1003
|
+
* });
|
|
1004
|
+
*
|
|
1005
|
+
* // With custom labels for analysis
|
|
1006
|
+
* const result4 = await client.quant.backtest({
|
|
1007
|
+
* startDate: '2023-01-01',
|
|
1008
|
+
* endDate: '2024-01-01',
|
|
1009
|
+
* symbol: '000001',
|
|
963
1010
|
* entryFormula: 'RSI(14) < 30',
|
|
964
1011
|
* exitFormula: 'RSI(14) > 70',
|
|
965
|
-
* labels: { rsi: 'RSI(14)', ma20: 'MA(20)' }
|
|
1012
|
+
* labels: { rsi: 'RSI(14)', ma20: 'MA(CLOSE, 20)' }
|
|
966
1013
|
* });
|
|
967
1014
|
* ```
|
|
968
1015
|
*/
|
package/dist/index.js
CHANGED
|
@@ -663,6 +663,8 @@ var QuantModule = class {
|
|
|
663
663
|
/**
|
|
664
664
|
* Get list of available technical indicators
|
|
665
665
|
*
|
|
666
|
+
* All indicators are functions and require parentheses when used (e.g., MA(CLOSE, 20), RSI(14), MACD()).
|
|
667
|
+
*
|
|
666
668
|
* @returns Array of indicator definitions
|
|
667
669
|
*
|
|
668
670
|
* @example
|
|
@@ -680,6 +682,10 @@ var QuantModule = class {
|
|
|
680
682
|
/**
|
|
681
683
|
* Compute indicator values for given symbols
|
|
682
684
|
*
|
|
685
|
+
* Variables vs Functions:
|
|
686
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME (aliases: C, O, H, L, V, VOL)
|
|
687
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), RSI(14), MACD(), etc.
|
|
688
|
+
*
|
|
683
689
|
* @param params - Indicator computation parameters
|
|
684
690
|
* @returns Array of indicator data
|
|
685
691
|
*
|
|
@@ -696,6 +702,12 @@ var QuantModule = class {
|
|
|
696
702
|
* symbols: ['000001'],
|
|
697
703
|
* formula: 'MACD()'
|
|
698
704
|
* });
|
|
705
|
+
*
|
|
706
|
+
* // Standard deviation
|
|
707
|
+
* const data = await client.quant.computeIndicators({
|
|
708
|
+
* symbols: ['000001'],
|
|
709
|
+
* formula: 'STD(CLOSE, 20)'
|
|
710
|
+
* });
|
|
699
711
|
* ```
|
|
700
712
|
*/
|
|
701
713
|
async computeIndicators(params) {
|
|
@@ -714,6 +726,10 @@ var QuantModule = class {
|
|
|
714
726
|
/**
|
|
715
727
|
* Get list of available factors (variables and functions)
|
|
716
728
|
*
|
|
729
|
+
* Variables vs Functions:
|
|
730
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, PE_TTM, ROE_TTM, etc.
|
|
731
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
732
|
+
*
|
|
717
733
|
* @returns Array of factor definitions organized by level
|
|
718
734
|
*/
|
|
719
735
|
async listFactors() {
|
|
@@ -724,6 +740,10 @@ var QuantModule = class {
|
|
|
724
740
|
*
|
|
725
741
|
* Uses Mai-language syntax compatible with TongDaXin/TongHuaShun.
|
|
726
742
|
*
|
|
743
|
+
* Variables vs Functions:
|
|
744
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
745
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
746
|
+
*
|
|
727
747
|
* @param params - Factor computation parameters
|
|
728
748
|
* @returns Array of factor data
|
|
729
749
|
*
|
|
@@ -744,7 +764,13 @@ var QuantModule = class {
|
|
|
744
764
|
* // Close above 20-day MA
|
|
745
765
|
* const data = await client.quant.computeFactors({
|
|
746
766
|
* symbols: ['000001'],
|
|
747
|
-
* formula: 'CLOSE > MA(20)'
|
|
767
|
+
* formula: 'CLOSE > MA(CLOSE, 20)'
|
|
768
|
+
* });
|
|
769
|
+
*
|
|
770
|
+
* // Fundamental factors (note: functions require parentheses)
|
|
771
|
+
* const data = await client.quant.computeFactors({
|
|
772
|
+
* symbols: ['000001'],
|
|
773
|
+
* formula: 'PE()'
|
|
748
774
|
* });
|
|
749
775
|
* ```
|
|
750
776
|
*/
|
|
@@ -761,6 +787,10 @@ var QuantModule = class {
|
|
|
761
787
|
/**
|
|
762
788
|
* Screen stocks based on factor formula
|
|
763
789
|
*
|
|
790
|
+
* Variables vs Functions:
|
|
791
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
792
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
793
|
+
*
|
|
764
794
|
* @param params - Screening parameters
|
|
765
795
|
* @returns Array of stocks that passed the filter
|
|
766
796
|
*
|
|
@@ -773,12 +803,17 @@ var QuantModule = class {
|
|
|
773
803
|
*
|
|
774
804
|
* // Golden cross
|
|
775
805
|
* const stocks = await client.quant.screen({
|
|
776
|
-
* formula: 'CROSS(MA(5), MA(10))'
|
|
806
|
+
* formula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 10))'
|
|
777
807
|
* });
|
|
778
808
|
*
|
|
779
809
|
* // Uptrend
|
|
780
810
|
* const stocks = await client.quant.screen({
|
|
781
|
-
* formula: '(CLOSE > MA(20)) & (MA(20) > MA(60))'
|
|
811
|
+
* formula: '(CLOSE > MA(CLOSE, 20)) & (MA(CLOSE, 20) > MA(CLOSE, 60))'
|
|
812
|
+
* });
|
|
813
|
+
*
|
|
814
|
+
* // Fundamental screening (note: functions require parentheses)
|
|
815
|
+
* const stocks = await client.quant.screen({
|
|
816
|
+
* formula: '(PE() < 20) & (ROE() > 0.15)'
|
|
782
817
|
* });
|
|
783
818
|
* ```
|
|
784
819
|
*/
|
|
@@ -846,6 +881,10 @@ var QuantModule = class {
|
|
|
846
881
|
/**
|
|
847
882
|
* Execute strategy backtest
|
|
848
883
|
*
|
|
884
|
+
* Variables vs Functions:
|
|
885
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
886
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
887
|
+
*
|
|
849
888
|
* @param params - Backtest parameters
|
|
850
889
|
* @returns Backtest results
|
|
851
890
|
*
|
|
@@ -856,7 +895,7 @@ var QuantModule = class {
|
|
|
856
895
|
* startDate: '2023-01-01',
|
|
857
896
|
* endDate: '2024-01-01',
|
|
858
897
|
* symbol: '000001',
|
|
859
|
-
* entryFormula: 'CROSS(MA(5), MA(20))', // Buy when MA5 crosses above MA20
|
|
898
|
+
* entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))', // Buy when MA5 crosses above MA20
|
|
860
899
|
* initialCash: 100000
|
|
861
900
|
* });
|
|
862
901
|
*
|
|
@@ -869,18 +908,26 @@ var QuantModule = class {
|
|
|
869
908
|
* startDate: '2023-01-01',
|
|
870
909
|
* endDate: '2024-01-01',
|
|
871
910
|
* symbol: '000001',
|
|
872
|
-
* entryFormula: 'CROSS(MA(5), MA(20))', // Buy signal
|
|
873
|
-
* exitFormula: 'CROSSDOWN(MA(5), MA(20))' // Sell signal
|
|
911
|
+
* entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))', // Buy signal
|
|
912
|
+
* exitFormula: 'CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))' // Sell signal
|
|
874
913
|
* });
|
|
875
914
|
*
|
|
876
|
-
* //
|
|
915
|
+
* // Fundamental screening backtest (note: functions require parentheses)
|
|
877
916
|
* const result3 = await client.quant.backtest({
|
|
878
917
|
* startDate: '2023-01-01',
|
|
879
918
|
* endDate: '2024-01-01',
|
|
880
919
|
* symbol: '000001',
|
|
920
|
+
* entryFormula: '(PE() < 20) & (ROE() > 0.15)'
|
|
921
|
+
* });
|
|
922
|
+
*
|
|
923
|
+
* // With custom labels for analysis
|
|
924
|
+
* const result4 = await client.quant.backtest({
|
|
925
|
+
* startDate: '2023-01-01',
|
|
926
|
+
* endDate: '2024-01-01',
|
|
927
|
+
* symbol: '000001',
|
|
881
928
|
* entryFormula: 'RSI(14) < 30',
|
|
882
929
|
* exitFormula: 'RSI(14) > 70',
|
|
883
|
-
* labels: { rsi: 'RSI(14)', ma20: 'MA(20)' }
|
|
930
|
+
* labels: { rsi: 'RSI(14)', ma20: 'MA(CLOSE, 20)' }
|
|
884
931
|
* });
|
|
885
932
|
* ```
|
|
886
933
|
*/
|
|
@@ -1664,7 +1711,7 @@ var Reportify = class {
|
|
|
1664
1711
|
headers: {
|
|
1665
1712
|
Authorization: `Bearer ${this.apiKey}`,
|
|
1666
1713
|
"Content-Type": "application/json",
|
|
1667
|
-
"User-Agent": "reportify-sdk-js/0.3.
|
|
1714
|
+
"User-Agent": "reportify-sdk-js/0.3.4"
|
|
1668
1715
|
},
|
|
1669
1716
|
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
1670
1717
|
signal: controller.signal
|
|
@@ -1725,7 +1772,7 @@ var Reportify = class {
|
|
|
1725
1772
|
headers: {
|
|
1726
1773
|
Authorization: `Bearer ${this.apiKey}`,
|
|
1727
1774
|
"Content-Type": "application/json",
|
|
1728
|
-
"User-Agent": "reportify-sdk-typescript/0.3.
|
|
1775
|
+
"User-Agent": "reportify-sdk-typescript/0.3.4"
|
|
1729
1776
|
}
|
|
1730
1777
|
});
|
|
1731
1778
|
if (!response.ok) {
|
package/dist/index.mjs
CHANGED
|
@@ -621,6 +621,8 @@ var QuantModule = class {
|
|
|
621
621
|
/**
|
|
622
622
|
* Get list of available technical indicators
|
|
623
623
|
*
|
|
624
|
+
* All indicators are functions and require parentheses when used (e.g., MA(CLOSE, 20), RSI(14), MACD()).
|
|
625
|
+
*
|
|
624
626
|
* @returns Array of indicator definitions
|
|
625
627
|
*
|
|
626
628
|
* @example
|
|
@@ -638,6 +640,10 @@ var QuantModule = class {
|
|
|
638
640
|
/**
|
|
639
641
|
* Compute indicator values for given symbols
|
|
640
642
|
*
|
|
643
|
+
* Variables vs Functions:
|
|
644
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME (aliases: C, O, H, L, V, VOL)
|
|
645
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), RSI(14), MACD(), etc.
|
|
646
|
+
*
|
|
641
647
|
* @param params - Indicator computation parameters
|
|
642
648
|
* @returns Array of indicator data
|
|
643
649
|
*
|
|
@@ -654,6 +660,12 @@ var QuantModule = class {
|
|
|
654
660
|
* symbols: ['000001'],
|
|
655
661
|
* formula: 'MACD()'
|
|
656
662
|
* });
|
|
663
|
+
*
|
|
664
|
+
* // Standard deviation
|
|
665
|
+
* const data = await client.quant.computeIndicators({
|
|
666
|
+
* symbols: ['000001'],
|
|
667
|
+
* formula: 'STD(CLOSE, 20)'
|
|
668
|
+
* });
|
|
657
669
|
* ```
|
|
658
670
|
*/
|
|
659
671
|
async computeIndicators(params) {
|
|
@@ -672,6 +684,10 @@ var QuantModule = class {
|
|
|
672
684
|
/**
|
|
673
685
|
* Get list of available factors (variables and functions)
|
|
674
686
|
*
|
|
687
|
+
* Variables vs Functions:
|
|
688
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, PE_TTM, ROE_TTM, etc.
|
|
689
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
690
|
+
*
|
|
675
691
|
* @returns Array of factor definitions organized by level
|
|
676
692
|
*/
|
|
677
693
|
async listFactors() {
|
|
@@ -682,6 +698,10 @@ var QuantModule = class {
|
|
|
682
698
|
*
|
|
683
699
|
* Uses Mai-language syntax compatible with TongDaXin/TongHuaShun.
|
|
684
700
|
*
|
|
701
|
+
* Variables vs Functions:
|
|
702
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
703
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
704
|
+
*
|
|
685
705
|
* @param params - Factor computation parameters
|
|
686
706
|
* @returns Array of factor data
|
|
687
707
|
*
|
|
@@ -702,7 +722,13 @@ var QuantModule = class {
|
|
|
702
722
|
* // Close above 20-day MA
|
|
703
723
|
* const data = await client.quant.computeFactors({
|
|
704
724
|
* symbols: ['000001'],
|
|
705
|
-
* formula: 'CLOSE > MA(20)'
|
|
725
|
+
* formula: 'CLOSE > MA(CLOSE, 20)'
|
|
726
|
+
* });
|
|
727
|
+
*
|
|
728
|
+
* // Fundamental factors (note: functions require parentheses)
|
|
729
|
+
* const data = await client.quant.computeFactors({
|
|
730
|
+
* symbols: ['000001'],
|
|
731
|
+
* formula: 'PE()'
|
|
706
732
|
* });
|
|
707
733
|
* ```
|
|
708
734
|
*/
|
|
@@ -719,6 +745,10 @@ var QuantModule = class {
|
|
|
719
745
|
/**
|
|
720
746
|
* Screen stocks based on factor formula
|
|
721
747
|
*
|
|
748
|
+
* Variables vs Functions:
|
|
749
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
750
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
751
|
+
*
|
|
722
752
|
* @param params - Screening parameters
|
|
723
753
|
* @returns Array of stocks that passed the filter
|
|
724
754
|
*
|
|
@@ -731,12 +761,17 @@ var QuantModule = class {
|
|
|
731
761
|
*
|
|
732
762
|
* // Golden cross
|
|
733
763
|
* const stocks = await client.quant.screen({
|
|
734
|
-
* formula: 'CROSS(MA(5), MA(10))'
|
|
764
|
+
* formula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 10))'
|
|
735
765
|
* });
|
|
736
766
|
*
|
|
737
767
|
* // Uptrend
|
|
738
768
|
* const stocks = await client.quant.screen({
|
|
739
|
-
* formula: '(CLOSE > MA(20)) & (MA(20) > MA(60))'
|
|
769
|
+
* formula: '(CLOSE > MA(CLOSE, 20)) & (MA(CLOSE, 20) > MA(CLOSE, 60))'
|
|
770
|
+
* });
|
|
771
|
+
*
|
|
772
|
+
* // Fundamental screening (note: functions require parentheses)
|
|
773
|
+
* const stocks = await client.quant.screen({
|
|
774
|
+
* formula: '(PE() < 20) & (ROE() > 0.15)'
|
|
740
775
|
* });
|
|
741
776
|
* ```
|
|
742
777
|
*/
|
|
@@ -804,6 +839,10 @@ var QuantModule = class {
|
|
|
804
839
|
/**
|
|
805
840
|
* Execute strategy backtest
|
|
806
841
|
*
|
|
842
|
+
* Variables vs Functions:
|
|
843
|
+
* - Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
844
|
+
* - Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
845
|
+
*
|
|
807
846
|
* @param params - Backtest parameters
|
|
808
847
|
* @returns Backtest results
|
|
809
848
|
*
|
|
@@ -814,7 +853,7 @@ var QuantModule = class {
|
|
|
814
853
|
* startDate: '2023-01-01',
|
|
815
854
|
* endDate: '2024-01-01',
|
|
816
855
|
* symbol: '000001',
|
|
817
|
-
* entryFormula: 'CROSS(MA(5), MA(20))', // Buy when MA5 crosses above MA20
|
|
856
|
+
* entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))', // Buy when MA5 crosses above MA20
|
|
818
857
|
* initialCash: 100000
|
|
819
858
|
* });
|
|
820
859
|
*
|
|
@@ -827,18 +866,26 @@ var QuantModule = class {
|
|
|
827
866
|
* startDate: '2023-01-01',
|
|
828
867
|
* endDate: '2024-01-01',
|
|
829
868
|
* symbol: '000001',
|
|
830
|
-
* entryFormula: 'CROSS(MA(5), MA(20))', // Buy signal
|
|
831
|
-
* exitFormula: 'CROSSDOWN(MA(5), MA(20))' // Sell signal
|
|
869
|
+
* entryFormula: 'CROSS(MA(CLOSE, 5), MA(CLOSE, 20))', // Buy signal
|
|
870
|
+
* exitFormula: 'CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))' // Sell signal
|
|
832
871
|
* });
|
|
833
872
|
*
|
|
834
|
-
* //
|
|
873
|
+
* // Fundamental screening backtest (note: functions require parentheses)
|
|
835
874
|
* const result3 = await client.quant.backtest({
|
|
836
875
|
* startDate: '2023-01-01',
|
|
837
876
|
* endDate: '2024-01-01',
|
|
838
877
|
* symbol: '000001',
|
|
878
|
+
* entryFormula: '(PE() < 20) & (ROE() > 0.15)'
|
|
879
|
+
* });
|
|
880
|
+
*
|
|
881
|
+
* // With custom labels for analysis
|
|
882
|
+
* const result4 = await client.quant.backtest({
|
|
883
|
+
* startDate: '2023-01-01',
|
|
884
|
+
* endDate: '2024-01-01',
|
|
885
|
+
* symbol: '000001',
|
|
839
886
|
* entryFormula: 'RSI(14) < 30',
|
|
840
887
|
* exitFormula: 'RSI(14) > 70',
|
|
841
|
-
* labels: { rsi: 'RSI(14)', ma20: 'MA(20)' }
|
|
888
|
+
* labels: { rsi: 'RSI(14)', ma20: 'MA(CLOSE, 20)' }
|
|
842
889
|
* });
|
|
843
890
|
* ```
|
|
844
891
|
*/
|
|
@@ -1622,7 +1669,7 @@ var Reportify = class {
|
|
|
1622
1669
|
headers: {
|
|
1623
1670
|
Authorization: `Bearer ${this.apiKey}`,
|
|
1624
1671
|
"Content-Type": "application/json",
|
|
1625
|
-
"User-Agent": "reportify-sdk-js/0.3.
|
|
1672
|
+
"User-Agent": "reportify-sdk-js/0.3.4"
|
|
1626
1673
|
},
|
|
1627
1674
|
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
1628
1675
|
signal: controller.signal
|
|
@@ -1683,7 +1730,7 @@ var Reportify = class {
|
|
|
1683
1730
|
headers: {
|
|
1684
1731
|
Authorization: `Bearer ${this.apiKey}`,
|
|
1685
1732
|
"Content-Type": "application/json",
|
|
1686
|
-
"User-Agent": "reportify-sdk-typescript/0.3.
|
|
1733
|
+
"User-Agent": "reportify-sdk-typescript/0.3.4"
|
|
1687
1734
|
}
|
|
1688
1735
|
});
|
|
1689
1736
|
if (!response.ok) {
|