Skip to main content

Portfolio risk, performance, optimization, and tax, with an agent and a web dashboard.

Project description

finkrit

Portfolio risk, performance, optimization, and tax analytics. An open core quant engine, with an optional conversational agent layer and a web dashboard on top.

What is in here

finkrit is a small, layered stack, a quant core with Agentic AI, an API, and a web app built on top.

Path Import name What it does
packages/finkritq finkritq Deterministic quant core. Holdings, tax lots, prices, risk, performance, optimization, and tax. No agent or web dependency.
packages/finkritintel finkritintel Tool contracts and capabilities. The bridge that exposes the core as callable tools.
packages/finagent finagent Conversational agents over the capabilities, built on pydantic-ai.
services/api/finkritserver finkritserver FastAPI layer that serves the JSON API and the built web app.
apps/finkritweb (web) SvelteKit dashboard. Upload a portfolio, see it, ask about it.

finkritq is the open core and stands on its own. Everything above it adds tools and an agent, and stays optional.

Quickstart

pip install finkrit           # or: pipx install finkrit
export LLM_API_KEY=sk-...      # any OpenAI, Anthropic, or Google key
finkrit                        # start the dashboard, opens your browser

finkrit needs an LLM key. Getting a portfolio in means uploading a CSV, which the model parses, so it does not start without one. Any provider pydantic-ai supports works, keyed by the single LLM_API_KEY variable, or pass it inline with finkrit --key sk-....

Prefer the terminal? finkrit cli chats with the agent over a portfolio instead.

Command line

finkrit            start the dashboard (opens your browser)
finkrit web        the same, explicit
finkrit cli        chat with the agent in the terminal

The dashboard takes:

finkrit --key sk-...           the LLM key inline (should match provider)
finkrit --model openai:gpt-5   pick the provider and model (defaults to openai:gpt-5)
finkrit --url http://host/v1   run against a local model, no key (see Local model)
finkrit --port 8001            serve on a different port
finkrit --dev                  Vite hot reload (source checkout only in case you want to tinker)

Local model

Point the agent at any OpenAI-compatible endpoint (a local Ollama, LM Studio, vLLM, llama.cpp server, or a self-hosted box) with --url. No cloud key is needed, and you set the model to whatever the endpoint serves:

finkrit --model openai:llama3.1 --url http://localhost:11434/v1
finkrit cli --ai qwen2.5 --url http://my-box.local:8000/v1

The agent leans on tool calling, so use a tool-capable model (llama 3.1 or 3.3 70B, qwen2.5-instruct, and similar). Small models often fumble the tool calls. And nothing leaves your machine, so a local model keeps the whole conversation private.

Chat with the agent

finkrit cli is a REPL over a portfolio. With no --file it uses a seeded offline portfolio, 40 AAPL, 30 MSFT, 20 NVDA, 25 JPM, and 35 XOM, each at a cost basis of 100 acquired 2022-01-03, priced with deterministic fake data so runs are reproducible. Point it at your own holdings with a CSV instead, which switches to live market data:

finkrit cli --file my_holdings.csv

A CSV file has one row per tax lot, with four columns: ticker, quantity, cost per share, and acquired date. For example:

ticker quantity cost_per_share acquired
AAPL 100 120.00 2021-05-12
AAPL 50 180.00 2023-03-09
MSFT 95 238.60 2021-02-18
NVDA 140 168.20 2023-03-09

Repeat a ticker for each time you bought it. AAPL above is one holding of 150 shares made of two lots, and they stay separate all the way through. That matters for tax, because a position can be up overall while individual lots are underwater, and those are the ones worth harvesting. Blending them into one average cost hides exactly the losses you are looking for. Buy once and a single row is all you need.

Column names are matched case-insensitively against common aliases, so a typical brokerage export loads without renaming anything:

Field Recognized column names
Ticker ticker, symbol
Quantity quantity, shares, qty, units
Cost per share cost_per_share, cost per share, cost/share, cost basis / share, cost basis per share, price per share, cost basis, avg cost, average cost basis, cost, price, price paid
Acquired acquired, date acquired, purchase date, date

Dates accept YYYY-MM-DD, MM/DD/YYYY, MM/DD/YY, or DD-MM-YYYY. Commas in numbers are stripped, extra columns are ignored, and a missing or unreadable date falls back to a default.

That strict parser is the finkrit cli --file path. The web upload is looser: the raw file goes to the model, which maps whatever columns and formats it finds onto the same four fields and flags anything it had to guess for you to review, so almost any layout works there.

-f, --file PATH    load a portfolio CSV, uses live prices
--ai openai        provider shortcut or a full provider:name string
-ag 0|1|2|3|4      router, risk, optimization, performance, tax
--key sk-...       the LLM key
--quiet            hide the live tool-call trace

