Git Product home page Git Product logo

peerberrypy's Introduction

Hi there ๐Ÿ‘‹

peerberrypy's People

Contributors

dependabot[bot] avatar mrdanao avatar svscorp avatar thicccat688 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

peerberrypy's Issues

Suggestion: improve API exception handling in RequestHandler

Hi,
First off, thanks for this nice little wrapper. Works great.

Here is my use case:
1 - List available loans
2 - Buy loans in a loop

This quickly causes the server to block me with a 429 response ("too many requests").

I want to be able to identify this response code and act accordingly (log it, wait and/or try to relogin).

As of now, RequestHandler.request() takes an Exception class as argument and raises an instance of that exception if the response code is => 400, no matter what the problem is.

So at a higher level, the only way for me to find out what happened is to read the exception message. But this message comes straight from the server, and in the case of a 429, it is not very explicit and may not be specific to this error: {'rules': 'wq7te'}.

Instead, I suggest creating and raising a TooManyRequests exception in RequestHandler.request() when the response code is 429. Or maybe there is a better way to handle it, such as using requests.raise_for_status().

In addition to that, for my use case, the InsufficientFunds exception that is passed by purchase_loan() to RequestHandler.request() covers too many cases. I counted at least 2 cases that cause this exception to be raised while my funds are sufficient, but there may be more:

  • "The remaining available loan amount after investment cannot be less than the minimum investment amount"
  • "The loan is sold out"

I'm not sure what the best solution would be. I would either remove the exception_type argument from RequestHandler.request(), only raise "technical" exceptions in RequestHandler.request() and let higher level functions process the response (and let them raise "business" exceptions).

I can drop a PR but would like to know your opinion beforehand.

Loan Types filter

Exception has occurred: TypeError 'int' object is not iterable File "\peerberrypy\api.py", line 211, in get_loans for idx, type_ in enumerate(loan_types): File "main.py", line 20, in <module> pd = api_client.get_loans(quantity=100, min_interest_rate= 9, loan_types=1) TypeError: 'int' object is not iterable
Hello, I think there's a little problem with the loan type filter, can you check if it works for you ? thanks.

No loan available

Good afternoon, first of all, I wanted to thank you for this magnificent API. I must say that I'm a beginner, I noticed that after a while of using the API from my account, no loans were visible, even though I hadn't set any filters (although in reality, 5-6 long loans were present). How could I solve the problem? I found another way to invest with the API, but I'm not sure if it will last long. Thank you very much for your work.Good afternoon, first of all, I wanted to thank you for this magnificent API. I must say that I'm a beginner, and I noticed that after a while of using the API from my account, no loans were visible, even though I hadn't set any filters (although in reality, 5-6 long loans were present). How could I solve the problem? I found another way to invest with the API, but I'm not sure if it will last long. Thank you very much for your work.

'group_guarantee' and 'exclude_invested_loans' parameters are not correctly checked in get_loans() method

In API.get_loans() method, the following parameters are booleans with default value: group_guarantee, exclude_invested_loans.

However they are not correctly checked:

if group_guarantee is not None:
    loan_params['groupGuarantee'] = 1

if exclude_invested_loans is not None:
    loan_params['hideInvested'] = 1

These conditions are never matched.

It should be:

if group_guarantee:
    loan_params['groupGuarantee'] = 1

if exclude_invested_loans:
    loan_params['hideInvested'] = 1

API.get_loans_page() got multiple values for argument 'self'

Hi!
First of all, thanks for the work :)

I have launched the examples of "Usage" (Readme file):
"print(api_client.get_loans(quantity=100, originators=['Smart Pozyczka PL']))" and it returns this error:

>>> print(api_client.get_loans(quantity=100, originators=['Smart Pozyczka PL']))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Nacho\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\peerberrypy\api.py", line 185, in get_loans
    loans_data = do_get_loans_page(page_num)['data']
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: API.get_loans_page() got multiple values for argument 'self'

I have tested without "originators" parameter and the result is the same.

The other functions works fine (get_profile and get_investments)

suggestion: use a project manager

A project manager would make it simpler to publish new versions and manage dependencies, including handling a lock file.

Poetry is a probably the most popular, but I think a simple one like pdm would suffice.

failing tests in github actions

Hi,

The tests on github CI are invariably failing. That's not very useful and causes error report fatigue.

I see now they're failing due to missing credentials. Not sure if you want to keep your PB password at GH. If not, a reasonable step would be disabling GH actions.

IMO The only good way to test such a remote API client would be recording real responses and mocking the HTTP requests, so not making any remote API calls. Optionally real tests (against live API) could be run manually.

Date format

Hi,

I would like to use the "get_profit_overview" function. Unfortunately, I don't know how to write the start and end dates. I wrote "api_client.get_profit_overview(start_date="2022-02-01", end_date="2023-02-01", periodicity="day")". I wanted to know in which format to write the dates.

Can you please help me? Thank you in advance.

API.get_loans_page() got multiple values for argument 'self'

Hey,

firstly I very much enjoy using this project, it's of great help to me.

Now I'm not a professional dev so it might also be a lack of understanding, but I did quite some digging and experimenting.

I am getting the following error when trying to get loans:
INFO Exception in getLoans function, error: API.get_loans_page() got multiple values for argument 'self'

Now the strange thing is, I have one poetry virtual environment where the same exact code works, but I am not able to get it running again with a fresh setup.
I am trying to build a docker container to run as Google Run Job, however it also fails locally. I got some feeling it might have to do with the pandas version on the system, but I was also not able to downgrade that as well trying for hours. In the working environment I have pandas 2.0.3 which seems to work but cannot be installed anymore (tried on Windows locally and in a docker container).

I also got this warning, not sure if that's related:
FutureWarning: Passing bytes to 'read_excel' is deprecated and will be removed in a future version. To read from a byte string, wrap it in a BytesIO object.
investment_data = pd.read_excel(

get_loans returns no loans anymore

Hi,

since a few days the get_loans function does not return anything for me anymore besides the Lithuanian loans that are always available (e.g. real estate).

I have checked this while there were loans available in the morning, e.g. PL or KZ that sit for a minute or two. Still got no returns. I also removed all parameters except for the quantity to check if anything changed there, but still no results.

It's not an account ban, since web and mobile app work fine, also same IP.
They might have changed sth. on their end - could you verifiy this as well and is there any way around?

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.