Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added interest payment function #481

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions robin_stocks/robinhood/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
get_linked_bank_accounts, get_margin_calls,
get_margin_interest, get_notifications,
get_open_stock_positions, get_referrals,
get_stock_loan_payments, get_subscription_fees,
get_total_dividends, get_watchlist_by_name,
get_stock_loan_payments, get_interest_payments,
get_subscription_fees, get_total_dividends, get_watchlist_by_name,
get_wire_transfers, load_phoenix_account,
post_symbols_to_watchlist, unlink_bank_account,
withdrawl_funds_to_bank_account)
Expand Down
13 changes: 13 additions & 0 deletions robin_stocks/robinhood/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,19 @@ def get_stock_loan_payments(info=None):
data = request_get(url, 'pagination')
return(filter_data(data, info))

@login_required
def get_interest_payments(info=None):
"""Returns a list of interest payments.

:param info: Will filter the results to get a specific value.
:type info: Optional[str]
:returns: Returns a list of dictionaries of key/value pairs for each interest payment. If info parameter is provided, \
a list of strings is returned where the strings are the value of the key that matches info.

"""
url = interest_url()
data = request_get(url, 'pagination')
return(filter_data(data, info))

@login_required
def get_margin_interest(info=None):
Expand Down
2 changes: 2 additions & 0 deletions robin_stocks/robinhood/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ def referral_url():
def stockloan_url():
return('https://api.robinhood.com/accounts/stock_loan_payments/')

def interest_url():
return('https://api.robinhood.com/accounts/sweeps/')

def subscription_url():
return('https://api.robinhood.com/subscription/subscription_fees/')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = f.read()

setup(name='robin_stocks',
version='3.1.1',
version='3.1.2',
description='A Python wrapper around the Robinhood API',
long_description=long_description,
long_description_content_type='text/x-rst',
Expand Down
19 changes: 18 additions & 1 deletion tests/test_robinhood.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,4 +857,21 @@ def isFloat(f):
assert ('amount' in payment)
assert isFloat(payment['amount']['amount'])
assert ('symbol' in payment)
assert ('description' in payment)
assert ('description' in payment)

def test_get_interest_payments(cls):
def isFloat(f):
try:
float(f)
return True
except ValueError:
return False

interests = r.get_interest_payments()
assert (interests)
for interest in interests:
assert ('amount' in interest)
assert isFloat(interest['amount']['amount'])
assert ('direction' in interest)
assert ('payout_type' in interest)
assert ('reason' in interest)