• This repository has been archived on 01/Apr/2023
  • Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python API for LendingClub

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:[email protected]
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:[email protected]
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:[email protected]
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:[email protected]
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='[email protected]', 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='[email protected]', 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.

More Repositories

1

jira-changelog

Generates a changelog by matching git commits to Jira tickets.
JavaScript
82
star
2

arduino-LEDFader

An arduino library to fade individual LEDs in the background without blocking your main program.
C++
78
star
3

LendingClubAutoInvestor

A simple command line tool that will automatically invest all cash that becomes available
Python
46
star
4

ThunderPack

A self-contained microcontroller, battery, and power management system that fits in your pocket.
HTML
42
star
5

python-pause

Suspend the execution of your program for a given amount of time.
Python
41
star
6

CodeSync

Immediately syncs file changes to a remote machine.
Shell
17
star
7

ruby-serialgps

Provides an easy API to get GPS data from your serial GPS module.
Ruby
13
star
8

avr-multidrop-bootloader

A bootloader for AVR devices on a multidrop bus, like RS485, where they can all be programmed at once
C++
12
star
9

react-native-a11y-slider

An accessible range slider that supports assistive devices like screen readers
TypeScript
10
star
10

DiscoDanceFloorV1

Interactive Disco Dance Floor controller and firmware
KiCad Layout
7
star
11

Ganzbot-Controller

A controller application for the Ganzbot robot.
Objective-C
6
star
12

AVR-Libs

A collection of handy AVR libraries
Makefile
5
star
13

avr-discobus

An Arduino/AVR library for the disco bus multidrop protocol.
C++
4
star
14

Disco-Bus-Protocol

A versatile master/slave multidrop communication protocol.
3
star
15

jwalk

A JavaScript inspection and documentation tool written in Java.
Java
3
star
16

LocalForageExplorer

A extension for viewing/editing localForage data stores in Chrome and Firefox.
JavaScript
2
star
17

gif_tabs

A chrome extension that shows a new animated gif for each new tab
JavaScript
2
star
18

test-coverage-reporter

Github Action that generates a test coverage report for a PR
TypeScript
1
star
19

disco-dongle

A USB to RS485 dongle uniquely designed for the the Disco Bus.
KiCad Layout
1
star
20

scrubbr

Serialize and sanitize your JSON API data using your TypeScript as the schema.
TypeScript
1
star
21

AddressableLEDStrip

A simple arduino library for interacting with WS2801 addressable RGB LEDs
Arduino
1
star
22

Spaces

An intuitive wiki-like knowledge base system that works.
CSS
1
star
23

test-coverage-annotations

A github action that add test coverage annotations to your files.
TypeScript
1
star
24

react-fancy-qrcode

Customizable QR code generated for React & React Native
TypeScript
1
star
25

node-multibootloader

Can program many AVR devices at once over a multidrop bus, like RS485
JavaScript
1
star
26

SVGIconsetCropper

Automatically removes the whitespace/padding around a batch of SVG files. Optionally, creates a icon font.
TypeScript
1
star
27

node-discobus

A Disco Bus protocol master node implementation for nodejs
JavaScript
1
star
28

ToughBanana

PHP
1
star