"Because nothing beats data"
An all-in-one Python toolkit that pulls transaction performance data from a venue and builds a highly customizable dynamic PDF containing key performance metrics, statistics, plots, and even a short LLM-generated summary.
- Generates tables of performance metrics, allowing for quick asset-group performance analysis.
- Generates plots: line, histogram, pie, density, violin, 2-D histogram, box plot.
- Fully configurable via
.envand easily extendable to suit your needs. - Allows for customization of the PDF layout.
| Feature | Capability |
|---|---|
| Data Collection | Pull transaction logs either locally or from a provider (using a simple connector). |
| Metric Engine | Calculate key performance metrics with a plug-and-play approach, allowing easy extensibility. |
| Asset-by-Asset Comparison | Generate tables of performance metrics, enabling quick analysis by asset group. |
| Layout Customization | Flexible PDF layout customization—build it once for your needs and never touch it again! |
| LLM Integration | Generate quick performance reviews using any Ollama compatible model. |
| Extensible | Easily add new metric functions and data columns for instant use in plots. |
# 1️⃣ Clone the repo
git clone https://github.com/vtx100/pdformance.git
cd pdformance
# 2️⃣ Setup venv
python -m venv .
# Run /Scripts/activate.bat
# 3️⃣ Install dependencies
pip install -r requirements.txt
# 4️⃣(Optional) Create a .env file (see Configuration) and fill in your API keys and LLM settings
# OR generate a sample input file by using `data/random_generator.ipynb`
# 5️⃣ Run the demo
python -m templates.all_features
# → generates example.pdf in the `generations/` folderYou can view a sample generated report here:
generations/example.pdf
This PDF demonstrates the full capabilities of Pdformance, including tables, plots, and LLM-generated summaries.
Sensitive data and configs live in a .env file.
| Variable | Purpose |
|---|---|
BYBIT_API_KEY |
Your Bybit API key |
BYBIT_API_SECRET |
Your Bybit API secret |
LLM_BASE_URL |
Base URL for your LLM provider |
LLM_MODEL |
The model name (use ollama list for local models) |
The base functionality is demonstrated in templates/all_features.py.
You can also generate example data using random_generator.ipynb.
# Read and sanitize logs from file
df = client.read_and_sanitize_logs(data_path)# Fetch Bybit logs and store the data
logs = client.get_closed_pnl_logs(Interval.WEEK)
client.save_pnl_logs_to_csv(logs, data_path)
# Format logs for further use
formatted_logs = client.sanitize_logs(logs)ctx = Context(...)
custom_metrics = get_metrics_from_header_symbols(
ctx=ctx,
header_symbols=...,
metrics=['all'] # add custom metric names here
)plots_list = [
(get_plot, (ctx.df, ..., ...), {...}),
(get_hist, (ctx.df, ...), {...}),
# Add additional plot types as needed
]
fig = plot_grid(plots=plots_list, cols=2)
pdf.add_plt(fig)pdf = PdfGenerator(...)
pdf.add_doc_info(...)
pdf.add_section(...)
pdf.add_llm_response(...)
pdf.add_stats_table(...)
pdf.add_plt(...)
pdf.add_baseline_data(...)
pdf.add_empty_line(...)llm = LLMAgent(
base_url=os.getenv("LLM_BASE_URL"),
model=os.getenv("LLM_MODEL"),
)
report = llm.generate_completion(
prompt=...,
data=...
)
pdf.add_llm_response(response=report)Define a function in src/metrics.py that accepts a Context and returns a Stat.
def my_custom_metric(ctx: Context) -> Stat:
# Your implementation here
return Stat(...)Follow the schema of functions inside src/plots.py.
The prompt string in ai_agent.generate_completion() is fully free-form.
You can also overwrite the context parameter to ask for sentiment analysis, trading strategy overview, or other insights.
This project was originally built for personal use, as I couldn't find anything similar on the market.
I use it frequently to generate simple performance reports and decided to release it publicly.
Feel free to build on it further if you find it useful.
Happy reporting! 🎉
Due to Unicode rendering of LLM output, this project uses Noto Sans.
- Font Family: Noto Sans
- License: SIL Open Font License, Version 1.1