@backtest-kit/ollama 0.1.1 → 0.1.2

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/build/index.cjs CHANGED
@@ -5051,7 +5051,7 @@ const SignalSchema = zod.z.object({
5051
5051
  .describe(functoolsKit.str.newline("Position direction (ALWAYS required):", "long: market shows consistent bullish signals, uptrend or growth potential", "short: market shows consistent bearish signals, downtrend or decline potential", "wait: conflicting signals between timeframes OR unfavorable trading conditions")),
5052
5052
  price_open: zod.z
5053
5053
  .number()
5054
- .describe(functoolsKit.str.newline("Position opening price in USD", "Use the current market price at the time of analysis")),
5054
+ .describe(functoolsKit.str.newline("Position entry price in USD", "Can be either:", "- Current market price for immediate entry (market order)", "- Price above/below market to open a limit order and wait for its resolve before entering")),
5055
5055
  price_stop_loss: zod.z
5056
5056
  .number()
5057
5057
  .describe(functoolsKit.str.newline("Stop-loss price in USD", "For LONG: price below price_open (protection against decline)", "For SHORT: price above price_open (protection against rise)", "NEVER set SL in 'empty space' without technical justification")),
@@ -5479,6 +5479,64 @@ const setLogger = (logger) => {
5479
5479
  lib.loggerService.setLogger(logger);
5480
5480
  };
5481
5481
 
5482
+ /**
5483
+ * Overrides the default signal format schema for LLM-generated trading signals.
5484
+ *
5485
+ * This function allows customization of the structured output format used by the
5486
+ * SignalOutline. It replaces the default signal schema with a custom Zod schema,
5487
+ * enabling flexible signal structure definitions while maintaining type safety.
5488
+ *
5489
+ * The override affects all subsequent signal generation calls using SignalOutline
5490
+ * until the application restarts or the schema is overridden again.
5491
+ *
5492
+ * @template ZodInput - The Zod schema type used for validation and type inference
5493
+ *
5494
+ * @param {ZodInput} format - Custom Zod schema defining the signal structure.
5495
+ * Must be a valid Zod type (z.object, z.string, etc.)
5496
+ *
5497
+ * @example
5498
+ * ```typescript
5499
+ * import { z } from 'zod';
5500
+ * import { overrideSignalFormat } from '@backtest-kit/ollama';
5501
+ *
5502
+ * // Override with custom signal schema
5503
+ * const CustomSignalSchema = z.object({
5504
+ * position: z.enum(['long', 'short', 'wait']),
5505
+ * price_open: z.number(),
5506
+ * confidence: z.number().min(0).max(100),
5507
+ * custom_field: z.string()
5508
+ * });
5509
+ *
5510
+ * overrideSignalFormat(CustomSignalSchema);
5511
+ * ```
5512
+ *
5513
+ * @example
5514
+ * ```typescript
5515
+ * // Override with simplified schema
5516
+ * const SimpleSignalSchema = z.object({
5517
+ * action: z.enum(['buy', 'sell', 'hold']),
5518
+ * price: z.number()
5519
+ * });
5520
+ *
5521
+ * overrideSignalFormat(SimpleSignalSchema);
5522
+ * ```
5523
+ *
5524
+ * @remarks
5525
+ * - The custom schema replaces the default SignalSchema completely
5526
+ * - Schema name in OpenAI format is always "position_open_decision"
5527
+ * - Changes persist until application restart or next override
5528
+ * - Ensure the custom schema matches your signal processing logic
5529
+ *
5530
+ * @see {@link SignalSchema} - Default signal schema structure
5531
+ * @see {@link OutlineName.SignalOutline} - Outline being overridden
5532
+ */
5533
+ function overrideSignalFormat(format) {
5534
+ agentSwarmKit.overrideOutline({
5535
+ outlineName: OutlineName$1.SignalOutline,
5536
+ format: zod$1.zodResponseFormat(format, "position_open_decision"),
5537
+ });
5538
+ }
5539
+
5482
5540
  exports.alibaba = alibaba;
5483
5541
  exports.claude = claude;
5484
5542
  exports.cohere = cohere;
@@ -5490,5 +5548,6 @@ exports.hf = hf;
5490
5548
  exports.lib = engine;
5491
5549
  exports.mistral = mistral;
5492
5550
  exports.ollama = ollama;
5551
+ exports.overrideSignalFormat = overrideSignalFormat;
5493
5552
  exports.perplexity = perplexity;
5494
5553
  exports.setLogger = setLogger;
package/build/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { json, event, validateToolArguments, RoundRobin, addCompletion, addOutline, validate } from 'agent-swarm-kit';
1
+ import { json, event, validateToolArguments, RoundRobin, addCompletion, addOutline, validate, overrideOutline } from 'agent-swarm-kit';
2
2
  import { scoped } from 'di-scoped';
3
3
  import { createActivator } from 'di-kit';
4
4
  import MarkdownIt from 'markdown-it';
@@ -5049,7 +5049,7 @@ const SignalSchema = z.object({
5049
5049
  .describe(str.newline("Position direction (ALWAYS required):", "long: market shows consistent bullish signals, uptrend or growth potential", "short: market shows consistent bearish signals, downtrend or decline potential", "wait: conflicting signals between timeframes OR unfavorable trading conditions")),
5050
5050
  price_open: z
5051
5051
  .number()
5052
- .describe(str.newline("Position opening price in USD", "Use the current market price at the time of analysis")),
5052
+ .describe(str.newline("Position entry price in USD", "Can be either:", "- Current market price for immediate entry (market order)", "- Price above/below market to open a limit order and wait for its resolve before entering")),
5053
5053
  price_stop_loss: z
5054
5054
  .number()
5055
5055
  .describe(str.newline("Stop-loss price in USD", "For LONG: price below price_open (protection against decline)", "For SHORT: price above price_open (protection against rise)", "NEVER set SL in 'empty space' without technical justification")),
@@ -5477,4 +5477,62 @@ const setLogger = (logger) => {
5477
5477
  lib.loggerService.setLogger(logger);
5478
5478
  };
5479
5479
 
5480
- export { alibaba, claude, cohere, deepseek, glm4, gpt5, grok, hf, engine as lib, mistral, ollama, perplexity, setLogger };
5480
+ /**
5481
+ * Overrides the default signal format schema for LLM-generated trading signals.
5482
+ *
5483
+ * This function allows customization of the structured output format used by the
5484
+ * SignalOutline. It replaces the default signal schema with a custom Zod schema,
5485
+ * enabling flexible signal structure definitions while maintaining type safety.
5486
+ *
5487
+ * The override affects all subsequent signal generation calls using SignalOutline
5488
+ * until the application restarts or the schema is overridden again.
5489
+ *
5490
+ * @template ZodInput - The Zod schema type used for validation and type inference
5491
+ *
5492
+ * @param {ZodInput} format - Custom Zod schema defining the signal structure.
5493
+ * Must be a valid Zod type (z.object, z.string, etc.)
5494
+ *
5495
+ * @example
5496
+ * ```typescript
5497
+ * import { z } from 'zod';
5498
+ * import { overrideSignalFormat } from '@backtest-kit/ollama';
5499
+ *
5500
+ * // Override with custom signal schema
5501
+ * const CustomSignalSchema = z.object({
5502
+ * position: z.enum(['long', 'short', 'wait']),
5503
+ * price_open: z.number(),
5504
+ * confidence: z.number().min(0).max(100),
5505
+ * custom_field: z.string()
5506
+ * });
5507
+ *
5508
+ * overrideSignalFormat(CustomSignalSchema);
5509
+ * ```
5510
+ *
5511
+ * @example
5512
+ * ```typescript
5513
+ * // Override with simplified schema
5514
+ * const SimpleSignalSchema = z.object({
5515
+ * action: z.enum(['buy', 'sell', 'hold']),
5516
+ * price: z.number()
5517
+ * });
5518
+ *
5519
+ * overrideSignalFormat(SimpleSignalSchema);
5520
+ * ```
5521
+ *
5522
+ * @remarks
5523
+ * - The custom schema replaces the default SignalSchema completely
5524
+ * - Schema name in OpenAI format is always "position_open_decision"
5525
+ * - Changes persist until application restart or next override
5526
+ * - Ensure the custom schema matches your signal processing logic
5527
+ *
5528
+ * @see {@link SignalSchema} - Default signal schema structure
5529
+ * @see {@link OutlineName.SignalOutline} - Outline being overridden
5530
+ */
5531
+ function overrideSignalFormat(format) {
5532
+ overrideOutline({
5533
+ outlineName: OutlineName$1.SignalOutline,
5534
+ format: zodResponseFormat(format, "position_open_decision"),
5535
+ });
5536
+ }
5537
+
5538
+ export { alibaba, claude, cohere, deepseek, glm4, gpt5, grok, hf, engine as lib, mistral, ollama, overrideSignalFormat, perplexity, setLogger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtest-kit/ollama",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Multi-provider LLM inference library for AI-powered trading strategies. Supports 10+ providers including OpenAI, Claude, DeepSeek, Grok, Mistral with unified API and automatic token rotation.",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -100,7 +100,8 @@
100
100
  "markdownlint": "^0.38.0",
101
101
  "sanitize-html": "^2.17.0",
102
102
  "get-moment-stamp": "^1.1.1",
103
- "agent-swarm-kit": "^1.1.182"
103
+ "agent-swarm-kit": "^1.1.182",
104
+ "zod": "^3.25.76"
104
105
  },
105
106
  "publishConfig": {
106
107
  "access": "public"
package/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { IOutlineMessage, ISwarmCompletionArgs, ISwarmMessage, IOutlineCompletionArgs } from 'agent-swarm-kit';
2
+ import { ZodType } from 'zod';
2
3
  import * as di_scoped from 'di-scoped';
3
4
 
4
5
  /**
@@ -370,6 +371,59 @@ interface ILogger {
370
371
  */
371
372
  declare const setLogger: (logger: ILogger) => void;
372
373
 
374
+ /**
375
+ * Overrides the default signal format schema for LLM-generated trading signals.
376
+ *
377
+ * This function allows customization of the structured output format used by the
378
+ * SignalOutline. It replaces the default signal schema with a custom Zod schema,
379
+ * enabling flexible signal structure definitions while maintaining type safety.
380
+ *
381
+ * The override affects all subsequent signal generation calls using SignalOutline
382
+ * until the application restarts or the schema is overridden again.
383
+ *
384
+ * @template ZodInput - The Zod schema type used for validation and type inference
385
+ *
386
+ * @param {ZodInput} format - Custom Zod schema defining the signal structure.
387
+ * Must be a valid Zod type (z.object, z.string, etc.)
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * import { z } from 'zod';
392
+ * import { overrideSignalFormat } from '@backtest-kit/ollama';
393
+ *
394
+ * // Override with custom signal schema
395
+ * const CustomSignalSchema = z.object({
396
+ * position: z.enum(['long', 'short', 'wait']),
397
+ * price_open: z.number(),
398
+ * confidence: z.number().min(0).max(100),
399
+ * custom_field: z.string()
400
+ * });
401
+ *
402
+ * overrideSignalFormat(CustomSignalSchema);
403
+ * ```
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * // Override with simplified schema
408
+ * const SimpleSignalSchema = z.object({
409
+ * action: z.enum(['buy', 'sell', 'hold']),
410
+ * price: z.number()
411
+ * });
412
+ *
413
+ * overrideSignalFormat(SimpleSignalSchema);
414
+ * ```
415
+ *
416
+ * @remarks
417
+ * - The custom schema replaces the default SignalSchema completely
418
+ * - Schema name in OpenAI format is always "position_open_decision"
419
+ * - Changes persist until application restart or next override
420
+ * - Ensure the custom schema matches your signal processing logic
421
+ *
422
+ * @see {@link SignalSchema} - Default signal schema structure
423
+ * @see {@link OutlineName.SignalOutline} - Outline being overridden
424
+ */
425
+ declare function overrideSignalFormat<ZodInput extends ZodType>(format: ZodInput): void;
426
+
373
427
  /**
374
428
  * Enumeration of supported LLM inference providers.
375
429
  *
@@ -987,4 +1041,4 @@ declare const engine: {
987
1041
  loggerService: LoggerService;
988
1042
  };
989
1043
 
990
- export { alibaba, claude, cohere, deepseek, glm4, gpt5, grok, hf, engine as lib, mistral, ollama, perplexity, setLogger };
1044
+ export { alibaba, claude, cohere, deepseek, glm4, gpt5, grok, hf, engine as lib, mistral, ollama, overrideSignalFormat, perplexity, setLogger };