Skip to content

About

FIN — the financier's bash terminal for markets & portfolio research: live quotes, crypto, FX, net worth, realtime TUI, and a full Bourse de Casablanca (MASI + dirham) corner for Moroccan market students

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

FIN — the financier's terminal

A batteries-included bash toolkit wired into your prompt (~/.bashrc → ~/.fin/fin.sh). Live quotes, crypto, FX, movers, net worth, a journal, a realtime TUI, a Bourse de Casablanca (BVC) focus, and a switchable palette system. This README is the tour — enjoy.


1. Quick start

The changes are already in your .bashrc. To pick them up in an already-open shell:

source ~/.bashrc        # or simply open a new tab
fin help                # the in-terminal cheat-sheet
fin theme               # preview the 5 palettes
bvc                     # the Casablanca board

2. Your prompt

Every prompt is two lines, kept clean — no market box:

╭─ yirviel@ubermensch · ~ · main✓  Sat 19 Sep · 02:26
╰─❯ 
piece meaning
user@host who and where
· path current directory (~ = home)
main✓ git branch shown while inside a repo; ● instead of ✓ = dirty
Sat 19 Sep date + local time
╰─❯ the input arrow

The live market signal was removed from the prompt — MASI is now command-only (masi, bvc, bvc watch). Nothing fetches in the background between commands.


3. Command reference

Which ever alias you remember, they all work:

command what it does
q AAPL MSFT BTC-USD instant quotes; add a sparkline by quoting one symbol
crypto / coins BTC ETH CoinGecko prices, 24h % and market cap
fx 100 USD EUR GBP currency converter (ECB daily rates)
markets full snapshot, BVC-first: MASI · dirham · US indices · crypto · FX
tape 5 loop markets live every 5s (Ctrl-C quits)
movers 10 / gainers 5 top gainers and losers across your stock universe
cmovers 8 / cg crypto movers
news AAPL (or news 8) top headlines (default market-wide)
worth / networth net-worth dashboard from worth.tsv, with allocation bar
journal add sold 2 AAPL timestamped note (re-log whatever happened)
journal show recent entries
portfolio new n AAPL:40 … build a weighted basket of symbols you pick
portfolio add n SYM W add / reweight a holding
portfolio show n / list inspect baskets (weights, live prices, allocation)
montecarlo n / mc n block-bootstrap Monte Carlo of basket n
mc n --years 2 --sims 50000 tune horizon / paths / --seed / --initial / --json
mkt / dash realtime TUI: charts, heatmap, macros (~/.bin/mkt)
ticker BTC-USD AAPL stream raw ticks to stdout
fticker BTC-USD SKY non-streaming poll loop
bvc the whole Casablanca board from TradingView
bvc watch / bw MASI + dirham + your BVC watchlist only
bvc tape [n] live loop of the Casablanca board
bvc ATW one Casablanca quote (any CSEMA ticker)
ma / morocco / casa / bourse aliases for bvc
fin / fin help the in-terminal help

BVC focus — bvc / ma / casa / bourse

The full Bourse de Casablanca, one command. Yahoo dropped MASI in 2019, so this pulls every listing from TradingView's CSEMA scan and the dirham from TradingView FX:

╭─ bvc · bourse de casablanca──────────────────────────
    ^MASI MASI · All-Shares Index      17,592.46  ▼ -2.01%   day 18,091.53 – 17,587.72
  listed 77  · adv/dec/flat 7/57/13
  volume 1.9M  · market cap 107G MAD
  dirham  USD/MAD 9.51  ·  EUR/MAD 10.90  (TradingView FX)

  ── top gainers ──      ── top losers ──      ── most active ──
  SYM   NAME ...         (best & worst of the board by change % / volume)

  ── sectors · market cap ──
  Finance              20  ██████████████████  100%         37G
  Non-Energy Minerals   8  ██████████████   79%         29G
  …

  ── watchlist  (FIN_BVC → CSEMA) ──
  ATW  Attijariwafa Bank SA  680.50 ▼ -2.47%  73k   …
  • bvc — the full board. bvc watch — just MASI, dirham and your watchlist. bvc tape 5 loops live, bvc ATW quotes a single listing.
  • masi — the index alone, with its daily range.
  • The MASI also leads markets (now BVC-first), and the prompt stays clean — no background market fetch between commands.
  • FIN_BVC in ~/.fin/finrc is the watchlist (naked CSEMA tickers; .CA is still accepted and stripped).
  • The dirham pairs come from TradingView (USDMAD, EURMAD).

