Giter Site home page Giter Site logo

Comments (17)

lasconic avatar lasconic commented on August 31, 2024 1

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

from finary_uapi.

Mameluk007 avatar Mameluk007 commented on August 31, 2024 1

I’ll test this. Thanks !

from finary_uapi.

Mameluk007 avatar Mameluk007 commented on August 31, 2024

from finary_uapi.

ToutUnProg avatar ToutUnProg commented on August 31, 2024

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.

from finary_uapi.

lasconic avatar lasconic commented on August 31, 2024

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.

from finary_uapi.

lasconic avatar lasconic commented on August 31, 2024

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

from finary_uapi.

lasconic avatar lasconic commented on August 31, 2024

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 ?

from finary_uapi.

lasconic avatar lasconic commented on August 31, 2024

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

from finary_uapi.

lasconic avatar lasconic commented on August 31, 2024

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

from finary_uapi.

ToutUnProg avatar ToutUnProg commented on August 31, 2024

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

from finary_uapi.

Mameluk007 avatar Mameluk007 commented on August 31, 2024

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 !

from finary_uapi.

lasconic avatar lasconic commented on August 31, 2024

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.

from finary_uapi.

lasconic avatar lasconic commented on August 31, 2024

@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 ?

  • Do not add lines that are already imported: based on which criteria ? name of the account + name of the project ?
  • Do you need to update lines then ? like if "name of the account + name of the project" is the same but current price changed ?
  • What if a line is on Finary but we can't find it in the CSV (based on the same criteria) ? We delete it from Finary ?

from finary_uapi.

Mameluk007 avatar Mameluk007 commented on August 31, 2024

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 :

  • Update existing projects : current price especially (the reste is not supposed to change)
  • If a line exist in Finary and not in the CSV, delete it in Finary. This is how I would like to work so I submit a complete CSV of my different accounts eache time I need to update. In this way the projects that ended would be deleted from Finary.
    Hope everything's clear enough.

Thank you again !

from finary_uapi.

lasconic avatar lasconic commented on August 31, 2024

I implemented just that.

I added two options:

  • -d will run without modifying Finary but print what it would do (add, delete, update)
  • -c if you want to delete the lines that are on Finary but not in the CSV, you need to add this flag. It's a safeguard...

@Mameluk007 could you test on your use case ?

from finary_uapi.

Mameluk007 avatar Mameluk007 commented on August 31, 2024

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 !

from finary_uapi.

Mameluk007 avatar Mameluk007 commented on August 31, 2024

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)

from finary_uapi.

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.