ohlcv-ai 1.0.8 → 1.1.0
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/LICENSE +661 -202
- package/dist/index.d.ts +166 -40
- package/dist/index.js +205 -32
- package/dist/index.mjs +1188 -637
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,17 +14,19 @@ export declare class AliyunAI {
|
|
|
14
14
|
/**
|
|
15
15
|
* Simplest method: single conversation
|
|
16
16
|
* @param message - User message
|
|
17
|
+
* @param i18n - Language restriction for AI response
|
|
17
18
|
* @param options - Chat options
|
|
18
19
|
* @returns AI response
|
|
19
20
|
*/
|
|
20
|
-
chat(message: string, options?: AliYunChatOptions): Promise<string>;
|
|
21
|
+
chat(message: string, i18n: 'en' | 'cn', options?: AliYunChatOptions): Promise<string>;
|
|
21
22
|
/**
|
|
22
23
|
* Multi-turn conversation
|
|
23
24
|
* @param messages - Message history
|
|
25
|
+
* @param i18n - Language restriction for AI response
|
|
24
26
|
* @param options - Chat options
|
|
25
27
|
* @returns Complete API response
|
|
26
28
|
*/
|
|
27
|
-
chatCompletion(messages: ChatMessage[], options?: {
|
|
29
|
+
chatCompletion(messages: ChatMessage[], i18n: 'en' | 'cn', options?: {
|
|
28
30
|
temperature?: number;
|
|
29
31
|
maxTokens?: number;
|
|
30
32
|
stream?: boolean;
|
|
@@ -34,13 +36,58 @@ export declare class AliyunAI {
|
|
|
34
36
|
* Streaming conversation (only supports OpenAI format)
|
|
35
37
|
* @param messages - Message history
|
|
36
38
|
* @param callback - Streaming callback function
|
|
39
|
+
* @param i18n - Language restriction for AI response
|
|
37
40
|
* @param options - Chat options
|
|
38
41
|
*/
|
|
39
|
-
chatStream(messages: ChatMessage[], callback: AliYunStreamCallback, options?: {
|
|
42
|
+
chatStream(messages: ChatMessage[], callback: AliYunStreamCallback, i18n: 'en' | 'cn', options?: {
|
|
40
43
|
temperature?: number;
|
|
41
44
|
maxTokens?: number;
|
|
42
45
|
modelType?: AliYunModelType;
|
|
43
46
|
}): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Analyze OHLCV data and return AI analysis results
|
|
49
|
+
* @param ohlcvArray - OHLCV data array
|
|
50
|
+
* @param i18n - Language restriction for AI response
|
|
51
|
+
* @param analysisType - Analysis type (optional, default: "comprehensive")
|
|
52
|
+
* - "trend": Trend analysis
|
|
53
|
+
* - "volume": Volume analysis
|
|
54
|
+
* - "technical": Technical analysis
|
|
55
|
+
* - "comprehensive": Comprehensive analysis
|
|
56
|
+
* @param message - User's subjective request or specific question (optional)
|
|
57
|
+
* @param options - Chat options
|
|
58
|
+
* @returns AI analysis result of OHLCV data (text description)
|
|
59
|
+
*/
|
|
60
|
+
analyzeOHLCV(ohlcvArray: OHLCV[], i18n: 'en' | 'cn', analysisType?: 'trend' | 'volume' | 'technical' | 'comprehensive', message?: string, options?: AliYunChatOptions): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Enhanced version: Analyze OHLCV and return structured results (optional)
|
|
63
|
+
* @param ohlcvArray - OHLCV data array
|
|
64
|
+
* @param i18n - Language restriction for AI response
|
|
65
|
+
* @param analysisType - Analysis type
|
|
66
|
+
* @param message - User's subjective request or specific question
|
|
67
|
+
* @param structured - Whether to return structured results (default: false)
|
|
68
|
+
* @param options - Chat options
|
|
69
|
+
* @returns AI analysis results
|
|
70
|
+
*/
|
|
71
|
+
analyzeOHLCVEnhanced(ohlcvArray: OHLCV[], i18n: 'en' | 'cn', analysisType?: 'trend' | 'volume' | 'technical' | 'comprehensive', message?: string, structured?: boolean, options?: AliYunChatOptions): Promise<string | {
|
|
72
|
+
summary: string;
|
|
73
|
+
details: string[];
|
|
74
|
+
recommendations: string[];
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Specialized method for processing OHLCV arrays
|
|
78
|
+
* @param ohlcvArray - OHLCV data array
|
|
79
|
+
* @param i18n - Language restriction for AI response
|
|
80
|
+
* @param instructions - Processing instructions, supports Chinese and English (optional, default: "Based on these OHLCV data, predict the next period")
|
|
81
|
+
* @param count - Number of OHLCV data items to return (optional, default: 1)
|
|
82
|
+
* @param options - Chat options
|
|
83
|
+
* @returns Predicted OHLCV array
|
|
84
|
+
*/
|
|
85
|
+
predictingOHLCV(ohlcvArray: OHLCV[], i18n: 'en' | 'cn', instructions?: string, count?: number, options?: AliYunChatOptions): Promise<OHLCV[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Parse AI returned OHLCV response
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
private parseOHLCVResponse;
|
|
44
91
|
/**
|
|
45
92
|
* Switch model
|
|
46
93
|
* @param modelType - New model type
|
|
@@ -69,20 +116,6 @@ export declare class AliyunAI {
|
|
|
69
116
|
private makeRequest;
|
|
70
117
|
private makeStreamRequest;
|
|
71
118
|
private extractContent;
|
|
72
|
-
/**
|
|
73
|
-
* Specialized method for processing OHLCV arrays
|
|
74
|
-
* @param ohlcvArray - OHLCV data array
|
|
75
|
-
* @param instructions - Processing instructions, supports Chinese and English (optional, default: "Based on these OHLCV data, predict the next period")
|
|
76
|
-
* @param count - Number of OHLCV data items to return (optional, default: 1)
|
|
77
|
-
* @param options - Chat options
|
|
78
|
-
* @returns Predicted OHLCV array
|
|
79
|
-
*/
|
|
80
|
-
predictingOHLCV(ohlcvArray: OHLCV[], instructions?: string, count?: number, options?: AliYunChatOptions): Promise<OHLCV[]>;
|
|
81
|
-
/**
|
|
82
|
-
* Parse AI returned OHLCV response
|
|
83
|
-
* @private
|
|
84
|
-
*/
|
|
85
|
-
private parseOHLCVResponse;
|
|
86
119
|
}
|
|
87
120
|
|
|
88
121
|
export declare interface AliYunChatOptions {
|
|
@@ -182,26 +215,79 @@ export declare class DeepSeekAI {
|
|
|
182
215
|
*/
|
|
183
216
|
constructor(config: DeepSeekConfig);
|
|
184
217
|
/**
|
|
185
|
-
* Simplest method: single conversation
|
|
218
|
+
* Simplest method: single conversation with i18n support
|
|
186
219
|
* @param message - User message
|
|
220
|
+
* @param i18n - Language restriction for AI response
|
|
187
221
|
* @param options - Chat options
|
|
188
222
|
* @returns AI response
|
|
189
223
|
*/
|
|
190
|
-
chat(message: string, options?: DeepSeekChatOptions): Promise<string>;
|
|
224
|
+
chat(message: string, i18n: 'en' | 'cn', options?: DeepSeekChatOptions): Promise<string>;
|
|
191
225
|
/**
|
|
192
|
-
* Multi-turn conversation
|
|
226
|
+
* Multi-turn conversation with i18n support
|
|
193
227
|
* @param messages - Message history
|
|
228
|
+
* @param i18n - Language restriction for AI response
|
|
194
229
|
* @param options - Chat options
|
|
195
230
|
* @returns Complete API response
|
|
196
231
|
*/
|
|
197
|
-
chatCompletion(messages: DeepSeekChatMessage[], options?:
|
|
232
|
+
chatCompletion(messages: DeepSeekChatMessage[], i18n: 'en' | 'cn', options?: {
|
|
233
|
+
temperature?: number;
|
|
234
|
+
maxTokens?: number;
|
|
235
|
+
stream?: boolean;
|
|
236
|
+
modelType?: DeepSeekModelType;
|
|
237
|
+
topP?: number;
|
|
238
|
+
frequencyPenalty?: number;
|
|
239
|
+
presencePenalty?: number;
|
|
240
|
+
stop?: string[];
|
|
241
|
+
tools?: any[];
|
|
242
|
+
toolChoice?: string | object;
|
|
243
|
+
}): Promise<any>;
|
|
198
244
|
/**
|
|
199
|
-
* Streaming conversation
|
|
245
|
+
* Streaming conversation with i18n support
|
|
200
246
|
* @param messages - Message history
|
|
201
247
|
* @param callback - Streaming callback function
|
|
248
|
+
* @param i18n - Language restriction for AI response
|
|
202
249
|
* @param options - Chat options
|
|
203
250
|
*/
|
|
204
|
-
chatStream(messages: DeepSeekChatMessage[], callback: DeepSeekStreamCallback, options?:
|
|
251
|
+
chatStream(messages: DeepSeekChatMessage[], callback: DeepSeekStreamCallback, i18n: 'en' | 'cn', options?: {
|
|
252
|
+
temperature?: number;
|
|
253
|
+
maxTokens?: number;
|
|
254
|
+
modelType?: DeepSeekModelType;
|
|
255
|
+
topP?: number;
|
|
256
|
+
frequencyPenalty?: number;
|
|
257
|
+
presencePenalty?: number;
|
|
258
|
+
stop?: string[];
|
|
259
|
+
tools?: any[];
|
|
260
|
+
toolChoice?: string | object;
|
|
261
|
+
}): Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* Analyze OHLCV data and return AI analysis results (text description)
|
|
264
|
+
* @param ohlcvArray - OHLCV data array
|
|
265
|
+
* @param i18n - Language restriction for AI response
|
|
266
|
+
* @param analysisType - Analysis type (optional, default: "comprehensive")
|
|
267
|
+
* - "trend": Trend analysis
|
|
268
|
+
* - "volume": Volume analysis
|
|
269
|
+
* - "technical": Technical analysis
|
|
270
|
+
* - "comprehensive": Comprehensive analysis
|
|
271
|
+
* @param message - User's subjective request or specific question (optional)
|
|
272
|
+
* @param options - Chat options
|
|
273
|
+
* @returns AI analysis result of OHLCV data (text description)
|
|
274
|
+
*/
|
|
275
|
+
analyzeOHLCV(ohlcvArray: OHLCV[], i18n: 'en' | 'cn', analysisType?: 'trend' | 'volume' | 'technical' | 'comprehensive', message?: string, options?: DeepSeekChatOptions): Promise<string>;
|
|
276
|
+
/**
|
|
277
|
+
* Enhanced version: Analyze OHLCV and return structured results (optional)
|
|
278
|
+
* @param ohlcvArray - OHLCV data array
|
|
279
|
+
* @param i18n - Language restriction for AI response
|
|
280
|
+
* @param analysisType - Analysis type
|
|
281
|
+
* @param message - User's subjective request or specific question
|
|
282
|
+
* @param structured - Whether to return structured results (default: false)
|
|
283
|
+
* @param options - Chat options
|
|
284
|
+
* @returns AI analysis results
|
|
285
|
+
*/
|
|
286
|
+
analyzeOHLCVEnhanced(ohlcvArray: OHLCV[], i18n: 'en' | 'cn', analysisType?: 'trend' | 'volume' | 'technical' | 'comprehensive', message?: string, structured?: boolean, options?: DeepSeekChatOptions): Promise<string | {
|
|
287
|
+
summary: string;
|
|
288
|
+
details: string[];
|
|
289
|
+
recommendations: string[];
|
|
290
|
+
}>;
|
|
205
291
|
/**
|
|
206
292
|
* Specialized method for processing OHLCV arrays
|
|
207
293
|
* @param ohlcvArray - OHLCV data array
|
|
@@ -225,7 +311,7 @@ export declare class DeepSeekAI {
|
|
|
225
311
|
description?: string;
|
|
226
312
|
};
|
|
227
313
|
/**
|
|
228
|
-
* Test connection
|
|
314
|
+
* Test connection with i18n support
|
|
229
315
|
* @returns Connection test result
|
|
230
316
|
*/
|
|
231
317
|
testConnection(): Promise<{
|
|
@@ -260,6 +346,7 @@ export declare interface DeepSeekChatOptions {
|
|
|
260
346
|
stop?: string[];
|
|
261
347
|
tools?: any[];
|
|
262
348
|
toolChoice?: string | object;
|
|
349
|
+
i18n?: 'en' | 'cn';
|
|
263
350
|
}
|
|
264
351
|
|
|
265
352
|
export declare interface DeepSeekConfig {
|
|
@@ -389,19 +476,21 @@ export declare class OpenAI {
|
|
|
389
476
|
*/
|
|
390
477
|
constructor(config: OpenAIConfig);
|
|
391
478
|
/**
|
|
392
|
-
* Simplest method: single conversation
|
|
479
|
+
* Simplest method: single conversation with i18n support
|
|
393
480
|
* @param message - User message
|
|
481
|
+
* @param i18n - Language restriction for AI response
|
|
394
482
|
* @param options - Chat options
|
|
395
483
|
* @returns AI response
|
|
396
484
|
*/
|
|
397
|
-
chat(message: string, options?: OpenAIChatOptions): Promise<string>;
|
|
485
|
+
chat(message: string, i18n: 'en' | 'cn', options?: OpenAIChatOptions): Promise<string>;
|
|
398
486
|
/**
|
|
399
|
-
* Multi-turn conversation
|
|
487
|
+
* Multi-turn conversation with i18n support
|
|
400
488
|
* @param messages - Message history
|
|
489
|
+
* @param i18n - Language restriction for AI response
|
|
401
490
|
* @param options - Chat options
|
|
402
491
|
* @returns Complete API response
|
|
403
492
|
*/
|
|
404
|
-
chatCompletion(messages: ChatMessage[], options?: {
|
|
493
|
+
chatCompletion(messages: ChatMessage[], i18n: 'en' | 'cn', options?: {
|
|
405
494
|
temperature?: number;
|
|
406
495
|
maxTokens?: number;
|
|
407
496
|
stream?: boolean;
|
|
@@ -412,12 +501,13 @@ export declare class OpenAI {
|
|
|
412
501
|
stop?: string[];
|
|
413
502
|
}): Promise<any>;
|
|
414
503
|
/**
|
|
415
|
-
* Streaming conversation
|
|
504
|
+
* Streaming conversation with i18n support
|
|
416
505
|
* @param messages - Message history
|
|
417
506
|
* @param callback - Streaming callback function
|
|
507
|
+
* @param i18n - Language restriction for AI response
|
|
418
508
|
* @param options - Chat options
|
|
419
509
|
*/
|
|
420
|
-
chatStream(messages: ChatMessage[], callback: OpenAIStreamCallback, options?: {
|
|
510
|
+
chatStream(messages: ChatMessage[], callback: OpenAIStreamCallback, i18n: 'en' | 'cn', options?: {
|
|
421
511
|
temperature?: number;
|
|
422
512
|
maxTokens?: number;
|
|
423
513
|
modelType?: OpenAIModelType;
|
|
@@ -426,6 +516,44 @@ export declare class OpenAI {
|
|
|
426
516
|
presencePenalty?: number;
|
|
427
517
|
stop?: string[];
|
|
428
518
|
}): Promise<void>;
|
|
519
|
+
/**
|
|
520
|
+
* Analyze OHLCV data and return AI analysis results (text description)
|
|
521
|
+
* @param ohlcvArray - OHLCV data array
|
|
522
|
+
* @param i18n - Language restriction for AI response
|
|
523
|
+
* @param analysisType - Analysis type (optional, default: "comprehensive")
|
|
524
|
+
* - "trend": Trend analysis
|
|
525
|
+
* - "volume": Volume analysis
|
|
526
|
+
* - "technical": Technical analysis
|
|
527
|
+
* - "comprehensive": Comprehensive analysis
|
|
528
|
+
* @param message - User's subjective request or specific question (optional)
|
|
529
|
+
* @param options - Chat options
|
|
530
|
+
* @returns AI analysis result of OHLCV data (text description)
|
|
531
|
+
*/
|
|
532
|
+
analyzeOHLCV(ohlcvArray: OHLCV[], i18n: 'en' | 'cn', analysisType?: 'trend' | 'volume' | 'technical' | 'comprehensive', message?: string, options?: OpenAIChatOptions): Promise<string>;
|
|
533
|
+
/**
|
|
534
|
+
* Enhanced version: Analyze OHLCV and return structured results (optional)
|
|
535
|
+
* @param ohlcvArray - OHLCV data array
|
|
536
|
+
* @param i18n - Language restriction for AI response
|
|
537
|
+
* @param analysisType - Analysis type
|
|
538
|
+
* @param message - User's subjective request or specific question
|
|
539
|
+
* @param structured - Whether to return structured results (default: false)
|
|
540
|
+
* @param options - Chat options
|
|
541
|
+
* @returns AI analysis results
|
|
542
|
+
*/
|
|
543
|
+
analyzeOHLCVEnhanced(ohlcvArray: OHLCV[], i18n: 'en' | 'cn', analysisType?: 'trend' | 'volume' | 'technical' | 'comprehensive', message?: string, structured?: boolean, options?: OpenAIChatOptions): Promise<string | {
|
|
544
|
+
summary: string;
|
|
545
|
+
details: string[];
|
|
546
|
+
recommendations: string[];
|
|
547
|
+
}>;
|
|
548
|
+
/**
|
|
549
|
+
* Specialized method for processing OHLCV arrays (predict future values)
|
|
550
|
+
* @param ohlcvArray - OHLCV data array
|
|
551
|
+
* @param instructions - Processing instructions, supports Chinese and English (optional, default: "Based on these OHLCV data, predict the next period")
|
|
552
|
+
* @param count - Number of OHLCV data items to return (optional, default: 1)
|
|
553
|
+
* @param options - Chat options
|
|
554
|
+
* @returns Predicted OHLCV array
|
|
555
|
+
*/
|
|
556
|
+
predictingOHLCV(ohlcvArray: OHLCV[], instructions?: string, count?: number, options?: OpenAIChatOptions): Promise<OHLCV[]>;
|
|
429
557
|
/**
|
|
430
558
|
* Generate images using DALL-E
|
|
431
559
|
* @param prompt - Image generation prompt
|
|
@@ -498,7 +626,7 @@ export declare class OpenAI {
|
|
|
498
626
|
description?: string;
|
|
499
627
|
};
|
|
500
628
|
/**
|
|
501
|
-
* Test connection
|
|
629
|
+
* Test connection with i18n support
|
|
502
630
|
* @returns Connection test result
|
|
503
631
|
*/
|
|
504
632
|
testConnection(): Promise<{
|
|
@@ -524,15 +652,6 @@ export declare class OpenAI {
|
|
|
524
652
|
private makeFormDataRequest;
|
|
525
653
|
private makeStreamRequest;
|
|
526
654
|
private extractContent;
|
|
527
|
-
/**
|
|
528
|
-
* Specialized method for processing OHLCV arrays
|
|
529
|
-
* @param ohlcvArray - OHLCV data array
|
|
530
|
-
* @param instructions - Processing instructions (optional, default: "Based on these OHLCV data, predict the next period")
|
|
531
|
-
* @param count - Number of OHLCV data items to return (optional, default: 1)
|
|
532
|
-
* @param options - Chat options
|
|
533
|
-
* @returns Predicted OHLCV array
|
|
534
|
-
*/
|
|
535
|
-
analyzeOHLCV(ohlcvArray: OHLCV[], instructions?: string, count?: number, options?: OpenAIChatOptions): Promise<OHLCV[]>;
|
|
536
655
|
/**
|
|
537
656
|
* Parse AI returned OHLCV response
|
|
538
657
|
* @private
|
|
@@ -552,6 +671,7 @@ export declare interface OpenAIChatOptions {
|
|
|
552
671
|
frequencyPenalty?: number;
|
|
553
672
|
presencePenalty?: number;
|
|
554
673
|
stop?: string[];
|
|
674
|
+
i18n?: 'en' | 'cn';
|
|
555
675
|
}
|
|
556
676
|
|
|
557
677
|
export declare interface OpenAIConfig {
|
|
@@ -621,6 +741,12 @@ export declare enum OpenAIModelType {
|
|
|
621
741
|
|
|
622
742
|
export declare type OpenAIStreamCallback = (chunk: string, isEnd: boolean) => void;
|
|
623
743
|
|
|
744
|
+
export declare function stringToAliYunModelType(modelString: string): AliYunModelType | null;
|
|
745
|
+
|
|
746
|
+
export declare function stringToDeepSeekModelType(modelString: string): DeepSeekModelType | null;
|
|
747
|
+
|
|
748
|
+
export declare function stringToOpenAIModelType(modelString: string): OpenAIModelType | null;
|
|
749
|
+
|
|
624
750
|
export declare function suggestModel(requirements: {
|
|
625
751
|
taskType: 'chat' | 'completion' | 'embedding' | 'image' | 'audio';
|
|
626
752
|
budget?: number;
|