-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdemo.py
executable file
·230 lines (218 loc) · 9.55 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/usr/bin/env python
"""
Welcome to Finalynx!
Finalynx is a tool to organize your investments in a custom hierarchy,
fetch real-time investment values from your personal account using the
Finary API and other pre-built sources, set targets, and simulate your
portfolio evolution with optional life events. Finalynx then outputs a
list of transfers between investments as recommendations to reach your
life goals. Finalynx is available as a CLI tool and as a web dashboard.
Finalynx is not a financial advisor and does not give financial advice.
Use this tool to help you make your own decisions. With that said, have
fun! Contributions and feedback on GitHub are warmly welcome!
This module is maintained by MadeInPierre. You can always get the latest
version of this module at:
> https://github.com/madeinpierre/finalynx
Checkout the documentation and tutorials at:
> https://finalynx.readthedocs.io
"""
# noreorder
from datetime import date
from rich import inspect, print, pretty, traceback # noqa
from finalynx import TargetRange, TargetMin, TargetMax, TargetRatio, TargetGlobalRatio # noqa
from finalynx import Folder, Line, Bucket, SharedFolder, Portfolio, FolderDisplay # noqa
from finalynx import AssetClass, AssetSubclass, Envelope, PEA, AV, PER # noqa
from finalynx import Assistant
# Enable rich's features
traceback.install()
pretty.install()
if __name__ in {"__main__", "__mp_main__"}:
"""
Define groups of Lines, called Buckets, that will be considered as
a single line in your portfolio.
"""
bucket_garanti = Bucket(
"Safe funds",
[
Line("Livret A", key="LIVRET A"),
Line("LDDS", key="Livret de Developpement Durable et Solidaire"),
Line("Livret Jeune", key="LIVRET JEUNE"),
Line("Fonds euro", key="Fonds Euro Nouvelle Generation"),
],
)
"""
Define your Envelopes, which are your investment accounts. They can
be used to store cash, or to store other investments. They can also
be used to store your debts.
"""
my_bank = Envelope("Bank", "BAN", date_created=date(2023, 1, 1), key="NAME_IN_FINARY")
my_av = AV("Linxea Spirit 2", "LIX", date_created=date(2018, 7, 1), key="NAME_IN_FINARY")
"""
Define your complete portfolio structure with Lines, Folders (groups
of Lines), and SharedFolders (Folder with one Bucket). See the README
file or the online documentation for complete usage instructions.
"""
portfolio = Portfolio(
"Portfolio",
children=[
Folder(
"Short Term",
newline=True,
children=[
Folder(
"Daily",
target=TargetRange(100, 500, tolerance=100),
children=[
Line("Neobank", key="CCP N26"),
],
),
Folder(
"Monthly",
target=TargetRange(1000, 2000, tolerance=500),
children=[
Line("Online Bank", key="CCP Boursorama"),
Line("Traditional Bank", key="CCP Banque Postale"),
],
),
SharedFolder(
"Safety net",
bucket=bucket_garanti,
target_amount=6000,
target=TargetMin(6000),
),
SharedFolder(
"Projects & Trips",
bucket=bucket_garanti,
target_amount=2000,
target=TargetRange(1500, 2000, tolerance=500),
),
],
),
SharedFolder(
"Medium Term",
bucket=bucket_garanti,
target_amount=20000,
target=TargetMin(20000),
newline=True,
),
Folder(
"Long Term (10+ years)",
children=[
SharedFolder(
"Guaranteed",
bucket=bucket_garanti,
target=TargetRatio(25),
),
Folder(
"Real estate",
target=TargetRatio(25),
children=[
Line("SCPIs, REITs, ..."),
],
),
Folder(
"Stocks",
target=TargetRatio(40),
children=[
Folder(
"ETF World (Business as usual)",
target=TargetRatio(60),
children=[
Line(
"SP500",
key="Amundi PEA S&P 500 UCITS ETF",
target=TargetRatio(41),
),
Line(
"Russell 2000",
key="",
target=TargetRatio(9),
),
Line(
"Europe 600",
key="BNP Paribas Stoxx Europe 600 UCITS ETF Acc",
target=TargetRatio(25),
),
Line(
"Europe Small Cap",
key="",
target=TargetRatio(5),
),
Line(
"Emerging markets",
key="Amundi PEA MSCI Emerging Markets UCITS ETF",
target=TargetRatio(14),
),
Line(
"Japan",
key="",
target=TargetRatio(6),
),
],
),
Folder(
"ETF World (ESG)",
target=TargetRatio(40),
children=[
Line(
"USA ESG",
key="Amundi INDEX MSCI USA SRI UCITS ETF DR",
target=TargetRatio(30),
),
Line(
"Euro ESG",
key="Amundi EURO ISTOXX CLIMATE PARIS ALIGNED PAB UCITS ETF DR - EUR (C)",
target=TargetRatio(20),
),
Line(
"Emerging markets ESG",
key="Amundi INDEX MSCI EMERGING MARKETS SRI UCITS ETF DR",
target=TargetRatio(10),
),
],
),
],
),
Folder(
"Satellite & Fun",
target=TargetRatio(10),
children=[
Line("Dividends, forests, others, ..."),
],
),
Line("..."),
],
),
],
)
"""
Run the Assistant to get a complete overview of your portfolio!
See the available options in the README file or the online documentation.
"""
assistant = Assistant(
portfolio,
buckets=[bucket_garanti], # If you have defined buckets, you must pass them here as a list.
envelopes=[my_bank, my_av], # If you have defined envelopes, you must pass them here as a list.
ignore_orphans=True, # Ignore fetched lines that you didn't reference in your portfolio.
hide_amounts=False, # Display your portfolio with dots instead of the real values (easier to share).
hide_root=False, # Display your portfolio without the root (cosmetic preference).
show_data=True, # Show what has been fetched online (e.g. from your Finary account)
)
"""
Finalynx needs to know where to fetch your data from. You can either
use the built-in fetchers (see the README file or the online documentation)
or define your own fetchers.
"""
# from finalynx.fetch.source_realt import SourceRealT # move this line to the top of the file
# assistant.add_source(SourceRealT("0xMY_REALT_TOKEN"))
"""
Run the Assistant to get a complete overview of your portfolio! The run()
method will fetch your data, compute your portfolio, and display it.
Optionally, you can use the other methods availavle in the `Assistant` class
to have more control over the process as run() is just a shortcut.
"""
assistant.run()
"""
Optionally, you can launch a web dashboard to get an interactive view!
"""
# assistant.dashboard()