portfolIQ
Documentation

The AI layer

How AI analyses are generated, historized, and versioned.

The AI layer

portfolIQ enriches each asset with AI-generated analyses. These are factual descriptions — not financial recommendations. Every analysis is stored with full auditability: model ID, prompt version, cost, and timestamp.

What the AI layer produces

Three analysis types are generated per asset:

TypeDescriptionExample output
token_classificationProtocol category and characteristics"Layer-1 proof-of-work network. Primary use case: store of value and settlement layer."
fundamental_summaryProse summary of market position and on-chain fundamentals"Bitcoin holds the largest market cap in crypto with a 30-day average volume of..."
sentiment_scoreAggregated sentiment from the last 48h of news coverage{"score": 0.62, "label": "positive", "source_count": 14}

These are descriptions of observable facts. They are not buy/sell signals, price targets, or investment recommendations.

Model routing

Two Anthropic models are used, selected by complexity and cost:

ModelUsage shareWhen used
Claude Haiku 4.585%Standard analyses — classification, sentiment
Claude Sonnet 4.615%Complex analyses — fundamental summaries, first run on a new asset

The routing logic is deterministic: Haiku for fast, repetitive analyses; Sonnet when the context is rich or the asset is new. This keeps API costs within the project budget (~80–115€/month).

Prompt versioning

Every analysis is linked to a specific prompt template version:

  • Prompts are stored in prompts/registry.yml and version-controlled in git.
  • The prompt_version field (e.g., fundamental_summary_v1.2) is returned in every API response.
  • When a prompt changes, old analyses remain in the database with their original version tag — the history is never overwritten.

This means you can track how the interpretation of an asset has evolved over time, and which prompt generated which output.

AMF guardrails

13 prescriptive patterns are banned from all AI outputs. Analyses are validated before storage:

Banned patterns include: "buy", "sell", "invest", "target price", "should buy/sell", "will rise/fall", "overvalued", "undervalued" (in prescriptive form), "recommended", "guaranteed return".

If an analysis triggers one of these patterns, it is automatically rejected and a regeneration is triggered. The rejection rate is logged (approximately 11 analyses per 78 rejected in Sprint 6 before prompt refinement).

Historization

Every analysis stored in sat_asset_ai_analysis includes:

FieldDescription
modelAnthropic model ID (e.g., claude-haiku-4-5)
prompt_versionTemplate version used to generate this analysis
cost_usd_microsAPI cost in micro-USD (for budget tracking)
cache_hitWhether Anthropic's prompt cache was hit
generated_atUTC timestamp of generation

The table is append-only — analyses are never updated in place. You can query the full history for an asset across all prompt versions.


Not financial advice. Not a fatwa. AI-generated analyses are factual descriptions based on observable market data. portfolIQ is not a registered investment advisor. Methodology disclosed.