robin_stocks
robin_stocks copied to clipboard
Add recurring investments API support
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.py
-
get_recurring_investments()- Fetch all recurring investments (supports filtering by account or asset types) -
create_recurring_investment()- Create new recurring investments with configurable frequency and amount -
update_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 frequency
Modified Files
-
robin_stocks/robinhood/urls.py- Added URL helper functions for recurring investment endpoints -
robin_stocks/robinhood/__init__.py- Exported all new recurring investment functions
Technical Details
-
Endpoint: Uses
bonfire.robinhood.com/recurring_schedules/(discovered through reverse engineering) -
Authentication: Uses existing
@login_requireddecorator and session management - Patterns: Follows existing library patterns and conventions
- Error Handling: Proper error handling and status code checking
Testing
✅ Tested with real Robinhood account:
- Successfully fetched 100+ existing recurring investments
- Created new recurring investments
- Updated recurring investments (pause/resume)
- Cancelled recurring investments
- Verified all functions work correctly
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
- Uses unofficial endpoint (Robinhood doesn't provide a public API)
- Consistent with existing
robin_stocksapproach since Robinhood doesn't offer a public API - All functions follow library conventions and patterns