Module Contents



Wrapper class for the finary_uapi package.


class finalynx.fetch.source_finary.SourceFinary(force_signin: bool = False, name: str = 'Finary', cache_validity: int = 12)[source]

Bases: finalynx.fetch.source_base_line.SourceBaseLine

Wrapper class for the finary_uapi package.


This class manages all interactions with your Finary account, namely:

  1. Authentication: The function starts by signing you in with the following sequence of attempts:

    • First, the function looks for environment variables named FINARY_EMAIL and FINARY_PASSWORD containing your credentials. If those are set, they will take priority over all other signin methods.

    • Second, if a file named finary_cookies.txt already exists in this same directory (which contains the session of a previous signin), it will skip the login step and retrieve the saved sessions.

    • Third, if neither the environment variables nor the cookies file exist, the function will manually ask for the credentials in the console.

  2. Fetch the data: Once the session is active, all investments declared in Finary are fetched.

  3. Populate the portfolio: Finally, each fetched investment is matched against either the name or key value of each Line object defined in your Portfolio and updated in the tree.

  4. Cache the data: Once the data has been fetched, all data is saved to a local file to reduce the frequency of calls to Finary API and enable the usage of this module offline temporarily.


Finalynx will ask you if you want to save two files:

  • finary_credentials.json: This file would store your credentials in a plain text file, which might be used by finary_uapi to refresh your session (to be confirmed). However, this is not recommended since only storing the session is more secure and you can always enter your credentials again from occasionally.

  • finary_cookies.txt: This file stores the session created after a successful login (without your plain credentials). It is recommended to save it if you don’t want to enter your credentials on each run.

You can run Finalynx with the -f or --force-signin option to delete all files and start over.

  • force_signin – Delete all saved credentials, cookies and cache files before logging in again, defaults to False

  • cache_validity – Finalynx will save fetched results to a file and reuse them on the next run if the cache age is less than the specified number of hours.


Returns a tree view of all fetched investments, which can be printed to the console to make sure everything was correctly found.


[‘fiats’, ‘securities’, ‘cryptos’, ‘fonds_euro’, ‘startups’, ‘precious_metals’, ‘scpis’, ‘generic_as…

_authenticate() Optional[requests.Session][source]

Internal method used to signin and retrieve a session from Finary. Called by _fetch_data once, only exists for better logic separation.


A session for fetching data if everything worked, None otherwise.

_fetch_data(tree: rich.tree.Tree) None[source]

Overridden method used to fetch every investment in your Finary account.


A dictionary of all fetched investments (name:amount format). This method also populates the tree instance with a hierarchical view of the fetched information. The tree instance can be displayed in the console to make sure everything was retrieved.

_process_account(dict_account: Dict[str, Any], tree: rich.tree.Tree) None[source]