Open-source financial indicators, signals, and risk models
Project description
finkit
Open-source financial analysis library. Production-grade indicators, signals, risk metrics, screening, and cost analysis.
No VecTrade account required — this is a standalone library for the quant/fintech community.
Installation
pip install vectrade-finkit
Quick Start
import pandas as pd
import finkit
# ── Technical Indicators ──
df["sma_20"] = finkit.sma(df["close"], period=20)
df["ema_12"] = finkit.ema(df["close"], period=12)
df["rsi"] = finkit.rsi(df["close"], period=14)
macd_line, signal, histogram = finkit.macd(df["close"])
upper, middle, lower = finkit.bollinger_bands(df["close"])
df["atr"] = finkit.atr(df["high"], df["low"], df["close"], period=14)
df["vwap"] = finkit.vwap(df["high"], df["low"], df["close"], df["volume"])
df["obv"] = finkit.obv(df["close"], df["volume"])
# ── Signal Detection ──
df["buy_signal"] = finkit.crossover(df["sma_10"], df["sma_50"])
df["sell_signal"] = finkit.crossunder(df["sma_10"], df["sma_50"])
df["divergence"] = finkit.divergence(df["close"], df["rsi"])
# ── Signal Engine (composable rules) ──
engine = finkit.SignalEngine()
engine.add_rule("rsi_oversold", lambda df: df["rsi"] < 30, direction="long")
engine.add_rule("macd_cross", lambda df: finkit.crossover(df["macd"], df["signal"]), direction="long")
signals = engine.evaluate(df)
# ── Risk Metrics ──
sharpe = finkit.sharpe_ratio(returns, risk_free_rate=0.04)
sortino = finkit.sortino_ratio(returns)
mdd = finkit.max_drawdown(equity_curve)
value_at_risk = finkit.var(returns, confidence=0.95)
# ── Stock Screening ──
from finkit import Rule, screen
results = screen(universe_df, rules=[
Rule("pe_ratio", "<", 25),
Rule("market_cap", ">", 10_000_000_000),
Rule("rsi_14", "between", (30, 70)),
Rule("sector", "in", ["Technology", "Healthcare"]),
])
# ── Cost Analysis ──
cost = finkit.calculate_trade_cost(shares=100, price=150.0, commission_per_share=0.005)
drag = finkit.annual_cost_drag(trades_per_year=200, avg_trade_cost=cost.total, portfolio_value=100_000)
API Reference
finkit.indicators
| Function | Signature | Description |
|---|---|---|
sma |
(series, period=20) |
Simple Moving Average |
ema |
(series, period=20) |
Exponential Moving Average |
rsi |
(series, period=14) |
Relative Strength Index (0–100) |
macd |
(series, fast=12, slow=26, signal=9) |
MACD → (line, signal, histogram) |
bollinger_bands |
(series, period=20, std_dev=2.0) |
Bollinger → (upper, middle, lower) |
atr |
(high, low, close, period=14) |
Average True Range (volatility) |
vwap |
(high, low, close, volume) |
Volume Weighted Average Price |
obv |
(close, volume) |
On-Balance Volume |
finkit.signals
| Function | Signature | Description |
|---|---|---|
crossover |
(fast, slow) |
Bullish crossover detection (boolean Series) |
crossunder |
(fast, slow) |
Bearish crossunder detection (boolean Series) |
divergence |
(price, indicator, window=14) |
Bullish divergence detection |
SignalEngine |
class | Composable rule-based signal scoring engine |
finkit.risk
| Function | Signature | Description |
|---|---|---|
sharpe_ratio |
(returns, risk_free_rate=0.0, periods=252) |
Annualized Sharpe Ratio |
sortino_ratio |
(returns, risk_free_rate=0.0, periods=252) |
Sortino Ratio (downside only) |
max_drawdown |
(returns) |
Maximum peak-to-trough drawdown |
var |
(returns, confidence=0.95, method="historical") |
Value at Risk (historical or parametric) |
finkit.screen
| Function | Signature | Description |
|---|---|---|
Rule |
(field, operator, value) |
Screening rule definition |
screen |
(df, rules) |
Apply rules and return matching rows |
Supported operators: <, <=, >, >=, ==, !=, between, in, contains
finkit.costs
| Function | Signature | Description |
|---|---|---|
calculate_trade_cost |
(shares, price, *, commission_per_share, ...) |
Total trade cost breakdown |
annual_cost_drag |
(trades_per_year, avg_trade_cost, portfolio_value) |
Annualized cost as portfolio drag |
TradeCost |
dataclass | Structured cost result |
Design Principles
- Zero API dependency — works with any pandas DataFrame
- NumPy vectorized — fast computation on large datasets
- Minimal dependencies — only
numpyandpandas - Fully typed —
py.typedmarker, works with mypy/pyright - Well-tested — 99% branch coverage
Part of the VecTrade Ecosystem
| Package | Description |
|---|---|
vectrade |
Python SDK for VecTrade API |
@vectrade/sdk |
TypeScript/Node SDK |
vectrade-finkit |
Financial computation library (this package) |
@vectrade/ai-provider |
Vercel AI SDK provider |
Documentation
Full documentation is available at docs.vectrade.io/sdks/finkit.
Contributing
See CONTRIBUTING.md for development setup and guidelines.
License
Apache-2.0 — see LICENSE.
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
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
File details
Details for the file vectrade_finkit-0.1.0.tar.gz.
File metadata
- Download URL: vectrade_finkit-0.1.0.tar.gz
- Upload date:
- Size: 24.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32c34bf45e24041dbe8e62b8c018487a23778d9e72d073fbcce24bbb9722239c
|
|
| MD5 |
97243db2835a3ae82f256d2c42b945d5
|
|
| BLAKE2b-256 |
31e71795888197d8a802b167c43759da256d091ec5b91e7da193b04217e24064
|
Provenance
The following attestation bundles were made for vectrade_finkit-0.1.0.tar.gz:
Publisher:
publish.yml on VecTrade-io/finkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vectrade_finkit-0.1.0.tar.gz -
Subject digest:
32c34bf45e24041dbe8e62b8c018487a23778d9e72d073fbcce24bbb9722239c - Sigstore transparency entry: 1605236864
- Sigstore integration time:
-
Permalink:
VecTrade-io/finkit@45190f0ebf9244270d94f564dc68a013518aa7ad -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/VecTrade-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@45190f0ebf9244270d94f564dc68a013518aa7ad -
Trigger Event:
release
-
Statement type:
File details
Details for the file vectrade_finkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vectrade_finkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b230bd9f0273a0c5b2455e43dbd07ecd57ba50bdb24bf635561e0edd7da1a4bb
|
|
| MD5 |
e479b637f0dd9b63f0b6a7dd0c949a05
|
|
| BLAKE2b-256 |
77f84da815f26a7adc078d80dbbbfb93e88c9ec860776f7b9b6d43d8a0a802bf
|
Provenance
The following attestation bundles were made for vectrade_finkit-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on VecTrade-io/finkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vectrade_finkit-0.1.0-py3-none-any.whl -
Subject digest:
b230bd9f0273a0c5b2455e43dbd07ecd57ba50bdb24bf635561e0edd7da1a4bb - Sigstore transparency entry: 1605236978
- Sigstore integration time:
-
Permalink:
VecTrade-io/finkit@45190f0ebf9244270d94f564dc68a013518aa7ad -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/VecTrade-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@45190f0ebf9244270d94f564dc68a013518aa7ad -
Trigger Event:
release
-
Statement type: