reportify-sdk 0.3.30 → 0.3.32
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/dist/index.d.mts +36 -25
- package/dist/index.d.ts +36 -25
- package/dist/index.js +62 -31
- package/dist/index.mjs +62 -31
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -736,23 +736,28 @@ interface BacktestParams {
|
|
|
736
736
|
minCommissionAmount?: number;
|
|
737
737
|
slippage?: number;
|
|
738
738
|
stopLoss?: number;
|
|
739
|
-
positionSize?: number;
|
|
740
|
-
maxPositions?: number;
|
|
739
|
+
positionSize?: number | null;
|
|
740
|
+
maxPositions?: number | null;
|
|
741
741
|
minVolume?: number;
|
|
742
742
|
autoClose?: boolean;
|
|
743
|
+
cheatOnOpen?: boolean;
|
|
743
744
|
signalFactors?: Record<string, string>;
|
|
744
745
|
}
|
|
745
|
-
interface
|
|
746
|
+
interface KlineParams {
|
|
746
747
|
symbol: string;
|
|
747
|
-
|
|
748
|
-
endDateTime: string;
|
|
748
|
+
klineType?: '1M' | '5M' | '15M' | '30M' | '60M' | '1D' | '1W' | '1MO';
|
|
749
749
|
market?: StockMarket;
|
|
750
|
+
stockType?: 'stock' | 'etf' | 'index' | 'sw';
|
|
751
|
+
startDateTime?: string;
|
|
752
|
+
endDateTime?: string;
|
|
750
753
|
}
|
|
751
|
-
interface
|
|
754
|
+
interface BatchKlineParams {
|
|
752
755
|
symbols: string[];
|
|
753
|
-
|
|
754
|
-
endDateTime: string;
|
|
756
|
+
klineType?: '1M' | '5M' | '15M' | '30M' | '60M' | '1D' | '1W' | '1MO';
|
|
755
757
|
market?: StockMarket;
|
|
758
|
+
stockType?: 'stock' | 'etf' | 'index' | 'sw';
|
|
759
|
+
startDateTime?: string;
|
|
760
|
+
endDateTime?: string;
|
|
756
761
|
}
|
|
757
762
|
interface MinuteParams {
|
|
758
763
|
symbol: string;
|
|
@@ -779,10 +784,11 @@ interface BacktestUploadParams {
|
|
|
779
784
|
sellCommission?: number;
|
|
780
785
|
minCommissionAmount?: number;
|
|
781
786
|
slippage?: number;
|
|
782
|
-
positionSize?: number;
|
|
783
|
-
maxPositions?: number;
|
|
787
|
+
positionSize?: number | null;
|
|
788
|
+
maxPositions?: number | null;
|
|
784
789
|
minVolume?: number;
|
|
785
790
|
autoClose?: boolean;
|
|
791
|
+
cheatOnOpen?: boolean;
|
|
786
792
|
signalFactors?: Record<string, string>;
|
|
787
793
|
}
|
|
788
794
|
interface BacktestResult {
|
|
@@ -843,6 +849,7 @@ interface BacktestResult {
|
|
|
843
849
|
*/
|
|
844
850
|
declare class QuantModule {
|
|
845
851
|
private client;
|
|
852
|
+
private static readonly BACKTEST_TIMEOUT_MS;
|
|
846
853
|
constructor(client: Reportify);
|
|
847
854
|
/**
|
|
848
855
|
* Get list of available factors (variables, functions, and indicators)
|
|
@@ -973,37 +980,40 @@ declare class QuantModule {
|
|
|
973
980
|
/**
|
|
974
981
|
* Get 1-minute kline data for a single symbol
|
|
975
982
|
*
|
|
983
|
+
/**
|
|
984
|
+
* Get kline data for a single symbol (supports all periods)
|
|
985
|
+
*
|
|
976
986
|
* @param params - Kline parameters
|
|
977
|
-
* @returns Array of
|
|
987
|
+
* @returns Array of kline data
|
|
978
988
|
*
|
|
979
989
|
* @example
|
|
980
990
|
* ```typescript
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
*
|
|
991
|
+
* // Daily kline (default)
|
|
992
|
+
* const data = await client.quant.kline({ symbol: '000001' });
|
|
993
|
+
* // 5-minute intraday
|
|
994
|
+
* const data = await client.quant.kline({
|
|
995
|
+
* symbol: '000001', klineType: '5M',
|
|
996
|
+
* startDateTime: '2026-04-09 09:30:00',
|
|
997
|
+
* endDateTime: '2026-04-09 15:00:00'
|
|
985
998
|
* });
|
|
986
|
-
* console.log(data);
|
|
987
999
|
* ```
|
|
988
1000
|
*/
|
|
989
|
-
|
|
1001
|
+
kline(params: KlineParams): Promise<OHLCVData[]>;
|
|
990
1002
|
/**
|
|
991
|
-
* Get
|
|
1003
|
+
* Get kline data for multiple symbols (supports all periods)
|
|
992
1004
|
*
|
|
993
1005
|
* @param params - Batch kline parameters
|
|
994
|
-
* @returns Array of
|
|
1006
|
+
* @returns Array of kline data
|
|
995
1007
|
*
|
|
996
1008
|
* @example
|
|
997
1009
|
* ```typescript
|
|
998
|
-
* const data = await client.quant.
|
|
1010
|
+
* const data = await client.quant.klineBatch({
|
|
999
1011
|
* symbols: ['000001', '600519'],
|
|
1000
|
-
*
|
|
1001
|
-
* endDateTime: '2024-01-01 15:00:00'
|
|
1012
|
+
* klineType: '1D'
|
|
1002
1013
|
* });
|
|
1003
|
-
* console.log(data);
|
|
1004
1014
|
* ```
|
|
1005
1015
|
*/
|
|
1006
|
-
|
|
1016
|
+
klineBatch(params: BatchKlineParams): Promise<OHLCVData[]>;
|
|
1007
1017
|
/**
|
|
1008
1018
|
* Get minute data for a single symbol
|
|
1009
1019
|
*
|
|
@@ -1964,6 +1974,7 @@ declare class Reportify {
|
|
|
1964
1974
|
params?: Record<string, unknown>;
|
|
1965
1975
|
body?: Record<string, unknown>;
|
|
1966
1976
|
formData?: FormData;
|
|
1977
|
+
timeoutMs?: number;
|
|
1967
1978
|
}): Promise<T>;
|
|
1968
1979
|
/**
|
|
1969
1980
|
* Make a GET request
|
|
@@ -1987,4 +1998,4 @@ declare class Reportify {
|
|
|
1987
1998
|
getBytes(path: string): Promise<ArrayBuffer>;
|
|
1988
1999
|
}
|
|
1989
2000
|
|
|
1990
|
-
export { APIError, type AgentConversation, type AgentMessage, AgentModule, AuthenticationError, type BacktestParams, type BacktestResult, type BacktestUploadParams, type
|
|
2001
|
+
export { APIError, type AgentConversation, type AgentMessage, AgentModule, AuthenticationError, type BacktestParams, type BacktestResult, type BacktestUploadParams, type BatchKlineParams, type BatchMinuteParams, type BatchOHLCVOutput, type BatchOHLCVParams, type Calendar, type Channel, ChannelsModule, type ChatCompletionOptions, type ChatCompletionResponse, type ChatMode, ChatModule, type Chunk, type ChunkSearchOptions, type CommodityData, type CommodityType, type CompanyInfo, type CompanyOverview, type Concept, type ConceptDoc, type ConceptEvent, type ConceptFeed, type ConceptStock, ConceptsModule, type DocsListOptions, DocsModule, type Document, type DocumentInput, type EarningsEvent, type EarningsSearchOptions, type FactorComputeData, type FactorComputeParams, type FactorMeta, type FinancialStatement, type FollowedCompany, FollowingModule, type IPOEvent, type IPOStatus, type IndexConstituent, type IndexFund, type IndustryConstituent, KBModule, type KBSearchOptions, type KlineParams, MacroModule, type Market, type MinuteParams, NotFoundError, type OHLCVData, type OHLCVParams, type PaginatedResponse, type Period, type PriceData, QuantModule, type Quote, RateLimitError, Reportify, type ReportifyConfig, ReportifyError, type ScreenParams, type ScreenedStock, SearchModule, type SearchOptions, type Shareholder, type ShareholderType, type StockInfo, type StockMarket, StockModule, TimelineModule, type TimelineOptions, type UploadDocRequest, UserModule };
|
package/dist/index.d.ts
CHANGED
|
@@ -736,23 +736,28 @@ interface BacktestParams {
|
|
|
736
736
|
minCommissionAmount?: number;
|
|
737
737
|
slippage?: number;
|
|
738
738
|
stopLoss?: number;
|
|
739
|
-
positionSize?: number;
|
|
740
|
-
maxPositions?: number;
|
|
739
|
+
positionSize?: number | null;
|
|
740
|
+
maxPositions?: number | null;
|
|
741
741
|
minVolume?: number;
|
|
742
742
|
autoClose?: boolean;
|
|
743
|
+
cheatOnOpen?: boolean;
|
|
743
744
|
signalFactors?: Record<string, string>;
|
|
744
745
|
}
|
|
745
|
-
interface
|
|
746
|
+
interface KlineParams {
|
|
746
747
|
symbol: string;
|
|
747
|
-
|
|
748
|
-
endDateTime: string;
|
|
748
|
+
klineType?: '1M' | '5M' | '15M' | '30M' | '60M' | '1D' | '1W' | '1MO';
|
|
749
749
|
market?: StockMarket;
|
|
750
|
+
stockType?: 'stock' | 'etf' | 'index' | 'sw';
|
|
751
|
+
startDateTime?: string;
|
|
752
|
+
endDateTime?: string;
|
|
750
753
|
}
|
|
751
|
-
interface
|
|
754
|
+
interface BatchKlineParams {
|
|
752
755
|
symbols: string[];
|
|
753
|
-
|
|
754
|
-
endDateTime: string;
|
|
756
|
+
klineType?: '1M' | '5M' | '15M' | '30M' | '60M' | '1D' | '1W' | '1MO';
|
|
755
757
|
market?: StockMarket;
|
|
758
|
+
stockType?: 'stock' | 'etf' | 'index' | 'sw';
|
|
759
|
+
startDateTime?: string;
|
|
760
|
+
endDateTime?: string;
|
|
756
761
|
}
|
|
757
762
|
interface MinuteParams {
|
|
758
763
|
symbol: string;
|
|
@@ -779,10 +784,11 @@ interface BacktestUploadParams {
|
|
|
779
784
|
sellCommission?: number;
|
|
780
785
|
minCommissionAmount?: number;
|
|
781
786
|
slippage?: number;
|
|
782
|
-
positionSize?: number;
|
|
783
|
-
maxPositions?: number;
|
|
787
|
+
positionSize?: number | null;
|
|
788
|
+
maxPositions?: number | null;
|
|
784
789
|
minVolume?: number;
|
|
785
790
|
autoClose?: boolean;
|
|
791
|
+
cheatOnOpen?: boolean;
|
|
786
792
|
signalFactors?: Record<string, string>;
|
|
787
793
|
}
|
|
788
794
|
interface BacktestResult {
|
|
@@ -843,6 +849,7 @@ interface BacktestResult {
|
|
|
843
849
|
*/
|
|
844
850
|
declare class QuantModule {
|
|
845
851
|
private client;
|
|
852
|
+
private static readonly BACKTEST_TIMEOUT_MS;
|
|
846
853
|
constructor(client: Reportify);
|
|
847
854
|
/**
|
|
848
855
|
* Get list of available factors (variables, functions, and indicators)
|
|
@@ -973,37 +980,40 @@ declare class QuantModule {
|
|
|
973
980
|
/**
|
|
974
981
|
* Get 1-minute kline data for a single symbol
|
|
975
982
|
*
|
|
983
|
+
/**
|
|
984
|
+
* Get kline data for a single symbol (supports all periods)
|
|
985
|
+
*
|
|
976
986
|
* @param params - Kline parameters
|
|
977
|
-
* @returns Array of
|
|
987
|
+
* @returns Array of kline data
|
|
978
988
|
*
|
|
979
989
|
* @example
|
|
980
990
|
* ```typescript
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
*
|
|
991
|
+
* // Daily kline (default)
|
|
992
|
+
* const data = await client.quant.kline({ symbol: '000001' });
|
|
993
|
+
* // 5-minute intraday
|
|
994
|
+
* const data = await client.quant.kline({
|
|
995
|
+
* symbol: '000001', klineType: '5M',
|
|
996
|
+
* startDateTime: '2026-04-09 09:30:00',
|
|
997
|
+
* endDateTime: '2026-04-09 15:00:00'
|
|
985
998
|
* });
|
|
986
|
-
* console.log(data);
|
|
987
999
|
* ```
|
|
988
1000
|
*/
|
|
989
|
-
|
|
1001
|
+
kline(params: KlineParams): Promise<OHLCVData[]>;
|
|
990
1002
|
/**
|
|
991
|
-
* Get
|
|
1003
|
+
* Get kline data for multiple symbols (supports all periods)
|
|
992
1004
|
*
|
|
993
1005
|
* @param params - Batch kline parameters
|
|
994
|
-
* @returns Array of
|
|
1006
|
+
* @returns Array of kline data
|
|
995
1007
|
*
|
|
996
1008
|
* @example
|
|
997
1009
|
* ```typescript
|
|
998
|
-
* const data = await client.quant.
|
|
1010
|
+
* const data = await client.quant.klineBatch({
|
|
999
1011
|
* symbols: ['000001', '600519'],
|
|
1000
|
-
*
|
|
1001
|
-
* endDateTime: '2024-01-01 15:00:00'
|
|
1012
|
+
* klineType: '1D'
|
|
1002
1013
|
* });
|
|
1003
|
-
* console.log(data);
|
|
1004
1014
|
* ```
|
|
1005
1015
|
*/
|
|
1006
|
-
|
|
1016
|
+
klineBatch(params: BatchKlineParams): Promise<OHLCVData[]>;
|
|
1007
1017
|
/**
|
|
1008
1018
|
* Get minute data for a single symbol
|
|
1009
1019
|
*
|
|
@@ -1964,6 +1974,7 @@ declare class Reportify {
|
|
|
1964
1974
|
params?: Record<string, unknown>;
|
|
1965
1975
|
body?: Record<string, unknown>;
|
|
1966
1976
|
formData?: FormData;
|
|
1977
|
+
timeoutMs?: number;
|
|
1967
1978
|
}): Promise<T>;
|
|
1968
1979
|
/**
|
|
1969
1980
|
* Make a GET request
|
|
@@ -1987,4 +1998,4 @@ declare class Reportify {
|
|
|
1987
1998
|
getBytes(path: string): Promise<ArrayBuffer>;
|
|
1988
1999
|
}
|
|
1989
2000
|
|
|
1990
|
-
export { APIError, type AgentConversation, type AgentMessage, AgentModule, AuthenticationError, type BacktestParams, type BacktestResult, type BacktestUploadParams, type
|
|
2001
|
+
export { APIError, type AgentConversation, type AgentMessage, AgentModule, AuthenticationError, type BacktestParams, type BacktestResult, type BacktestUploadParams, type BatchKlineParams, type BatchMinuteParams, type BatchOHLCVOutput, type BatchOHLCVParams, type Calendar, type Channel, ChannelsModule, type ChatCompletionOptions, type ChatCompletionResponse, type ChatMode, ChatModule, type Chunk, type ChunkSearchOptions, type CommodityData, type CommodityType, type CompanyInfo, type CompanyOverview, type Concept, type ConceptDoc, type ConceptEvent, type ConceptFeed, type ConceptStock, ConceptsModule, type DocsListOptions, DocsModule, type Document, type DocumentInput, type EarningsEvent, type EarningsSearchOptions, type FactorComputeData, type FactorComputeParams, type FactorMeta, type FinancialStatement, type FollowedCompany, FollowingModule, type IPOEvent, type IPOStatus, type IndexConstituent, type IndexFund, type IndustryConstituent, KBModule, type KBSearchOptions, type KlineParams, MacroModule, type Market, type MinuteParams, NotFoundError, type OHLCVData, type OHLCVParams, type PaginatedResponse, type Period, type PriceData, QuantModule, type Quote, RateLimitError, Reportify, type ReportifyConfig, ReportifyError, type ScreenParams, type ScreenedStock, SearchModule, type SearchOptions, type Shareholder, type ShareholderType, type StockInfo, type StockMarket, StockModule, TimelineModule, type TimelineOptions, type UploadDocRequest, UserModule };
|
package/dist/index.js
CHANGED
|
@@ -614,10 +614,11 @@ var DocsModule = class {
|
|
|
614
614
|
};
|
|
615
615
|
|
|
616
616
|
// src/quant.ts
|
|
617
|
-
var QuantModule = class {
|
|
617
|
+
var QuantModule = class _QuantModule {
|
|
618
618
|
constructor(client) {
|
|
619
619
|
this.client = client;
|
|
620
620
|
}
|
|
621
|
+
static BACKTEST_TIMEOUT_MS = 12e4;
|
|
621
622
|
// ===========================================================================
|
|
622
623
|
// Factors (includes technical indicators and fundamental factors)
|
|
623
624
|
// ===========================================================================
|
|
@@ -788,50 +789,57 @@ var QuantModule = class {
|
|
|
788
789
|
/**
|
|
789
790
|
* Get 1-minute kline data for a single symbol
|
|
790
791
|
*
|
|
792
|
+
/**
|
|
793
|
+
* Get kline data for a single symbol (supports all periods)
|
|
794
|
+
*
|
|
791
795
|
* @param params - Kline parameters
|
|
792
|
-
* @returns Array of
|
|
796
|
+
* @returns Array of kline data
|
|
793
797
|
*
|
|
794
798
|
* @example
|
|
795
799
|
* ```typescript
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
+
* // Daily kline (default)
|
|
801
|
+
* const data = await client.quant.kline({ symbol: '000001' });
|
|
802
|
+
* // 5-minute intraday
|
|
803
|
+
* const data = await client.quant.kline({
|
|
804
|
+
* symbol: '000001', klineType: '5M',
|
|
805
|
+
* startDateTime: '2026-04-09 09:30:00',
|
|
806
|
+
* endDateTime: '2026-04-09 15:00:00'
|
|
800
807
|
* });
|
|
801
|
-
* console.log(data);
|
|
802
808
|
* ```
|
|
803
809
|
*/
|
|
804
|
-
async
|
|
805
|
-
const response = await this.client.get("/v1/quant/quotes/
|
|
810
|
+
async kline(params) {
|
|
811
|
+
const response = await this.client.get("/v1/quant/quotes/kline", {
|
|
806
812
|
symbol: params.symbol,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
813
|
+
kline_type: params.klineType || "1D",
|
|
814
|
+
market: params.market || "cn",
|
|
815
|
+
...params.stockType && { stock_type: params.stockType },
|
|
816
|
+
...params.startDateTime && { start_datetime: params.startDateTime },
|
|
817
|
+
...params.endDateTime && { end_datetime: params.endDateTime }
|
|
810
818
|
});
|
|
811
819
|
return response.datas || [];
|
|
812
820
|
}
|
|
813
821
|
/**
|
|
814
|
-
* Get
|
|
822
|
+
* Get kline data for multiple symbols (supports all periods)
|
|
815
823
|
*
|
|
816
824
|
* @param params - Batch kline parameters
|
|
817
|
-
* @returns Array of
|
|
825
|
+
* @returns Array of kline data
|
|
818
826
|
*
|
|
819
827
|
* @example
|
|
820
828
|
* ```typescript
|
|
821
|
-
* const data = await client.quant.
|
|
829
|
+
* const data = await client.quant.klineBatch({
|
|
822
830
|
* symbols: ['000001', '600519'],
|
|
823
|
-
*
|
|
824
|
-
* endDateTime: '2024-01-01 15:00:00'
|
|
831
|
+
* klineType: '1D'
|
|
825
832
|
* });
|
|
826
|
-
* console.log(data);
|
|
827
833
|
* ```
|
|
828
834
|
*/
|
|
829
|
-
async
|
|
830
|
-
const response = await this.client.post("/v1/quant/quotes/
|
|
835
|
+
async klineBatch(params) {
|
|
836
|
+
const response = await this.client.post("/v1/quant/quotes/kline/batch", {
|
|
831
837
|
symbols: params.symbols,
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
838
|
+
kline_type: params.klineType || "1D",
|
|
839
|
+
market: params.market || "cn",
|
|
840
|
+
...params.stockType && { stock_type: params.stockType },
|
|
841
|
+
...params.startDateTime && { start_datetime: params.startDateTime },
|
|
842
|
+
...params.endDateTime && { end_datetime: params.endDateTime }
|
|
835
843
|
});
|
|
836
844
|
return response.datas || [];
|
|
837
845
|
}
|
|
@@ -956,8 +964,6 @@ var QuantModule = class {
|
|
|
956
964
|
min_commission_amount: params.minCommissionAmount ?? 0,
|
|
957
965
|
slippage: params.slippage ?? 0,
|
|
958
966
|
stop_loss: params.stopLoss ?? 0,
|
|
959
|
-
position_size: params.positionSize ?? 0.2,
|
|
960
|
-
max_positions: params.maxPositions ?? 5,
|
|
961
967
|
min_volume: params.minVolume ?? 100,
|
|
962
968
|
auto_close: params.autoClose ?? true
|
|
963
969
|
};
|
|
@@ -976,10 +982,22 @@ var QuantModule = class {
|
|
|
976
982
|
if (params.exitFormula !== void 0) {
|
|
977
983
|
body.exit_formula = params.exitFormula;
|
|
978
984
|
}
|
|
985
|
+
if (params.positionSize !== void 0) {
|
|
986
|
+
body.position_size = params.positionSize;
|
|
987
|
+
}
|
|
988
|
+
if (params.maxPositions !== void 0) {
|
|
989
|
+
body.max_positions = params.maxPositions;
|
|
990
|
+
}
|
|
991
|
+
if (params.cheatOnOpen !== void 0) {
|
|
992
|
+
body.cheat_on_open = params.cheatOnOpen;
|
|
993
|
+
}
|
|
979
994
|
if (params.signalFactors !== void 0) {
|
|
980
995
|
body.signal_factors = params.signalFactors;
|
|
981
996
|
}
|
|
982
|
-
return this.client.
|
|
997
|
+
return this.client.request("POST", "/v1/quant/backtest", {
|
|
998
|
+
body,
|
|
999
|
+
timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
|
|
1000
|
+
});
|
|
983
1001
|
}
|
|
984
1002
|
/**
|
|
985
1003
|
* Upload an Excel file to run backtest
|
|
@@ -1035,9 +1053,7 @@ var QuantModule = class {
|
|
|
1035
1053
|
formData.append("sell_commission", String(params.sellCommission ?? 0));
|
|
1036
1054
|
formData.append("min_commission_amount", String(params.minCommissionAmount ?? 0));
|
|
1037
1055
|
formData.append("slippage", String(params.slippage ?? 0));
|
|
1038
|
-
formData.append("
|
|
1039
|
-
formData.append("max_positions", String(params.maxPositions ?? 5));
|
|
1040
|
-
formData.append("min_volume", String(params.minVolume ?? 100));
|
|
1056
|
+
formData.append("min_volume", String(params.minVolume ?? 1));
|
|
1041
1057
|
formData.append("auto_close", String(params.autoClose ?? true));
|
|
1042
1058
|
if (params.startDate !== void 0) {
|
|
1043
1059
|
formData.append("start_date", params.startDate);
|
|
@@ -1054,10 +1070,22 @@ var QuantModule = class {
|
|
|
1054
1070
|
if (params.exitFormula !== void 0) {
|
|
1055
1071
|
formData.append("exit_formula", params.exitFormula);
|
|
1056
1072
|
}
|
|
1073
|
+
if (params.positionSize !== void 0 && params.positionSize !== null) {
|
|
1074
|
+
formData.append("position_size", String(params.positionSize));
|
|
1075
|
+
}
|
|
1076
|
+
if (params.maxPositions !== void 0 && params.maxPositions !== null) {
|
|
1077
|
+
formData.append("max_positions", String(params.maxPositions));
|
|
1078
|
+
}
|
|
1079
|
+
if (params.cheatOnOpen !== void 0) {
|
|
1080
|
+
formData.append("cheat_on_open", String(params.cheatOnOpen));
|
|
1081
|
+
}
|
|
1057
1082
|
if (params.signalFactors !== void 0) {
|
|
1058
1083
|
formData.append("signal_factors", JSON.stringify(params.signalFactors));
|
|
1059
1084
|
}
|
|
1060
|
-
return this.client.request("POST", "/v1/quant/backtest/upload", {
|
|
1085
|
+
return this.client.request("POST", "/v1/quant/backtest/upload", {
|
|
1086
|
+
formData,
|
|
1087
|
+
timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
|
|
1088
|
+
});
|
|
1061
1089
|
}
|
|
1062
1090
|
};
|
|
1063
1091
|
|
|
@@ -2121,7 +2149,10 @@ var Reportify = class {
|
|
|
2121
2149
|
});
|
|
2122
2150
|
}
|
|
2123
2151
|
const controller = new AbortController();
|
|
2124
|
-
const timeoutId = setTimeout(
|
|
2152
|
+
const timeoutId = setTimeout(
|
|
2153
|
+
() => controller.abort(),
|
|
2154
|
+
options.timeoutMs ?? this.timeout
|
|
2155
|
+
);
|
|
2125
2156
|
const headers = {
|
|
2126
2157
|
Authorization: `Bearer ${this.apiKey}`,
|
|
2127
2158
|
"User-Agent": "reportify-sdk-js/0.3.10"
|
package/dist/index.mjs
CHANGED
|
@@ -570,10 +570,11 @@ var DocsModule = class {
|
|
|
570
570
|
};
|
|
571
571
|
|
|
572
572
|
// src/quant.ts
|
|
573
|
-
var QuantModule = class {
|
|
573
|
+
var QuantModule = class _QuantModule {
|
|
574
574
|
constructor(client) {
|
|
575
575
|
this.client = client;
|
|
576
576
|
}
|
|
577
|
+
static BACKTEST_TIMEOUT_MS = 12e4;
|
|
577
578
|
// ===========================================================================
|
|
578
579
|
// Factors (includes technical indicators and fundamental factors)
|
|
579
580
|
// ===========================================================================
|
|
@@ -744,50 +745,57 @@ var QuantModule = class {
|
|
|
744
745
|
/**
|
|
745
746
|
* Get 1-minute kline data for a single symbol
|
|
746
747
|
*
|
|
748
|
+
/**
|
|
749
|
+
* Get kline data for a single symbol (supports all periods)
|
|
750
|
+
*
|
|
747
751
|
* @param params - Kline parameters
|
|
748
|
-
* @returns Array of
|
|
752
|
+
* @returns Array of kline data
|
|
749
753
|
*
|
|
750
754
|
* @example
|
|
751
755
|
* ```typescript
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
+
* // Daily kline (default)
|
|
757
|
+
* const data = await client.quant.kline({ symbol: '000001' });
|
|
758
|
+
* // 5-minute intraday
|
|
759
|
+
* const data = await client.quant.kline({
|
|
760
|
+
* symbol: '000001', klineType: '5M',
|
|
761
|
+
* startDateTime: '2026-04-09 09:30:00',
|
|
762
|
+
* endDateTime: '2026-04-09 15:00:00'
|
|
756
763
|
* });
|
|
757
|
-
* console.log(data);
|
|
758
764
|
* ```
|
|
759
765
|
*/
|
|
760
|
-
async
|
|
761
|
-
const response = await this.client.get("/v1/quant/quotes/
|
|
766
|
+
async kline(params) {
|
|
767
|
+
const response = await this.client.get("/v1/quant/quotes/kline", {
|
|
762
768
|
symbol: params.symbol,
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
769
|
+
kline_type: params.klineType || "1D",
|
|
770
|
+
market: params.market || "cn",
|
|
771
|
+
...params.stockType && { stock_type: params.stockType },
|
|
772
|
+
...params.startDateTime && { start_datetime: params.startDateTime },
|
|
773
|
+
...params.endDateTime && { end_datetime: params.endDateTime }
|
|
766
774
|
});
|
|
767
775
|
return response.datas || [];
|
|
768
776
|
}
|
|
769
777
|
/**
|
|
770
|
-
* Get
|
|
778
|
+
* Get kline data for multiple symbols (supports all periods)
|
|
771
779
|
*
|
|
772
780
|
* @param params - Batch kline parameters
|
|
773
|
-
* @returns Array of
|
|
781
|
+
* @returns Array of kline data
|
|
774
782
|
*
|
|
775
783
|
* @example
|
|
776
784
|
* ```typescript
|
|
777
|
-
* const data = await client.quant.
|
|
785
|
+
* const data = await client.quant.klineBatch({
|
|
778
786
|
* symbols: ['000001', '600519'],
|
|
779
|
-
*
|
|
780
|
-
* endDateTime: '2024-01-01 15:00:00'
|
|
787
|
+
* klineType: '1D'
|
|
781
788
|
* });
|
|
782
|
-
* console.log(data);
|
|
783
789
|
* ```
|
|
784
790
|
*/
|
|
785
|
-
async
|
|
786
|
-
const response = await this.client.post("/v1/quant/quotes/
|
|
791
|
+
async klineBatch(params) {
|
|
792
|
+
const response = await this.client.post("/v1/quant/quotes/kline/batch", {
|
|
787
793
|
symbols: params.symbols,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
794
|
+
kline_type: params.klineType || "1D",
|
|
795
|
+
market: params.market || "cn",
|
|
796
|
+
...params.stockType && { stock_type: params.stockType },
|
|
797
|
+
...params.startDateTime && { start_datetime: params.startDateTime },
|
|
798
|
+
...params.endDateTime && { end_datetime: params.endDateTime }
|
|
791
799
|
});
|
|
792
800
|
return response.datas || [];
|
|
793
801
|
}
|
|
@@ -912,8 +920,6 @@ var QuantModule = class {
|
|
|
912
920
|
min_commission_amount: params.minCommissionAmount ?? 0,
|
|
913
921
|
slippage: params.slippage ?? 0,
|
|
914
922
|
stop_loss: params.stopLoss ?? 0,
|
|
915
|
-
position_size: params.positionSize ?? 0.2,
|
|
916
|
-
max_positions: params.maxPositions ?? 5,
|
|
917
923
|
min_volume: params.minVolume ?? 100,
|
|
918
924
|
auto_close: params.autoClose ?? true
|
|
919
925
|
};
|
|
@@ -932,10 +938,22 @@ var QuantModule = class {
|
|
|
932
938
|
if (params.exitFormula !== void 0) {
|
|
933
939
|
body.exit_formula = params.exitFormula;
|
|
934
940
|
}
|
|
941
|
+
if (params.positionSize !== void 0) {
|
|
942
|
+
body.position_size = params.positionSize;
|
|
943
|
+
}
|
|
944
|
+
if (params.maxPositions !== void 0) {
|
|
945
|
+
body.max_positions = params.maxPositions;
|
|
946
|
+
}
|
|
947
|
+
if (params.cheatOnOpen !== void 0) {
|
|
948
|
+
body.cheat_on_open = params.cheatOnOpen;
|
|
949
|
+
}
|
|
935
950
|
if (params.signalFactors !== void 0) {
|
|
936
951
|
body.signal_factors = params.signalFactors;
|
|
937
952
|
}
|
|
938
|
-
return this.client.
|
|
953
|
+
return this.client.request("POST", "/v1/quant/backtest", {
|
|
954
|
+
body,
|
|
955
|
+
timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
|
|
956
|
+
});
|
|
939
957
|
}
|
|
940
958
|
/**
|
|
941
959
|
* Upload an Excel file to run backtest
|
|
@@ -991,9 +1009,7 @@ var QuantModule = class {
|
|
|
991
1009
|
formData.append("sell_commission", String(params.sellCommission ?? 0));
|
|
992
1010
|
formData.append("min_commission_amount", String(params.minCommissionAmount ?? 0));
|
|
993
1011
|
formData.append("slippage", String(params.slippage ?? 0));
|
|
994
|
-
formData.append("
|
|
995
|
-
formData.append("max_positions", String(params.maxPositions ?? 5));
|
|
996
|
-
formData.append("min_volume", String(params.minVolume ?? 100));
|
|
1012
|
+
formData.append("min_volume", String(params.minVolume ?? 1));
|
|
997
1013
|
formData.append("auto_close", String(params.autoClose ?? true));
|
|
998
1014
|
if (params.startDate !== void 0) {
|
|
999
1015
|
formData.append("start_date", params.startDate);
|
|
@@ -1010,10 +1026,22 @@ var QuantModule = class {
|
|
|
1010
1026
|
if (params.exitFormula !== void 0) {
|
|
1011
1027
|
formData.append("exit_formula", params.exitFormula);
|
|
1012
1028
|
}
|
|
1029
|
+
if (params.positionSize !== void 0 && params.positionSize !== null) {
|
|
1030
|
+
formData.append("position_size", String(params.positionSize));
|
|
1031
|
+
}
|
|
1032
|
+
if (params.maxPositions !== void 0 && params.maxPositions !== null) {
|
|
1033
|
+
formData.append("max_positions", String(params.maxPositions));
|
|
1034
|
+
}
|
|
1035
|
+
if (params.cheatOnOpen !== void 0) {
|
|
1036
|
+
formData.append("cheat_on_open", String(params.cheatOnOpen));
|
|
1037
|
+
}
|
|
1013
1038
|
if (params.signalFactors !== void 0) {
|
|
1014
1039
|
formData.append("signal_factors", JSON.stringify(params.signalFactors));
|
|
1015
1040
|
}
|
|
1016
|
-
return this.client.request("POST", "/v1/quant/backtest/upload", {
|
|
1041
|
+
return this.client.request("POST", "/v1/quant/backtest/upload", {
|
|
1042
|
+
formData,
|
|
1043
|
+
timeoutMs: _QuantModule.BACKTEST_TIMEOUT_MS
|
|
1044
|
+
});
|
|
1017
1045
|
}
|
|
1018
1046
|
};
|
|
1019
1047
|
|
|
@@ -2077,7 +2105,10 @@ var Reportify = class {
|
|
|
2077
2105
|
});
|
|
2078
2106
|
}
|
|
2079
2107
|
const controller = new AbortController();
|
|
2080
|
-
const timeoutId = setTimeout(
|
|
2108
|
+
const timeoutId = setTimeout(
|
|
2109
|
+
() => controller.abort(),
|
|
2110
|
+
options.timeoutMs ?? this.timeout
|
|
2111
|
+
);
|
|
2081
2112
|
const headers = {
|
|
2082
2113
|
Authorization: `Bearer ${this.apiKey}`,
|
|
2083
2114
|
"User-Agent": "reportify-sdk-js/0.3.10"
|