The agents

Under the chat sit five agents, four specialists and a router. Each specialist owns one domain and only that domain's tools.

Agent Answers Covers
Risk how risky, what could be lost volatility, variance, semivariance, downside deviation, drawdown and maximum drawdown, value at risk and conditional VaR, beta, and each holding's marginal and component contribution to risk
Performance how it has done total return, annualized return, and the risk-adjusted Sharpe, Sortino, and Calmar ratios
Optimization what to hold the minimum-variance and maximum-Sharpe target weights, long only. Proposed allocations, never trades
Tax what the IRS sees unrealized gains and losses per lot, tax-loss harvesting candidates net of the wash sale window, and the long versus short term split. Read only, describes the tax position and never trades
Orchestrator anything, mixed reads the question, calls whichever specialists can answer, and combines their replies into one

Target a single specialist with -ag, by number or by name:

finkrit cli -ag 1                # risk
finkrit cli -ag performance      # same as -ag 3
finkrit cli --agent optimization

Numbers are 0 router, 1 risk, 2 optimization, 3 performance, 4 tax. Left off, the CLI shows a menu. A single specialist is the direct path, the model sees only that domain's tools and answers with no routing overhead, so pick one when you already know the domain.

How the orchestrator works. The router (agent 0) is itself an agent whose tools each hand a focused sub-question to one specialist. It reads your question, decides which specialists it needs, calls them (one or several), and synthesizes a single answer. So a mixed question in one message, for example "what is my volatility, my annualized return, and the optimal weights?", fans out to those three and comes back combined. It never invents or alters a number, it reports only what a specialist returned. The tradeoff is one extra model loop around the specialists it invokes, which is why a single specialist is cheaper when the domain is known.

The web dashboard always routes through the orchestrator, so any question, risk, performance, or allocation, reaches the right specialist without you choosing one.

From source

To hack on finkrit, clone it and use the bootstrap, which sets up a virtual environment, installs dependencies, builds the web app, and launches.

git clone https://github.com/finkrit/finkrit
cd finkrit
export LLM_API_KEY=sk-...
./run                          # same flags as finkrit web, for example --dev

Prerequisites: Python 3.11 or newer and Node 18 or newer. Later runs skip the setup.

Using the quant core on its own

finkritq is the open core, published on its own so you can install just the quant engine without the agent or web layers.

pip install finkritq            # core, numpy and scipy only
pip install "finkritq[data]"    # adds the live yfinance data provider

It also ships a runnable demo that prints every analytic pillar over a portfolio, no agent involved:

python -m finkritq                                             # seeded, offline
python -m finkritq real NVDA KO PG --benchmark SPY --years 3   # needs [data]

Development

Sources live under packages/ and services/api/. The test runner is configured to put those on the import path, so a fresh clone runs the suite with no extra setup.

pip install -r requirements.txt
pytest                       # the whole suite
pytest packages/finkritq     # one package

Status

Early and moving. The layers above finkritq are the newest. Expect the agent and web surfaces to change while the core settles.

Disclaimer

finkrit is for educational and informational purposes only. It is not financial, investment, or tax advice, and nothing it produces is a recommendation to buy or sell any security. Use your own judgment and consult a licensed professional before making decisions.

The optional data provider uses yfinance to pull market data from Yahoo Finance. finkrit and yfinance are not affiliated with, endorsed by, or sponsored by Yahoo. That data is subject to Yahoo's terms of use and is intended for personal and educational use. Verify anything you rely on against an authoritative source.

The software is provided as is, without warranty of any kind.

License

Apache-2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finkrit-0.1.3.tar.gz (21.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finkrit-0.1.3-py3-none-any.whl (206.3 kB view details)

Uploaded Python 3

File details

Details for the file finkrit-0.1.3.tar.gz.

File metadata

  • Download URL: finkrit-0.1.3.tar.gz
  • Upload date:
  • Size: 21.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for finkrit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 356cc32fead2d4e79e8ab6c913fa28e896fd4e88c370b6230da29990a7824ad2
MD5 1bf813916fde60f23212a1a6895e3a2a
BLAKE2b-256 df1f88ef15f9887781720a0343f7434aa30cf07ce5d4b99527111369f6764259

See more details on using hashes here.

File details

Details for the file finkrit-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: finkrit-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 206.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for finkrit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d8700e0fe20026f4dd21788e46ee6cdd0ba269911cf13f2d744782d9e315e965
MD5 18d79704137fac91303c2d0624c47895
BLAKE2b-256 7a95d81665aa8cca58dc5be5d341a46dffeef1b504a6ee1658ebcc9a91eee2bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page