4. Style — pick a palette

Five color families, mixed at 256-color depth so every fin view stays cohesive:

theme vibe
bvc Bourse de Casablanca: royal blue, emerald, gold — the default, no pink
casablanca midnight-in-Casablanca: hibiscus, sand, mint, ochre
aurora northern lights: meadow, ocean, summit violet
ribat royal Moroccan flag: crimson, emerald, gold
neondark terminal neon sign: magenta, cyan, amber
fin theme               # list palettes (shows each accent bar)
fin theme casablanca    # switch instantly, right now
fin theme --persist ribat   # switch AND save for every new terminal
fin theme --persist bvc     # back to the BVC default

The persisted choice is stored in ~/.fin/finrc as FIN_THEME=…. To hand-tune any color, edit the palettes inside fin_apply_theme() at the top of ~/.fin/fin.sh.

Your terminal (Ptyxis) color scheme

The emulator palette was set to Nord (blue/green, no pink) to match the BVC look. To change it: Ptyxis → Preferences → Profile → Colors — or from a terminal:

# list the palettes bundled with Ptyxis
gresource list /usr/bin/ptyxis | sed 's#.*/palettes/##; s#\.palette$##'
# switch (replace <UUID> — see ptyxis-restore.txt)
gsettings set "org.gnome.Ptyxis.Profile:/org/gnome/Ptyxis/profile-2129f7604351f2299ac394ca6aadd39f/" palette 'Nord'

The terminal stays in dark mode (interface-style = dark).

Wanted the default palette back? Reset it:

gsettings reset "org.gnome.Ptyxis.Profile:/org/gnome/Ptyxis/profile-2129f7604351f2299ac394ca6aadd39f/" palette

Backups live here: ~/.fin/ptyxis-restore.txt.


5. Config — ~/.fin/finrc

Everything is overridable:

FIN_THEME=bvc            # active palette (bvc casablanca aurora ribat neondark)

FIN_TTL_QUOTE=45         # quote cache TTL (seconds)
FIN_TTL_CRYPTO=30        # crypto cache TTL

FIN_MACRO=…              # rows shown by `markets`/`tape` (BVC-first: ^MASI, USDMAD=X, …)
FIN_BVC=…                # Casablanca watchlist for `bvc` / `bvc watch`
FIN_UNIVERSE=…           # universe scanned by `movers`
FIN_COINS=…              # default coins for `crypto`
FIN_NEWS_SYM=^GSPC       # default news symbol
FIN_WORTH_FILE=…         # net-worth ledger path
FIN_TAIPE_INTERVAL=8     # `tape` refresh (seconds)

FIN_MC_YEARS=1           # Monte Carlo horizon (years)
FIN_MC_SIMS=10000        # Monte Carlo paths
FIN_MC_RANGE=5y          # history window per asset (Yahoo)
FIN_MC_BLOCK=5           # block-bootstrap block (trading days)
FIN_MC_INITIAL=10000     # starting capital for the distribution
FIN_MC_SOURCE=auto       # history: auto (TradingView→Yahoo) | tv | yahoo

6. Net worth ledger — ~/.fin/worth.tsv

Tab-separated: label <TAB> qty <TAB> symbol <TAB> class.

Schwab cash     12000    USD      cash
Euro savings     15000   EUR      cash      # counts only if the pair resolves
Apple             100    AAPL     stock
SPDR S&P 500 ETF   50    SPY      etf
Bitcoin           0.42    BTC-USD  crypto

Classes: cash (symbol = a currency like USD/EUR/GBP), stock, etf, crypto. worth prints every holding in USD, the total, and an allocation bar per class.

7. Journal

journal add … appends YYYY-mm-dd HH:MM<TAB>message to ~/.fin/journal/YYYY-MM.tsv; journal shows the newest entries first.


8. Portfolio + Monte Carlo

Pick your own symbols and weights, then simulate the basket — all from the prompt.

