LendingClub

The stand-alone python module for interacting with your Lending Club account.

class lendingclub.LendingClub(email=None, password=None, logger=None)

The main entry point for interacting with Lending Club.

Parameters:

email : string

The email of a user on Lending Club

password : string

The user’s password, for authentication.

logger : Logger

A python logger used to get debugging output from this module.

Examples

Get the cash balance in your lending club account:

>>> from lendingclub import LendingClub
>>> lc = LendingClub()
>>> lc.authenticate()         # Authenticate with your lending club credentials
Email:test@test.com
Password:
True
>>> lc.get_cash_balance()     # See the cash you have available for investing
463.80000000000001

You can also enter your email and password when you instantiate the LendingClub class, in one line:

>>> from lendingclub import LendingClub
>>> lc = LendingClub(email='test@test.com', password='secret123')
>>> lc.authenticate()
True

Attributes

order  
session  

Methods

assign_to_portfolio(portfolio_name, loan_id, order_id)

Assign a note to a named portfolio. loan_id and order_id can be either integer values or lists. If choosing lists, they both MUST be the same length and line up. For example, order_id[5] must be the order ID for loan_id[5]

Parameters:

portfolio_name : string

The name of the portfolio to assign a the loan note to – new or existing

loan_id : int or list

The loan ID, or list of loan IDs, to assign to the portfolio

order_id : int or list

The order ID, or list of order IDs, that this loan note was invested with. You can find this in the dict returned from get_note()

Returns:

boolean

True on success

authenticate(email=None, password=None)

Attempt to authenticate the user.

Parameters:

email : string

The email of a user on Lending Club

password : string

The user’s password, for authentication.

Returns:

boolean

True if the user authenticated or raises an exception if not

Raises:

session.AuthenticationError

If authentication failed

session.NetworkError

If a network error occurred

build_portfolio(cash, max_per_note=25, min_percent=0, max_percent=20, filters=None, automatically_invest=False, do_not_clear_staging=False)

Returns a list of loan notes that are diversified by your min/max percent request and filters. One way to invest in these loan notes, is to start an order and use add_batch to add all the loan fragments to them. (see examples)

Parameters:

cash : int

The total amount you want to invest across a portfolio of loans (at least $25).

max_per_note : int, optional

The maximum dollar amount you want to invest per note. Must be a multiple of 25

min_percent : int, optional

THIS IS NOT PER NOTE, but the minimum average percent of return for the entire portfolio.

max_percent : int, optional

THIS IS NOT PER NOTE, but the maxmimum average percent of return for the entire portfolio.

filters : lendingclub.filters.*, optional

The filters to use to search for portfolios

automatically_invest : boolean, optional

If you want the tool to create an order and automatically invest in the portfolio that matches your filter. (default False)

do_not_clear_staging : boolean, optional

Similar to automatically_invest, don’t do this unless you know what you’re doing. Setting this to True stops the method from clearing the loan staging area before returning

Returns:

dict

A dict representing a new portfolio or False if nothing was found. If automatically_invest was set to True, the dict will contain an order_id key with the ID of the completed investment order.

Notes

The min/max_percent parameters

When searching for portfolios, these parameters will match a portfolio of loan notes which have an AVERAGE percent return between these values. If there are multiple portfolio matches, the one closes to the max percent will be chosen.

Examples

Here we want to invest $400 in a portfolio with only B, C, D and E grade notes with an average overall return between 17% - 19%. This similar to finding a portfolio in the ‘Invest’ section on lendingclub.com:

>>> from lendingclub import LendingClub
>>> from lendingclub.filters import Filter
>>> lc = LendingClub()
>>> lc.authenticate()
Email:test@test.com
Password:
True
>>> filters = Filter()                  # Set the search filters (only B, C, D and E grade notes)
>>> filters['grades']['C'] = True
>>> filters['grades']['D'] = True
>>> filters['grades']['E'] = True
>>> lc.get_cash_balance()               # See the cash you have available for investing
463.80000000000001

>>> portfolio = lc.build_portfolio(400, # Invest $400 in a portfolio...
        min_percent=17.0,               # Return percent average between 17 - 19%
        max_percent=19.0,
        max_per_note=50,                # As much as $50 per note
        filters=filters)                # Search using your filters

>>> len(portfolio['loan_fractions'])    # See how many loans are in this portfolio
16
>>> loans_notes = portfolio['loan_fractions']
>>> order = lc.start_order()            # Start a new order
>>> order.add_batch(loans_notes)        # Add the loan notes to the order
>>> order.execute()                     # Execute the order
1861880

Here we do a similar search, but automatically invest the found portfolio. NOTE This does not allow you to review the portfolio before you invest in it.

>>> from lendingclub import LendingClub
>>> from lendingclub.filters import Filter
>>> lc = LendingClub()
>>> lc.authenticate()
Email:test@test.com
Password:
True
                                        # Filter shorthand
