Skip to content

Commit fd2c790

Browse files
committed
commit
1 parent 7c99804 commit fd2c790

File tree

18 files changed

+87
-346
lines changed

18 files changed

+87
-346
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ ibctl holding list
3030
# View holdings in CAD instead of USD.
3131
ibctl holding list --base-currency CAD
3232

33+
# View holdings with real-time prices from Yahoo Finance.
34+
ibctl holding list --realtime
35+
3336
# View all transactions for the year.
3437
ibctl transaction list --from 20250101 --to 20251231 --base-currency USD
3538
```
@@ -56,9 +59,8 @@ ibctl transaction list --from 20250101 --to 20251231 --base-currency USD
5659
| `ibctl holding value` | Display portfolio value with estimated tax impact |
5760
| `ibctl transaction list` | List all transactions (buys, sells, dividends, interest, WHT, etc.) chronologically |
5861
| `ibctl transaction sale list` | List realized security sales with FIFO lot matching for tax reporting |
59-
| `ibctl probe` | Probe the API and show per-account data counts |
6062

61-
All commands accept `--dir` to specify the ibctl directory (defaults to `.`). All holding and transaction commands accept `--base-currency` (default `USD`) to convert values to a different currency. Use `--help` on any command for detailed documentation.
63+
All commands accept `--dir` to specify the ibctl directory (defaults to `.`). All holding and transaction commands accept `--base-currency` (default `USD`) to convert values to a different currency. Holding commands accept `--realtime` to fetch current stock prices and FX rates from Yahoo Finance on-demand. For international symbols where IBKR and Yahoo symbols differ, add mappings to `realtime_symbols` in `ibctl.yaml`. Use `--help` on any command for detailed documentation.
6264

6365
## Tax Reporting
6466

book/src/commands/holding-category-list.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# holding category list
22

33
```
4-
ibctl holding category list [--dir DIR] [--format FORMAT] [--download] [--geo GEO] [--base-currency CURRENCY]
4+
ibctl holding category list [--dir DIR] [--format FORMAT] [--download] [--realtime] [--geo GEO] [--base-currency CURRENCY]
55
```
66

77
Aggregates holdings by category and displays each category's market value, percentage of net liquidation value, and capital gains breakdown.
@@ -38,5 +38,6 @@ Use `--geo` to filter holdings to a single geographic classification before aggr
3838
| `--dir` | `.` | The ibctl directory containing `ibctl.yaml` |
3939
| `--format` | `table` | Output format: `table`, `csv`, or `json` |
4040
| `--download` | `false` | Download fresh data before displaying |
41+
| `--realtime` | `false` | Fetch real-time stock quotes and FX rates from Yahoo Finance |
4142
| `--geo` | (all) | Filter by geographic classification before aggregating (e.g., `US`, `INTL`) |
4243
| `--base-currency` | `USD` | Base currency for value conversion (case-insensitive, e.g., `USD`, `CAD`) |

book/src/commands/holding-geo-list.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# holding geo list
22

33
```
4-
ibctl holding geo list [--dir DIR] [--format FORMAT] [--download] [--category CATEGORY] [--base-currency CURRENCY]
4+
ibctl holding geo list [--dir DIR] [--format FORMAT] [--download] [--realtime] [--category CATEGORY] [--base-currency CURRENCY]
55
```
66

77
Aggregates holdings by geographic classification and displays each geo's market value, percentage of net liquidation value, and capital gains breakdown.
@@ -38,5 +38,6 @@ Use `--category` to filter holdings to a single category before aggregating by g
3838
| `--dir` | `.` | The ibctl directory containing `ibctl.yaml` |
3939
| `--format` | `table` | Output format: `table`, `csv`, or `json` |
4040
| `--download` | `false` | Download fresh data before displaying |
41+
| `--realtime` | `false` | Fetch real-time stock quotes and FX rates from Yahoo Finance |
4142
| `--category` | (all) | Filter by category before aggregating (e.g., `EQUITY`, `FIXED_INCOME`) |
4243
| `--base-currency` | `USD` | Base currency for value conversion (case-insensitive, e.g., `USD`, `CAD`) |

book/src/commands/holding-list.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# holding list
22

33
```
4-
ibctl holding list [--dir DIR] [--format FORMAT] [--download] [--base-currency CURRENCY]
4+
ibctl holding list [--dir DIR] [--format FORMAT] [--download] [--realtime] [--base-currency CURRENCY]
55
```
66

77
Shows combined positions across all accounts. Positions are computed via FIFO tax lot matching with weighted average cost basis, then verified against IBKR-reported positions.
@@ -62,11 +62,18 @@ The command verifies computed positions against IBKR-reported positions and logs
6262

6363
Unmatched sells (where the buy occurred before the data window) are also logged as warnings.
6464

65+
## Real-time pricing
66+
67+
Use `--realtime` to fetch current market prices and FX rates from Yahoo Finance on-demand, without downloading or persisting data. This is useful for intraday portfolio monitoring. Symbols that Yahoo cannot resolve (bonds, unmapped international tickers) fall back to cached IBKR prices with a warning.
68+
69+
For international symbols where IBKR and Yahoo Finance symbols differ (e.g., Canadian equities), add symbol mappings to the `realtime_symbols` section of your config. Real-time data is not cached — each run fetches fresh prices from Yahoo Finance.
70+
6571
## Flags
6672

6773
| Flag | Default | Description |
6874
|------|---------|-------------|
6975
| `--dir` | `.` | The ibctl directory containing `ibctl.yaml` |
7076
| `--format` | `table` | Output format: `table`, `csv`, or `json` |
7177
| `--download` | `false` | Download fresh data before displaying |
78+
| `--realtime` | `false` | Fetch real-time stock quotes and FX rates from Yahoo Finance |
7279
| `--base-currency` | `USD` | Base currency for value conversion (case-insensitive, e.g., `USD`, `CAD`) |

book/src/commands/holding-lot-list.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# holding lot list
22

33
```
4-
ibctl holding lot list [--dir DIR] [--format FORMAT] [--download] [--symbol SYMBOL] [--base-currency CURRENCY]
4+
ibctl holding lot list [--dir DIR] [--format FORMAT] [--download] [--realtime] [--symbol SYMBOL] [--base-currency CURRENCY]
55
```
66

77
Lists individual FIFO tax lots. Unlike `holding list`, which aggregates positions by symbol, this command shows each tax lot separately with its own open date, quantity, and cost basis.
@@ -51,5 +51,6 @@ The table output includes a totals row summing P&L {BASE}, STCG {BASE}, LTCG {BA
5151
| `--dir` | `.` | The ibctl directory containing `ibctl.yaml` |
5252
| `--format` | `table` | Output format: `table`, `csv`, or `json` |
5353
| `--download` | `false` | Download fresh data before displaying |
54+
| `--realtime` | `false` | Fetch real-time stock quotes and FX rates from Yahoo Finance |
5455
| `--symbol` | (all) | Filter to a specific symbol. Omit to show all symbols. |
5556
| `--base-currency` | `USD` | Base currency for value conversion (case-insensitive, e.g., `USD`, `CAD`) |

book/src/commands/holding-value.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# holding value
22

33
```
4-
ibctl holding value [--dir DIR] [--download] [--base-currency CURRENCY]
4+
ibctl holding value [--dir DIR] [--download] [--realtime] [--base-currency CURRENCY]
55
```
66

77
Displays the total portfolio value, unrealized short-term and long-term capital gains, estimated tax liability, and after-tax portfolio value.
@@ -54,4 +54,5 @@ Tax-exempt holdings (RRSP, TFSA, additions with `tax_exempt: true`) contribute z
5454
|------|---------|-------------|
5555
| `--dir` | `.` | The ibctl directory containing `ibctl.yaml` |
5656
| `--download` | `false` | Download fresh data before displaying |
57+
| `--realtime` | `false` | Fetch real-time stock quotes and FX rates from Yahoo Finance |
5758
| `--base-currency` | `USD` | Base currency for value conversion (case-insensitive, e.g., `USD`, `CAD`) |

book/src/configuration.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ additions:
6868
quantity: "100"
6969
last_price: "115.30"
7070
tax_exempt: true
71+
72+
# Symbol mapping for real-time quote lookups.
73+
# Optional. Maps IBKR symbols to Yahoo Finance symbols for international tickers
74+
# where symbols differ. Only used with the --realtime flag.
75+
realtime_symbols:
76+
BRK B: BRK-B
77+
"700": "0700.HK"
7178
```
7279
7380
## Field Reference
@@ -137,3 +144,14 @@ If not set, both rates default to zero and the `holding value` command shows no
137144
| `quantity` | Quantity as a decimal string | Yes |
138145
| `last_price` | Most recent market price as a decimal string (fallback when no IBKR position exists) | Yes |
139146
| `tax_exempt` | Whether this trade is in a tax-sheltered account (TFSA, RRSP). When true, P&L, STCG, and LTCG are shown as zero in all output. | No (default: `false`) |
147+
148+
### `realtime_symbols`
149+
150+
**Optional.** A mapping from IBKR ticker symbols to Yahoo Finance symbols, used by the `--realtime` flag on holding commands. Only needed for international tickers where IBKR and Yahoo Finance use different symbols (e.g., Canadian equities, Hong Kong stocks).
151+
152+
| Field | Description | Example |
153+
|-------|-------------|---------|
154+
| Key (IBKR symbol) | The ticker symbol as reported by IBKR | `BRK B`, `700` |
155+
| Value (Yahoo symbol) | The equivalent symbol on Yahoo Finance | `BRK-B`, `0700.HK` |
156+
157+
US-listed securities typically need no mapping. If a symbol is not mapped and Yahoo Finance cannot resolve the IBKR symbol, the command logs a warning and falls back to the cached IBKR price for that symbol.

