Skip to content

Title: Add --limit / -n flag to cap returned data points#11

Open
Loboston wants to merge 2 commits into
alphavantage:mainfrom
Loboston:add-limit-flag
Open

Title: Add --limit / -n flag to cap returned data points#11
Loboston wants to merge 2 commits into
alphavantage:mainfrom
Loboston:add-limit-flag

Conversation

@Loboston

Copy link
Copy Markdown
  • Adds a --limit / -n flag to all CLI commands to cap the number of data points returned
  • Fixes _apply_limit to correctly handle CSV string responses (the default format for most endpoints)
  • Adds a test suite for _apply_limit covering all response types and CLI flag wiring

Why

Most Alpha Vantage endpoints return large datasets by default. The --limit / -n flag gives users a quick way to preview the most recent N data points without processing the full response.

Testing

Manually tested against TIME_SERIES_DAILY, TIME_SERIES_WEEKLY, TIME_SERIES_MONTHLY, FX_DAILY, FX_WEEKLY,
DIGITAL_CURRENCY_DAILY, and SMA. Also added 5 unit tests covering all code paths, the first test suite in this repo.

Examples
1.

marketdata-cli TIME_SERIES_DAILY AAPL --limit 5

timestamp,open,high,low,close,volume
2026-03-20,247.9750,249.1999,246.0000,247.9900,87139466
2026-03-19,249.4000,251.8300,247.3000,248.9600,34864082
2026-03-18,252.6250,254.9400,249.0000,249.9400,35757874
2026-03-17,252.9550,255.1300,252.1800,254.2300,32361607
2026-03-16,252.1050,253.8850,249.8800,252.8200,32074209


marketdata-cli fx_weekly --from_symbol USD --to_symbol EUR -n 5

timestamp,open,high,low,close
2026-03-19,0.87600,0.87620,0.86080,0.86280
2026-03-13,0.86430,0.87630,0.85690,0.87590
2026-03-06,0.84710,0.86720,0.84710,0.86070
2026-02-27,0.84830,0.84980,0.84470,0.84640
2026-02-20,0.84250,0.85160,0.84180,0.84870

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant