Wrapper class for the
- class finalynx.fetch.source_finary.SourceFinary(force_signin: bool = False, name: str = 'Finary', cache_validity: int = 12)
Wrapper class for the
This class manages all interactions with your Finary account, namely:
Authentication: The function starts by signing you in with the following sequence of attempts:
First, the function looks for environment variables named
FINARY_PASSWORDcontaining your credentials. If those are set, they will take priority over all other signin methods.
Second, if a file named
finary_cookies.txtalready 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.
Fetch the data: Once the session is active, all investments declared in Finary are fetched.
Populate the portfolio: Finally, each fetched investment is matched against either the
keyvalue of each
Lineobject defined in your
Portfolioand updated in the tree.
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_uapito 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
--force-signinoption 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]
Internal method used to signin and retrieve a session from Finary. Called by
_fetch_dataonce, only exists for better logic separation.
A session for fetching data if everything worked, None otherwise.
- _fetch_data(tree: rich.tree.Tree) None
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
treeinstance with a hierarchical view of the fetched information. The
treeinstance can be displayed in the console to make sure everything was retrieved.
- _process_account(dict_account: Dict[str, Any], tree: rich.tree.Tree) None