Skip to content

eyalk11/compare-my-stocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

465 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compare My Stocks

A portfolio analysis lab — not a chart viewer. A workbench where you compose multi-dimensional comparisons of your holdings through point-and-click controls and see the result the moment you adjust a knob.

compare-my-stocks is a desktop app (PySide6 + PyQtGraph + pandas) with deep Interactive Brokers and Polygon integration. Free, open source, no telemetry — BYOK (Bring Your Own Keys): your data stays on disk.

It's meant to provide every stock-chart option you'd want — to make an informed decision or view your portfolio from a new angle. It comes with a research (Jupyter) notebook that provides complementary information of your choice for the relevant stocks.

Slice by ticker, sector, or your own custom groups (e.g. "Airlines", "Cloud", "Banks"); cross against any benchmark, any other ticker, or your full portfolio; switch between price, profit, and value; aggregate a group by mean price or mean performance — every combination is one click apart!

Transactions are pulled directly from Interactive Brokers in real time. They give you realized + unrealized P&L, currency-normalized across markets and automatically split-adjusted. Every parameter combination is reproducible as a saved preset.

If you don't use IB, no problem — just upload a CSV of your transactions from any broker and get a similar experience.

📚 Docs: Quick start · UI reference · Data sources · Configuration · Config help · Command-line · Hosted version


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 shit

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 on Windows (Python 3.14), one PowerShell line — downloads install/installdev.ps1 to your temp dir and runs it. The script pip installs the package and seeds ~/.compare_my_stocks/ with the bundled defaults so the app boots straight away:

$tmp="$env:TEMP\installdev.ps1"; irm https://raw.githubusercontent.com/eyalk11/compare-my-stocks/master/install/installdev.ps1 -OutFile $tmp; try { & $tmp } finally { rm $tmp -Force -ErrorAction SilentlyContinue }

From a checkout, run the script directly — -currentbranch installs from the working tree, -Branch <name> installs from a different GitHub branch:

./install/installdev.ps1                  # install from GitHub master
./install/installdev.ps1 -currentbranch   # install from this checkout
./install/installdev.ps1 -Branch dev      # install from a different branch

installdev.ps1 requires PowerShell, so it's Windows-only. On macOS / Linux follow the manual recipe in the Quick start — same two pip + copy-defaults steps installdev.ps1 runs internally.

Full instructions, IB / Polygon configuration, and your first graph are in the Quick start.


Guides & Configuration

Highly configurable. Because of the many options across both configuration and the UI, it is recommended to start with the guide.

  1. Quick start — install, hook up Interactive Brokers or Polygon.
  2. UI reference — every control in the main window and what it does. Has a page about pitfalls and interacasies .
  3. Data sources — how IB / Polygon / Flex / Statement / CSV / RapidAPI fit together: merge behavior, caches, the gotchas the field-by-field docs don't surface.
  4. Configuration — every field in myconfig.yaml, grouped by area.
  5. Config help — field-by-field credential reference with screenshots of the broker / RapidAPI pages where each token comes from. (Same content as the GUI's Help tab.)
  6. Command-line — all launch flags and environment variables.

Configuration layers

There are two layers, and they don't overlap:

  1. Stocks, groups, categories — configure these in the main app GUI. Use the Add stock combo box to add tickers and the Edit Groups button to manage groups. State is persisted to groups.json automatically; don't hand-edit it.
  2. Data sources, credentials, behavior toggles — are all controlled from
    ~/.compare_my_stocks/myconfig.yaml. Easiest way to edit is the bundled config GUI (though Config/Help button)

More details on configuration in the Configuration guide.


Running

End user (Windows installer)

Launch from Start menu → Compare My Stocks. The same folder also has these pre-made shortcuts:

Shortcut Effect
Compare My Stocks Normal launch
Compare My Stocks (Console) Keeps the terminal attached so startup logs are visible — use this if something looks wrong
Compare My Stocks (Tutorial) Boots against frozen sample data and runs the guided UI tour
Configure Compare My Stocks Standalone config editor (no main window needed)

compare-my-stocks.exe (in the install dir) accepts the same flags as the developer launch below.

Developer (pip)

python -m compare_my_stocks                       # normal launch
python -m compare_my_stocks --console             # keep the terminal attached so startup logs are visible
python -m compare_my_stocks --debug               # DEBUG-level logging
python -m compare_my_stocks --trace               # TRACE-level (even more verbose)
python -m compare_my_stocks --nogui --noprompt    # headless / CI smoke test
python -m compare_my_stocks --tutorial            # launch the guided UI tour
python -m compare_my_stocks --config-file D:\alt.yaml

Standalone config editor (same panes as the installer's Configure shortcut):

python -m compare_my_stocks.gui.config_gui

Set COMPARE_STOCK_PATH=<dir> to point the whole data dir somewhere else — caches, myconfig.yaml, groups.json, graphs.json, logs all live under it.

If something looks wrong, start with --console to see logs. Full flag list and environment variables in the CLI reference.


Architecture (1‑minute version)

┌──────────────┐     ┌──────────────┐     ┌──────────────────────┐
│  gui (Qt)    │────▶│ CompareEngine│────▶│  GraphGenerator      │
│  mainwindow  │     │  orchestrator│     │  (PyQtGraph)         │
└──────────────┘     └──────┬───────┘     └──────────────────────┘
                            │
            ┌───────────────┼─────────────────┐
            ▼               ▼                 ▼
     ┌────────────┐  ┌──────────────┐  ┌──────────────────┐
     │ InputProc. │  │ Transactions │  │ DataGenerator    │
     │ (IB/Poly/  │  │ (IB Flex +   │  │ (price/profit/   │
     │  Cache)    │  │  MyStocks)   │  │  compare/group)  │
     └─────┬──────┘  └──────────────┘  └──────────────────┘
           │
           ▼
     ┌─────────────┐
     │  IBSource   │
     │             │
     └─────────────┘

More detail in CLADUE_REPO.md and the docs site.


Tests

pytest src/compare_my_stocks/tests

The suite covers a wide range of functionality — pure utilities (jupytertools, stockprices.get_hist_split), engine orchestration (call_graph_generator, required_syms, the synthetic-IB end-to-end path), input-pipeline branches (InputProcessor.get_hist_sym, get_status_df, currency adjustment), data-generation parameter grids, serialization round-trips, IB-statement and ibflex parsing, form/parameter wiring, and the full Qt-form initialization. Integration tests (real IB Gateway, live RapidAPI) are gated behind -m integration; the default run is hermetic and offline.


Contributing

Issues and PRs welcome. Practical setup tips live in the detailed guide and the config-GUI help.

If you want to dig into the code:

  • CLADUE_REPO.md — architecture overview and conventions (also useful for humans)
  • Configuration reference — 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: developed and tested on Python 3.14. Older 3.11-based installs may still work but are no longer the primary target.
  • Pandas: the on-disk caches (hist_file.cache, stocksplit.cache, buydicn.cache) are pickled; if you swap pandas versions you may need to migrate them. Don't silently delete the caches — they hold data that's not always re-fetchable.

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. (w.l.g)
  2. The software can consume CSVs exported from My Stocks Portfolio & Widget by Peeksoft.
  3. This project was developed individually in spare time without any 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 data, including graph and computed P&L. ( w.l.g)

Contact

eyalk5@gmail.com · contributions and bug reports welcome.

As a side note, this is not a newbie project - I am quite veteran in coding (despite being a researcher). And I tried to make it as intuitive and user-friendly as possible(as well as pretty well-tested). However, it's a complex project with many moving parts, done in my spare time and mistakes can happen.

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

Packages

 
 
 

Contributors

Languages