Add recurring investments API support#1633
Open
parthchandak02 wants to merge 9 commits into
Open
Conversation
- Add recurring_investments.py module with full CRUD operations - Add get_recurring_investments() to fetch all recurring investments - Add create_recurring_investment() to create new recurring investments - Add update_recurring_investment() to update/pause/resume investments - Add cancel_recurring_investment() to cancel investments (uses PATCH) - Add get_next_investment_date() to get next investment date - Add URL helper functions for recurring investments endpoints - Export all functions in __init__.py Uses bonfire.robinhood.com/recurring_schedules/ endpoint discovered through reverse engineering. Addresses feature request for native recurring investments support in robin_stocks.
- Change investment_target to investment_asset (matches Robinhood's POST format) - Change instrument_id to asset_id - Add account_number, ref_id, and other required fields - Fixes HTTP 400 errors when creating recurring investments
…ignore - Add examples/recurring_investments/ with example scripts: - create_from_csv.py: Bulk create recurring investments from CSV - get_all_recurring.py: List all recurring investments - create_recurring.py: Create single recurring investment - cancel_recurring.py: Cancel recurring investment - README.md: Documentation for examples - Update .gitignore to ignore logs/ and recurring.csv files - Move recurring.csv to examples folder (ignored by git)
- Add thread-safe rate limiting to helper.py (request_get, request_post, request_delete, request_document) - Rate limiting disabled by default for backward compatibility - Add enable_rate_limiting() and disable_rate_limiting() functions - Move config.py to examples/recurring_investments/ (better location) - Update create_from_csv.py to use core rate limiting - Update .gitignore to exclude trapezoid folder and user data files Rate limiting is opt-in and maintains full backward compatibility. All existing code continues to work without changes.
… scripts - Add compare_portfolio_changes.py utility to compare original vs current portfolio - Add generate_final_portfolio_summary.py to create theme-based portfolio summaries - Enhance get_all_recurring.py with Rich formatting, export options, and company info - Fix update_recurring_investment() to use PATCH method correctly - Improve cancel_recurring_investment() Content-Type handling - Add portfolio_comparison_table.md with verified company information - Update .gitignore to exclude .cursor/ and portfolio summary files - Update README with new script documentation
- Add 'Enhancements and Additions' section to README.rst documenting: * Enhanced portfolio performance checker with caching and progress bars * Portfolio comparison tool * New dependencies (requests-cache, tqdm) - Add portfolio_comparison_report.json to .gitignore - Remove portfolio_comparison_table.md (now ignored)
DhruvaBansal00
added a commit
to DhruvaBansal00/robin_stocks
that referenced
this pull request
May 23, 2026
Upstream PR jmfernandes#1633 (jmfernandes/robin_stocks). Cherry-picks only the SDK-side changes from the PR; skips the unrelated repo bloat (fork-branded README sections, compare_portfolio_changes.py script at the repo root, examples/recurring_investments/ scripts, new tqdm and requests-cache deps, .gitignore additions). What was taken: - robin_stocks/robinhood/recurring_investments.py: new module with five functions for the bonfire.robinhood.com/recurring_schedules/ endpoint — get, create, update, cancel, and a next-investment-date helper. These endpoints are undocumented and may break. - robin_stocks/robinhood/urls.py: recurring_schedules_url and next_investment_date_url helpers. - robin_stocks/robinhood/globals.py + helper.py: opt-in, thread-safe rate-limiting hooked into request_get/request_post/request_delete/ request_document, controlled by enable_rate_limiting(delay) / disable_rate_limiting(). Disabled by default to preserve backwards-compatible request timing. - robin_stocks/robinhood/__init__.py: exports the new public API. Adds matching MCP coverage: - robin_stocks_mcp/tools/robinhood_recurring.py registers two read tools (rh_get_recurring_investments, rh_get_next_investment_date) and three write tools (rh_create_recurring_investment, rh_update_recurring_investment, rh_cancel_recurring_investment) guarded by the read-only mode. - tests/mcp/test_robinhood_recurring_tools.py covers dispatch for every tool plus the read-only guard for each write. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
DhruvaBansal00
added a commit
to DhruvaBansal00/robin_stocks
that referenced
this pull request
May 23, 2026
…in rate limiting
DhruvaBansal00
added a commit
to DhruvaBansal00/robin_stocks
that referenced
this pull request
May 23, 2026
Caught while auditing MCP coverage after merging PR jmfernandes#1633: the SDK's opt-in rate-limiter ships with toggle helpers but they had no MCP wrapper, so an MCP client couldn't turn rate limiting on/off without restarting with env config. Both are marked as read-tools because they only mutate local SDK state (no server-side effect), so the read-only guard does not need to block them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks for this contribution! It's included with test coverage in the new repo, alongside 11 other open PRs from here. If you'd like a maintained build with this change, that's where to find it. Cherry-picked the recurring-investments module + opt-in rate limiter; left out the unrelated portfolio script/examples to keep the merge focused. |
- Track .test.env.example instead; gitignore local .test.env Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive support for Robinhood's recurring investments feature, allowing users to programmatically create, retrieve, update, and cancel recurring investment schedules.
Changes
New Module:
robin_stocks/robinhood/recurring_investments.pyget_recurring_investments()- Fetch all recurring investments (supports filtering by account or asset types)create_recurring_investment()- Create new recurring investments with configurable frequency and amountupdate_recurring_investment()- Update existing investments (pause/resume, change amount/frequency)cancel_recurring_investment()- Cancel recurring investments (uses PATCH with state="deleted")get_next_investment_date()- Get the next investment date for a given frequencyModified Files
robin_stocks/robinhood/urls.py- Added URL helper functions for recurring investment endpointsrobin_stocks/robinhood/__init__.py- Exported all new recurring investment functionsTechnical Details
bonfire.robinhood.com/recurring_schedules/(discovered through reverse engineering)@login_requireddecorator and session managementTesting
✅ Tested with real Robinhood account:
Example Usage
n
import robin_stocks.robinhood as rh
rh.login(username='...', password='...')
Get all recurring investments
investments = rh.get_recurring_investments()
Create a new recurring investment
rh.create_recurring_investment('TSLA', 50.0, frequency='weekly')
Pause an investment
rh.update_recurring_investment(schedule_id, state='paused')
Cancel an investment
rh.cancel_recurring_investment(schedule_id)## Notes
robin_stocksapproach since Robinhood doesn't offer a public API