@@ -26,6 +26,9 @@ import (
2626// formatFlagName is the flag name for the output format.
2727const formatFlagName = "format"
2828
29+ // cachedFlagName is the flag name for skipping download and using cached data only.
30+ const cachedFlagName = "cached"
31+
2932// NewCommand returns a new holdings overview command.
3033func NewCommand (name string , builder appext.SubCommandBuilder ) * appcmd.Command {
3134 flags := newFlags ()
@@ -42,12 +45,9 @@ func NewCommand(name string, builder appext.SubCommandBuilder) *appcmd.Command {
4245 }
4346}
4447
45- // cachedFlagName is the flag name for skipping download and using cached data only.
46- const cachedFlagName = "cached"
47-
4848type flags struct {
49- // Config is the path to the configuration file .
50- Config string
49+ // Dir is the base directory containing ibctl.yaml and data subdirectories .
50+ Dir string
5151 // Format is the output format (table, csv, json).
5252 Format string
5353 // Cached skips downloading and uses only cached data.
@@ -60,7 +60,7 @@ func newFlags() *flags {
6060
6161// Bind registers the flag definitions with the given flag set.
6262func (f * flags ) Bind (flagSet * pflag.FlagSet ) {
63- flagSet .StringVar (& f .Config , ibctlcmd .ConfigFlagName , ibctlconfig . DefaultConfigFileName , "The configuration file path " )
63+ flagSet .StringVar (& f .Dir , ibctlcmd .DirFlagName , "." , "The ibctl directory containing ibctl.yaml " )
6464 flagSet .StringVar (& f .Format , formatFlagName , "table" , "Output format (table, csv, json)" )
6565 flagSet .BoolVar (& f .Cached , cachedFlagName , false , "Skip downloading and use only cached data" )
6666}
@@ -70,14 +70,14 @@ func run(ctx context.Context, container appext.Container, flags *flags) error {
7070 if err != nil {
7171 return appcmd .NewInvalidArgumentError (err .Error ())
7272 }
73- // Read and validate the configuration file.
74- config , err := ibctlconfig .ReadConfig (flags .Config )
73+ // Read and validate the configuration file from the base directory .
74+ config , err := ibctlconfig .ReadConfig (flags .Dir )
7575 if err != nil {
7676 return err
7777 }
7878 // Download fresh data unless --cached is set.
7979 if ! flags .Cached {
80- downloader , err := ibctlcmd .NewDownloader (container , flags .Config )
80+ downloader , err := ibctlcmd .NewDownloader (container , flags .Dir )
8181 if err != nil {
8282 return err
8383 }
@@ -86,19 +86,19 @@ func run(ctx context.Context, container appext.Container, flags *flags) error {
8686 }
8787 }
8888 // Merge seed lots + Activity Statement CSVs + Flex Query cached data across all accounts.
89- // Trades come from data_dir (persistent), snapshots from cache_dir (blow-away safe).
89+ // Trades come from data/ (persistent), snapshots from cache/ (blow-away safe).
9090 mergedData , err := ibctlmerge .Merge (
91- ibctlpath .DataAccountsDirPath (config .DataDirPath ),
92- ibctlpath .CacheAccountsDirPath (config .CacheDirPath ),
93- config .ActivityStatementsDirPath ,
94- config .SeedDirPath ,
91+ ibctlpath .DataAccountsDirPath (config .DirPath ),
92+ ibctlpath .CacheAccountsDirPath (config .DirPath ),
93+ ibctlpath .ActivityStatementsDirPath ( config . DirPath ) ,
94+ ibctlpath .SeedDirPath ( config . DirPath ) ,
9595 config .AccountAliases ,
9696 )
9797 if err != nil {
9898 return err
9999 }
100100 // Load FX rates for USD price conversion. Returns an empty store if no data available.
101- fxStore := ibctlfxrates .NewStore (ibctlpath .CacheFXDirPath (config .CacheDirPath ))
101+ fxStore := ibctlfxrates .NewStore (ibctlpath .CacheFXDirPath (config .DirPath ))
102102 // Compute holdings via FIFO from all trade data, verified against IBKR positions.
103103 result , err := ibctlholdings .GetHoldingsOverview (mergedData .Trades , mergedData .Positions , mergedData .CashPositions , config , fxStore )
104104 if err != nil {
0 commit comments