Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
b200138a9e | |||
53b163e739 | |||
1de8c08c39 | |||
358f0d7eaf | |||
3558f52b84 | |||
5d1f1b452a | |||
fed10c7110 | |||
5e0d207d84 | |||
59bd699727 | |||
c063ae498c | |||
abe6bb1cbb | |||
2ee4d65c8d |
@ -1,8 +0,0 @@
|
||||
.git/
|
||||
.vscode/
|
||||
node_modules/
|
||||
|
||||
.dockerignore
|
||||
.editorconfig
|
||||
.gitignore
|
||||
Dockerfile
|
7
.env
7
.env
@ -1,8 +1,6 @@
|
||||
COMPOSE_PROJECT_NAME=ghostfolio-development
|
||||
|
||||
# CACHE
|
||||
CACHE_TTL=1
|
||||
MAX_ITEM_IN_CACHE=9999
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
|
||||
@ -14,10 +12,5 @@ POSTGRES_DB=ghostfolio-db
|
||||
ACCESS_TOKEN_SALT=GHOSTFOLIO
|
||||
ALPHA_VANTAGE_API_KEY=
|
||||
DATABASE_URL=postgresql://user:password@localhost:5432/ghostfolio-db?sslmode=prefer
|
||||
GOOGLE_CLIENT_ID=test
|
||||
GOOGLE_SECRET=test
|
||||
IS_DEVELOPMENT_MODE=true
|
||||
JWT_SECRET_KEY=123456
|
||||
PORT=3333
|
||||
RAKUTEN_RAPID_API_KEY=
|
||||
ROOT_URL=http://localhost:4200
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,11 +1,8 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
/dist/apps/api/data/*.json
|
||||
/docker/**/*.*.*
|
||||
/docker/**/*.*.*.zip
|
||||
/tmp
|
||||
/out-tsc
|
||||
/tmp
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
@ -24,7 +21,6 @@
|
||||
!.vscode/extensions.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
|
19
CHANGELOG.md
19
CHANGELOG.md
@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## 0.86.1 - 18.04.2021
|
||||
|
||||
### Added
|
||||
|
||||
- Added the license to the about page
|
||||
- Added a validation for environment variables
|
||||
- Added support for feature flags to simplify the initial project setup
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed the about page for the new license
|
||||
- Optimized the data management for historical data
|
||||
- Optimized the exchange rate service
|
||||
- Improved the user table in the admin control panel
|
||||
|
||||
### Fixed
|
||||
|
||||
- Restored the scroll position when opening a new page
|
||||
|
||||
## 0.85.0 - 16.04.2021
|
||||
|
||||
### Changed
|
||||
|
617
LICENSE
Normal file
617
LICENSE
Normal file
@ -0,0 +1,617 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
65
README.md
65
README.md
@ -1,17 +1,62 @@
|
||||
<div align="center">
|
||||
<h1>Ghostfolio</h1>
|
||||
<p>
|
||||
<strong>Privacy-first Portfolio Tracker</strong>
|
||||
</p>
|
||||
<h1>Ghostfolio</h1>
|
||||
<p>
|
||||
<a href="https://www.ghostfol.io"><strong>Ghostfolio</strong></a>
|
||||
<strong>Open Source Portfolio Tracker</strong>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://ghostfol.io"><strong>Live Demo</strong></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://www.gnu.org/licenses/agpl-3.0" rel="nofollow">
|
||||
<img src="https://img.shields.io/badge/License-AGPL%20v3-blue.svg" alt="License: AGPL v3">
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
**Ghostfolio** is an open source portfolio tracker. The software empowers busy folks to have a sharp look of their financial assets and to make solid, data-driven investment decisions by evaluating automated static portfolio analysis rules.
|
||||
|
||||
## Why Ghostfolio?
|
||||
|
||||
Ghostfolio is for you if you are...
|
||||
|
||||
- 💼 trading stocks, ETFs or cryptocurrencies on multiple platforms
|
||||
|
||||
- 🏦 pursuing a buy & hold strategy
|
||||
|
||||
- 🎯 interested in getting insights of your portfolio composition
|
||||
|
||||
- 👻 valuing privacy and data ownership
|
||||
|
||||
- 🧘 into minimalism
|
||||
|
||||
- 🧺 caring about diversifying your financial resources
|
||||
|
||||
- 🆓 interested in financial independence
|
||||
|
||||
- 🙅 saying no to spreadsheets in 2021
|
||||
|
||||
- 😎 still reading this list
|
||||
|
||||
## Features
|
||||
|
||||
- ✅ Create, update and delete transactions
|
||||
- ✅ Portfolio performance (`Today`, `YTD`, `1Y`, `5Y`, `Max`)
|
||||
- ✅ Various charts
|
||||
- ✅ Static analysis to identify potential risks in your portfolio
|
||||
- ✅ Dark Mode
|
||||
|
||||
## Technology
|
||||
|
||||
Ghostfolio is a modern web application written in [TypeScript](https://www.typescriptlang.org) and organized as an [Nx](https://nx.dev) workspace.
|
||||
|
||||
### Frontend
|
||||
|
||||
The frontend is built with [Angular](https://angular.io).
|
||||
|
||||
### Backend
|
||||
|
||||
The backend is based on [NestJS](https://nestjs.com) using [PostgreSQL](https://www.postgresql.org) as a database and [Redis](https://redis.io) for caching.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
@ -25,10 +70,10 @@
|
||||
1. Run `yarn install`
|
||||
2. Run `cd docker`
|
||||
3. Run `docker compose build`
|
||||
4. Run `docker compose up -d`
|
||||
5. Run `yarn setup:database`
|
||||
4. Run `docker compose up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)
|
||||
5. Run `yarn setup:database` to initialize the database schema and populate your database with (example) data
|
||||
6. Start server and client (see _Development_)
|
||||
7. Login as _Admin_ with the `Security Token`: `ae76872ae8f3419c6d6f64bf51888ecbcc703927a342d815fafe486acdb938da07d0cf44fca211a0be74a423238f535362d390a41e81e633a9ce668a6e31cdf9`
|
||||
7. Login as _Admin_ with the following _Security Token_: `ae76872ae8f3419c6d6f64bf51888ecbcc703927a342d815fafe486acdb938da07d0cf44fca211a0be74a423238f535362d390a41e81e633a9ce668a6e31cdf9`
|
||||
|
||||
## Development
|
||||
|
||||
@ -44,3 +89,7 @@
|
||||
## Testing
|
||||
|
||||
Run `yarn test`
|
||||
|
||||
## License
|
||||
|
||||
Licensed under the [AGPLv3 License](https://www.gnu.org/licenses/agpl-3.0.html).
|
||||
|
@ -99,6 +99,11 @@
|
||||
"input": "",
|
||||
"output": "./"
|
||||
},
|
||||
{
|
||||
"glob": "LICENSE",
|
||||
"input": "",
|
||||
"output": "./"
|
||||
},
|
||||
{
|
||||
"glob": "sitemap.xml",
|
||||
"input": "apps/client/src/assets",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { DataGatheringService } from '../../services/data-gathering.service';
|
||||
import { DataProviderService } from '../../services/data-provider.service';
|
||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||
@ -16,6 +17,7 @@ import { AdminService } from './admin.service';
|
||||
providers: [
|
||||
AdminService,
|
||||
AlphaVantageService,
|
||||
ConfigurationService,
|
||||
DataGatheringService,
|
||||
DataProviderService,
|
||||
ExchangeRateDataService,
|
||||
|
@ -14,7 +14,6 @@ export class AdminService {
|
||||
|
||||
public async get(): Promise<AdminData> {
|
||||
return {
|
||||
analytics: await this.getUserAnalytics(),
|
||||
exchangeRates: [
|
||||
{
|
||||
label1: Currency.EUR,
|
||||
@ -64,7 +63,8 @@ export class AdminService {
|
||||
],
|
||||
lastDataGathering: await this.getLastDataGathering(),
|
||||
transactionCount: await this.prisma.order.count(),
|
||||
userCount: await this.prisma.user.count()
|
||||
userCount: await this.prisma.user.count(),
|
||||
users: await this.getUsersWithAnalytics()
|
||||
};
|
||||
}
|
||||
|
||||
@ -88,20 +88,27 @@ export class AdminService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private async getUserAnalytics() {
|
||||
return await this.prisma.analytics.findMany({
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
select: {
|
||||
activityCount: true,
|
||||
updatedAt: true,
|
||||
User: {
|
||||
select: {
|
||||
alias: true,
|
||||
createdAt: true,
|
||||
id: true
|
||||
}
|
||||
private async getUsersWithAnalytics() {
|
||||
return await this.prisma.user.findMany({
|
||||
orderBy: {
|
||||
Analytics: {
|
||||
updatedAt: 'desc'
|
||||
}
|
||||
},
|
||||
select: {
|
||||
_count: {
|
||||
select: { Order: true }
|
||||
},
|
||||
alias: true,
|
||||
Analytics: {
|
||||
select: {
|
||||
activityCount: true,
|
||||
updatedAt: true
|
||||
}
|
||||
},
|
||||
createdAt: true,
|
||||
id: true
|
||||
},
|
||||
take: 20
|
||||
});
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
export interface AdminData {
|
||||
analytics: {
|
||||
activityCount: number;
|
||||
updatedAt: Date;
|
||||
User: {
|
||||
alias: string;
|
||||
id: string;
|
||||
};
|
||||
}[];
|
||||
exchangeRates: { label1: string; label2: string; value: number }[];
|
||||
lastDataGathering: Date | 'IN_PROGRESS';
|
||||
transactionCount: number;
|
||||
userCount: number;
|
||||
users: {
|
||||
alias: string;
|
||||
createdAt: Date;
|
||||
Analytics: {
|
||||
activityCount: number;
|
||||
updatedAt: Date;
|
||||
};
|
||||
id: string;
|
||||
}[];
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import { ConfigModule } from '@nestjs/config';
|
||||
import { ScheduleModule } from '@nestjs/schedule';
|
||||
import { ServeStaticModule } from '@nestjs/serve-static';
|
||||
|
||||
import { ConfigurationService } from '../services/configuration.service';
|
||||
import { CronService } from '../services/cron.service';
|
||||
import { DataGatheringService } from '../services/data-gathering.service';
|
||||
import { DataProviderService } from '../services/data-provider.service';
|
||||
@ -59,6 +60,7 @@ import { UserModule } from './user/user.module';
|
||||
controllers: [AppController],
|
||||
providers: [
|
||||
AlphaVantageService,
|
||||
ConfigurationService,
|
||||
CronService,
|
||||
DataGatheringService,
|
||||
DataProviderService,
|
||||
|
@ -10,11 +10,15 @@ import {
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
public constructor(private readonly authService: AuthService) {}
|
||||
public constructor(
|
||||
private readonly authService: AuthService,
|
||||
private readonly configurationService: ConfigurationService
|
||||
) {}
|
||||
|
||||
@Get('anonymous/:accessToken')
|
||||
public async accessTokenLogin(@Param('accessToken') accessToken: string) {
|
||||
@ -44,9 +48,9 @@ export class AuthController {
|
||||
const jwt: string = req.user.jwt;
|
||||
|
||||
if (jwt) {
|
||||
res.redirect(`${process.env.ROOT_URL}/auth/${jwt}`);
|
||||
res.redirect(`${this.configurationService.get('ROOT_URL')}/auth/${jwt}`);
|
||||
} else {
|
||||
res.redirect(`${process.env.ROOT_URL}/auth`);
|
||||
res.redirect(`${this.configurationService.get('ROOT_URL')}/auth`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { PrismaService } from '../../services/prisma.service';
|
||||
import { UserService } from '../user/user.service';
|
||||
import { AuthController } from './auth.controller';
|
||||
@ -18,6 +19,7 @@ import { JwtStrategy } from './jwt.strategy';
|
||||
],
|
||||
providers: [
|
||||
AuthService,
|
||||
ConfigurationService,
|
||||
GoogleStrategy,
|
||||
JwtStrategy,
|
||||
PrismaService,
|
||||
|
@ -1,13 +1,15 @@
|
||||
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { UserService } from '../user/user.service';
|
||||
import { ValidateOAuthLoginParams } from './interfaces/interfaces';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
public constructor(
|
||||
private jwtService: JwtService,
|
||||
private readonly configurationService: ConfigurationService,
|
||||
private readonly jwtService: JwtService,
|
||||
private readonly userService: UserService
|
||||
) {}
|
||||
|
||||
@ -16,7 +18,7 @@ export class AuthService {
|
||||
try {
|
||||
const hashedAccessToken = this.userService.createAccessToken(
|
||||
accessToken,
|
||||
process.env.ACCESS_TOKEN_SALT
|
||||
this.configurationService.get('ACCESS_TOKEN_SALT')
|
||||
);
|
||||
|
||||
const [user] = await this.userService.users({
|
||||
|
@ -3,15 +3,21 @@ import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Provider } from '@prisma/client';
|
||||
import { Strategy } from 'passport-google-oauth20';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
@Injectable()
|
||||
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
||||
public constructor(private readonly authService: AuthService) {
|
||||
public constructor(
|
||||
private readonly authService: AuthService,
|
||||
readonly configurationService: ConfigurationService
|
||||
) {
|
||||
super({
|
||||
callbackURL: `${process.env.ROOT_URL}/api/auth/google/callback`,
|
||||
clientID: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_SECRET,
|
||||
callbackURL: `${configurationService.get(
|
||||
'ROOT_URL'
|
||||
)}/api/auth/google/callback`,
|
||||
clientID: configurationService.get('GOOGLE_CLIENT_ID'),
|
||||
clientSecret: configurationService.get('GOOGLE_SECRET'),
|
||||
passReqToCallback: true,
|
||||
scope: ['email', 'profile']
|
||||
});
|
||||
|
@ -2,18 +2,20 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { ExtractJwt, Strategy } from 'passport-jwt';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { PrismaService } from '../../services/prisma.service';
|
||||
import { UserService } from '../user/user.service';
|
||||
|
||||
@Injectable()
|
||||
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
public constructor(
|
||||
readonly configurationService: ConfigurationService,
|
||||
private prisma: PrismaService,
|
||||
private readonly userService: UserService
|
||||
) {
|
||||
super({
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
secretOrKey: process.env.JWT_SECRET_KEY
|
||||
secretOrKey: configurationService.get('JWT_SECRET_KEY')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { DataProviderService } from '../../services/data-provider.service';
|
||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||
@ -15,6 +16,7 @@ import { ExperimentalService } from './experimental.service';
|
||||
controllers: [ExperimentalController],
|
||||
providers: [
|
||||
AlphaVantageService,
|
||||
ConfigurationService,
|
||||
DataProviderService,
|
||||
ExchangeRateDataService,
|
||||
ExperimentalService,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { PrismaService } from '../../services/prisma.service';
|
||||
import { InfoController } from './info.controller';
|
||||
import { InfoService } from './info.service';
|
||||
@ -13,6 +14,6 @@ import { InfoService } from './info.service';
|
||||
})
|
||||
],
|
||||
controllers: [InfoController],
|
||||
providers: [InfoService, PrismaService]
|
||||
providers: [ConfigurationService, InfoService, PrismaService]
|
||||
})
|
||||
export class InfoModule {}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { permissions } from '@ghostfolio/helper';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { Currency } from '@prisma/client';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { PrismaService } from '../../services/prisma.service';
|
||||
import { InfoItem } from './interfaces/info-item.interface';
|
||||
|
||||
@ -10,6 +12,7 @@ export class InfoService {
|
||||
private static DEMO_USER_ID = '9b112b4d-3b7d-4bad-9bdd-3b0f7b4dac2f';
|
||||
|
||||
public constructor(
|
||||
private readonly configurationService: ConfigurationService,
|
||||
private jwtService: JwtService,
|
||||
private prisma: PrismaService
|
||||
) {}
|
||||
@ -20,7 +23,14 @@ export class InfoService {
|
||||
select: { id: true, name: true }
|
||||
});
|
||||
|
||||
const globalPermissions: string[] = [];
|
||||
|
||||
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
|
||||
globalPermissions.push(permissions.useSocialLogin);
|
||||
}
|
||||
|
||||
return {
|
||||
globalPermissions,
|
||||
platforms,
|
||||
currencies: Object.values(Currency),
|
||||
demoAuthToken: this.getDemoAuthToken(),
|
||||
|
@ -3,6 +3,7 @@ import { Currency } from '@prisma/client';
|
||||
export interface InfoItem {
|
||||
currencies: Currency[];
|
||||
demoAuthToken: string;
|
||||
globalPermissions: string[];
|
||||
lastDataGathering?: Date;
|
||||
message?: {
|
||||
text: string;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { DataGatheringService } from '../../services/data-gathering.service';
|
||||
import { DataProviderService } from '../../services/data-provider.service';
|
||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||
@ -18,6 +19,7 @@ import { OrderService } from './order.service';
|
||||
providers: [
|
||||
AlphaVantageService,
|
||||
CacheService,
|
||||
ConfigurationService,
|
||||
DataGatheringService,
|
||||
DataProviderService,
|
||||
ImpersonationService,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { DataGatheringService } from '../../services/data-gathering.service';
|
||||
import { DataProviderService } from '../../services/data-provider.service';
|
||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||
@ -22,6 +23,7 @@ import { PortfolioService } from './portfolio.service';
|
||||
providers: [
|
||||
AlphaVantageService,
|
||||
CacheService,
|
||||
ConfigurationService,
|
||||
DataGatheringService,
|
||||
DataProviderService,
|
||||
ExchangeRateDataService,
|
||||
|
@ -2,6 +2,7 @@ import { CacheModule, Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import * as redisStore from 'cache-manager-redis-store';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { RedisCacheService } from './redis-cache.service';
|
||||
|
||||
@Module({
|
||||
@ -9,16 +10,16 @@ import { RedisCacheService } from './redis-cache.service';
|
||||
CacheModule.registerAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: async (configService: ConfigService) => ({
|
||||
host: configService.get('REDIS_HOST'),
|
||||
max: configService.get('MAX_ITEM_IN_CACHE'),
|
||||
port: configService.get('REDIS_PORT'),
|
||||
useFactory: async (configurationService: ConfigurationService) => ({
|
||||
host: configurationService.get('REDIS_HOST'),
|
||||
max: configurationService.get('MAX_ITEM_IN_CACHE'),
|
||||
port: configurationService.get('REDIS_PORT'),
|
||||
store: redisStore,
|
||||
ttl: configService.get('CACHE_TTL')
|
||||
ttl: configurationService.get('CACHE_TTL')
|
||||
})
|
||||
})
|
||||
],
|
||||
providers: [RedisCacheService],
|
||||
providers: [ConfigurationService, RedisCacheService],
|
||||
exports: [RedisCacheService]
|
||||
})
|
||||
export class RedisCacheModule {}
|
||||
|
@ -1,9 +1,14 @@
|
||||
import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
|
||||
import { Cache } from 'cache-manager';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
|
||||
@Injectable()
|
||||
export class RedisCacheService {
|
||||
public constructor(@Inject(CACHE_MANAGER) private readonly cache: Cache) {}
|
||||
public constructor(
|
||||
@Inject(CACHE_MANAGER) private readonly cache: Cache,
|
||||
private readonly configurationService: ConfigurationService
|
||||
) {}
|
||||
|
||||
public async get(key: string): Promise<string> {
|
||||
return await this.cache.get(key);
|
||||
@ -18,6 +23,8 @@ export class RedisCacheService {
|
||||
}
|
||||
|
||||
public async set(key: string, value: string) {
|
||||
await this.cache.set(key, value, { ttl: Number(process.env.CACHE_TTL) });
|
||||
await this.cache.set(key, value, {
|
||||
ttl: this.configurationService.get('CACHE_TTL')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { DataProviderService } from '../../services/data-provider.service';
|
||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||
@ -13,6 +14,7 @@ import { SymbolService } from './symbol.service';
|
||||
controllers: [SymbolController],
|
||||
providers: [
|
||||
AlphaVantageService,
|
||||
ConfigurationService,
|
||||
DataProviderService,
|
||||
PrismaService,
|
||||
RakutenRapidApiService,
|
||||
|
@ -10,7 +10,7 @@ export interface User {
|
||||
settings: UserSettings;
|
||||
subscription: {
|
||||
expiresAt: Date;
|
||||
type: 'Diamond';
|
||||
type: 'Trial';
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { PrismaService } from '../../services/prisma.service';
|
||||
import { UserController } from './user.controller';
|
||||
import { UserService } from './user.service';
|
||||
@ -13,6 +14,6 @@ import { UserService } from './user.service';
|
||||
})
|
||||
],
|
||||
controllers: [UserController],
|
||||
providers: [PrismaService, UserService]
|
||||
providers: [ConfigurationService, PrismaService, UserService]
|
||||
})
|
||||
export class UserModule {}
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Currency, Prisma, Provider, User } from '@prisma/client';
|
||||
import { add } from 'date-fns';
|
||||
import { locale, resetHours } from 'libs/helper/src';
|
||||
import { locale, permissions, resetHours } from 'libs/helper/src';
|
||||
import { getPermissions } from 'libs/helper/src';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
import { PrismaService } from '../../services/prisma.service';
|
||||
import { UserWithSettings } from '../interfaces/user-with-settings';
|
||||
import { User as IUser } from './interfaces/user.interface';
|
||||
@ -14,7 +15,10 @@ const crypto = require('crypto');
|
||||
export class UserService {
|
||||
public static DEFAULT_CURRENCY = Currency.USD;
|
||||
|
||||
public constructor(private prisma: PrismaService) {}
|
||||
public constructor(
|
||||
private readonly configurationService: ConfigurationService,
|
||||
private prisma: PrismaService
|
||||
) {}
|
||||
|
||||
public async getUser({
|
||||
alias,
|
||||
@ -30,6 +34,16 @@ export class UserService {
|
||||
where: { GranteeUser: { id } }
|
||||
});
|
||||
|
||||
const currentPermissions = getPermissions(role);
|
||||
|
||||
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
||||
currentPermissions.push(permissions.accessFearAndGreedIndex);
|
||||
}
|
||||
|
||||
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
|
||||
currentPermissions.push(permissions.useSocialLogin);
|
||||
}
|
||||
|
||||
return {
|
||||
alias,
|
||||
id,
|
||||
@ -39,14 +53,14 @@ export class UserService {
|
||||
id: accessItem.id
|
||||
};
|
||||
}),
|
||||
permissions: getPermissions(role),
|
||||
permissions: currentPermissions,
|
||||
settings: {
|
||||
baseCurrency: Settings?.currency || UserService.DEFAULT_CURRENCY,
|
||||
locale
|
||||
},
|
||||
subscription: {
|
||||
expiresAt: resetHours(add(new Date(), { days: 7 })),
|
||||
type: 'Diamond'
|
||||
type: 'Trial'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { baseCurrency } from 'libs/helper/src';
|
||||
import { getYesterday } from 'libs/helper/src';
|
||||
import { getUtc } from 'libs/helper/src';
|
||||
|
||||
import { ConfigurationService } from '../services/configuration.service';
|
||||
import { DataProviderService } from '../services/data-provider.service';
|
||||
import { AlphaVantageService } from '../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||
import { RakutenRapidApiService } from '../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||
@ -15,6 +16,7 @@ import { Portfolio } from './portfolio';
|
||||
|
||||
describe('Portfolio', () => {
|
||||
let alphaVantageService: AlphaVantageService;
|
||||
let configurationService: ConfigurationService;
|
||||
let dataProviderService: DataProviderService;
|
||||
let exchangeRateDataService: ExchangeRateDataService;
|
||||
let portfolio: Portfolio;
|
||||
@ -28,6 +30,7 @@ describe('Portfolio', () => {
|
||||
imports: [],
|
||||
providers: [
|
||||
AlphaVantageService,
|
||||
ConfigurationService,
|
||||
DataProviderService,
|
||||
ExchangeRateDataService,
|
||||
PrismaService,
|
||||
@ -38,6 +41,7 @@ describe('Portfolio', () => {
|
||||
}).compile();
|
||||
|
||||
alphaVantageService = app.get<AlphaVantageService>(AlphaVantageService);
|
||||
configurationService = app.get<ConfigurationService>(ConfigurationService);
|
||||
dataProviderService = app.get<DataProviderService>(DataProviderService);
|
||||
exchangeRateDataService = app.get<ExchangeRateDataService>(
|
||||
ExchangeRateDataService
|
||||
|
32
apps/api/src/services/configuration.service.ts
Normal file
32
apps/api/src/services/configuration.service.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { bool, cleanEnv, num, port, str } from 'envalid';
|
||||
|
||||
import { Environment } from './interfaces/environment.interface';
|
||||
|
||||
@Injectable()
|
||||
export class ConfigurationService {
|
||||
private readonly environmentConfiguration: Environment;
|
||||
|
||||
public constructor() {
|
||||
this.environmentConfiguration = cleanEnv(process.env, {
|
||||
ACCESS_TOKEN_SALT: str(),
|
||||
ALPHA_VANTAGE_API_KEY: str({ default: '' }),
|
||||
CACHE_TTL: num({ default: 1 }),
|
||||
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),
|
||||
ENABLE_FEATURE_SOCIAL_LOGIN: bool({ default: false }),
|
||||
GOOGLE_CLIENT_ID: str({ default: 'dummyClientId' }),
|
||||
GOOGLE_SECRET: str({ default: 'dummySecret' }),
|
||||
JWT_SECRET_KEY: str({}),
|
||||
MAX_ITEM_IN_CACHE: num({ default: 9999 }),
|
||||
PORT: port({ default: 3333 }),
|
||||
RAKUTEN_RAPID_API_KEY: str({ default: '' }),
|
||||
REDIS_HOST: str({ default: 'localhost' }),
|
||||
REDIS_PORT: port({ default: 6379 }),
|
||||
ROOT_URL: str({ default: 'http://localhost:4200' })
|
||||
});
|
||||
}
|
||||
|
||||
public get<K extends keyof Environment>(key: K): Environment[K] {
|
||||
return this.environmentConfiguration[key];
|
||||
}
|
||||
}
|
@ -11,13 +11,15 @@ import {
|
||||
import { benchmarks, currencyPairs } from 'libs/helper/src';
|
||||
import { getUtc, resetHours } from 'libs/helper/src';
|
||||
|
||||
import { ConfigurationService } from './configuration.service';
|
||||
import { DataProviderService } from './data-provider.service';
|
||||
import { PrismaService } from './prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class DataGatheringService {
|
||||
public constructor(
|
||||
private dataProviderService: DataProviderService,
|
||||
private readonly configurationService: ConfigurationService,
|
||||
private readonly dataProviderService: DataProviderService,
|
||||
private prisma: PrismaService
|
||||
) {}
|
||||
|
||||
@ -64,9 +66,11 @@ export class DataGatheringService {
|
||||
}
|
||||
|
||||
public async gatherMax() {
|
||||
const isDataGatheringNeeded = await this.isDataGatheringNeeded();
|
||||
const isDataGatheringLocked = await this.prisma.property.findUnique({
|
||||
where: { key: 'LOCKED_DATA_GATHERING' }
|
||||
});
|
||||
|
||||
if (isDataGatheringNeeded) {
|
||||
if (!isDataGatheringLocked) {
|
||||
console.log('Max data gathering has been started.');
|
||||
console.time('data-gathering');
|
||||
|
||||
@ -174,6 +178,24 @@ export class DataGatheringService {
|
||||
}
|
||||
}
|
||||
|
||||
private getBenchmarksToGather(startDate: Date) {
|
||||
const benchmarksToGather = benchmarks.map((symbol) => {
|
||||
return {
|
||||
symbol,
|
||||
date: startDate
|
||||
};
|
||||
});
|
||||
|
||||
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
||||
benchmarksToGather.push({
|
||||
date: startDate,
|
||||
symbol: 'GF.FEAR_AND_GREED_INDEX'
|
||||
});
|
||||
}
|
||||
|
||||
return benchmarksToGather;
|
||||
}
|
||||
|
||||
private async getSymbols7D(): Promise<{ date: Date; symbol: string }[]> {
|
||||
const startDate = subDays(resetHours(new Date()), 7);
|
||||
|
||||
@ -190,13 +212,6 @@ export class DataGatheringService {
|
||||
};
|
||||
});
|
||||
|
||||
const benchmarksToGather = benchmarks.map((symbol) => {
|
||||
return {
|
||||
symbol,
|
||||
date: startDate
|
||||
};
|
||||
});
|
||||
|
||||
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
||||
return {
|
||||
symbol,
|
||||
@ -205,7 +220,7 @@ export class DataGatheringService {
|
||||
});
|
||||
|
||||
return [
|
||||
...benchmarksToGather,
|
||||
...this.getBenchmarksToGather(startDate),
|
||||
...currencyPairsToGather,
|
||||
...distinctOrdersWithDate
|
||||
];
|
||||
@ -220,13 +235,6 @@ export class DataGatheringService {
|
||||
select: { date: true, symbol: true }
|
||||
});
|
||||
|
||||
const benchmarksToGather = benchmarks.map((symbol) => {
|
||||
return {
|
||||
symbol,
|
||||
date: startDate
|
||||
};
|
||||
});
|
||||
|
||||
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
||||
return {
|
||||
symbol,
|
||||
@ -234,7 +242,11 @@ export class DataGatheringService {
|
||||
};
|
||||
});
|
||||
|
||||
return [...benchmarksToGather, ...currencyPairsToGather, ...distinctOrders];
|
||||
return [
|
||||
...this.getBenchmarksToGather(startDate),
|
||||
...currencyPairsToGather,
|
||||
...distinctOrders
|
||||
];
|
||||
}
|
||||
|
||||
private async isDataGatheringNeeded() {
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { isCrypto, isRakutenRapidApi } from '@ghostfolio/helper';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { MarketData } from '@prisma/client';
|
||||
import { format } from 'date-fns';
|
||||
import { isCrypto, isRakutenRapidApi } from 'libs/helper/src';
|
||||
|
||||
import { ConfigurationService } from './configuration.service';
|
||||
import { AlphaVantageService } from './data-provider/alpha-vantage/alpha-vantage.service';
|
||||
import { RakutenRapidApiService } from './data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||
import { YahooFinanceService } from './data-provider/yahoo-finance/yahoo-finance.service';
|
||||
@ -17,10 +18,11 @@ import { PrismaService } from './prisma.service';
|
||||
@Injectable()
|
||||
export class DataProviderService implements DataProviderInterface {
|
||||
public constructor(
|
||||
private alphaVantageService: AlphaVantageService,
|
||||
private readonly alphaVantageService: AlphaVantageService,
|
||||
private readonly configurationService: ConfigurationService,
|
||||
private prisma: PrismaService,
|
||||
private rakutenRapidApiService: RakutenRapidApiService,
|
||||
private yahooFinanceService: YahooFinanceService
|
||||
private readonly rakutenRapidApiService: RakutenRapidApiService,
|
||||
private readonly yahooFinanceService: YahooFinanceService
|
||||
) {
|
||||
this.rakutenRapidApiService.setPrisma(this.prisma);
|
||||
}
|
||||
@ -107,7 +109,10 @@ export class DataProviderService implements DataProviderInterface {
|
||||
if (aSymbols.length === 1) {
|
||||
const symbol = aSymbols[0];
|
||||
|
||||
if (isCrypto(symbol)) {
|
||||
if (
|
||||
isCrypto(symbol) &&
|
||||
this.configurationService.get('ALPHA_VANTAGE_API_KEY')
|
||||
) {
|
||||
// Merge data from Yahoo with data from Alpha Vantage
|
||||
const dataOfAlphaVantage = await this.alphaVantageService.getHistorical(
|
||||
[symbol],
|
||||
@ -122,7 +127,10 @@ export class DataProviderService implements DataProviderInterface {
|
||||
...dataOfAlphaVantage[symbol]
|
||||
}
|
||||
};
|
||||
} else if (isRakutenRapidApi(symbol)) {
|
||||
} else if (
|
||||
isRakutenRapidApi(symbol) &&
|
||||
this.configurationService.get('RAKUTEN_RAPID_API_KEY')
|
||||
) {
|
||||
const dataOfRakutenRapidApi = await this.rakutenRapidApiService.getHistorical(
|
||||
[symbol],
|
||||
undefined,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { isAfter, isBefore, parse } from 'date-fns';
|
||||
|
||||
import { ConfigurationService } from '../../configuration.service';
|
||||
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
||||
import { Granularity } from '../../interfaces/granularity.type';
|
||||
import {
|
||||
@ -9,13 +10,17 @@ import {
|
||||
} from '../../interfaces/interfaces';
|
||||
import { IAlphaVantageHistoricalResponse } from './interfaces/interfaces';
|
||||
|
||||
const alphaVantage = require('alphavantage')({
|
||||
key: process.env.ALPHA_VANTAGE_API_KEY
|
||||
});
|
||||
|
||||
@Injectable()
|
||||
export class AlphaVantageService implements DataProviderInterface {
|
||||
public constructor() {}
|
||||
public alphaVantage;
|
||||
|
||||
public constructor(
|
||||
private readonly configurationService: ConfigurationService
|
||||
) {
|
||||
this.alphaVantage = require('alphavantage')({
|
||||
key: this.configurationService.get('ALPHA_VANTAGE_API_KEY')
|
||||
});
|
||||
}
|
||||
|
||||
public async get(
|
||||
aSymbols: string[]
|
||||
@ -40,7 +45,7 @@ export class AlphaVantageService implements DataProviderInterface {
|
||||
try {
|
||||
const historicalData: {
|
||||
[symbol: string]: IAlphaVantageHistoricalResponse[];
|
||||
} = await alphaVantage.crypto.daily(
|
||||
} = await this.alphaVantage.crypto.daily(
|
||||
symbol.substring(0, symbol.length - 3).toLowerCase(),
|
||||
'usd'
|
||||
);
|
||||
@ -73,6 +78,6 @@ export class AlphaVantageService implements DataProviderInterface {
|
||||
}
|
||||
|
||||
public search(aSymbol: string) {
|
||||
return alphaVantage.data.search(aSymbol);
|
||||
return this.alphaVantage.data.search(aSymbol);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import * as bent from 'bent';
|
||||
import { format, subMonths, subWeeks, subYears } from 'date-fns';
|
||||
import { getToday, getYesterday } from 'libs/helper/src';
|
||||
|
||||
import { ConfigurationService } from '../../configuration.service';
|
||||
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
||||
import { Granularity } from '../../interfaces/granularity.type';
|
||||
import {
|
||||
@ -17,7 +18,9 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
||||
|
||||
private prisma: PrismaService;
|
||||
|
||||
public constructor() {}
|
||||
public constructor(
|
||||
private readonly configurationService: ConfigurationService
|
||||
) {}
|
||||
|
||||
public async get(
|
||||
aSymbols: string[]
|
||||
@ -127,7 +130,9 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
||||
{
|
||||
useQueryString: true,
|
||||
'x-rapidapi-host': 'fear-and-greed-index.p.rapidapi.com',
|
||||
'x-rapidapi-key': process.env.RAKUTEN_RAPID_API_KEY
|
||||
'x-rapidapi-key': this.configurationService.get(
|
||||
'RAKUTEN_RAPID_API_KEY'
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { getYesterday } from '@ghostfolio/helper';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Currency } from '@prisma/client';
|
||||
import { format } from 'date-fns';
|
||||
import { getYesterday } from 'libs/helper/src';
|
||||
|
||||
import { DataProviderService } from './data-provider.service';
|
||||
|
||||
@ -15,6 +15,8 @@ export class ExchangeRateDataService {
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
this.pairs = [];
|
||||
|
||||
this.addPairs(Currency.CHF, Currency.EUR);
|
||||
this.addPairs(Currency.CHF, Currency.GBP);
|
||||
this.addPairs(Currency.CHF, Currency.USD);
|
||||
@ -25,11 +27,6 @@ export class ExchangeRateDataService {
|
||||
await this.loadCurrencies();
|
||||
}
|
||||
|
||||
private addPairs(aCurrency1: Currency, aCurrency2: Currency) {
|
||||
this.pairs.push(`${aCurrency1}${aCurrency2}`);
|
||||
this.pairs.push(`${aCurrency2}${aCurrency1}`);
|
||||
}
|
||||
|
||||
public async loadCurrencies() {
|
||||
const result = await this.dataProviderService.getHistorical(
|
||||
this.pairs,
|
||||
@ -38,19 +35,34 @@ export class ExchangeRateDataService {
|
||||
getYesterday()
|
||||
);
|
||||
|
||||
const resultExtended = result;
|
||||
|
||||
Object.keys(result).forEach((pair) => {
|
||||
const [currency1, currency2] = pair.match(/.{1,3}/g);
|
||||
const [date] = Object.keys(result[pair]);
|
||||
|
||||
// Calculate the opposite direction
|
||||
resultExtended[`${currency2}${currency1}`] = {
|
||||
[date]: {
|
||||
marketPrice: 1 / result[pair][date].marketPrice
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
this.pairs.forEach((pair) => {
|
||||
this.currencies[pair] =
|
||||
result[pair]?.[format(getYesterday(), 'yyyy-MM-dd')]?.marketPrice || 1;
|
||||
const [currency1, currency2] = pair.match(/.{1,3}/g);
|
||||
const date = format(getYesterday(), 'yyyy-MM-dd');
|
||||
|
||||
if (this.currencies[pair] === 1) {
|
||||
// Calculate the other direction
|
||||
const [currency1, currency2] = pair.match(/.{1,3}/g);
|
||||
this.currencies[pair] = resultExtended[pair]?.[date]?.marketPrice;
|
||||
|
||||
if (!this.currencies[pair]) {
|
||||
// Not found, calculate indirectly via USD
|
||||
this.currencies[pair] =
|
||||
1 /
|
||||
result[`${currency2}${currency1}`]?.[
|
||||
format(getYesterday(), 'yyyy-MM-dd')
|
||||
]?.marketPrice;
|
||||
resultExtended[`${currency1}${Currency.USD}`][date].marketPrice *
|
||||
resultExtended[`${Currency.USD}${currency2}`][date].marketPrice;
|
||||
|
||||
// Calculate the opposite direction
|
||||
this.currencies[`${currency2}${currency1}`] = 1 / this.currencies[pair];
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -60,6 +72,11 @@ export class ExchangeRateDataService {
|
||||
aFromCurrency: Currency,
|
||||
aToCurrency: Currency
|
||||
) {
|
||||
if (isNaN(this.currencies[`${Currency.USD}${Currency.CHF}`])) {
|
||||
// Reinitialize if data is not loaded correctly
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
let factor = 1;
|
||||
|
||||
if (aFromCurrency !== aToCurrency) {
|
||||
@ -68,4 +85,9 @@ export class ExchangeRateDataService {
|
||||
|
||||
return factor * aValue;
|
||||
}
|
||||
|
||||
private addPairs(aCurrency1: Currency, aCurrency2: Currency) {
|
||||
this.pairs.push(`${aCurrency1}${aCurrency2}`);
|
||||
this.pairs.push(`${aCurrency2}${aCurrency1}`);
|
||||
}
|
||||
}
|
||||
|
18
apps/api/src/services/interfaces/environment.interface.ts
Normal file
18
apps/api/src/services/interfaces/environment.interface.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { CleanedEnvAccessors } from 'envalid';
|
||||
|
||||
export interface Environment extends CleanedEnvAccessors {
|
||||
ACCESS_TOKEN_SALT: string;
|
||||
ALPHA_VANTAGE_API_KEY: string;
|
||||
CACHE_TTL: number;
|
||||
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;
|
||||
ENABLE_FEATURE_SOCIAL_LOGIN: boolean;
|
||||
GOOGLE_CLIENT_ID: string;
|
||||
GOOGLE_SECRET: string;
|
||||
JWT_SECRET_KEY: string;
|
||||
MAX_ITEM_IN_CACHE: number;
|
||||
PORT: number;
|
||||
RAKUTEN_RAPID_API_KEY: string;
|
||||
REDIS_HOST: string;
|
||||
REDIS_PORT: number;
|
||||
ROOT_URL: string;
|
||||
}
|
@ -81,7 +81,8 @@ const routes: Routes = [
|
||||
{
|
||||
preloadingStrategy: ModulePreloadService,
|
||||
// enableTracing: true // <-- debugging purposes only
|
||||
relativeLinkResolution: 'legacy'
|
||||
relativeLinkResolution: 'legacy',
|
||||
scrollPositionRestoration: 'enabled'
|
||||
}
|
||||
)
|
||||
],
|
||||
|
@ -2,6 +2,7 @@
|
||||
<gf-header
|
||||
class="position-fixed px-2 w-100"
|
||||
[currentRoute]="currentRoute"
|
||||
[info]="info"
|
||||
[user]="user"
|
||||
></gf-header>
|
||||
</header>
|
||||
@ -26,7 +27,10 @@
|
||||
|
||||
<footer class="footer d-flex justify-content-center position-absolute w-100">
|
||||
<div class="container text-center">
|
||||
<div>Ghostfolio {{ version }}</div>
|
||||
<div>
|
||||
© {{ currentYear }} <a href="https://ghostfol.io">Ghostfolio</a>
|
||||
{{ version }}
|
||||
</div>
|
||||
<div class="py-2 text-muted">
|
||||
<small i18n
|
||||
>The risk of loss in trading can be substantial. It is not advisable to
|
||||
|
@ -7,8 +7,8 @@ import {
|
||||
} from '@angular/core';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { MaterialCssVarsService } from 'angular-material-css-vars';
|
||||
import { InfoItem } from 'apps/api/src/app/info/interfaces/info-item.interface';
|
||||
import { User } from 'apps/api/src/app/user/interfaces/user.interface';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { primaryColorHex, secondaryColorHex } from 'libs/helper/src';
|
||||
import { hasPermission, permissions } from 'libs/helper/src';
|
||||
import { Subject } from 'rxjs';
|
||||
@ -27,8 +27,9 @@ import { TokenStorageService } from './services/token-storage.service';
|
||||
export class AppComponent implements OnDestroy, OnInit {
|
||||
public canCreateAccount: boolean;
|
||||
public currentRoute: string;
|
||||
public currentYear = new Date().getFullYear();
|
||||
public info: InfoItem;
|
||||
public isLoggedIn = false;
|
||||
public lastDataGathering: string;
|
||||
public user: User;
|
||||
public version = environment.version;
|
||||
|
||||
@ -46,10 +47,8 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.dataService.fetchInfo().subscribe(({ lastDataGathering }) => {
|
||||
this.lastDataGathering = lastDataGathering
|
||||
? formatDistanceToNow(new Date(lastDataGathering), { addSuffix: true })
|
||||
: '';
|
||||
this.dataService.fetchInfo().subscribe((info) => {
|
||||
this.info = info;
|
||||
});
|
||||
|
||||
this.router.events
|
||||
|
@ -147,9 +147,8 @@
|
||||
i18n
|
||||
mat-menu-item
|
||||
[ngClass]="{ 'font-weight-bold': currentRoute === 'account' }"
|
||||
><span>Account</span
|
||||
><ion-icon class="ml-1 text-muted" name="diamond-outline"></ion-icon
|
||||
></a>
|
||||
>Account</a
|
||||
>
|
||||
<a
|
||||
*ngIf="canAccessAdminAccessControl"
|
||||
class="d-block d-sm-none"
|
||||
@ -198,6 +197,12 @@
|
||||
[color]="currentRoute === 'about' ? 'primary' : null"
|
||||
>About</a
|
||||
>
|
||||
<a
|
||||
class="d-none d-sm-block mx-1"
|
||||
href="https://github.com/ghostfolio/ghostfolio"
|
||||
mat-flat-button
|
||||
>GitHub</a
|
||||
>
|
||||
<button i18n mat-flat-button (click)="openLoginDialog()">Sign in</button>
|
||||
</ng-container>
|
||||
</mat-toolbar>
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { Router } from '@angular/router';
|
||||
import { InfoItem } from 'apps/api/src/app/info/interfaces/info-item.interface';
|
||||
import { User } from 'apps/api/src/app/user/interfaces/user.interface';
|
||||
import { hasPermission, permissions } from 'libs/helper/src';
|
||||
import { EMPTY, Subject } from 'rxjs';
|
||||
@ -24,9 +25,11 @@ import { TokenStorageService } from '../../services/token-storage.service';
|
||||
})
|
||||
export class HeaderComponent implements OnChanges {
|
||||
@Input() currentRoute: string;
|
||||
@Input() info: InfoItem;
|
||||
@Input() user: User;
|
||||
|
||||
public canAccessAdminAccessControl: boolean;
|
||||
public hasPermissionToUseSocialLogin: boolean;
|
||||
public impersonationId: string;
|
||||
|
||||
private unsubscribeSubject = new Subject<void>();
|
||||
@ -52,6 +55,11 @@ export class HeaderComponent implements OnChanges {
|
||||
permissions.accessAdminControl
|
||||
);
|
||||
}
|
||||
|
||||
this.hasPermissionToUseSocialLogin = hasPermission(
|
||||
this.info?.globalPermissions,
|
||||
permissions.useSocialLogin
|
||||
);
|
||||
}
|
||||
|
||||
public impersonateAccount(aId: string) {
|
||||
@ -72,7 +80,10 @@ export class HeaderComponent implements OnChanges {
|
||||
public openLoginDialog(): void {
|
||||
const dialogRef = this.dialog.open(LoginWithAccessTokenDialog, {
|
||||
autoFocus: false,
|
||||
data: { accessToken: '' },
|
||||
data: {
|
||||
accessToken: '',
|
||||
hasPermissionToUseSocialLogin: this.hasPermissionToUseSocialLogin
|
||||
},
|
||||
width: '30rem'
|
||||
});
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
></gf-line-chart>
|
||||
</div>
|
||||
|
||||
<div class="container p-0">
|
||||
<div *ngIf="data.fearAndGreedIndex" class="container p-0">
|
||||
<gf-fear-and-greed-index
|
||||
class="d-flex flex-column justify-content-center"
|
||||
[fearAndGreedIndex]="data.fearAndGreedIndex"
|
||||
|
@ -5,33 +5,54 @@
|
||||
<mat-card class="mb-3">
|
||||
<mat-card-content>
|
||||
<p>
|
||||
Ghostfolio is a side project by
|
||||
<strong>Ghostfolio</strong> ({{ version }}) is open source software
|
||||
which empowers busy folks to have a sharp look of their financial
|
||||
assets and to make solid, data-driven investment decisions by
|
||||
evaluating automated static portfolio analysis rules. The project
|
||||
has been initiated by
|
||||
<a href="https://dotsilver.ch">Thomas Kaul</a>.
|
||||
</p>
|
||||
<p>
|
||||
This is <strong>Ghostfolio {{ version }}</strong>
|
||||
<ng-container *ngIf="lastPublish">
|
||||
and was last published on {{ lastPublish }}</ng-container
|
||||
>.
|
||||
This instance has been last published on {{ lastPublish
|
||||
}}</ng-container
|
||||
>
|
||||
</p>
|
||||
<p>
|
||||
If you encounter a bug or would like to suggest an improvement or a
|
||||
new feature, please send an e-mail to
|
||||
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a> or tweet to
|
||||
<a href="https://twitter.com/ghostfolio_">@ghostfolio_</a>.
|
||||
new feature, please open an issue at
|
||||
<a href="https://github.com/ghostfolio/ghostfolio">GitHub</a>, tweet
|
||||
to <a href="https://twitter.com/ghostfolio_">@ghostfolio_</a> or
|
||||
send an e-mail to
|
||||
<a href="mailto:hi@ghostfol.io">hi@ghostfol.io</a>.
|
||||
</p>
|
||||
<p class="text-center">
|
||||
<a
|
||||
class="mx-2"
|
||||
href="https://github.com/ghostfolio/ghostfolio"
|
||||
mat-icon-button
|
||||
title="Find Ghostfolio on GitHub"
|
||||
>
|
||||
<ion-icon name="logo-github" size="large"></ion-icon>
|
||||
</a>
|
||||
<a
|
||||
class="mx-2"
|
||||
href="https://twitter.com/ghostfolio_"
|
||||
mat-icon-button
|
||||
title="Follow Ghostfolio on Twitter"
|
||||
>
|
||||
<ion-icon name="logo-twitter" size="large"></ion-icon>
|
||||
</a>
|
||||
<a
|
||||
class="mx-2"
|
||||
href="mailto:hi@ghostfol.io"
|
||||
mat-icon-button
|
||||
title="Send an e-mail"
|
||||
>
|
||||
<ion-icon name="mail" size="large"></ion-icon>
|
||||
</a>
|
||||
</p>
|
||||
<div class="d-flex justify-content-center">
|
||||
<div
|
||||
class="independent-and-bootstrapped-logo"
|
||||
class="independent-and-bootstrapped-logo mb-2"
|
||||
title="Ghostfolio is an independent & bootstrapped business"
|
||||
></div>
|
||||
</div>
|
||||
@ -46,11 +67,8 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<mat-card class="mb-3">
|
||||
<h4 i18n>Basic</h4>
|
||||
<p>
|
||||
The starting point for tracking your goals and adopting your
|
||||
personal investment strategy.
|
||||
</p>
|
||||
<h4 i18n>Open Source</h4>
|
||||
<p>Host your <strong>Ghostfolio</strong> instance by yourself.</p>
|
||||
<ul class="list-unstyled mb-3">
|
||||
<li class="align-items-center d-flex mb-1">
|
||||
<ion-icon
|
||||
@ -73,7 +91,13 @@
|
||||
></ion-icon>
|
||||
<span>Unlimited Transactions</span>
|
||||
</li>
|
||||
<li class="d-none d-sm-block mb-1">​</li>
|
||||
<li class="align-items-center d-flex mb-1">
|
||||
<ion-icon
|
||||
class="mr-1 text-muted"
|
||||
name="checkmark-circle-outline"
|
||||
></ion-icon>
|
||||
<span>Advanced Insights</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="h5 text-right">
|
||||
<span>Free</span>
|
||||
@ -83,7 +107,7 @@
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<mat-card
|
||||
class="mb-3"
|
||||
[ngClass]="{ 'active': user?.subscription?.type === 'Diamond' }"
|
||||
[ngClass]="{ 'active': user?.subscription?.type === 'Trial' }"
|
||||
>
|
||||
<h4 class="align-items-center d-flex" i18n>
|
||||
Diamond
|
||||
@ -92,10 +116,7 @@
|
||||
name="diamond-outline"
|
||||
></ion-icon>
|
||||
</h4>
|
||||
<p>
|
||||
Get a bird's-eye view of your financial assets for making
|
||||
sustainable investment decisions.
|
||||
</p>
|
||||
<p>Get a managed <strong>Ghostfolio</strong> cloud offering.</p>
|
||||
<ul class="list-unstyled mb-3">
|
||||
<li class="align-items-center d-flex mb-1">
|
||||
<ion-icon
|
||||
@ -129,8 +150,8 @@
|
||||
<p class="h5 text-right">
|
||||
<span class="font-weight-normal"
|
||||
>{{ user?.settings.baseCurrency || baseCurrency }}
|
||||
<strong>3.99</strong>
|
||||
<del class="ml-1 text-muted">4.99</del> / Month</span
|
||||
<strong>2.99</strong>
|
||||
<del class="ml-1 text-muted">3.99</del> / Month</span
|
||||
>
|
||||
</p>
|
||||
</mat-card>
|
||||
@ -139,7 +160,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="mb-5 row">
|
||||
<div class="col">
|
||||
<h3 class="mb-3 text-center" i18n>Changelog</h3>
|
||||
<mat-card class="changelog mb-3">
|
||||
@ -149,4 +170,15 @@
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3 class="mb-3 text-center" i18n>License</h3>
|
||||
<mat-card class="mb-3">
|
||||
<mat-card-content>
|
||||
<markdown [src]="'LICENSE'"></markdown>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -19,11 +19,7 @@
|
||||
<div class="w-50" i18n>Membership</div>
|
||||
<div class="w-50">
|
||||
<div class="align-items-center d-flex mb-1">
|
||||
<span>{{ user?.subscription?.type }}</span>
|
||||
<ion-icon
|
||||
class="ml-1 text-muted"
|
||||
name="diamond-outline"
|
||||
></ion-icon>
|
||||
{{ user?.subscription?.type }}
|
||||
</div>
|
||||
<div>
|
||||
Valid until {{ user.subscription.expiresAt | date:
|
||||
|
@ -15,13 +15,13 @@ import { DataService } from '../../services/data.service';
|
||||
styleUrls: ['./admin-page.scss']
|
||||
})
|
||||
export class AdminPageComponent implements OnInit {
|
||||
public analytics: AdminData['analytics'];
|
||||
public dataGatheringInProgress: boolean;
|
||||
public defaultDateFormat = DEFAULT_DATE_FORMAT;
|
||||
public exchangeRates: { label1: string; label2: string; value: number }[];
|
||||
public lastDataGathering: string;
|
||||
public transactionCount: number;
|
||||
public userCount: number;
|
||||
public users: AdminData['users'];
|
||||
|
||||
private unsubscribeSubject = new Subject<void>();
|
||||
|
||||
@ -44,14 +44,14 @@ export class AdminPageComponent implements OnInit {
|
||||
.pipe(takeUntil(this.unsubscribeSubject))
|
||||
.subscribe(
|
||||
({
|
||||
analytics,
|
||||
exchangeRates,
|
||||
lastDataGathering,
|
||||
transactionCount,
|
||||
userCount
|
||||
userCount,
|
||||
users
|
||||
}) => {
|
||||
this.analytics = analytics;
|
||||
this.exchangeRates = exchangeRates;
|
||||
this.users = users;
|
||||
|
||||
if (isValid(parseISO(lastDataGathering?.toString()))) {
|
||||
this.lastDataGathering = formatDistanceToNow(
|
||||
@ -83,11 +83,17 @@ export class AdminPageComponent implements OnInit {
|
||||
}
|
||||
|
||||
public onGatherMax() {
|
||||
this.adminService.gatherMax().subscribe(() => {
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 300);
|
||||
});
|
||||
const confirmation = confirm(
|
||||
'This action may take some time. Do you want to proceed?'
|
||||
);
|
||||
|
||||
if (confirmation === true) {
|
||||
this.adminService.gatherMax().subscribe(() => {
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public formatDistanceToNow(aDateString: string) {
|
||||
|
@ -34,11 +34,16 @@
|
||||
(click)="onFlushCache()"
|
||||
>
|
||||
<ion-icon class="mr-1" name="close-circle-outline"></ion-icon>
|
||||
<span i18n>Reset</span>
|
||||
<span i18n>Reset Data Gathering</span>
|
||||
</button>
|
||||
<button color="warn" mat-flat-button (click)="onGatherMax()">
|
||||
<button
|
||||
color="warn"
|
||||
mat-flat-button
|
||||
[disabled]="dataGatheringInProgress"
|
||||
(click)="onGatherMax()"
|
||||
>
|
||||
<ion-icon class="mr-1" name="warning-outline"></ion-icon>
|
||||
<span i18n>Gather Max</span>
|
||||
<span i18n>Gather All Data</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -62,33 +67,45 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3 class="mb-3 text-center" i18n>Analytics</h3>
|
||||
<mat-card>
|
||||
<h3 class="mb-3 text-center" i18n>Users</h3>
|
||||
<mat-card class="px-0">
|
||||
<mat-card-content>
|
||||
<table class="analytics w-100">
|
||||
<table class="users w-100">
|
||||
<thead>
|
||||
<tr class="mat-header-row">
|
||||
<th class="mat-header-cell pl-2 py-2" i18n>User</th>
|
||||
<th class="mat-header-cell pr-2 py-2" i18n>
|
||||
<th class="mat-header-cell pl-2 py-2 text-truncate" i18n>
|
||||
User
|
||||
</th>
|
||||
<th class="mat-header-cell pr-2 py-2 text-truncate" i18n>
|
||||
Registration Date
|
||||
</th>
|
||||
<th class="mat-header-cell pr-2 py-2" i18n>Engagement</th>
|
||||
<th class="mat-header-cell pr-2 py-2" i18n>Last Activitiy</th>
|
||||
<th class="mat-header-cell pr-2 py-2 text-truncate" i18n>
|
||||
Transactions
|
||||
</th>
|
||||
<th class="mat-header-cell pr-2 py-2 text-truncate" i18n>
|
||||
Engagement
|
||||
</th>
|
||||
<th class="mat-header-cell pr-2 py-2 text-truncate" i18n>
|
||||
Last Activitiy
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let analyticsItem of analytics" class="mat-row">
|
||||
<td class="mat-cell text-truncate pl-2 py-2">
|
||||
{{ analyticsItem.User.alias || analyticsItem.User.id }}
|
||||
<tr *ngFor="let userItem of users" class="mat-row">
|
||||
<td class="mat-cell pl-2 py-2 text-truncate">
|
||||
{{ userItem.alias || userItem.id }}
|
||||
</td>
|
||||
<td class="mat-cell pr-2 py-2">
|
||||
{{ analyticsItem.User.createdAt | date: defaultDateFormat }}
|
||||
<td class="mat-cell pr-2 py-2 text-truncate">
|
||||
{{ userItem.createdAt | date: defaultDateFormat }}
|
||||
</td>
|
||||
<td class="mat-cell pr-2 py-2">
|
||||
{{ analyticsItem.activityCount }}
|
||||
<td class="mat-cell pr-2 py-2 text-truncate">
|
||||
{{ userItem._count.Order }}
|
||||
</td>
|
||||
<td class="mat-cell pr-2 py-2">
|
||||
{{ formatDistanceToNow(analyticsItem.updatedAt) }}
|
||||
<td class="mat-cell pr-2 py-2 text-truncate">
|
||||
{{ userItem.Analytics.activityCount }}
|
||||
</td>
|
||||
<td class="mat-cell pr-2 py-2 text-truncate">
|
||||
{{ formatDistanceToNow(userItem.Analytics.updatedAt) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -3,7 +3,7 @@
|
||||
display: block;
|
||||
|
||||
table {
|
||||
&.analytics {
|
||||
&.users {
|
||||
table-layout: fixed;
|
||||
|
||||
tr {
|
||||
|
@ -168,10 +168,9 @@
|
||||
<div class="col-lg">
|
||||
<mat-card class="mb-3">
|
||||
<mat-card-header>
|
||||
<mat-card-title class="align-items-center d-flex"
|
||||
><span i18n>Investment</span
|
||||
><ion-icon class="ml-1 text-muted" name="diamond-outline"></ion-icon
|
||||
></mat-card-title>
|
||||
<mat-card-title class="align-items-center d-flex" i18n
|
||||
>Investment</mat-card-title
|
||||
>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<!--<gf-positions-chart
|
||||
|
@ -39,6 +39,7 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
||||
public deviceType: string;
|
||||
public fearAndGreedIndex: number;
|
||||
public hasImpersonationId: boolean;
|
||||
public hasPermissionToAccessFearAndGreedIndex: boolean;
|
||||
public hasPermissionToReadForeignPortfolio: boolean;
|
||||
public hasPositions = false;
|
||||
public historicalDataItems: LineChartItem[];
|
||||
@ -80,6 +81,10 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
||||
.subscribe(() => {
|
||||
this.dataService.fetchUser().subscribe((user) => {
|
||||
this.user = user;
|
||||
this.hasPermissionToAccessFearAndGreedIndex = hasPermission(
|
||||
user.permissions,
|
||||
permissions.accessFearAndGreedIndex
|
||||
);
|
||||
this.hasPermissionToReadForeignPortfolio = hasPermission(
|
||||
user.permissions,
|
||||
permissions.readForeignPortfolio
|
||||
@ -175,14 +180,16 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
|
||||
this.dataService
|
||||
.fetchSymbolItem('GF.FEAR_AND_GREED_INDEX')
|
||||
.pipe(takeUntil(this.unsubscribeSubject))
|
||||
.subscribe(({ marketPrice }) => {
|
||||
this.fearAndGreedIndex = marketPrice;
|
||||
if (this.hasPermissionToAccessFearAndGreedIndex) {
|
||||
this.dataService
|
||||
.fetchSymbolItem('GF.FEAR_AND_GREED_INDEX')
|
||||
.pipe(takeUntil(this.unsubscribeSubject))
|
||||
.subscribe(({ marketPrice }) => {
|
||||
this.fearAndGreedIndex = marketPrice;
|
||||
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
}
|
||||
|
||||
this.cd.markForCheck();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { Router } from '@angular/router';
|
||||
import { hasPermission, permissions } from '@ghostfolio/helper';
|
||||
import { format } from 'date-fns';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
@ -276,7 +277,10 @@ export class LoginPageComponent implements OnDestroy, OnInit {
|
||||
authToken: string
|
||||
): void {
|
||||
const dialogRef = this.dialog.open(ShowAccessTokenDialog, {
|
||||
data: { accessToken, authToken },
|
||||
data: {
|
||||
accessToken,
|
||||
authToken
|
||||
},
|
||||
disableClose: true,
|
||||
width: '30rem'
|
||||
});
|
||||
|
@ -4,7 +4,7 @@
|
||||
class="align-items-center d-flex flex-column justify-content-center mb-4 w-100"
|
||||
>
|
||||
<gf-logo size="large"></gf-logo>
|
||||
<p class="lead m-0">Privacy-first Portfolio Tracker</p>
|
||||
<p class="lead m-0">Open Source Portfolio Tracker</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -132,7 +132,7 @@
|
||||
<div class="col-md-6 offset-md-3">
|
||||
<h2 class="h4 mb-1 text-center">Are <strong>you</strong> ready?</h2>
|
||||
<p class="lead mb-3 text-center">
|
||||
Join for free now or check out the example account
|
||||
Join now or check out the example account
|
||||
</p>
|
||||
<div class="py-2 text-center">
|
||||
<button
|
||||
|
@ -1,8 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
|
||||
import { DataService } from '../../../services/data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'login-with-access-token-dialog',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
|
@ -1,13 +1,15 @@
|
||||
<h1 mat-dialog-title i18n>Sign in</h1>
|
||||
<div mat-dialog-content>
|
||||
<div>
|
||||
<div class="text-center">
|
||||
<a color="accent" href="/api/auth/google" mat-flat-button
|
||||
><ion-icon class="mr-1" name="logo-google"></ion-icon
|
||||
><span i18n>Sign in with Google</span></a
|
||||
>
|
||||
</div>
|
||||
<div class="my-3 text-center text-muted" i18n>or</div>
|
||||
<ng-container *ngIf="data.hasPermissionToUseSocialLogin">
|
||||
<div class="text-center">
|
||||
<a color="accent" href="/api/auth/google" mat-flat-button
|
||||
><ion-icon class="mr-1" name="logo-google"></ion-icon
|
||||
><span i18n>Sign in with Google</span></a
|
||||
>
|
||||
</div>
|
||||
<div class="my-3 text-center text-muted" i18n>or</div>
|
||||
</ng-container>
|
||||
<mat-form-field appearance="outline" class="w-100">
|
||||
<mat-label i18n>Security Token</mat-label>
|
||||
<textarea
|
||||
|
@ -1,9 +1,8 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3 class="align-items-center d-flex justify-content-center mb-3">
|
||||
<span i18n>X-ray</span
|
||||
><ion-icon class="ml-2 text-muted" name="diamond-outline"></ion-icon>
|
||||
<h3 class="align-items-center d-flex justify-content-center mb-3" i18n>
|
||||
X-ray
|
||||
</h3>
|
||||
<p class="mb-4" i18n>
|
||||
Ghostfolio X-ray uses static analysis to identify potential issues and
|
||||
|
@ -1,10 +1,5 @@
|
||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { resolveFearAndGreedIndex } from 'libs/helper/src';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
import { DataService } from '../../services/data.service';
|
||||
import { TokenStorageService } from '../../services/token-storage.service';
|
||||
|
||||
@Component({
|
||||
selector: 'gf-resources-page',
|
||||
@ -12,41 +7,17 @@ import { TokenStorageService } from '../../services/token-storage.service';
|
||||
styleUrls: ['./resources-page.scss']
|
||||
})
|
||||
export class ResourcesPageComponent implements OnInit {
|
||||
public currentFearAndGreedIndex: number;
|
||||
public currentFearAndGreedIndexAsText: string;
|
||||
public isLoggedIn: boolean;
|
||||
|
||||
private unsubscribeSubject = new Subject<void>();
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
public constructor(
|
||||
private cd: ChangeDetectorRef,
|
||||
private dataService: DataService,
|
||||
private tokenStorageService: TokenStorageService
|
||||
) {}
|
||||
public constructor() {}
|
||||
|
||||
/**
|
||||
* Initializes the controller
|
||||
*/
|
||||
public ngOnInit() {
|
||||
this.isLoggedIn = !!this.tokenStorageService.getToken();
|
||||
|
||||
if (this.isLoggedIn) {
|
||||
this.dataService
|
||||
.fetchSymbolItem('GF.FEAR_AND_GREED_INDEX')
|
||||
.pipe(takeUntil(this.unsubscribeSubject))
|
||||
.subscribe(({ marketPrice }) => {
|
||||
this.currentFearAndGreedIndex = marketPrice;
|
||||
this.currentFearAndGreedIndexAsText = resolveFearAndGreedIndex(
|
||||
this.currentFearAndGreedIndex
|
||||
).text;
|
||||
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
}
|
||||
}
|
||||
public ngOnInit() {}
|
||||
|
||||
public ngOnDestroy() {
|
||||
this.unsubscribeSubject.next();
|
||||
|
@ -7,16 +7,8 @@
|
||||
<h4 class="mb-3">Market</h4>
|
||||
<div class="mb-5">
|
||||
<div class="mb-4 media">
|
||||
<!--<img src="" class="mr-3" />-->
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0">
|
||||
Fear & Greed Index<br class="d-block d-sm-none" />
|
||||
<small *ngIf="currentFearAndGreedIndex">
|
||||
(currently
|
||||
<strong>{{ currentFearAndGreedIndexAsText }}</strong> at
|
||||
<strong>{{ currentFearAndGreedIndex }}</strong>/100)</small
|
||||
>
|
||||
</h5>
|
||||
<h5 class="mt-0">Fear & Greed Index</h5>
|
||||
<div class="mb-1">
|
||||
The fear and greed index was developed by <i>CNNMoney</i> to
|
||||
measure the primary emotions (fear and greed) that influence
|
||||
@ -32,7 +24,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="media">
|
||||
<!--<img src="" class="mr-3" />-->
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0">Inflation Chart</h5>
|
||||
<div class="mb-1">
|
||||
|
@ -2,20 +2,9 @@ import { Currency } from '.prisma/client';
|
||||
|
||||
export const baseCurrency = Currency.CHF;
|
||||
|
||||
export const benchmarks = [
|
||||
'CSSMIM.SW',
|
||||
'GC=F',
|
||||
'GF.FEAR_AND_GREED_INDEX',
|
||||
'VOO',
|
||||
'VTI',
|
||||
'VWRD.L',
|
||||
'VXUS'
|
||||
];
|
||||
export const benchmarks = ['VOO'];
|
||||
|
||||
export const currencyPairs = [
|
||||
`${Currency.EUR}${Currency.CHF}`,
|
||||
`${Currency.GBP}${Currency.CHF}`,
|
||||
`${Currency.GBP}${Currency.EUR}`,
|
||||
`${Currency.USD}${Currency.EUR}`,
|
||||
`${Currency.USD}${Currency.GBP}`,
|
||||
`${Currency.USD}${Currency.CHF}`
|
||||
|
@ -6,12 +6,14 @@ export function isApiTokenAuthorized(aApiToken: string) {
|
||||
|
||||
export const permissions = {
|
||||
accessAdminControl: 'accessAdminControl',
|
||||
accessFearAndGreedIndex: 'accessFearAndGreedIndex',
|
||||
createAccount: 'createAccount',
|
||||
createOrder: 'createOrder',
|
||||
deleteOrder: 'deleteOrder',
|
||||
readForeignPortfolio: 'readForeignPortfolio',
|
||||
updateOrder: 'updateOrder',
|
||||
updateUserSettings: 'updateUserSettings'
|
||||
updateUserSettings: 'updateUserSettings',
|
||||
useSocialLogin: 'useSocialLogin'
|
||||
};
|
||||
|
||||
export function hasPermission(
|
||||
|
11
package.json
11
package.json
@ -1,6 +1,8 @@
|
||||
{
|
||||
"name": "ghostfolio",
|
||||
"version": "0.85.0",
|
||||
"version": "0.86.1",
|
||||
"homepage": "https://ghostfol.io",
|
||||
"license": "AGPL-3.0",
|
||||
"scripts": {
|
||||
"affected": "nx affected",
|
||||
"affected:apps": "nx affected:apps",
|
||||
@ -16,10 +18,6 @@
|
||||
"database:push": "yarn prisma db push --preview-feature",
|
||||
"database:seed": "prisma db seed --preview-feature",
|
||||
"dep-graph": "nx dep-graph",
|
||||
"docker:build": "cd docker/1.0.1 && docker-compose build",
|
||||
"docker:dockerize": "./node_modules/.bin/ts-node ./scripts/dockerize.ts",
|
||||
"docker:down": "cd docker/1.0.1 && docker-compose down",
|
||||
"docker:up": "cd docker/1.0.1 && docker-compose up -d",
|
||||
"e2e": "ng e2e",
|
||||
"format": "nx format:write",
|
||||
"format:check": "nx format:check",
|
||||
@ -42,7 +40,6 @@
|
||||
"watch:server": "yarn run nx build api --watch",
|
||||
"workspace-generator": "nx workspace-generator"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "11.2.4",
|
||||
"@angular/cdk": "11.0.4",
|
||||
@ -79,6 +76,7 @@
|
||||
"countup.js": "2.0.7",
|
||||
"cryptocurrencies": "7.0.0",
|
||||
"date-fns": "2.19.0",
|
||||
"envalid": "7.1.0",
|
||||
"http-status-codes": "2.1.4",
|
||||
"ionicons": "5.5.1",
|
||||
"lodash": "4.17.21",
|
||||
@ -132,7 +130,6 @@
|
||||
"prettier": "2.2.1",
|
||||
"replace-in-file": "6.2.0",
|
||||
"rimraf": "3.0.2",
|
||||
"s3-node": "0.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-node": "9.1.1",
|
||||
"typescript": "4.1.4"
|
||||
|
Reference in New Issue
Block a user