portfolio new tech AAPL:40 MSFT:35 BTC-USD:25   # create (SYM:WEIGHT; % optional)
portfolio add tech NVDA 10                       # add / reweight a holding
portfolio show tech                              # weights, live prices, allocation bar
portfolio list                                   # every basket you've saved
mc tech                                          # 1y · 10,000 paths · 5d block bootstrap
mc tech --years 2 --sims 50000 --initial 25000   # tune horizon, paths, capital
mc tech --seed 42                                 # reproducible run
mc tech --json                                    # machine-readable result

Baskets live in ~/.fin/portfolios/<name>.tsv as SYMBOL<TAB>WEIGHT; weights are normalized automatically, so 20 20 20 means equal thirds. portfolio edit <name> opens the raw file in $EDITOR.

The engine (~/.fin/mc.py, numpy) pulls daily history per asset, computes the joint return matrix, then block-bootstraps it (default 5-day blocks) into future paths — so real fat tails and cross-asset correlations survive. It reports the terminal-value distribution, percentiles, P(loss), VaR/CVaR 95 and a median CAGR, plus an ASCII histogram. Portfolio return is the weight-sum of asset returns (target weights, daily rebalanced).

Data. History comes from TradingView's websocket by default — it covers BVC / CSEMA (ATW, ATW.CA, CSEMA:ATW), US and global stocks, crypto (BTC-USD → CRYPTO:BTCUSD), FX and indices — with Yahoo as fallback (--source auto|tv|yahoo). The first run caches each series in ~/.fin/cache/mc_*.json; after that it's instant and works offline, and a throttled source falls back to the newest cached copy. No websocket-client? It degrades to Yahoo automatically.

Symbols are mapped for you: .CA → CSEMA:ticker, BTC-USD → CRYPTO:BTCUSD, USDMAD=X → FX_IDC:USDMAD, ^GSPC → SP:SPX, and a full EXCHANGE:TICKER (e.g. NASDAQ:AAPL, BINANCE:BTCUSDT) passes straight through. A bare ticker is resolved by TradingView.

Prefer your own data? Drop a CSV in the basket or use --prices:

mc bvc --prices ~/prices.csv          # CSV: date,AAPL,ATW,IAM,... (one column per asset)
mc bvc                                # or reference a per-symbol CSV in the portfolio:
#   /home/me/exports/ATW.csv  40       # date,Open,High,Low,Close (TradingView export)
#   /home/me/exports/IAM.csv  60

A per-symbol CSV may be a TradingView export (the column named Close is used) or plain date,close. Daily data is aligned across assets by ISO date (YYYY-MM-DD).

Tune the defaults in ~/.fin/finrc: FIN_MC_YEARS, FIN_MC_SIMS, FIN_MC_RANGE, FIN_MC_BLOCK, FIN_MC_INITIAL, FIN_MC_SOURCE.


9. Troubleshooting

  • Too Many Requests (429) — Yahoo throttles free endpoints. FIN serves cached data within its TTL and self-heals; wait a minute and retry. The BVC board is safe: cast from TradingView, so it keeps working while Yahoo is angry.
  • A stock row shows n/a — the symbol didn't resolve. For Casablanca listings the fix is the right CSEMA ticker (TradingView), or trim FIN_BVC.
  • No colors — confirm your terminal reports 256-color support and re-run fin theme <name>. Colors auto-disable when stdout isn't a terminal.
  • jq is required — sudo apt install jq if something ever reports parse errors.
  • My prompt/PROMPT_COMMAND conflict — fin owns PROMPT_COMMAND; keep other prompt workarounds inside fin_prompt_cmd.

10. Files

file purpose
~/.fin/fin.sh the engine (colors, quotes, commands)
~/.fin/finrc your configuration
~/.fin/completions.bash tab-completion for mkt
~/.fin/worth.tsv net-worth ledger
~/.fin/journal/ dated notes
~/.fin/portfolios/ portfolio baskets (<name>.tsv)
~/.fin/mc.py the Monte Carlo engine (numpy)
~/.fin/cache/ price snapshots, csema.json, mc_*.json history — safe to delete
~/.fin/ptyxis-restore.txt how to put the terminal colors back
~/.bin/mkt the realtime TUI binary

Enjoy. When the MASI prints a green triangle, say inchallah.

About

FIN — the financier's bash terminal for markets & portfolio research: live quotes, crypto, FX, net worth, realtime TUI, and a full Bourse de Casablanca (MASI + dirham) corner for Moroccan market students

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages