Skip to content

Commit a867a26

Browse files
committed
Add paid tax field to config for tracking YTD tax payments
1 parent 76b4f5c commit a867a26

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

internal/ibctl/ibctlconfig/ibctlconfig.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ type ExternalTaxConfigV1 struct {
112112
DividendTax float64 `yaml:"dividend_tax"`
113113
// InterestTax is the tax rate on interest and bond coupon income (e.g., 0.5353 for 53.53%).
114114
InterestTax float64 `yaml:"interest_tax"`
115+
// Paid maps currency codes to the total tax amount already paid this year (e.g., {"USD": "50000", "CAD": "30000"}).
116+
Paid map[string]string `yaml:"paid"`
115117
}
116118

117119
// ExternalCategorizationV1 holds classification metadata for a symbol in v1 config.
@@ -183,6 +185,8 @@ type Config struct {
183185
TaxRateDividend float64
184186
// TaxRateInterest is the tax rate on interest and bond coupon income (e.g., 0.5353).
185187
TaxRateInterest float64
188+
// TaxPaid maps currency codes to tax amounts already paid in micros for the current year.
189+
TaxPaid map[string]int64
186190
// CashInterestRates maps currency codes to annual interest rates on cash balances.
187191
CashInterestRates map[string]float64
188192
// OptionsDataProviders is the ordered list of options data providers for covered call screening.
@@ -280,11 +284,21 @@ func NewConfigV1(externalConfig ExternalConfigV1, dirPath string) (*Config, erro
280284
}
281285
// Extract tax rates if configured (zero defaults mean no tax impact).
282286
var taxRateSTCG, taxRateLTCG, taxRateDividend, taxRateInterest float64
287+
// Initialize taxPaid outside the nil check so it is always available for the Config struct.
288+
taxPaid := make(map[string]int64)
283289
if externalConfig.Taxes != nil {
284290
taxRateSTCG = externalConfig.Taxes.STCG
285291
taxRateLTCG = externalConfig.Taxes.LTCG
286292
taxRateDividend = externalConfig.Taxes.DividendTax
287293
taxRateInterest = externalConfig.Taxes.InterestTax
294+
// Parse tax paid amounts if configured (empty map means no payments recorded).
295+
for currency, value := range externalConfig.Taxes.Paid {
296+
units, micros, err := mathpb.ParseToUnitsMicros(value)
297+
if err != nil {
298+
return nil, fmt.Errorf("invalid taxes.paid amount for %s: %w", currency, err)
299+
}
300+
taxPaid[strings.ToUpper(currency)] = units*1_000_000 + micros
301+
}
288302
}
289303
// Parse and validate additions from non-IBKR brokers.
290304
additions, additionLastPrices, err := parseAdditions(externalConfig.Additions, accountAliases)
@@ -326,6 +340,7 @@ func NewConfigV1(externalConfig ExternalConfigV1, dirPath string) (*Config, erro
326340
TaxRateLTCG: taxRateLTCG,
327341
TaxRateDividend: taxRateDividend,
328342
TaxRateInterest: taxRateInterest,
343+
TaxPaid: taxPaid,
329344
Additions: additions,
330345
AdditionLastPrices: additionLastPrices,
331346
RealtimeSymbols: realtimeSymbols,

0 commit comments

Comments
 (0)