Skip to content

Commit

Permalink
Merge pull request #481 from anarghya-das/master
Browse files Browse the repository at this point in the history
Added interest payment function
  • Loading branch information
jmfernandes committed Jul 5, 2024
2 parents f055188 + 2cf6f55 commit 2e12794
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
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)

0 comments on commit 2e12794

Please sign in to comment.