X402 Git

crypto-balanced-portolio-builder

Paul Martin

Balances your crypto portfolio using coinstats export

Top level of the repository
SizeFolderInside
2.5 MBdocs/3 assets · 2 docs
60.2 kB(root)2 docs · 2 other files
10 files · 2.6 MB · computed 2026-09-16
SizePath
72 B.gitignore
1.1 kBLICENSE
7.2 kBREADME.md
51.8 kBcrypto_portfolio_capped_v4.html
572 kBdocs/coinstats-export-mobile.jpg · binary
1.1 MBdocs/coinstats-export-web.png · binary
1 kBdocs/release-v1.0.0.md
1.3 kBdocs/release-v1.0.1.md
339 Bdocs/sample-coinstats-balances.csv
847 kBdocs/screenshot.png · binary
computed 2026-09-16 12:44 UTC · analyzer 0.1.0

Already bought this?

View your purchases

README

Crypto Portfolio by Market Cap

Build a market-cap-weighted crypto portfolio with per-asset caps, then get an exact buy/sell list to rebalance. Built with CoinStats users in mind, but any holdings CSV works.

Crypto Portfolio by Market Cap: inputs on the left, target allocation table and donut chart top right, and the buy/sell rebalancing table generated from a holdings export below

License: MIT Version Single file No dependencies


Who this is for

CoinStats users who want to rebalance quickly. CoinStats tells you what you own, but not what to buy or sell to reach a target allocation. Export your Balances CSV, set a target, upload the file, and you get a per-coin BUY / SELL / HOLD list with exact units and dollar amounts. The export steps are documented below with screenshots.

Anyone who wants a market-cap-weighted portfolio. You don't need CoinStats, or any holdings file at all. Set a portfolio size, a number of coins and a maximum weight per coin, and the tool builds the allocation from live market data. If you track holdings somewhere else, any CSV with a Symbol column and an Amount column gives you the same rebalancing list.

Either way, the whole thing is one HTML file that runs in your browser. No accounts, no servers, no API keys, no install. Your holdings never leave your machine.

Quick start

  1. Download crypto_portfolio_capped_v4.html.
  2. Open it in any modern browser (double-click it).
  3. Set your inputs and click Build Portfolio. This fetches live market caps from CoinGecko and builds your target allocation.
  4. Optional: under Rebalance from CoinStats, upload your holdings CSV and click Compare Holdings.
  5. Read the Portfolio Adjustments Needed table, or click Download Adjustments CSV.

Want to try step 4 before exporting anything? Upload docs/sample-coinstats-balances.csv.


Exporting your balances from CoinStats

If you use CoinStats, this is the file to upload in step 4. CoinStats currently marks CSV export as a Premium feature.

Web (coinstats.app)

  1. Go to the Portfolio Tracker page and select the portfolio you want to rebalance.
  2. Open the Assets tab.
  3. Click the Export button (the download icon at the top right of the assets table).
  4. Choose Balances. Save the CSV file.

CoinStats web app: Assets tab selected in the left sidebar, Export button highlighted at the top right of the assets table, with a dropdown showing Transaction History and Balances

Mobile app (iOS / Android)

  1. Open the Portfolio tab and pick the portfolio you want to rebalance.
  2. Tap the three-dot button below the chart.
  3. Tap Portfolio Settings.
  4. Scroll down and tap Export Data.
  5. Choose Balances and save or share the CSV file, then get it onto the computer where you'll open the tool.

CoinStats mobile app: the three-dot menu below the portfolio chart opens a sheet with Portfolio Settings; the Portfolio Settings screen has Export Data at the bottom

Steps and screenshots are from the CoinStats help article How to Export Transactions to CSV. If the CoinStats interface changes, that article is the source of truth.

Export Balances rather than Transaction History. The transaction export lists individual trades, not what you currently hold.

Using a CSV from somewhere else

The tool only needs two columns: Symbol and Amount (column names are matched case-insensitively, and an Amount or Total column both work). Extra columns are ignored. Multiple rows for the same symbol are summed, so a coin held on several exchanges or wallets is treated as one position. Exports from most other trackers and exchanges will work as-is or after renaming a header.


What the tool does

Builds a target allocation

  • Pulls the top N coins by market cap from CoinGecko (live, paginated, deduplicated by symbol).
  • Weights each coin by market cap, clips anything over your per-coin cap, and redistributes the excess proportionally until every dollar is allocated.
  • Lets you pin specific coins to exact percentages with custom targets. Whatever remains is spread across the market-cap-weighted coins.
  • Excludes stablecoins by default, plus a default exclusion list you can edit.

Compares it against your current holdings

  • Every coin you hold or should hold gets an action: BUY, SELL or HOLD.
  • Shows current units, target units, the delta, and the same in USD.
  • Coins you hold that are not in the target get a SELL row so nothing is silently ignored.
  • Summary chips: current value, target value, number of buys and sells, net adjustment.

