Skip to content

Commit 2b83212

Browse files
committed
commit
1 parent 2aa26de commit 2b83212

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

cmd/ibctl/internal/command/holding/lot/lotlist/lotlist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func run(ctx context.Context, container appext.Container, flags *flags) error {
103103
// Load FX rates for USD conversion.
104104
fxStore := ibctlfxrates.NewStore(ibctlpath.CacheFXDirPath(config.DirPath))
105105
// Get the lot list, optionally filtered by symbol.
106-
result, err := ibctlholdings.GetLotList(flags.Symbol, mergedData.Trades, mergedData.Positions, fxStore)
106+
result, err := ibctlholdings.GetLotList(flags.Symbol, mergedData.Trades, mergedData.Positions, config, fxStore)
107107
if err != nil {
108108
return err
109109
}

internal/ibctl/ibctlholdings/ibctlholdings.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,19 @@ type LotOverview struct {
190190
STCGUSD string `json:"stcg_usd"`
191191
// LTCGUSD is the long-term P&L in USD (held >= 365 days). Equals PnLUSD or 0.
192192
LTCGUSD string `json:"ltcg_usd"`
193+
// Category is the user-defined asset category (e.g., "EQUITY").
194+
Category string `json:"category,omitempty"`
195+
// Type is the user-defined asset type (e.g., "STOCK", "ETF").
196+
Type string `json:"type,omitempty"`
197+
// Sector is the user-defined sector classification (e.g., "TECH").
198+
Sector string `json:"sector,omitempty"`
199+
// Geo is the user-defined geographic classification (e.g., "US", "INTL").
200+
Geo string `json:"geo,omitempty"`
193201
}
194202

195203
// LotListHeaders returns the column headers for lot list table/CSV output.
196204
func LotListHeaders() []string {
197-
return []string{"SYMBOL", "ACCOUNT", "DATE", "QUANTITY", "CURRENCY", "AVG PRICE", "P&L", "VALUE", "AVG USD", "P&L USD", "STCG USD", "LTCG USD", "VALUE USD"}
205+
return []string{"SYMBOL", "ACCOUNT", "DATE", "QUANTITY", "CURRENCY", "AVG PRICE", "P&L", "VALUE", "AVG USD", "P&L USD", "STCG USD", "LTCG USD", "VALUE USD", "CATEGORY", "TYPE", "SECTOR", "GEO"}
198206
}
199207

200208
// LotOverviewToRow converts a LotOverview to a string slice for CSV output.
@@ -213,6 +221,10 @@ func LotOverviewToRow(l *LotOverview) []string {
213221
l.STCGUSD,
214222
l.LTCGUSD,
215223
l.ValueUSD,
224+
l.Category,
225+
l.Type,
226+
l.Sector,
227+
l.Geo,
216228
}
217229
}
218230

@@ -233,6 +245,10 @@ func LotOverviewToTableRow(l *LotOverview) []string {
233245
cliio.FormatUSD(l.STCGUSD),
234246
cliio.FormatUSD(l.LTCGUSD),
235247
cliio.FormatUSD(l.ValueUSD),
248+
l.Category,
249+
l.Type,
250+
l.Sector,
251+
l.Geo,
236252
}
237253
}
238254

@@ -369,6 +385,7 @@ func GetLotList(
369385
symbol string,
370386
trades []*datav1.Trade,
371387
positions []*datav1.Position,
388+
config *ibctlconfig.Config,
372389
fxStore *ibctlfxrates.Store,
373390
) (*LotListResult, error) {
374391
// Filter out CASH asset category trades.
@@ -452,6 +469,13 @@ func GetLotList(
452469
PnL: moneypb.MoneyValueToString(moneypb.MoneyFromMicros(currency, pnlMicros)),
453470
Value: moneypb.MoneyValueToString(moneypb.MoneyFromMicros(currency, valueMicros)),
454471
}
472+
// Merge symbol classification from config.
473+
if symbolConfig, ok := config.SymbolConfigs[lotSymbol]; ok {
474+
l.Category = symbolConfig.Category
475+
l.Type = symbolConfig.Type
476+
l.Sector = symbolConfig.Sector
477+
l.Geo = symbolConfig.Geo
478+
}
455479
// Convert to USD using FX rates.
456480
if fxStore != nil {
457481
if usdCost, ok := fxStore.ConvertToUSD(lot.GetCostBasisPrice()); ok {

0 commit comments

Comments
 (0)