Code Monkey home page Code Monkey logo

Comments (6)

jgillick avatar jgillick commented on September 27, 2024

Hi. I'm glad that you're using the module.

How are you trying to add the IDs to the order? Are you following the first example in the README?

When creating an order, it should handle staging the loans for you. Currently, however, the batch_add method requires a list of dictionaries -- not a list of IDs (I should fix this) Here's an example of how it should work:

from lendingclub import LendingClub

lc = LendingClub(email='[email protected]', password='secret123')

# Create list of loan IDs
ids = [
    {'loan_id': 1234}, 
    {'loan_id': 2345}, 
    {'loan_id': 3456}
]

# Invest $25 in all loans
order = lc.start_order()
order.add_batch(ids, 25)
order_id = order.execute() 

print 'Order placed: {0}'.format(order_id)

If this doesn't work, send me the error message you're seeing and we'll go from there. Cheers.

from lendingclub.

jgillick avatar jgillick commented on September 27, 2024

I think I might have found a bug in my order staging code. Please send me the error you're getting so I can verify. Thank you.

from lendingclub.

jgillick avatar jgillick commented on September 27, 2024

I found and fixed some bugs with the loan note staging code. I'm not sure if these were your bugs, but update to version 0.1.1 and let me know.

You can now add a list of IDs to the add_batch method, instead of a list of dictionaries. The example I showed above still works, but here is a simpler version, using version 0.1.1:

from lendingclub import LendingClub

lc = LendingClub(email='[email protected]', password='secret123')

# Create list of loan IDs
ids = [1234, 2345, 3456]

# Invest $25 in all loans
order = lc.start_order()
order.add_batch(ids, 25)
order_id = order.execute() 

print 'Order placed: {0}'.format(order_id)

from lendingclub.

phaedrus75 avatar phaedrus75 commented on September 27, 2024

Thank you so much

I'll try running this and let you know if it fixes the issue

Regards

Sent from my iPhone

On 30 Jul, 2013, at 12:03 PM, Jeremy Gillick [email protected] wrote:

I found and fixed some bugs with the loan note staging code. I'm not sure if these were your bugs, but update to version 0.1.1 and let me know.

You can now add a list of IDs to the add_batch method, instead of a list of dictionaries. The example I showed above still works, but here is a simpler version, using version 0.1.1:

from lendingclub import LendingClub

lc = LendingClub(email='[email protected]', password='secret123')

Create list of loan IDs

ids = [1234, 2345, 3456]

Invest $25 in all loans

order = lc.start_order()
order.add_batch(ids, 25)
order_id = order.execute()

print 'Order placed: {0}'.format(order_id)

Reply to this email directly or view it on GitHub.

from lendingclub.

phaedrus75 avatar phaedrus75 commented on September 27, 2024

I think it fixed the previous issue but it is still not working..

Here's what I am trying to do.

My program downloads the InFunding2Statsnew csv file from lending club - the file that is periodically refreshed and has new loans available for lending.

I am running criteria off the file - reason is there are far more attributes in the file than are available in web UI and my criteria uses some of these variables

Now since the file is updated in batches - there are notes in the file that are filled up by the time the program runs and thus is no longer available on the web. In such a case I just want to be able to pick whatever is available out of the pool that I find through parsing the file

Here is the error it is picking up. I found 45 matches on the file ... but only 22 were available when I run the code to add batch order as you explain above

Found 45 selected ones
Traceback (most recent call last):
File "csv_lc.py", line 109, in
order.execute()
File "/Users/xxx/Documents/LendingClub-master/lendingclub/init.py", line 714, in execute
self.stage_order()
File "/Users/xxx/Documents/LendingClub-master/lendingclub/__init
.py", line 771, in __stage_order
raise LendingClubError('Could not stage the loans. The number of loans in your batch does not match totalRecords. {0} != {1}'.format(len(self.loans), results['totalRecords']), results)
lendingclub.LendingClubError: 'Could not stage the loans. The number of loans in your batch does not match totalRecords. 45 != 22'

from lendingclub.

jgillick avatar jgillick commented on September 27, 2024

Ah, this makes sense. Currently, when you create an order it treats it as an atomic transaction, all loans are invested in or none. I might change this in the future, but there is a good workaround.

First I've updated the module to make this process smoother, so update your version of lendingclub to version 0.1.2 or greater:

sudo pip install lendingclub --upgrade

Now, get the list of loan IDs from your CSV and perform a search by ID. Only the loans that are still available will return. You can then add these to the order and invest. In the following example, it searches for 4 loans by ID and then invests $25 in whichever ones are still available:

from lendingclub.filters import FilterByLoanID

# Search for loans by ID
loan_ids = [54321, 65432, 76543, 876543]
filter = FilterByLoanID(loan_ids)
results = lc.search(filter)
print len(results['loans'])

# Invest $25 in all the loans that were found
order = lc.start_order()
order.add_batch(results['loans'], 25)
order.execute()

I haven't tried this myself, but it should work. The search results contain quite a bit of up-to-date information about each loan. So you could also check the funding progress on each one and adjust amount you invest per loan note -- you don't want to invest $100 in a loan that only has $25 left to fund.

I also finally have the full API documentation hosted, which might help:
https://python-lendingclub.readthedocs.org/en/latest/index.html

Feel free to message me with any other questions.

from lendingclub.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.