Skip to content

eyalk11/compare-my-stocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

316 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Compare My Stocks

Visualize and compare the performance of stocks in your portfolio β€” by ticker, by sector, against benchmarks, and against your own realized P&L.

compare-my-stocks is a desktop app (PySide6/Qt + matplotlib + pandas) with deep Interactive Brokers and Polygon integration, plus an embedded Jupyter notebook for ad‑hoc analysis. BYOK (Bring Your Own Keys): you keep your data, the app just visualizes it.

πŸ“š Docs: GitHub Pages Β· Quick start Β· Configuration reference Β· Wiki


Examples

Profit per sector vs the entire portfolio, since a chosen date:

sectors

(You won't see your portfolio until you upload your transactions.)

A specific airline, the airlines as a group, and Nasdaq:

airlines

ESYJY here is ~48% behind the Nasdaq since 04/01/2021 β€” and significantly behind airlines as a group. That kind of cross-cut is the point of the app.


Why use it

  • Cross-sectional comparison. Group your tickers (e.g. "Airlines", "Cloud") and compare a group's average against any other ticker, group, or your portfolio.
  • Real P&L. Pull realized + unrealized profit, automatically synced with IB, split-adjusted, currency-normalized.
  • No vendor lock-in. Works offline once data is cached. Export to CSV. Load your own Jupyter notebook for custom analysis.
  • Free and open source. No subscription, no telemetry.

Features

βœ… Working Β Β  βšͺ Present but not finished Β Β  βš•οΈ Planned

Market data

  • βœ… Price history from Interactive Brokers (via the ibsrv sidecar)
  • βœ… Price history from Polygon
  • βœ… Crypto and ETFs
  • βœ… Stocks from any exchange IB supports

Portfolio

  • βœ… Import transactions from My Stocks Portfolio CSV β€” works with any broker
  • βœ… Pull transactions from IB Flex
  • βœ… Realized + unrealized P&L
  • βœ… Currency normalization (set a base currency; everything converts)
  • βœ… Holdings auto-adjusted for stock splits

Graphs

  • βœ… Many graph types: Total Profit, Price, Realized Profit, Compare, …
  • βœ… Compare vs another ticker, vs a group, vs your portfolio
  • βœ… Show % change / % diff from a chosen point, max, or min
  • βœ… Pick top-N stocks or filter by value range
  • βœ… Unite a group by avg price or avg performance
  • βœ… Save and reload graph parameter presets (graphs.json)
  • βšͺ Compare your actual P&L against a hypothetical "what if I'd bought the index instead" portfolio

Jupyter integration

  • βœ… Embedded notebook with the current graph's data preloaded
  • βœ… Edit & reload notebook directly from the app
  • βœ… One-line correlations: mydata.act.df.corr(method='pearson')
  • βœ… Generate graphs from code:
    gen_graph(Parameters(type=Types.PRICE | Types.COMPARE,
                         compare_with='QQQ', groups=["FANG"]))
  • βšͺ Inline graphs in Jupyter

More

  • βœ… Define & edit categories / groups in the GUI
  • βœ… Completely free and open source

Planned

  • βš•οΈ P/E and price-to-sales overlays
  • βš•οΈ Bar graphs
  • βš•οΈ Inflation-adjusted performance
  • βš•οΈ Web frontend
  • πŸ”΄ Not planned: technical-analysis indicators

Install

End users should grab the Windows installer from Releases.

This is actually recommended to everyone if not want to mess with Python and dependencies β€” the installer bundles everything.

For developers, the easiest path is the bundled PowerShell installer install/installdev.ps1 (Python 3.11) β€” it runs pip install "compare-my-stocks[full]" and copies the bundled defaults into ~/.compare_my_stocks/. Pass -currentbranch to install from the current checkout instead of PyPI:

./install/installdev.ps1                  # install from PyPI
./install/installdev.ps1 -currentbranch   # install from this checkout

The pip-based developer install should also work on macOS and Linux, but those platforms are untested β€” installdev.ps1 itself requires PowerShell, so on non-Windows you'll need to run its pip install and data-copy steps by hand.

Full instructions, IB / Polygon configuration, and your first graph are in docs/QUICKSTART.md.


Configuration

All behavior is controlled by ~/.compare_my_stocks/data/myconfig.yaml. Every option is documented in docs/CONFIGURATION.md, along with the most common tweaks (longer history, different data source, display scaling, …).

Highly configurable.


Running

python -m compare_my_stocks               # normal launch (developer)
compare-my-stocks.exe                     # normal launch (installed)

python -m compare_my_stocks --console     # keep the console attached
python -m compare_my_stocks --debug       # DEBUG-level logging
python -m compare_my_stocks --nogui       # headless mode
python -m compare_my_stocks --config-file D:\alt.yaml

If something looks wrong, always start with --console to see logs.


Architecture (1‑minute version)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  gui (Qt)    │────▢│ CompareEngine│────▢│  GraphGenerator      β”‚
β”‚  mainwindow  β”‚     β”‚  orchestratorβ”‚     β”‚  (matplotlib)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β–Ό               β–Ό                 β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚ InputProc. β”‚  β”‚ Transactions β”‚  β”‚ DataGenerator    β”‚
     β”‚ (IB/Poly/  β”‚  β”‚ (IB Flex +   β”‚  β”‚ (price/profit/   β”‚
     β”‚  Cache)    β”‚  β”‚  MyStocks)   β”‚  β”‚  compare/group)  β”‚
     β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚  ibsrv.exe  β”‚ ◀────── β”‚  Pyro5 RPC (separate     β”‚
     β”‚  sidecar    β”‚         β”‚  process; isolates IB)   β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

More detail in CLAUDE.md and the wiki.


Tests

pytest src/compare_my_stocks/tests

Contributing

Issues and PRs welcome. Pre-existing wiki: Things good to know when using the app.

If you want to dig into the code:

  • CLAUDE_REPO.md β€” architecture overview and conventions (also useful for humans)
  • docs/CONFIGURATION.md β€” every config field
  • src/compare_my_stocks/engine/compareengine.py β€” the orchestrator
  • src/compare_my_stocks/processing/ β€” data transforms
  • src/compare_my_stocks/ibsrv.py β€” the IB sidecar process

Compatibility & remarks

  • OS: developed and tested on Windows. Other OSes are unverified.
  • Display: designed around 1920Γ—1080. Auto-scales for other resolutions; set Running.TryToScaleDisplay: false if the auto-scale misfires.
  • Data location: the app creates ~/.compare_my_stocks/ (override via COMPARE_STOCK_PATH) for logs, caches, and config.
  • Python & Pandas pin: pandas==1.5.3 is intentional β€” caches on disk are pickled with that version. Don't upgrade without migrating the cache. Will change soon. That also means Python 3.11 is required, since Pandas 1.5 is not supported on 3.12 .

Legal

  1. No warranty. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM USE OF THIS SOFTWARE β€” including any claim associated with usage of the Interactive Brokers API. Consult the relevant providers' licenses before use.
  2. The software can consume CSVs exported from My Stocks Portfolio & Widget by Peeksoft.
  3. This project was developed individually, in spare time, without compensation. The author is not affiliated with Interactive Brokers, Polygon, Peeksoft, or any mentioned company.
  4. The author takes no responsibility for the correctness of any displayed graph or computed P&L.

Contact

Eyal Karni Β· eyalk5@gmail.com Β· contributions and bug reports welcome.

About

A system for visualizing interesting stocks. Has powerful comparison capabilities and works seamlessly with your jupyter notebook. Written in QT with matplotlib.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors