Skip to main content

utss-llm - LLM Strategy Parser

Convert natural language descriptions into validated UTSS trading strategies.

Installation

# Core package
pip install utss-llm

# With specific provider
pip install utss-llm[openai]      # OpenAI (GPT-4)
pip install utss-llm[anthropic]   # Anthropic (Claude)
pip install utss-llm[gemini]      # Google (Gemini)
pip install utss-llm[local]       # Ollama (local models)

# All providers
pip install utss-llm[all]

Quick Start

from utss_llm import StrategyParser
from utss_llm.providers import get_anthropic_provider

# Initialize provider
AnthropicProvider = get_anthropic_provider()
provider = AnthropicProvider(api_key="sk-ant-...")

# Create parser
parser = StrategyParser(provider=provider)

# Parse natural language to strategy
result = parser.parse_sync(
    "RSI reversal strategy for AAPL. "
    "Buy when RSI drops below 30, sell when above 70. "
    "Use 10% of equity per trade with 5% stop loss."
)

if result.success:
    print(f"Strategy: {result.strategy.info.name}")
    print(f"YAML:\n{result.yaml_output}")
else:
    print(f"Errors: {result.errors}")

Providers

OpenAI

from utss_llm.providers import get_openai_provider

OpenAIProvider = get_openai_provider()
provider = OpenAIProvider(
    api_key="sk-...",  # or set OPENAI_API_KEY env var
    model="gpt-4o",    # default
)

Anthropic

from utss_llm.providers import get_anthropic_provider

AnthropicProvider = get_anthropic_provider()
provider = AnthropicProvider(
    api_key="sk-ant-...",  # or set ANTHROPIC_API_KEY env var
    model="claude-sonnet-4-20250514",  # default
)

Google Gemini

from utss_llm.providers import get_gemini_provider

GeminiProvider = get_gemini_provider()
provider = GeminiProvider(
    api_key="...",  # or set GOOGLE_API_KEY env var
    model="gemini-1.5-flash",  # default
)

Local (Ollama)

from utss_llm.providers import get_local_provider

LocalProvider = get_local_provider()
provider = LocalProvider(
    model="llama3.1",  # default
    host="http://localhost:11434",  # default
)

Parsing Modes

Advanced Mode (Default)

One-shot generation - the LLM generates the complete strategy immediately.

parser = StrategyParser(provider=provider, mode=ParseMode.ADVANCED)
result = parser.parse_sync("Buy AAPL when RSI < 30")

Beginner Mode

Interactive Q&A - the parser asks clarifying questions before generating.

parser = StrategyParser(provider=provider, mode=ParseMode.BEGINNER)

# First call may return questions
result = parser.parse_sync("Create a momentum strategy")
if isinstance(result, list):
    print("Questions:", result)
    # Answer questions and call again
    result = parser.parse_sync("Create a momentum strategy", answers={...})

Async Usage

import asyncio
from utss_llm import StrategyParser

async def main():
    parser = StrategyParser(provider=provider)
    result = await parser.parse("Buy when RSI < 30")
    print(result.strategy)

asyncio.run(main())

ParseResult

@dataclass
class ParseResult:
    success: bool                    # Whether parsing succeeded
    strategy: Strategy | None        # Validated UTSS Strategy object
    yaml_output: str | None          # Generated YAML string
    errors: list[str]                # Validation or generation errors
    assumptions: list[str]           # Assumptions made by the LLM
    suggestions: list[str]           # Suggestions for improvement
    tokens_used: int                 # Total tokens consumed

License

MIT

Metadata

Release files for utss-llm 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for utss-llm 0.1.1
File Size Uploaded Provenance
utss_llm-0.1.1.tar.gz 21.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for utss-llm 0.1.1
File Interpreter ABI Platform
utss_llm-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 50.6 kB

Release files / utss_llm-0.1.1.tar.gz

Download URL utss_llm-0.1.1.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a1aebe9df09959ff8cd8d8ced83ed531a88839952fdeb9ba05d3ce539ae34652
BLAKE2b-256 checksum
How to use checksums
9f44cc2a06137a4860b5cc00d6e3c855800a176393ccb9a8ab3ee6e2d884f80c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release files / utss_llm-0.1.1-py3-none-any.whl

Download URL utss_llm-0.1.1-py3-none-any.whl
Size 29.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6699a9f051e32fdb8ddf18bb5bde6057dce3cdc171235bec2415f653ac812ace
BLAKE2b-256 checksum
How to use checksums
062455c987d158a1cfd91f8951ea1148b9c4edcd0937ca53a50a2b8d8c0cbf6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Security for utss-llm 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page