Summary
hlgo agent pnl silently accepts an extra positional argument like 720h, ignores it, and falls back to the default --lookback-hours 24.
This is easy to miss in scripts/agent flows because the command succeeds and returns valid-looking JSON, but for the wrong time window.
Environment
- repo:
timbrinded/hlgo
- local repro commit:
aa673f0
- binary rebuilt from source on Linux arm64
Steps to reproduce
Assuming HL_PRIVATE_KEY is set and the account has fills/positions:
hlgo agent pnl 720h --format json
Actual outcome
The command succeeds, but the positional 720h is ignored. The output still reports the default lookback:
{
"lookback_hours": 24,
...
}
In my repro, the same happened for 168h and 336h as well.
Expected outcome
One of these should happen instead:
- Preferred: reject unexpected positional args with a validation error, e.g.
unknown argument: 720h or accepts no args.
- Alternative: intentionally support positional duration syntax and parse
720h / 168h / 336h into lookback_hours.
What should not happen is silent success with the default 24h window.
Likely root cause
cmd/agent_pnl.go only reads the --lookback-hours flag:
lookbackHours, _ := cmd.Flags().GetInt("lookback-hours")
and defines:
cmd.Flags().Int("lookback-hours", 24, ...)
But the command does not appear to set an Args validator (for example cobra.NoArgs), so extra positional input is accepted and ignored.
Suggested fix
- Add
Args: cobra.NoArgs to newAgentPnlCmd() (and possibly audit other commands for the same silent-extra-arg pattern).
- Add a regression test covering:
which should fail with a non-zero exit code.
Why this matters
For humans this is confusing; for agents/scripts it is worse, because the command returns plausible output and can lead to incorrect performance analysis or decision-making while appearing to work correctly.
Summary
hlgo agent pnlsilently accepts an extra positional argument like720h, ignores it, and falls back to the default--lookback-hours 24.This is easy to miss in scripts/agent flows because the command succeeds and returns valid-looking JSON, but for the wrong time window.
Environment
timbrinded/hlgoaa673f0Steps to reproduce
Assuming
HL_PRIVATE_KEYis set and the account has fills/positions:Actual outcome
The command succeeds, but the positional
720his ignored. The output still reports the default lookback:{ "lookback_hours": 24, ... }In my repro, the same happened for
168hand336has well.Expected outcome
One of these should happen instead:
unknown argument: 720horaccepts no args.720h/168h/336hintolookback_hours.What should not happen is silent success with the default 24h window.
Likely root cause
cmd/agent_pnl.goonly reads the--lookback-hoursflag:and defines:
But the command does not appear to set an
Argsvalidator (for examplecobra.NoArgs), so extra positional input is accepted and ignored.Suggested fix
Args: cobra.NoArgstonewAgentPnlCmd()(and possibly audit other commands for the same silent-extra-arg pattern).which should fail with a non-zero exit code.
Why this matters
For humans this is confusing; for agents/scripts it is worse, because the command returns plausible output and can lead to incorrect performance analysis or decision-making while appearing to work correctly.