Skip to main content

An library for Lending Club that lets you check your cash balance, search for notes, build orders and invest.

Project description

Lending Club API

A stand-alone python module for interacting with your Lending Club account. In a nutshell, it lets you check your cash balance, search for notes, build orders, invest and more.

Disclaimer

I have tested this tool to the best of my ability, but understand that it may have bugs. Use at your own risk!

Dependencies

The following Python libraries are required (ignore if installing with pip):

Install with PIP

The easiest way to install is with pip:

sudo pip install lendingclub

Install Manually

First make sure the dependencies are instaled and then run:

sudo python ./setup.py install

Documentation

View the full API documentation.

Examples

Here are a few examples, in the python interactive shell, of using the Lending Club API module.

Simple Search and Order

Searching for grade B loans and investing $25 in the first one you find:

>>> from lendingclub import LendingClub
>>> from lendingclub.filters import Filter
>>> lc = LendingClub()
>>> lc.authenticate()
Email:test@test.com
Password:
True
>>> filters = Filter()
>>> filters['grades']['B'] = True      # Filter for only B grade loans
>>> results = lc.search(filters)       # Search using this filter
>>> len(results['loans'])              # See how many results returned
100
>>> results['loans'][0]['loan_id']     # See the loan_id of the first loan
1763030
>>> order = lc.start_order()           # Start a new investment order
>>> order.add(1763030, 25)             # Add the first loan to the order with a $25 investment
>>> order.execute()                    # Execute the order
1861879
>>> order.order_id                     # See the order ID
1861879
>>> order.assign_to_portfolio('Foo')   # Assign the loans in this order to a portfolio called 'Foo'
True

Invest in a Portfolio of Loans

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 filters
>>> filters['grades']['B'] = True     # See Pro Tips for a shorter way to do this
>>> 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
                                      # Find a portfolio to invest in ($400, between 17-19%, $25 per note)
>>> portfolio = lc.build_portfolio(400,
        min_percent=17.0,
        max_percent=19.0,
        max_per_note=25,
        filters=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 loans to the order
>>> order.execute()                   # Execute the order
1861880

Your Loan Notes

Get a list of the loan notes that you have already invested in (by default this will only return 100 at a time):

>>> from lendingclub import LendingClub
>>> lc = LendingClub()
>>> lc.authenticate()
Email:test@test.com
Password:
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

Using Saved Filters

Use a filter saved on lendingclub.com to search for loans SEE NOTE BELOW:

>>> from lendingclub import LendingClub
>>> from lendingclub.filters import SavedFilter
>>> lc = LendingClub()
>>> lc.authenticate()
Email:test@test.com
Password:
True
>>> filters = lc.get_saved_filters()         # Get a list of all saved filters on LendinClub.com
>>> print filters                            # I've pretty printed the output for you
[
    <SavedFilter: 12345, '90 Percent'>,
    <SavedFilter: 23456, 'Only A loans'>
]
>>> filter = lc.get_saved_filter(23456)      # Load a saved filter by ID 7611034
>>> filter.name
u'Only A'
>>> results = lc.search(filter)              # Search for loan notes with that filter
>>> len(results['loans'])
100

NOTE: When using saved search filters you should always confirm that the returned results match your filters. This is because LendingClub’s search API is not very forgiving. When we get the saved filter from the server and then send it to the search API, if any part of it has been altered or becomes corrupt, LendingClub will do a wildcard search instead of using the filter. The code in this python module takes great care to keep the filter pristine and check for inconsistencies, but that’s no substitute for the individual investor’s diligence.

Batch Investing

Invest in a list of loans in one action:

>>> from lendingclub import LendingClub
>>> lc = LendingClub(email='test@test.com', password='secret123')
>>> lc.authenticate()
True
>>> loans = [1234, 2345, 3456]       # Create a list of loan IDs
>>> order = lc.start_order()          # Start a new order
>>> order.add_batch(loans, 25)        # Invest $25 in each loan
>>> order.execute()                   # Execute the order
1861880

Get More Note Details

When browsing notes, you can get more details about a note by requesting the “loanDetailAj.action” URL:

>>> import pprint as pp
>>> from lendingclub import LendingClub
>>> from lendingclub.filters import Filter
>>> lc = LendingClub()
>>> lc.authenticate()
True
>>> filters = Filter()
>>> filters['grades']['B'] = True
>>> results = lc.search(filters)
>>> load_id = results['loans'][0]['loan_id']
>>> request = lc.session.get('/browse/loanDetailAj.action', query={'loan_id': load_id} )
>>> details = request.json()
>>> pp.pprint(details)
{u'DTI': u'21.24',
 u'amountDelinquent': u'$0.00',
 u'collectionsExcludingMedical': u'0',
 u'completeTenure': u'10+ years',
 u'creditDateShort': u'7/14/14',
 ...
 u'verifiedIncome': u'false'}

Pro Tips

Email/Password

Set your email/password when you initialize the LendingClub object:

lc = LendingClub(email='you@your.com', password='illnevertell')

Filter One-liner

Define some of your filters in the init line:

filters = Filter({'grades': {'B': True, 'C': True, 'D': True, 'E': True}})

License

The MIT License (MIT)

Copyright (c) 2013 Jeremy Gillick

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lendingclub-0.1.10.tar.gz (44.4 kB view details)

Uploaded Source

File details

Details for the file lendingclub-0.1.10.tar.gz.

File metadata

File hashes

Hashes for lendingclub-0.1.10.tar.gz
Algorithm Hash digest
SHA256 225d8a14499b93111a1fe053b91649b1b81cb84722d8b945cd0188b1125b5c26
MD5 bd3eda87afd2ca13364ac63ab0bc71ef
BLAKE2b-256 859d63ed6f3736f5d6794467f2e8b42f0018a30aaa7e2a46229155468976429e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page