lasconic / finary_uapi

MIT License
38 stars 11 forks source link

Add crowdlending projects #149

Closed Mameluk007 closed 7 months ago

Mameluk007 commented 11 months ago

Bonjour,

je souhaiterais ajouter des entrées liées à des projets crowdfunding ou crowdlending présentés dans un tableur Excel. Quelle fonction dois-je utiliser ?

Merci.

Stef

lasconic commented 11 months ago

Il n'y a pas de support pour le crowdlending en écriture pour le moment. On peut regarder ensemble si tu veux.

Mameluk007 commented 11 months ago

Salut,

Tout d’abord merci pour ton retour et pour le travail réalisé. Je suis un geek de la génération précédente (assembleur, Pascal, C, démos 4Ko… ) et si je suis resté très connecté nouvelles technos, IA etc. je n’ai malheureusement pas eu le temps de me former sur les nouveaux langages incontournables pour ce genre de projet (Python…). Grâce au net et à Bing IA j’arrive tout de même à bidouiller pour des besoins très pratiques (admin de mon NAS, serveur Plex, serveur VPN mais aussi suivi de mes investissements…).

Assez parlé de moi. L’idée étant donc de pouvoir injecter des extraits de mon tableur de suivi des investissements en crowdfunding (340 lignes sur 29 plateformes différentes) qui s’inspire du tableau de suivi de ce blog : https://fairevivrevotreargent.com/blog-crowdfunding-crowdlending/

Dis-moi comment je peux t’aider très modestement.

Merci à toi.

Stéphane

Le 7 déc. 2023 à 10:06, Nicolas Froment @.***> a écrit :

Il n'y a pas de support pour le crowdlending en écriture pour le moment. On peut regarder ensemble si tu veux.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ToutUnProg commented 10 months ago

This API does not exist on Finary side ? I am not a professional python dev but I will be glad to help to implement it if you know the API to call. I also have almost 400 lines in an excel file I want to import.

lasconic commented 10 months ago

It does exist. You can add an investment manually with the Network tab of your Development tool panel opened in a browser. You will see the calls to implement.

lasconic commented 9 months ago

@Mameluk007 @ToutUnProg I'm looking into it. Did you start something ?

lasconic commented 9 months ago

To create a crowdlending entry, we need to do a POST with the following content

{
  "start_date": "Tue Dec 26 2023 01:00:00 GMT+0100 (heure normale d’Europe centrale)",
  "month_duration": 10,
  "initial_investment": 10,
  "annual_yield": 5,
  "current_price": 10,
  "name": "test",
  "account": {
    "id": "ACCOUNT_ID"
  },
  "currency": {
    "code": "EUR"
  }
}

ACCOUNT_ID can be found with a call to get_holdings_account. The other params are obvious except for this weird looking date... Maybe we can send something else for the date.

Once we have a function to do this. We can create another one that takes all these information but an account name instead of the account id. We need to check if the account exists, create it and get the id if it doesn't, and then we can call the POST.

Once we have this last function, we can write the importer, go through each line and we are good to go.

Do you have the necessary data in your excel files ?

lasconic commented 9 months ago

It's now possible to import crowdlending projects from a csv file. See a CSV example here : https://github.com/lasconic/finary_uapi/blob/main/tests/data/crowdlendings.csv

lasconic commented 9 months ago

I have no idea how it will handle 400 lines :) but please report any issue !

Mameluk007 commented 9 months ago

I’ll test this. Thanks !

ToutUnProg commented 9 months ago

It works so well thank you! You saved me a lot of time

Mameluk007 commented 7 months ago

It works well but if we need to update. How do we do ? Because a new entry with the same name is created when we try to import one that does already exist. Thanks !

lasconic commented 7 months ago

We would need more logic. 1/ Support for update in the API wrapper 2/ Choose a key to check if a record exists (The project name ?) 3/ For each line, check if the key exists, do an update if it does, a POST if it doesn't.

lasconic commented 7 months ago

@Mameluk007 Can you explain your use case a little bit more ?

I understand that you have a new CSV, exported a few months later and you want to import again. What's the expected behavior ?

Mameluk007 commented 7 months ago

Hello. Sure ! Thanks for your support.

This is correct. I need to update existing lines (based on the name of the project AND the name of the account). My need is as follows :

Thank you again !

lasconic commented 7 months ago

I implemented just that.

I added two options:

@Mameluk007 could you test on your use case ?

Mameluk007 commented 7 months ago

It works well, thanks ! Except there is an error every 40 or 50 lines or so. But when I run it again it resumes and keep on updating till the end and it finally looks like all the line have been updated. I'll send you the error messages.

Thanks again !

Mameluk007 commented 7 months ago

The error :


myname@iMac-Stef finary_uapi-main % python3 -m finary_uapi import crowdlending_csv CockpitDuCrowdfunder_BBB.csv Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/Users/myname/Downloads/finary_uapi-main/finary_uapi/main.py", line 449, in sys.exit(main()) ^^^^^^ File "/Users/myname/Downloads/finary_uapi-main/finary_uapi/main.py", line 439, in main add_imported_user_crowdlendings( File "/Users/myname/Downloads/finary_uapi-main/finary_uapi/user_crowdlendings.py", line 149, in add_imported_user_crowdlendings add_user_crowdlending_to_account(

File "/Users/myname/Downloads/finary_uapi-main/finary_uapi/user_crowdlendings.py", line 100, in add_user_crowdlending_to_account account = add_holdings_account( ^^^^^^^^^^^^^^^^^^^^^ File "/Users/myname/Downloads/finary_uapi-main/finary_uapi/user_holdings_accounts.py", line 43, in add_holdings_account logging.debug(json.dumps(x.json(), indent=4)) ^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)