>>> filters = Filter({'grades': {'B': True, 'C': True, 'D': True, 'E': True}})
>>> lc.get_cash_balance()               # See the cash you have available for investing
463.80000000000001
>>> portfolio = lc.build_portfolio(400,
        min_percent=17.0,
        max_percent=19.0,
        max_per_note=50,
        filters=filters,
        automatically_invest=True)      # Same settings, except invest immediately
>>> portfolio['order_id']               # See order ID
1861880
get_cash_balance()

Returns the account cash balance available for investing

Returns:

float

The cash balance in your account.

get_investable_balance()

Returns the amount of money from your account that you can invest. Loans are multiples of $25, so this is your total cash balance, adjusted to be a multiple of 25.

Returns:

int

The amount of cash you can invest

get_note(note_id)

Get a loan note that you’ve invested in by ID

Parameters:

note_id : int

The note ID

Returns:

dict

A dictionary representing the matching note or False

Examples

>>> from lendingclub import LendingClub
>>> lc = LendingClub(email='test@test.com', password='secret123')
>>> lc.authenticate()
True
>>> notes = lc.my_notes()                  # Get the first 100 loan notes
>>> len(notes['loans'])
100
>>> notes['total']                          # See the total number of loan notes you have
630
>>> notes = lc.my_notes(start_index=100)   # Get the next 100 loan notes
>>> len(notes['loans'])
100
>>> notes = lc.my_notes(get_all=True)       # Get all notes in one request (may be slow)
>>> len(notes['loans'])
630
get_portfolio_list(names_only=False)

Get your list of named portfolios from the lendingclub.com

Parameters:

names_only : boolean, optional

If set to True, the function will return a list of portfolio names, instead of portfolio objects

Returns:

list

A list of portfolios (or names, if names_only is True)

get_saved_filter(filter_id)

Load a single saved search filter from the site by ID

Parameters:

filter_id : int

The ID of the saved filter

Returns:

SavedFilter

get_saved_filters()

Get a list of all the saved search filters you’ve created on lendingclub.com

Returns:

list

is_site_available()

Returns true if we can access LendingClub.com This is also a simple test to see if there’s an internet connection

Returns:boolean
my_notes(start_index=0, limit=100, get_all=False, sort_by='loanId', sort_dir='asc')

Return all the loan notes you’ve already invested in. By default it’ll return 100 results at a time.

Parameters:

start_index : int, optional

The result index to start on. By default only 100 records will be returned at a time, so use this to start at a later index in the results. For example, to get results 200 - 300, set start_index to 200. (default is 0)

limit : int, optional

The number of results to return per request. (default is 100)

get_all : boolean, optional

Return all results in one request, instead of 100 per request.

sort_by : string, optional

What key to sort on

sort_dir : {‘asc’, ‘desc’}, optional

Which direction to sort

Returns:

dict

A dictionary with a list of matching notes on the loans key

search(filters=None, start_index=0, limit=100)

Search for a list of notes that can be invested in. (similar to searching for notes in the Browse section on the site)

Parameters:

filters : lendingclub.filters.*, optional

The filter to use to search for notes. If no filter is passed, a wildcard search will be performed.

start_index : int, optional

The result index to start on. By default only 100 records will be returned at a time, so use this to start at a later index in the results. For example, to get results 200 - 300, set start_index to 200. (default is 0)

limit : int, optional

The number of results to return per request. (default is 100)

Returns:

dict

A dictionary object with the list of matching loans under the loans key.

search_my_notes(loan_id=None, order_id=None, grade=None, portfolio_name=None, status=None, term=None)

Search for notes you are invested in. Use the parameters to define how to search. Passing no parameters is the same as calling my_notes(get_all=True)

Parameters:

loan_id : int, optional

Search for notes for a specific loan. Since a loan is broken up into a pool of notes, it’s possible to invest multiple notes in a single loan

order_id : int, optional

Search for notes from a particular investment order.

grade : {A, B, C, D, E, F, G}, optional

Match by a particular loan grade

portfolio_name : string, optional

Search for notes in a portfolio with this name (case sensitive)

status : string, {issued, in-review, in-funding, current, charged-off, late, in-grace-period, fully-paid}, optional

The funding status string.

term : {60, 36}, optional

Term length, either 60 or 36 (for 5 year and 3 year, respectively)

Returns:

dict

A dictionary with a list of matching notes on the loans key

set_logger(logger)

Set a logger to send debug messages to

Parameters:

logger : Logger

A python logger used to get debugging output from this module.

start_order()

Start a new investment order for loans

Returns:

lendingclub.Order

The lendingclub.Order object you can use for investing in loan notes.

version()

Return the version number of the Lending Club Investor tool

Returns:

string

The version number string

Exceptions

exception lendingclub.LendingClubError(value, response=None)

Bases: exceptions.Exception

An error occurred. If the error was the result of an API call, the response attribute will contain the HTTP requests response object that was used to make the call to LendingClub.

Parameters:

value : string

The error message

response : requests.Response