book/src/quickstart.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ View holdings in CAD instead of the default USD:
5656
ibctl holding list --base-currency CAD
5757
```
5858

59+
View holdings with real-time prices from Yahoo Finance:
60+
61+
```bash
62+
ibctl holding list --realtime
63+
```
64+
5965
View all transactions for a tax year:
6066

6167
```bash

cmd/ibctl/internal/command/holding/category/categorylist/categorylist.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/bufdev/ibctl/internal/ibctl/ibctlpath"
2222
"github.com/bufdev/ibctl/internal/ibctl/ibctlrealtime"
2323
"github.com/bufdev/ibctl/internal/pkg/cliio"
24+
"github.com/bufdev/ibctl/internal/pkg/yahoofinance"
2425
"github.com/spf13/pflag"
2526
)
2627

@@ -51,7 +52,10 @@ config are grouped as "UNCATEGORIZED". Sorted by market value descending.
5152
5253
Use --geo to filter to a single geographic classification before
5354
aggregating. For example, --geo US shows only US holdings grouped by
54-
category. The --geo flag is case-insensitive.`,
55+
category. The --geo flag is case-insensitive.
56+
57+
Use --realtime to fetch current stock prices and FX rates from Yahoo Finance
58+
for real-time category breakdowns.`,
5559
Args: appcmd.NoArgs,
5660
Run: builder.NewRunFunc(
5761
func(ctx context.Context, container appext.Container) error {
@@ -134,7 +138,7 @@ func run(ctx context.Context, container appext.Container, flags *flags) error {
134138
// Override market prices and FX rates with real-time data from Yahoo Finance.
135139
if flags.Realtime {
136140
todayDate := time.Now().Format("2006-01-02")
137-
if err := ibctlrealtime.ApplyOverrides(ctx, container.Logger(), mergedData.Positions, fxStore, config, baseCurrency, todayDate); err != nil {
141+
if err := ibctlrealtime.ApplyOverrides(ctx, container.Logger(), yahoofinance.NewClient(), mergedData.Positions, fxStore, config, baseCurrency, todayDate); err != nil {
138142
return err
139143
}
140144
}

cmd/ibctl/internal/command/holding/geo/geolist/geolist.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/bufdev/ibctl/internal/ibctl/ibctlpath"
2222
"github.com/bufdev/ibctl/internal/ibctl/ibctlrealtime"
2323
"github.com/bufdev/ibctl/internal/pkg/cliio"
24+
"github.com/bufdev/ibctl/internal/pkg/yahoofinance"
2425
"github.com/spf13/pflag"
2526
)
2627

@@ -52,7 +53,10 @@ descending.
5253
5354
Use --category to filter to a single asset category before aggregating.
5455
For example, --category EQUITY shows only equity holdings grouped by geo.
55-
The --category flag is case-insensitive.`,
56+
The --category flag is case-insensitive.
57+
58+
Use --realtime to fetch current stock prices and FX rates from Yahoo Finance
59+
for real-time geographic breakdowns.`,
5660
Args: appcmd.NoArgs,
5761
Run: builder.NewRunFunc(
5862
func(ctx context.Context, container appext.Container) error {
@@ -135,7 +139,7 @@ func run(ctx context.Context, container appext.Container, flags *flags) error {
135139
// Override market prices and FX rates with real-time data from Yahoo Finance.
136140
if flags.Realtime {
137141
todayDate := time.Now().Format("2006-01-02")
138-
if err := ibctlrealtime.ApplyOverrides(ctx, container.Logger(), mergedData.Positions, fxStore, config, baseCurrency, todayDate); err != nil {
142+
if err := ibctlrealtime.ApplyOverrides(ctx, container.Logger(), yahoofinance.NewClient(), mergedData.Positions, fxStore, config, baseCurrency, todayDate); err != nil {
139143
return err
140144
}
141145
}

0 commit comments

Comments
 (0)