Order

class lendingclub.Order(lc)

Used to create an order for one or more loan notes. It’s best to create the Order instance through the lendingclub.LendingClub.start_order() method (see examples below).

Parameters:

lc : lendingclub.LendingClub

The LendingClub API object that is used to communicate with lendingclub.com

Examples

Invest in a single loan:

>>> from lendingclub import LendingClub
>>> lc = LendingClub()
>>> lc.authenticate()
Email:test@test.com
Password:
True
>>> order = lc.start_order()           # Start a new investment order
>>> order.add(654321, 25)              # Add loan 654321 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 loan in this order to a portfolio called 'Foo'
True

Invest $25 in multiple loans:

>>> from lendingclub import LendingClub
>>> lc = LendingClub(email='test@test.com', password='mysecret')
>>> 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

Invest different amounts in multiple loans:

>>> from lendingclub import LendingClub
>>> lc = LendingClub(email='test@test.com', password='mysecret')
>>> lc.authenticate()
True
>>> loans = [
    {'loan_id': 1234, invest_amount: 50},  # $50 in 1234
    {'loan_id': 2345, invest_amount: 25},  # $25 in 2345
    {'loan_id': 3456, invest_amount: 150}  # $150 in 3456
]
>>> order = lc.start_order()
>>> order.add_batch(loans)                 # Do not pass `batch_amount` parameter this time
>>> order.execute()                        # Execute the order
1861880

Attributes

lc  
loans  

Methods

add(loan_id, amount)

Add a loan and amount you want to invest, to your order. If this loan is already in your order, it’s amount will be replaced with the this new amount

Parameters:

loan_id : int or dict

The ID of the loan you want to add or a dictionary containing a loan_id value

amount : int % 25

The dollar amount you want to invest in this loan, as a multiple of 25.

add_batch(loans, batch_amount=None)

Add a batch of loans to your order.

Parameters:

loans : list

A list of dictionary objects representing each loan and the amount you want to invest in it (see examples below).

batch_amount : int, optional

The dollar amount you want to set on ALL loans in this batch. NOTE: This will override the invest_amount value for each loan.

Examples

Each item in the loans list can either be a loan ID OR a dictionary object containing loan_id and invest_amount values. The invest_amount value is the dollar amount you wish to invest in this loan.

List of IDs:

# Invest $50 in 3 loans
order.add_batch([1234, 2345, 3456], 50)

List of Dictionaries:

# Invest different amounts in each loans
order.add_batch([
    {'loan_id': 1234, invest_amount: 50},
    {'loan_id': 2345, invest_amount: 25},
    {'loan_id': 3456, invest_amount: 150}
])
assign_to_portfolio(portfolio_name=None)

Assign all the notes in this order to a portfolio

Parameters:

portfolio_name – The name of the portfolio to assign it to (new or existing)

Returns:

boolean

True on success

Raises:

LendingClubError

execute(portfolio_name=None)

Place the order with LendingClub

Parameters:

portfolio_name : string

The name of the portfolio to add the invested loan notes to. This can be a new or existing portfolio name.

Returns:

int

The completed order ID

Raises:

LendingClubError

remove(loan_id)

Remove a loan from your order

Parameters:

loan_id : int

The ID of the loan you want to remove

remove_all()

Remove all loans from your order

update(loan_id, amount)

Update a loan in your order with this new amount

Parameters:

loan_id : int or dict

The ID of the loan you want to update or a dictionary containing a loan_id value

amount : int % 25

The dollar amount you want to invest in this loan, as a multiple of 25.