<commit_before>Lending Club API
================

A stand-alone python API for Lending Club. In a nutshell, this module lets you check your cash balance, search for notes, build orders and invest.

It is still a work in progress but I expect the first stable release by the end of July. The current release works well but may have some bugs -- use at your own risk.

The code has been ported out of the `LendingClub Auto Investor <https://github.com/jgillick/LendingClubAutoInvestor>`_ project.

Disclaimer
----------

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

Requirements
------------

The following Python libraries are required:

* requests
* beautifulsoup4
* html5lib
* pybars

These can automatically be installed with `pip <http://www.pip-installer.org/en/latest/>`_::

    sudo pip install requests beautifulsoup4 html5lib pybars


Install
-------

To install, run::

    sudo python ./setup.py install


Examples
--------

Here's a step-by-step example of searching for grade B loans and investing $25 in the first one::

    >>> from lendingclub import LendingClub
    >>> from lendingclub.filters import Filter
    >>> lc = LendingClub()
    >>> lc.authenticate()
    Email:<EMAIL>
    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

Create a diversified portfolio of loan notes. 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%::

    >>> from lendingclub import LendingClub
    >>> from lendingclub.filters import Filter
    >>> lc = LendingClub()
    >>> lc.authenticate()
    Email:<EMAIL>
    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%)
    >>> portfolio = lc.build_portfolio(400, 17.0, 19.0, filters)<commit_msg>Fix built_portfolio description<commit_after>Lending Club API
================

A stand-alone python API for Lending Club. In a nutshell, this module lets you check your cash balance, search for notes, build orders and invest.

It is still a work in progress but I expect the first stable release by the end of July. The current release works well but may have some bugs -- use at your own risk.

The code has been ported out of the `LendingClub Auto Investor <https://github.com/jgillick/LendingClubAutoInvestor>`_ project.

Disclaimer
----------

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

Requirements
------------

The following Python libraries are required:

* requests
* beautifulsoup4
* html5lib
* pybars

These can automatically be installed with `pip <http://www.pip-installer.org/en/latest/>`_::

    sudo pip install requests beautifulsoup4 html5lib pybars


Install
-------

To install, run::

    sudo python ./setup.py install


Examples
--------

Here's a step-by-step example of searching for grade B loans and investing $25 in the first one::

    >>> from lendingclub import LendingClub
    >>> from lendingclub.filters import Filter
    >>> lc = LendingClub()
    >>> lc.authenticate()
    Email:<EMAIL>
    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

Create a diversified portfolio of loan notes. 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%::

    >>> from lendingclub import LendingClub
    >>> from lendingclub.filters import Filter
    >>> lc = LendingClub()
    >>> lc.authenticate()
    Email:<EMAIL>
    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)

{'fraction_non_alphanumeric': 0.11326648035508795, 'fraction_numerical': 0.02761795166858458, 'mean_word_length': 2.5978710821998816, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 161, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6379202', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1622, 'n_words': 675}