LLM-powered natural language to UTSS strategy parser
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
utss_llm-0.1.1.tar.gz
(21.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
utss_llm-0.1.1-py3-none-any.whl
(29.0 kB
view details)
File details
Details for the file utss_llm-0.1.1.tar.gz.
File metadata
- Download URL: utss_llm-0.1.1.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1aebe9df09959ff8cd8d8ced83ed531a88839952fdeb9ba05d3ce539ae34652
|
|
| MD5 |
c66fadf22da8c73dc7a5deb17c813fdd
|
|
| BLAKE2b-256 |
9f44cc2a06137a4860b5cc00d6e3c855800a176393ccb9a8ab3ee6e2d884f80c
|
File details
Details for the file utss_llm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: utss_llm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6699a9f051e32fdb8ddf18bb5bde6057dce3cdc171235bec2415f653ac812ace
|
|
| MD5 |
90a67a00428a571b202fa29dc3ea6fd3
|
|
| BLAKE2b-256 |
062455c987d158a1cfd91f8951ea1148b9c4edcd0937ca53a50a2b8d8c0cbf6e
|