Exports

  • Target allocation as CSV or JSON, respecting the current sort order.
  • Adjustments list as a separate CSV once you've compared holdings.

Interface

  • Sortable results table with inline weight bars showing the cap and any clipped portion.
  • Donut chart with hover highlighting synced to the legend.
  • Dark, responsive, keyboard accessible. Coin names link to CoinGecko.

How the allocation maths works

  1. Fetch the top N coins by market cap from CoinGecko.
  2. Compute baseline weights as coin market cap / total market cap.
  3. Apply the per-coin cap and redistribute clipped weight proportionally until fully allocated.
  4. Subtract any custom targets first; the rest of the portfolio is allocated by market cap.
  5. Convert weights to target USD and target units using your portfolio value.
  6. If you uploaded holdings, compare target units against what you hold to produce the buy/sell list.

Development

  • Stack: HTML + CSS + vanilla JS, no dependencies
  • Single file: edit crypto_portfolio_capped_v4.html directly
  • Testing: open the file in a browser; there is no build

Notes & limitations

  • Uses CoinGecko's free public API for market data. Rate limits (HTTP 429) are handled with retry/backoff, but heavy refreshing will still get throttled.
  • Prices come from CoinGecko, not from your holdings export, so values can differ slightly from what your tracker shows.
  • All calculations are client-side. Verify the numbers before you trade on them.
  • Not financial advice.

Privacy

100% client-side. The only network request the page makes is to CoinGecko's public API for market data. Your portfolio size, holdings CSV, and allocations never leave your machine.


Attribution

License

MIT — free to use, modify, and distribute, including commercially.

Security scan report

Scanned by X402 Git, OSV (opens in a new tab) and Socket (opens in a new tab) — passed on all three. Findings from X402 Git are listed below.

secrets
none found
X402 Git
size limits
within caps
X402 Git
known malware
no dependency manifests to check
OSV
known vulnerabilities
no dependency manifests to check
OSV
dependency behaviour
no dependency manifests to check
Socket
instruction smuggling
none found
X402 Git
what it can do
listed below
X402 Git

What this can do

Tools
none
Runs
nothing
Talks to
  • api.coingecko.com
  • www.coingecko.com
Reads
no environment variables
At install
nothing runs
Links to
  • coingecko.com
  • help.coinstats.app
  • img.shields.io
Findings (2)
  • LOWcrypto_portfolio_capped_v4.html — Talks to api.coingecko.com
  • LOWcrypto_portfolio_capped_v4.html — Talks to www.coingecko.com

Releases 2

  1. v1.0.12026-09-16

    Repositioning and documentation release. No changes to the allocation or rebalancing maths.

    Getting started: download crypto_portfolio_capped_v4.html below and open it in any modern browser.

    • CoinStats front and centre. The README and in-app copy now explain that the tool is built for CoinStats users who want to rebalance quickly, while still working for anyone with a Symbol/Amount holdings CSV or no holdings file at all.
    • Step-by-step CoinStats export guide for web and mobile, with screenshots from the CoinStats Help Center, plus a sample Balances CSV (docs/sample-coinstats-balances.csv) to try the rebalancing flow without exporting anything.
    • New demo screenshot showing the full flow: target allocation, donut chart and the buy/sell adjustments table.
    • Holdings panel renamed to "Rebalance from CoinStats" with the export path shown inline.
    • White-labelling removed. The branding config object, footer and related docs are gone; the title and version are plain text.
    • Third-party branding removed from the README, HTML and LICENSE.
    Notes

    Uses CoinGecko's free public API; rate limits are handled with retry/backoff but heavy refreshing will still get throttled. All calculations are client-side. Verify before trading. Not financial advice.

  2. v1.0.02026-09-01

    First packaged release of Crypto Portfolio by Market Cap.

    A single-file, client-side tool that builds a market-cap-weighted crypto portfolio with per-asset caps. Live CoinGecko data, buy/sell rebalancing against your current holdings, CSV/JSON export. No accounts, no servers, no API keys, no build step.

    Getting started: download crypto_portfolio_capped_v4.html below and open it in any modern browser.

    What's in this release
    • MIT licensed — free to use, modify and distribute, including commercially.
    • White-label ready — every brand-facing string lives in a single APP object at the top of the script block. Change the name, version, brand and footer in one place; set brandName to an empty string to hide the footer. Colors are CSS custom properties in :root.
    • Metadata — proper page title, meta description, Open Graph tags and an inline SVG favicon, all embedded so the file stays genuinely standalone.
    • Rewritten README with a screenshot of the running app and white-labelling docs.
    Notes

    Uses CoinGecko's free public API; rate limits are handled with retry/backoff but heavy refreshing will still get throttled. All calculations are client-side — verify before trading. Not financial advice.

$0.02updates $0.005

Buy — go to the order block