Compare commits
49 Commits
Author | SHA1 | Date | |
---|---|---|---|
40c95a541d | |||
2d04d7b8d5 | |||
94e0feac68 | |||
cd9e974c40 | |||
11700f75d9 | |||
0439a7beaa | |||
608b195ba9 | |||
8cb5fd64dd | |||
ef317a86ed | |||
19ada83d0b | |||
6ecf66ea2a | |||
65ba16c07c | |||
aee7c12c44 | |||
125956eb3e | |||
954224401d | |||
d268de3e12 | |||
39cfb4603b | |||
15a70abf67 | |||
5cb69291f5 | |||
cf582b2e98 | |||
82e159a083 | |||
2aff139982 | |||
6c7adb6193 | |||
bb2cd1c85a | |||
9d92c48ab7 | |||
dbed4ea527 | |||
8d149b5e2b | |||
27f1ec5d8a | |||
c361143ba2 | |||
069006145a | |||
3e3395aff9 | |||
a2687eacbc | |||
0f2c8c856c | |||
ec4dbf2a51 | |||
3d34aa5e80 | |||
c45bd70711 | |||
9f876e6020 | |||
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
|
COMPOSE_PROJECT_NAME=ghostfolio-development
|
||||||
|
|
||||||
# CACHE
|
# CACHE
|
||||||
CACHE_TTL=1
|
|
||||||
MAX_ITEM_IN_CACHE=9999
|
|
||||||
REDIS_HOST=localhost
|
REDIS_HOST=localhost
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
@ -14,10 +12,5 @@ POSTGRES_DB=ghostfolio-db
|
|||||||
ACCESS_TOKEN_SALT=GHOSTFOLIO
|
ACCESS_TOKEN_SALT=GHOSTFOLIO
|
||||||
ALPHA_VANTAGE_API_KEY=
|
ALPHA_VANTAGE_API_KEY=
|
||||||
DATABASE_URL=postgresql://user:password@localhost:5432/ghostfolio-db?sslmode=prefer
|
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
|
JWT_SECRET_KEY=123456
|
||||||
PORT=3333
|
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.
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
# compiled output
|
# compiled output
|
||||||
/dist/apps/api/data/*.json
|
|
||||||
/docker/**/*.*.*
|
|
||||||
/docker/**/*.*.*.zip
|
|
||||||
/tmp
|
|
||||||
/out-tsc
|
/out-tsc
|
||||||
|
/tmp
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/node_modules
|
||||||
@ -24,7 +21,6 @@
|
|||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/settings.json
|
!.vscode/settings.json
|
||||||
!.vscode/tasks.json
|
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
/.sass-cache
|
/.sass-cache
|
||||||
|
119
CHANGELOG.md
119
CHANGELOG.md
@ -5,6 +5,109 @@ 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/),
|
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## 0.95.0 - 28.04.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a data source attribute to the transactions model
|
||||||
|
|
||||||
|
## 0.94.0 - 27.04.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added the generic scraper symbols to the symbol lookup results
|
||||||
|
|
||||||
|
## 0.93.0 - 26.04.2021
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the user table styling of the admin control panel
|
||||||
|
- Improved the background colors in the dark mode
|
||||||
|
|
||||||
|
## 0.92.0 - 25.04.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Prepared further for multi accounts support: store account for new transactions
|
||||||
|
- Added a horizontal scrollbar to the user table of the admin control panel
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue in the header with outdated data
|
||||||
|
- Fixed an issue on the about page with outdated data
|
||||||
|
|
||||||
|
## 0.91.0 - 25.04.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Extended the support for feature flags to simplify the initial project setup
|
||||||
|
- Prepared for multi accounts support
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the styling of the rules in the _X-ray_ section
|
||||||
|
|
||||||
|
## 0.90.0 - 22.04.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added the symbol logo to the position detail dialog
|
||||||
|
- Introduced a third option for the market state: `delayed` (besides `open` and `closed`)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved the user table of the admin control panel
|
||||||
|
|
||||||
|
## 0.89.0 - 21.04.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a prettifier (pipe) for generic scraper symbols
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the text truncation in buttons of the admin control panel
|
||||||
|
|
||||||
|
## 0.88.0 - 20.04.2021
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Reverted the restoring of the scroll position when opening a new page
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the frozen screen if the token has expired
|
||||||
|
- Fixed some issues in the generic scraper
|
||||||
|
|
||||||
|
## 0.87.0 - 19.04.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a generic scraper
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue in the user table of the admin control panel with missing data
|
||||||
|
|
||||||
|
## 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 of the admin control panel
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Restored the scroll position when opening a new page
|
||||||
|
|
||||||
## 0.85.0 - 16.04.2021
|
## 0.85.0 - 16.04.2021
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
@ -34,7 +137,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed an issue in the portfolio update on deleting a transaction
|
- Fixed an issue in the portfolio update on deleting a transaction
|
||||||
- Fixed an issue in the _X-Ray_ section (missing redirection on logout)
|
- Fixed an issue in the _X-ray_ section (missing redirection on logout)
|
||||||
|
|
||||||
## 0.82.0 - 10.04.2021
|
## 0.82.0 - 10.04.2021
|
||||||
|
|
||||||
@ -107,7 +210,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Grouped the _X-Ray_ section visually in _Currency Cluster Risk_ and _Platform Cluster Risk_
|
- Grouped the _X-ray_ section visually in _Currency Cluster Risk_ and _Platform Cluster Risk_
|
||||||
|
|
||||||
## 0.76.0 - 02.04.2021
|
## 0.76.0 - 02.04.2021
|
||||||
|
|
||||||
@ -119,7 +222,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed an issue in the _X-Ray_ section (empty portfolio)
|
- Fixed an issue in the _X-ray_ section (empty portfolio)
|
||||||
|
|
||||||
## 0.75.0 - 01.04.2021
|
## 0.75.0 - 01.04.2021
|
||||||
|
|
||||||
@ -132,7 +235,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Added a _Create Account_ message in the _Live Demo_
|
- Added a _Create Account_ message in the _Live Demo_
|
||||||
- Added skeleton loaders to the _X-Ray_ section
|
- Added skeleton loaders to the _X-ray_ section
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
@ -148,7 +251,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Improved the intro text in the _X-Ray_ section
|
- Improved the intro text in the _X-ray_ section
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
@ -164,7 +267,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Added an intro text to the _X-Ray_ section
|
- Added an intro text to the _X-ray_ section
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
@ -183,7 +286,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Improved the styling in the _X-Ray_ section
|
- Improved the styling in the _X-ray_ section
|
||||||
|
|
||||||
## 0.70.0 - 27.03.2021
|
## 0.70.0 - 27.03.2021
|
||||||
|
|
||||||
@ -191,7 +294,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Added the current _Fear & Greed Index_ as text
|
- Added the current _Fear & Greed Index_ as text
|
||||||
- Extended the landing page text: _Ghostfolio_ empowers busy folks...
|
- Extended the landing page text: _Ghostfolio_ empowers busy folks...
|
||||||
- Added the first static portfolio analysis rule in the brand new _X-Ray_ section
|
- Added the first static portfolio analysis rule in the brand new _X-ray_ section
|
||||||
|
|
||||||
### Changed
|
### 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.
|
76
README.md
76
README.md
@ -1,22 +1,67 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
<h1>Ghostfolio</h1>
|
<h1>Ghostfolio</h1>
|
||||||
<p>
|
|
||||||
<strong>Privacy-first Portfolio Tracker</strong>
|
|
||||||
</p>
|
|
||||||
<p>
|
<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>
|
</p>
|
||||||
</div>
|
</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
|
## 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
|
- ✅ Dark Mode
|
||||||
|
|
||||||
|
## Technology Stack
|
||||||
|
|
||||||
|
Ghostfolio is a modern web application written in [TypeScript](https://www.typescriptlang.org) and organized as an [Nx](https://nx.dev) workspace.
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
### Frontend
|
||||||
|
|
||||||
|
The frontend is built with [Angular](https://angular.io).
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- [Node.js](https://nodejs.org/en/download)
|
- [Node.js](https://nodejs.org/en/download) (version 14+)
|
||||||
- [Yarn](https://yarnpkg.com/en/docs/install)
|
- [Yarn](https://yarnpkg.com/en/docs/install)
|
||||||
- [Docker](https://www.docker.com/products/docker-desktop)
|
- [Docker](https://www.docker.com/products/docker-desktop)
|
||||||
|
|
||||||
@ -25,13 +70,18 @@
|
|||||||
1. Run `yarn install`
|
1. Run `yarn install`
|
||||||
2. Run `cd docker`
|
2. Run `cd docker`
|
||||||
3. Run `docker compose build`
|
3. Run `docker compose build`
|
||||||
4. Run `docker compose up -d`
|
4. Run `docker compose up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)
|
||||||
5. Run `yarn setup:database`
|
5. Run `cd -` to go back to the project root directory
|
||||||
6. Start server and client (see _Development_)
|
6. Run `yarn setup:database` to initialize the database schema and populate your database with (example) data
|
||||||
7. Login as _Admin_ with the `Security Token`: `ae76872ae8f3419c6d6f64bf51888ecbcc703927a342d815fafe486acdb938da07d0cf44fca211a0be74a423238f535362d390a41e81e633a9ce668a6e31cdf9`
|
7. Start server and client (see _Development_)
|
||||||
|
8. Login as _Admin_ with the following _Security Token_: `ae76872ae8f3419c6d6f64bf51888ecbcc703927a342d815fafe486acdb938da07d0cf44fca211a0be74a423238f535362d390a41e81e633a9ce668a6e31cdf9`
|
||||||
|
9. Go to the _Admin Control Panel_ and press _Gather All Data_ to fetch historical data
|
||||||
|
10. Press _Sign out_ and check out the _Live Demo_
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
Please make sure you have completed the instructions from _Setup_
|
||||||
|
|
||||||
### Start server
|
### Start server
|
||||||
|
|
||||||
- Debug: Run `yarn watch:server` and click "Launch Program" in _Visual Studio Code_
|
- Debug: Run `yarn watch:server` and click "Launch Program" in _Visual Studio Code_
|
||||||
@ -44,3 +94,9 @@
|
|||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Run `yarn test`
|
Run `yarn test`
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
© 2021 [Ghostfolio](https://ghostfol.io)
|
||||||
|
|
||||||
|
Licensed under the [AGPLv3 License](https://www.gnu.org/licenses/agpl-3.0.html).
|
||||||
|
@ -99,6 +99,11 @@
|
|||||||
"input": "",
|
"input": "",
|
||||||
"output": "./"
|
"output": "./"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"glob": "LICENSE",
|
||||||
|
"input": "",
|
||||||
|
"output": "./"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"glob": "sitemap.xml",
|
"glob": "sitemap.xml",
|
||||||
"input": "apps/client/src/assets",
|
"input": "apps/client/src/assets",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { RequestWithUser } from '@ghostfolio/api/app/interfaces/request-with-user.type';
|
||||||
import { Controller, Get, Inject, UseGuards } from '@nestjs/common';
|
import { Controller, Get, Inject, UseGuards } from '@nestjs/common';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { RequestWithUser } from 'apps/api/src/app/interfaces/request-with-user.type';
|
|
||||||
|
|
||||||
import { AccessService } from './access.service';
|
import { AccessService } from './access.service';
|
||||||
import { Access } from './interfaces/access.interface';
|
import { Access } from './interfaces/access.interface';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { AccessController } from './access.controller';
|
import { AccessController } from './access.controller';
|
||||||
import { AccessService } from './access.service';
|
import { AccessService } from './access.service';
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { AccessWithGranteeUser } from './interfaces/access-with-grantee-user.type';
|
import { AccessWithGranteeUser } from './interfaces/access-with-grantee-user.type';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import { RequestWithUser } from '@ghostfolio/api/app/interfaces/request-with-user.type';
|
||||||
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
|
import { getPermissions, hasPermission, permissions } from '@ghostfolio/helper';
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
@ -8,11 +11,8 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { RequestWithUser } from 'apps/api/src/app/interfaces/request-with-user.type';
|
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
import { getPermissions, hasPermission, permissions } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { DataGatheringService } from '../../services/data-gathering.service';
|
|
||||||
import { AdminService } from './admin.service';
|
import { AdminService } from './admin.service';
|
||||||
import { AdminData } from './interfaces/admin-data.interface';
|
import { AdminData } from './interfaces/admin-data.interface';
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
||||||
|
import { AlphaVantageService } from '@ghostfolio/api/services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
|
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
|
import { RakutenRapidApiService } from '@ghostfolio/api/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
|
import { YahooFinanceService } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
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';
|
|
||||||
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
|
||||||
import { YahooFinanceService } from '../../services/data-provider/yahoo-finance/yahoo-finance.service';
|
|
||||||
import { ExchangeRateDataService } from '../../services/exchange-rate-data.service';
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { AdminController } from './admin.controller';
|
import { AdminController } from './admin.controller';
|
||||||
import { AdminService } from './admin.service';
|
import { AdminService } from './admin.service';
|
||||||
|
|
||||||
@ -16,9 +18,11 @@ import { AdminService } from './admin.service';
|
|||||||
providers: [
|
providers: [
|
||||||
AdminService,
|
AdminService,
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
DataGatheringService,
|
DataGatheringService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
|
GhostfolioScraperApiService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
RakutenRapidApiService,
|
RakutenRapidApiService,
|
||||||
YahooFinanceService
|
YahooFinanceService
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
|
|
||||||
import { ExchangeRateDataService } from '../../services/exchange-rate-data.service';
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { AdminData } from './interfaces/admin-data.interface';
|
import { AdminData } from './interfaces/admin-data.interface';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -14,7 +14,6 @@ export class AdminService {
|
|||||||
|
|
||||||
public async get(): Promise<AdminData> {
|
public async get(): Promise<AdminData> {
|
||||||
return {
|
return {
|
||||||
analytics: await this.getUserAnalytics(),
|
|
||||||
exchangeRates: [
|
exchangeRates: [
|
||||||
{
|
{
|
||||||
label1: Currency.EUR,
|
label1: Currency.EUR,
|
||||||
@ -64,7 +63,8 @@ export class AdminService {
|
|||||||
],
|
],
|
||||||
lastDataGathering: await this.getLastDataGathering(),
|
lastDataGathering: await this.getLastDataGathering(),
|
||||||
transactionCount: await this.prisma.order.count(),
|
transactionCount: await this.prisma.order.count(),
|
||||||
userCount: await this.prisma.user.count()
|
userCount: await this.prisma.user.count(),
|
||||||
|
users: await this.getUsersWithAnalytics()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,21 +88,33 @@ export class AdminService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getUserAnalytics() {
|
private async getUsersWithAnalytics() {
|
||||||
return await this.prisma.analytics.findMany({
|
return await this.prisma.user.findMany({
|
||||||
orderBy: { updatedAt: 'desc' },
|
orderBy: {
|
||||||
select: {
|
Analytics: {
|
||||||
activityCount: true,
|
updatedAt: 'desc'
|
||||||
updatedAt: true,
|
|
||||||
User: {
|
|
||||||
select: {
|
|
||||||
alias: true,
|
|
||||||
createdAt: true,
|
|
||||||
id: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
take: 20
|
select: {
|
||||||
|
_count: {
|
||||||
|
select: { Account: true, Order: true }
|
||||||
|
},
|
||||||
|
alias: true,
|
||||||
|
Analytics: {
|
||||||
|
select: {
|
||||||
|
activityCount: true,
|
||||||
|
updatedAt: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
createdAt: true,
|
||||||
|
id: true
|
||||||
|
},
|
||||||
|
take: 20,
|
||||||
|
where: {
|
||||||
|
NOT: {
|
||||||
|
Analytics: null
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
export interface AdminData {
|
export interface AdminData {
|
||||||
analytics: {
|
|
||||||
activityCount: number;
|
|
||||||
updatedAt: Date;
|
|
||||||
User: {
|
|
||||||
alias: string;
|
|
||||||
id: string;
|
|
||||||
};
|
|
||||||
}[];
|
|
||||||
exchangeRates: { label1: string; label2: string; value: number }[];
|
exchangeRates: { label1: string; label2: string; value: number }[];
|
||||||
lastDataGathering: Date | 'IN_PROGRESS';
|
lastDataGathering: Date | 'IN_PROGRESS';
|
||||||
transactionCount: number;
|
transactionCount: number;
|
||||||
userCount: number;
|
userCount: number;
|
||||||
|
users: {
|
||||||
|
alias: string;
|
||||||
|
createdAt: Date;
|
||||||
|
Analytics: {
|
||||||
|
activityCount: number;
|
||||||
|
updatedAt: Date;
|
||||||
|
};
|
||||||
|
id: string;
|
||||||
|
}[];
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,12 @@ import { ConfigModule } from '@nestjs/config';
|
|||||||
import { ScheduleModule } from '@nestjs/schedule';
|
import { ScheduleModule } from '@nestjs/schedule';
|
||||||
import { ServeStaticModule } from '@nestjs/serve-static';
|
import { ServeStaticModule } from '@nestjs/serve-static';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../services/configuration.service';
|
||||||
import { CronService } from '../services/cron.service';
|
import { CronService } from '../services/cron.service';
|
||||||
import { DataGatheringService } from '../services/data-gathering.service';
|
import { DataGatheringService } from '../services/data-gathering.service';
|
||||||
import { DataProviderService } from '../services/data-provider.service';
|
import { DataProviderService } from '../services/data-provider.service';
|
||||||
import { AlphaVantageService } from '../services/data-provider/alpha-vantage/alpha-vantage.service';
|
import { AlphaVantageService } from '../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
|
import { GhostfolioScraperApiService } from '../services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
import { RakutenRapidApiService } from '../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
import { RakutenRapidApiService } from '../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
import { YahooFinanceService } from '../services/data-provider/yahoo-finance/yahoo-finance.service';
|
import { YahooFinanceService } from '../services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
import { ExchangeRateDataService } from '../services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '../services/exchange-rate-data.service';
|
||||||
@ -59,10 +61,12 @@ import { UserModule } from './user/user.module';
|
|||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
CronService,
|
CronService,
|
||||||
DataGatheringService,
|
DataGatheringService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
|
GhostfolioScraperApiService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
RakutenRapidApiService,
|
RakutenRapidApiService,
|
||||||
YahooFinanceService
|
YahooFinanceService
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
@ -14,7 +15,10 @@ import { AuthService } from './auth.service';
|
|||||||
|
|
||||||
@Controller('auth')
|
@Controller('auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
public constructor(private readonly authService: AuthService) {}
|
public constructor(
|
||||||
|
private readonly authService: AuthService,
|
||||||
|
private readonly configurationService: ConfigurationService
|
||||||
|
) {}
|
||||||
|
|
||||||
@Get('anonymous/:accessToken')
|
@Get('anonymous/:accessToken')
|
||||||
public async accessTokenLogin(@Param('accessToken') accessToken: string) {
|
public async accessTokenLogin(@Param('accessToken') accessToken: string) {
|
||||||
@ -44,9 +48,9 @@ export class AuthController {
|
|||||||
const jwt: string = req.user.jwt;
|
const jwt: string = req.user.jwt;
|
||||||
|
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
res.redirect(`${process.env.ROOT_URL}/auth/${jwt}`);
|
res.redirect(`${this.configurationService.get('ROOT_URL')}/auth/${jwt}`);
|
||||||
} else {
|
} else {
|
||||||
res.redirect(`${process.env.ROOT_URL}/auth`);
|
res.redirect(`${this.configurationService.get('ROOT_URL')}/auth`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { UserService } from '../user/user.service';
|
import { UserService } from '../user/user.service';
|
||||||
import { AuthController } from './auth.controller';
|
import { AuthController } from './auth.controller';
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
@ -18,6 +19,7 @@ import { JwtStrategy } from './jwt.strategy';
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AuthService,
|
AuthService,
|
||||||
|
ConfigurationService,
|
||||||
GoogleStrategy,
|
GoogleStrategy,
|
||||||
JwtStrategy,
|
JwtStrategy,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
|
|
||||||
@ -7,7 +8,8 @@ import { ValidateOAuthLoginParams } from './interfaces/interfaces';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
public constructor(
|
public constructor(
|
||||||
private jwtService: JwtService,
|
private readonly configurationService: ConfigurationService,
|
||||||
|
private readonly jwtService: JwtService,
|
||||||
private readonly userService: UserService
|
private readonly userService: UserService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -16,7 +18,7 @@ export class AuthService {
|
|||||||
try {
|
try {
|
||||||
const hashedAccessToken = this.userService.createAccessToken(
|
const hashedAccessToken = this.userService.createAccessToken(
|
||||||
accessToken,
|
accessToken,
|
||||||
process.env.ACCESS_TOKEN_SALT
|
this.configurationService.get('ACCESS_TOKEN_SALT')
|
||||||
);
|
);
|
||||||
|
|
||||||
const [user] = await this.userService.users({
|
const [user] = await this.userService.users({
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { PassportStrategy } from '@nestjs/passport';
|
import { PassportStrategy } from '@nestjs/passport';
|
||||||
import { Provider } from '@prisma/client';
|
import { Provider } from '@prisma/client';
|
||||||
@ -7,11 +8,16 @@ import { AuthService } from './auth.service';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
||||||
public constructor(private readonly authService: AuthService) {
|
public constructor(
|
||||||
|
private readonly authService: AuthService,
|
||||||
|
readonly configurationService: ConfigurationService
|
||||||
|
) {
|
||||||
super({
|
super({
|
||||||
callbackURL: `${process.env.ROOT_URL}/api/auth/google/callback`,
|
callbackURL: `${configurationService.get(
|
||||||
clientID: process.env.GOOGLE_CLIENT_ID,
|
'ROOT_URL'
|
||||||
clientSecret: process.env.GOOGLE_SECRET,
|
)}/api/auth/google/callback`,
|
||||||
|
clientID: configurationService.get('GOOGLE_CLIENT_ID'),
|
||||||
|
clientSecret: configurationService.get('GOOGLE_SECRET'),
|
||||||
passReqToCallback: true,
|
passReqToCallback: true,
|
||||||
scope: ['email', 'profile']
|
scope: ['email', 'profile']
|
||||||
});
|
});
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||||
import { PassportStrategy } from '@nestjs/passport';
|
import { PassportStrategy } from '@nestjs/passport';
|
||||||
import { ExtractJwt, Strategy } from 'passport-jwt';
|
import { ExtractJwt, Strategy } from 'passport-jwt';
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { UserService } from '../user/user.service';
|
import { UserService } from '../user/user.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||||
public constructor(
|
public constructor(
|
||||||
|
readonly configurationService: ConfigurationService,
|
||||||
private prisma: PrismaService,
|
private prisma: PrismaService,
|
||||||
private readonly userService: UserService
|
private readonly userService: UserService
|
||||||
) {
|
) {
|
||||||
super({
|
super({
|
||||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||||
secretOrKey: process.env.JWT_SECRET_KEY
|
secretOrKey: configurationService.get('JWT_SECRET_KEY')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
apps/api/src/app/cache/cache.controller.ts
vendored
2
apps/api/src/app/cache/cache.controller.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
|
import { RequestWithUser } from '@ghostfolio/api/app/interfaces/request-with-user.type';
|
||||||
import { Controller, Inject, Param, Post, UseGuards } from '@nestjs/common';
|
import { Controller, Inject, Param, Post, UseGuards } from '@nestjs/common';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { RequestWithUser } from 'apps/api/src/app/interfaces/request-with-user.type';
|
|
||||||
|
|
||||||
import { RedisCacheService } from '../redis-cache/redis-cache.service';
|
import { RedisCacheService } from '../redis-cache/redis-cache.service';
|
||||||
import { CacheService } from './cache.service';
|
import { CacheService } from './cache.service';
|
||||||
|
2
apps/api/src/app/cache/cache.module.ts
vendored
2
apps/api/src/app/cache/cache.module.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { RedisCacheModule } from '../redis-cache/redis-cache.module';
|
import { RedisCacheModule } from '../redis-cache/redis-cache.module';
|
||||||
import { CacheController } from './cache.controller';
|
import { CacheController } from './cache.controller';
|
||||||
import { CacheService } from './cache.service';
|
import { CacheService } from './cache.service';
|
||||||
|
4
apps/api/src/app/cache/cache.service.ts
vendored
4
apps/api/src/app/cache/cache.service.ts
vendored
@ -1,7 +1,5 @@
|
|||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Prisma, User } from '@prisma/client';
|
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CacheService {
|
export class CacheService {
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
import { RequestWithUser } from '@ghostfolio/api/app/interfaces/request-with-user.type';
|
||||||
|
import {
|
||||||
|
baseCurrency,
|
||||||
|
benchmarks,
|
||||||
|
isApiTokenAuthorized
|
||||||
|
} from '@ghostfolio/helper';
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
@ -9,11 +15,8 @@ import {
|
|||||||
Post
|
Post
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { RequestWithUser } from 'apps/api/src/app/interfaces/request-with-user.type';
|
|
||||||
import { parse } from 'date-fns';
|
import { parse } from 'date-fns';
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
import { baseCurrency, benchmarks } from 'libs/helper/src';
|
|
||||||
import { isApiTokenAuthorized } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { CreateOrderDto } from './create-order.dto';
|
import { CreateOrderDto } from './create-order.dto';
|
||||||
import { ExperimentalService } from './experimental.service';
|
import { ExperimentalService } from './experimental.service';
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
||||||
|
import { AlphaVantageService } from '@ghostfolio/api/services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
|
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
|
import { RakutenRapidApiService } from '@ghostfolio/api/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
|
import { YahooFinanceService } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
|
import { RulesService } from '@ghostfolio/api/services/rules.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
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';
|
|
||||||
import { YahooFinanceService } from '../../services/data-provider/yahoo-finance/yahoo-finance.service';
|
|
||||||
import { ExchangeRateDataService } from '../../services/exchange-rate-data.service';
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { RulesService } from '../../services/rules.service';
|
|
||||||
import { ExperimentalController } from './experimental.controller';
|
import { ExperimentalController } from './experimental.controller';
|
||||||
import { ExperimentalService } from './experimental.service';
|
import { ExperimentalService } from './experimental.service';
|
||||||
|
|
||||||
@ -15,9 +17,11 @@ import { ExperimentalService } from './experimental.service';
|
|||||||
controllers: [ExperimentalController],
|
controllers: [ExperimentalController],
|
||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
ExperimentalService,
|
ExperimentalService,
|
||||||
|
GhostfolioScraperApiService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
RakutenRapidApiService,
|
RakutenRapidApiService,
|
||||||
RulesService,
|
RulesService,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
import { Portfolio } from '@ghostfolio/api/models/portfolio';
|
||||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
||||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
|
import { RulesService } from '@ghostfolio/api/services/rules.service';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Currency, Type } from '@prisma/client';
|
import { Currency, Type } from '@prisma/client';
|
||||||
import { parseISO } from 'date-fns';
|
import { parseISO } from 'date-fns';
|
||||||
|
|
||||||
import { Portfolio } from '../../models/portfolio';
|
|
||||||
import { DataProviderService } from '../../services/data-provider.service';
|
|
||||||
import { ExchangeRateDataService } from '../../services/exchange-rate-data.service';
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { RulesService } from '../../services/rules.service';
|
|
||||||
import { OrderWithPlatform } from '../order/interfaces/order-with-platform.type';
|
import { OrderWithPlatform } from '../order/interfaces/order-with-platform.type';
|
||||||
import { CreateOrderDto } from './create-order.dto';
|
import { CreateOrderDto } from './create-order.dto';
|
||||||
import { Data } from './interfaces/data.interface';
|
import { Data } from './interfaces/data.interface';
|
||||||
@ -36,7 +36,10 @@ export class ExperimentalService {
|
|||||||
const ordersWithPlatform: OrderWithPlatform[] = aOrders.map((order) => {
|
const ordersWithPlatform: OrderWithPlatform[] = aOrders.map((order) => {
|
||||||
return {
|
return {
|
||||||
...order,
|
...order,
|
||||||
|
accountId: undefined,
|
||||||
|
accountUserId: undefined,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
dataSource: undefined,
|
||||||
date: parseISO(order.date),
|
date: parseISO(order.date),
|
||||||
fee: 0,
|
fee: 0,
|
||||||
id: undefined,
|
id: undefined,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { InfoController } from './info.controller';
|
import { InfoController } from './info.controller';
|
||||||
import { InfoService } from './info.service';
|
import { InfoService } from './info.service';
|
||||||
|
|
||||||
@ -13,6 +14,6 @@ import { InfoService } from './info.service';
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
controllers: [InfoController],
|
controllers: [InfoController],
|
||||||
providers: [InfoService, PrismaService]
|
providers: [ConfigurationService, InfoService, PrismaService]
|
||||||
})
|
})
|
||||||
export class InfoModule {}
|
export class InfoModule {}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
|
import { permissions } from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { InfoItem } from './interfaces/info-item.interface';
|
import { InfoItem } from './interfaces/info-item.interface';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -10,6 +12,7 @@ export class InfoService {
|
|||||||
private static DEMO_USER_ID = '9b112b4d-3b7d-4bad-9bdd-3b0f7b4dac2f';
|
private static DEMO_USER_ID = '9b112b4d-3b7d-4bad-9bdd-3b0f7b4dac2f';
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
|
private readonly configurationService: ConfigurationService,
|
||||||
private jwtService: JwtService,
|
private jwtService: JwtService,
|
||||||
private prisma: PrismaService
|
private prisma: PrismaService
|
||||||
) {}
|
) {}
|
||||||
@ -20,7 +23,18 @@ export class InfoService {
|
|||||||
select: { id: true, name: true }
|
select: { id: true, name: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const globalPermissions: string[] = [];
|
||||||
|
|
||||||
|
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
|
||||||
|
globalPermissions.push(permissions.enableSocialLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
|
||||||
|
globalPermissions.push(permissions.enableSubscription);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
globalPermissions,
|
||||||
platforms,
|
platforms,
|
||||||
currencies: Object.values(Currency),
|
currencies: Object.values(Currency),
|
||||||
demoAuthToken: this.getDemoAuthToken(),
|
demoAuthToken: this.getDemoAuthToken(),
|
||||||
|
@ -3,6 +3,7 @@ import { Currency } from '@prisma/client';
|
|||||||
export interface InfoItem {
|
export interface InfoItem {
|
||||||
currencies: Currency[];
|
currencies: Currency[];
|
||||||
demoAuthToken: string;
|
demoAuthToken: string;
|
||||||
|
globalPermissions: string[];
|
||||||
lastDataGathering?: Date;
|
lastDataGathering?: Date;
|
||||||
message?: {
|
message?: {
|
||||||
text: string;
|
text: string;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
import { Settings, User } from '@prisma/client';
|
import { Account, Settings, User } from '@prisma/client';
|
||||||
|
|
||||||
export type UserWithSettings = User & { Settings: Settings };
|
export type UserWithSettings = User & {
|
||||||
|
Account: Account[];
|
||||||
|
Settings: Settings;
|
||||||
|
};
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
import { Currency, Type } from '@prisma/client';
|
import { Currency, DataSource, Type } from '@prisma/client';
|
||||||
import { IsISO8601, IsNumber, IsString, ValidateIf } from 'class-validator';
|
import { IsISO8601, IsNumber, IsString, ValidateIf } from 'class-validator';
|
||||||
|
|
||||||
export class CreateOrderDto {
|
export class CreateOrderDto {
|
||||||
|
@IsString()
|
||||||
|
accountId: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
currency: Currency;
|
currency: Currency;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
dataSource: DataSource;
|
||||||
|
|
||||||
@IsISO8601()
|
@IsISO8601()
|
||||||
date: string;
|
date: string;
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
import { RequestWithUser } from '@ghostfolio/api/app/interfaces/request-with-user.type';
|
||||||
|
import { nullifyValuesInObjects } from '@ghostfolio/api/helper/object.helper';
|
||||||
|
import { ImpersonationService } from '@ghostfolio/api/services/impersonation.service';
|
||||||
|
import { getPermissions, hasPermission, permissions } from '@ghostfolio/helper';
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
@ -14,13 +18,9 @@ import {
|
|||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { Order as OrderModel } from '@prisma/client';
|
import { Order as OrderModel } from '@prisma/client';
|
||||||
import { RequestWithUser } from 'apps/api/src/app/interfaces/request-with-user.type';
|
|
||||||
import { parseISO } from 'date-fns';
|
import { parseISO } from 'date-fns';
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
import { getPermissions, hasPermission, permissions } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { nullifyValuesInObjects } from '../../helper/object.helper';
|
|
||||||
import { ImpersonationService } from '../../services/impersonation.service';
|
|
||||||
import { CreateOrderDto } from './create-order.dto';
|
import { CreateOrderDto } from './create-order.dto';
|
||||||
import { OrderService } from './order.service';
|
import { OrderService } from './order.service';
|
||||||
import { UpdateOrderDto } from './update-order.dto';
|
import { UpdateOrderDto } from './update-order.dto';
|
||||||
@ -118,6 +118,9 @@ export class OrderController {
|
|||||||
|
|
||||||
const date = parseISO(data.date);
|
const date = parseISO(data.date);
|
||||||
|
|
||||||
|
const accountId = data.accountId;
|
||||||
|
delete data.accountId;
|
||||||
|
|
||||||
if (data.platformId) {
|
if (data.platformId) {
|
||||||
const platformId = data.platformId;
|
const platformId = data.platformId;
|
||||||
delete data.platformId;
|
delete data.platformId;
|
||||||
@ -126,6 +129,11 @@ export class OrderController {
|
|||||||
{
|
{
|
||||||
...data,
|
...data,
|
||||||
date,
|
date,
|
||||||
|
Account: {
|
||||||
|
connect: {
|
||||||
|
id_userId: { id: accountId, userId: this.request.user.id }
|
||||||
|
}
|
||||||
|
},
|
||||||
Platform: { connect: { id: platformId } },
|
Platform: { connect: { id: platformId } },
|
||||||
User: { connect: { id: this.request.user.id } }
|
User: { connect: { id: this.request.user.id } }
|
||||||
},
|
},
|
||||||
@ -138,6 +146,11 @@ export class OrderController {
|
|||||||
{
|
{
|
||||||
...data,
|
...data,
|
||||||
date,
|
date,
|
||||||
|
Account: {
|
||||||
|
connect: {
|
||||||
|
id_userId: { id: accountId, userId: this.request.user.id }
|
||||||
|
}
|
||||||
|
},
|
||||||
User: { connect: { id: this.request.user.id } }
|
User: { connect: { id: this.request.user.id } }
|
||||||
},
|
},
|
||||||
this.request.user.id
|
this.request.user.id
|
||||||
@ -169,6 +182,9 @@ export class OrderController {
|
|||||||
|
|
||||||
const date = parseISO(data.date);
|
const date = parseISO(data.date);
|
||||||
|
|
||||||
|
const accountId = data.accountId;
|
||||||
|
delete data.accountId;
|
||||||
|
|
||||||
if (data.platformId) {
|
if (data.platformId) {
|
||||||
const platformId = data.platformId;
|
const platformId = data.platformId;
|
||||||
delete data.platformId;
|
delete data.platformId;
|
||||||
@ -178,6 +194,11 @@ export class OrderController {
|
|||||||
data: {
|
data: {
|
||||||
...data,
|
...data,
|
||||||
date,
|
date,
|
||||||
|
Account: {
|
||||||
|
connect: {
|
||||||
|
id_userId: { id: accountId, userId: this.request.user.id }
|
||||||
|
}
|
||||||
|
},
|
||||||
Platform: { connect: { id: platformId } },
|
Platform: { connect: { id: platformId } },
|
||||||
User: { connect: { id: this.request.user.id } }
|
User: { connect: { id: this.request.user.id } }
|
||||||
},
|
},
|
||||||
@ -199,6 +220,11 @@ export class OrderController {
|
|||||||
data: {
|
data: {
|
||||||
...data,
|
...data,
|
||||||
date,
|
date,
|
||||||
|
Account: {
|
||||||
|
connect: {
|
||||||
|
id_userId: { id: accountId, userId: this.request.user.id }
|
||||||
|
}
|
||||||
|
},
|
||||||
Platform: originalOrder.platformId
|
Platform: originalOrder.platformId
|
||||||
? { disconnect: true }
|
? { disconnect: true }
|
||||||
: undefined,
|
: undefined,
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
||||||
|
import { AlphaVantageService } from '@ghostfolio/api/services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
|
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
|
import { RakutenRapidApiService } from '@ghostfolio/api/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
|
import { YahooFinanceService } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
|
import { ImpersonationService } from '@ghostfolio/api/services/impersonation.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
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';
|
|
||||||
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
|
||||||
import { YahooFinanceService } from '../../services/data-provider/yahoo-finance/yahoo-finance.service';
|
|
||||||
import { ImpersonationService } from '../../services/impersonation.service';
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { CacheService } from '../cache/cache.service';
|
import { CacheService } from '../cache/cache.service';
|
||||||
import { RedisCacheModule } from '../redis-cache/redis-cache.module';
|
import { RedisCacheModule } from '../redis-cache/redis-cache.module';
|
||||||
import { OrderController } from './order.controller';
|
import { OrderController } from './order.controller';
|
||||||
@ -18,8 +20,10 @@ import { OrderService } from './order.service';
|
|||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
CacheService,
|
CacheService,
|
||||||
|
ConfigurationService,
|
||||||
DataGatheringService,
|
DataGatheringService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
|
GhostfolioScraperApiService,
|
||||||
ImpersonationService,
|
ImpersonationService,
|
||||||
OrderService,
|
OrderService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Order, Prisma } from '@prisma/client';
|
import { Order, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
import { DataGatheringService } from '../../services/data-gathering.service';
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { CacheService } from '../cache/cache.service';
|
import { CacheService } from '../cache/cache.service';
|
||||||
import { RedisCacheService } from '../redis-cache/redis-cache.service';
|
import { RedisCacheService } from '../redis-cache/redis-cache.service';
|
||||||
import { OrderWithPlatform } from './interfaces/order-with-platform.type';
|
import { OrderWithPlatform } from './interfaces/order-with-platform.type';
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
import { Currency, Type } from '@prisma/client';
|
import { Currency, DataSource, Type } from '@prisma/client';
|
||||||
import { IsISO8601, IsNumber, IsString, ValidateIf } from 'class-validator';
|
import { IsISO8601, IsNumber, IsString, ValidateIf } from 'class-validator';
|
||||||
|
|
||||||
export class UpdateOrderDto {
|
export class UpdateOrderDto {
|
||||||
|
@IsString()
|
||||||
|
accountId: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
currency: Currency;
|
currency: Currency;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
dataSource: DataSource;
|
||||||
|
|
||||||
@IsISO8601()
|
@IsISO8601()
|
||||||
date: string;
|
date: string;
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
import { Currency } from '@prisma/client';
|
||||||
|
|
||||||
export interface PortfolioPositionDetail {
|
export interface PortfolioPositionDetail {
|
||||||
averagePrice: number;
|
averagePrice: number;
|
||||||
currency: string;
|
currency: Currency;
|
||||||
firstBuyDate: string;
|
firstBuyDate: string;
|
||||||
grossPerformance: number;
|
grossPerformance: number;
|
||||||
grossPerformancePercent: number;
|
grossPerformancePercent: number;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { MarketState } from '@ghostfolio/api/services/interfaces/interfaces';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
|
|
||||||
export interface PortfolioPosition {
|
export interface PortfolioPosition {
|
||||||
@ -7,10 +8,10 @@ export interface PortfolioPosition {
|
|||||||
grossPerformancePercent: number;
|
grossPerformancePercent: number;
|
||||||
industry?: string;
|
industry?: string;
|
||||||
investment: number;
|
investment: number;
|
||||||
isMarketOpen: boolean;
|
|
||||||
marketChange?: number;
|
marketChange?: number;
|
||||||
marketChangePercent?: number;
|
marketChangePercent?: number;
|
||||||
marketPrice: number;
|
marketPrice: number;
|
||||||
|
marketState: MarketState;
|
||||||
name: string;
|
name: string;
|
||||||
platforms: {
|
platforms: {
|
||||||
[name: string]: { current: number; original: number };
|
[name: string]: { current: number; original: number };
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
import {
|
||||||
|
hasNotDefinedValuesInObject,
|
||||||
|
nullifyValuesInObject
|
||||||
|
} from '@ghostfolio/api/helper/object.helper';
|
||||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { ImpersonationService } from '@ghostfolio/api/services/impersonation.service';
|
||||||
|
import { getPermissions, hasPermission, permissions } from '@ghostfolio/helper';
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
@ -13,14 +20,7 @@ import { REQUEST } from '@nestjs/core';
|
|||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
import { getPermissions, hasPermission, permissions } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import {
|
|
||||||
hasNotDefinedValuesInObject,
|
|
||||||
nullifyValuesInObject
|
|
||||||
} from '../../helper/object.helper';
|
|
||||||
import { ExchangeRateDataService } from '../../services/exchange-rate-data.service';
|
|
||||||
import { ImpersonationService } from '../../services/impersonation.service';
|
|
||||||
import { RequestWithUser } from '../interfaces/request-with-user.type';
|
import { RequestWithUser } from '../interfaces/request-with-user.type';
|
||||||
import { PortfolioItem } from './interfaces/portfolio-item.interface';
|
import { PortfolioItem } from './interfaces/portfolio-item.interface';
|
||||||
import { PortfolioOverview } from './interfaces/portfolio-overview.interface';
|
import { PortfolioOverview } from './interfaces/portfolio-overview.interface';
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
||||||
|
import { AlphaVantageService } from '@ghostfolio/api/services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
|
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
|
import { RakutenRapidApiService } from '@ghostfolio/api/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
|
import { YahooFinanceService } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { ImpersonationService } from '@ghostfolio/api/services/impersonation.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
|
import { RulesService } from '@ghostfolio/api/services/rules.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
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';
|
|
||||||
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
|
||||||
import { YahooFinanceService } from '../../services/data-provider/yahoo-finance/yahoo-finance.service';
|
|
||||||
import { ExchangeRateDataService } from '../../services/exchange-rate-data.service';
|
|
||||||
import { ImpersonationService } from '../../services/impersonation.service';
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { RulesService } from '../../services/rules.service';
|
|
||||||
import { CacheService } from '../cache/cache.service';
|
import { CacheService } from '../cache/cache.service';
|
||||||
import { OrderService } from '../order/order.service';
|
import { OrderService } from '../order/order.service';
|
||||||
import { RedisCacheModule } from '../redis-cache/redis-cache.module';
|
import { RedisCacheModule } from '../redis-cache/redis-cache.module';
|
||||||
@ -22,9 +24,11 @@ import { PortfolioService } from './portfolio.service';
|
|||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
CacheService,
|
CacheService,
|
||||||
|
ConfigurationService,
|
||||||
DataGatheringService,
|
DataGatheringService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
|
GhostfolioScraperApiService,
|
||||||
ImpersonationService,
|
ImpersonationService,
|
||||||
OrderService,
|
OrderService,
|
||||||
PortfolioService,
|
PortfolioService,
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
|
import { RequestWithUser } from '@ghostfolio/api/app/interfaces/request-with-user.type';
|
||||||
|
import { Portfolio } from '@ghostfolio/api/models/portfolio';
|
||||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
||||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { ImpersonationService } from '@ghostfolio/api/services/impersonation.service';
|
||||||
|
import { IOrder } from '@ghostfolio/api/services/interfaces/interfaces';
|
||||||
|
import { RulesService } from '@ghostfolio/api/services/rules.service';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { RequestWithUser } from 'apps/api/src/app/interfaces/request-with-user.type';
|
|
||||||
import {
|
import {
|
||||||
add,
|
add,
|
||||||
format,
|
format,
|
||||||
@ -9,7 +15,6 @@ import {
|
|||||||
getYear,
|
getYear,
|
||||||
isAfter,
|
isAfter,
|
||||||
isSameDay,
|
isSameDay,
|
||||||
parse,
|
|
||||||
parseISO,
|
parseISO,
|
||||||
setDate,
|
setDate,
|
||||||
setMonth,
|
setMonth,
|
||||||
@ -18,12 +23,6 @@ import {
|
|||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
import * as roundTo from 'round-to';
|
import * as roundTo from 'round-to';
|
||||||
|
|
||||||
import { Portfolio } from '../../models/portfolio';
|
|
||||||
import { DataProviderService } from '../../services/data-provider.service';
|
|
||||||
import { ExchangeRateDataService } from '../../services/exchange-rate-data.service';
|
|
||||||
import { ImpersonationService } from '../../services/impersonation.service';
|
|
||||||
import { IOrder } from '../../services/interfaces/interfaces';
|
|
||||||
import { RulesService } from '../../services/rules.service';
|
|
||||||
import { OrderService } from '../order/order.service';
|
import { OrderService } from '../order/order.service';
|
||||||
import { RedisCacheService } from '../redis-cache/redis-cache.service';
|
import { RedisCacheService } from '../redis-cache/redis-cache.service';
|
||||||
import { UserService } from '../user/user.service';
|
import { UserService } from '../user/user.service';
|
||||||
@ -48,53 +47,6 @@ export class PortfolioService {
|
|||||||
private readonly userService: UserService
|
private readonly userService: UserService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private convertDateRangeToDate(aDateRange: DateRange, aMinDate: Date) {
|
|
||||||
let currentDate = new Date();
|
|
||||||
|
|
||||||
const normalizedMinDate =
|
|
||||||
getDate(aMinDate) === 1
|
|
||||||
? aMinDate
|
|
||||||
: add(setDate(aMinDate, 1), { months: 1 });
|
|
||||||
|
|
||||||
const year = getYear(currentDate);
|
|
||||||
const month = getMonth(currentDate);
|
|
||||||
const day = getDate(currentDate);
|
|
||||||
|
|
||||||
currentDate = new Date(Date.UTC(year, month, day, 0));
|
|
||||||
|
|
||||||
switch (aDateRange) {
|
|
||||||
case '1d':
|
|
||||||
return sub(currentDate, {
|
|
||||||
days: 1
|
|
||||||
});
|
|
||||||
case 'ytd':
|
|
||||||
currentDate = setDate(currentDate, 1);
|
|
||||||
currentDate = setMonth(currentDate, 0);
|
|
||||||
return isAfter(currentDate, normalizedMinDate)
|
|
||||||
? currentDate
|
|
||||||
: undefined;
|
|
||||||
case '1y':
|
|
||||||
currentDate = setDate(currentDate, 1);
|
|
||||||
currentDate = sub(currentDate, {
|
|
||||||
years: 1
|
|
||||||
});
|
|
||||||
return isAfter(currentDate, normalizedMinDate)
|
|
||||||
? currentDate
|
|
||||||
: undefined;
|
|
||||||
case '5y':
|
|
||||||
currentDate = setDate(currentDate, 1);
|
|
||||||
currentDate = sub(currentDate, {
|
|
||||||
years: 5
|
|
||||||
});
|
|
||||||
return isAfter(currentDate, normalizedMinDate)
|
|
||||||
? currentDate
|
|
||||||
: undefined;
|
|
||||||
default:
|
|
||||||
// Gets handled as all data
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async createPortfolio(aUserId: string): Promise<Portfolio> {
|
public async createPortfolio(aUserId: string): Promise<Portfolio> {
|
||||||
let portfolio: Portfolio;
|
let portfolio: Portfolio;
|
||||||
let stringifiedPortfolio = await this.redisCacheService.get(
|
let stringifiedPortfolio = await this.redisCacheService.get(
|
||||||
@ -382,4 +334,51 @@ export class PortfolioService {
|
|||||||
symbol: aSymbol
|
symbol: aSymbol
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private convertDateRangeToDate(aDateRange: DateRange, aMinDate: Date) {
|
||||||
|
let currentDate = new Date();
|
||||||
|
|
||||||
|
const normalizedMinDate =
|
||||||
|
getDate(aMinDate) === 1
|
||||||
|
? aMinDate
|
||||||
|
: add(setDate(aMinDate, 1), { months: 1 });
|
||||||
|
|
||||||
|
const year = getYear(currentDate);
|
||||||
|
const month = getMonth(currentDate);
|
||||||
|
const day = getDate(currentDate);
|
||||||
|
|
||||||
|
currentDate = new Date(Date.UTC(year, month, day, 0));
|
||||||
|
|
||||||
|
switch (aDateRange) {
|
||||||
|
case '1d':
|
||||||
|
return sub(currentDate, {
|
||||||
|
days: 1
|
||||||
|
});
|
||||||
|
case 'ytd':
|
||||||
|
currentDate = setDate(currentDate, 1);
|
||||||
|
currentDate = setMonth(currentDate, 0);
|
||||||
|
return isAfter(currentDate, normalizedMinDate)
|
||||||
|
? currentDate
|
||||||
|
: undefined;
|
||||||
|
case '1y':
|
||||||
|
currentDate = setDate(currentDate, 1);
|
||||||
|
currentDate = sub(currentDate, {
|
||||||
|
years: 1
|
||||||
|
});
|
||||||
|
return isAfter(currentDate, normalizedMinDate)
|
||||||
|
? currentDate
|
||||||
|
: undefined;
|
||||||
|
case '5y':
|
||||||
|
currentDate = setDate(currentDate, 1);
|
||||||
|
currentDate = sub(currentDate, {
|
||||||
|
years: 5
|
||||||
|
});
|
||||||
|
return isAfter(currentDate, normalizedMinDate)
|
||||||
|
? currentDate
|
||||||
|
: undefined;
|
||||||
|
default:
|
||||||
|
// Gets handled as all data
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import { CacheModule, Module } from '@nestjs/common';
|
import { CacheModule, Module } from '@nestjs/common';
|
||||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||||
import * as redisStore from 'cache-manager-redis-store';
|
import * as redisStore from 'cache-manager-redis-store';
|
||||||
@ -9,16 +10,16 @@ import { RedisCacheService } from './redis-cache.service';
|
|||||||
CacheModule.registerAsync({
|
CacheModule.registerAsync({
|
||||||
imports: [ConfigModule],
|
imports: [ConfigModule],
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
useFactory: async (configService: ConfigService) => ({
|
useFactory: async (configurationService: ConfigurationService) => ({
|
||||||
host: configService.get('REDIS_HOST'),
|
host: configurationService.get('REDIS_HOST'),
|
||||||
max: configService.get('MAX_ITEM_IN_CACHE'),
|
max: configurationService.get('MAX_ITEM_IN_CACHE'),
|
||||||
port: configService.get('REDIS_PORT'),
|
port: configurationService.get('REDIS_PORT'),
|
||||||
store: redisStore,
|
store: redisStore,
|
||||||
ttl: configService.get('CACHE_TTL')
|
ttl: configurationService.get('CACHE_TTL')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
providers: [RedisCacheService],
|
providers: [ConfigurationService, RedisCacheService],
|
||||||
exports: [RedisCacheService]
|
exports: [RedisCacheService]
|
||||||
})
|
})
|
||||||
export class RedisCacheModule {}
|
export class RedisCacheModule {}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
|
import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
|
||||||
import { Cache } from 'cache-manager';
|
import { Cache } from 'cache-manager';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RedisCacheService {
|
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> {
|
public async get(key: string): Promise<string> {
|
||||||
return await this.cache.get(key);
|
return await this.cache.get(key);
|
||||||
@ -18,6 +22,8 @@ export class RedisCacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async set(key: string, value: string) {
|
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,6 +1,7 @@
|
|||||||
import { Currency } from '@prisma/client';
|
import { Currency, DataSource } from '@prisma/client';
|
||||||
|
|
||||||
export interface SymbolItem {
|
export interface SymbolItem {
|
||||||
currency: Currency;
|
currency: Currency;
|
||||||
|
dataSource: DataSource;
|
||||||
marketPrice: number;
|
marketPrice: number;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { RequestWithUser } from '@ghostfolio/api/app/interfaces/request-with-user.type';
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
@ -9,7 +10,6 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { RequestWithUser } from 'apps/api/src/app/interfaces/request-with-user.type';
|
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
|
|
||||||
import { LookupItem } from './interfaces/lookup-item.interface';
|
import { LookupItem } from './interfaces/lookup-item.interface';
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
||||||
|
import { AlphaVantageService } from '@ghostfolio/api/services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
|
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
|
import { RakutenRapidApiService } from '@ghostfolio/api/services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
|
import { YahooFinanceService } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
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';
|
|
||||||
import { YahooFinanceService } from '../../services/data-provider/yahoo-finance/yahoo-finance.service';
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { SymbolController } from './symbol.controller';
|
import { SymbolController } from './symbol.controller';
|
||||||
import { SymbolService } from './symbol.service';
|
import { SymbolService } from './symbol.service';
|
||||||
|
|
||||||
@ -13,7 +15,9 @@ import { SymbolService } from './symbol.service';
|
|||||||
controllers: [SymbolController],
|
controllers: [SymbolController],
|
||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
|
GhostfolioScraperApiService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
RakutenRapidApiService,
|
RakutenRapidApiService,
|
||||||
SymbolService,
|
SymbolService,
|
||||||
|
@ -1,40 +1,62 @@
|
|||||||
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
||||||
|
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
|
import { convertFromYahooSymbol } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
import { convertFromYahooSymbol } from 'apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service';
|
|
||||||
import * as bent from 'bent';
|
import * as bent from 'bent';
|
||||||
|
|
||||||
import { DataProviderService } from '../../services/data-provider.service';
|
|
||||||
import { LookupItem } from './interfaces/lookup-item.interface';
|
import { LookupItem } from './interfaces/lookup-item.interface';
|
||||||
import { SymbolItem } from './interfaces/symbol-item.interface';
|
import { SymbolItem } from './interfaces/symbol-item.interface';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SymbolService {
|
export class SymbolService {
|
||||||
public constructor(
|
public constructor(
|
||||||
private readonly dataProviderService: DataProviderService
|
private readonly dataProviderService: DataProviderService,
|
||||||
|
private readonly ghostfolioScraperApiService: GhostfolioScraperApiService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async get(aSymbol: string): Promise<SymbolItem> {
|
public async get(aSymbol: string): Promise<SymbolItem> {
|
||||||
const response = await this.dataProviderService.get([aSymbol]);
|
const response = await this.dataProviderService.get([aSymbol]);
|
||||||
const { currency, marketPrice } = response[aSymbol];
|
const { currency, dataSource, marketPrice } = response[aSymbol];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
dataSource,
|
||||||
marketPrice,
|
marketPrice,
|
||||||
currency: <Currency>(<unknown>currency)
|
currency: <Currency>(<unknown>currency)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async lookup(aQuery: string): Promise<LookupItem[]> {
|
public async lookup(aQuery = ''): Promise<LookupItem[]> {
|
||||||
|
const query = aQuery.toLowerCase();
|
||||||
|
const results: LookupItem[] = [];
|
||||||
|
|
||||||
|
if (!query) {
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
const get = bent(
|
const get = bent(
|
||||||
`https://query1.finance.yahoo.com/v1/finance/search?q=${aQuery}&lang=en-US®ion=US"esCount=8&newsCount=0&enableFuzzyQuery=false"esQueryId=tss_match_phrase_query&multiQuoteQueryId=multi_quote_single_token_query&newsQueryId=news_cie_vespa&enableCb=true&enableNavLinks=false&enableEnhancedTrivialQuery=true`,
|
`https://query1.finance.yahoo.com/v1/finance/search?q=${query}&lang=en-US®ion=US"esCount=8&newsCount=0&enableFuzzyQuery=false"esQueryId=tss_match_phrase_query&multiQuoteQueryId=multi_quote_single_token_query&newsQueryId=news_cie_vespa&enableCb=true&enableNavLinks=false&enableEnhancedTrivialQuery=true`,
|
||||||
'GET',
|
'GET',
|
||||||
'json',
|
'json',
|
||||||
200
|
200
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add custom symbols
|
||||||
|
const scraperConfigurations = await this.ghostfolioScraperApiService.getScraperConfigurations();
|
||||||
|
scraperConfigurations.forEach((scraperConfiguration) => {
|
||||||
|
if (scraperConfiguration.name.toLowerCase().startsWith(query)) {
|
||||||
|
results.push({
|
||||||
|
name: scraperConfiguration.name,
|
||||||
|
symbol: scraperConfiguration.symbol
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { quotes } = await get();
|
const { quotes } = await get();
|
||||||
|
|
||||||
return quotes
|
const searchResult = quotes
|
||||||
.filter(({ isYahooFinance }) => {
|
.filter(({ isYahooFinance }) => {
|
||||||
return isYahooFinance;
|
return isYahooFinance;
|
||||||
})
|
})
|
||||||
@ -59,6 +81,8 @@ export class SymbolService {
|
|||||||
symbol: convertFromYahooSymbol(symbol)
|
symbol: convertFromYahooSymbol(symbol)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return results.concat(searchResult);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import { Currency } from '@prisma/client';
|
import { Account, Currency } from '@prisma/client';
|
||||||
|
|
||||||
import { Access } from './access.interface';
|
import { Access } from './access.interface';
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
access: Access[];
|
access: Access[];
|
||||||
|
accounts: Account[];
|
||||||
alias?: string;
|
alias?: string;
|
||||||
id: string;
|
id: string;
|
||||||
permissions: string[];
|
permissions: string[];
|
||||||
settings: UserSettings;
|
settings: UserSettings;
|
||||||
subscription: {
|
subscription: {
|
||||||
expiresAt: Date;
|
expiresAt: Date;
|
||||||
type: 'Diamond';
|
type: 'Trial';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { RequestWithUser } from '@ghostfolio/api/app/interfaces/request-with-user.type';
|
||||||
|
import { getPermissions, hasPermission, permissions } from '@ghostfolio/helper';
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
@ -13,9 +15,7 @@ import { REQUEST } from '@nestjs/core';
|
|||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { Provider } from '@prisma/client';
|
import { Provider } from '@prisma/client';
|
||||||
import { RequestWithUser } from 'apps/api/src/app/interfaces/request-with-user.type';
|
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
import { getPermissions, hasPermission, permissions } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { UserItem } from './interfaces/user-item.interface';
|
import { UserItem } from './interfaces/user-item.interface';
|
||||||
import { User } from './interfaces/user.interface';
|
import { User } from './interfaces/user.interface';
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { UserController } from './user.controller';
|
import { UserController } from './user.controller';
|
||||||
import { UserService } from './user.service';
|
import { UserService } from './user.service';
|
||||||
|
|
||||||
@ -13,6 +14,6 @@ import { UserService } from './user.service';
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
controllers: [UserController],
|
controllers: [UserController],
|
||||||
providers: [PrismaService, UserService]
|
providers: [ConfigurationService, PrismaService, UserService]
|
||||||
})
|
})
|
||||||
export class UserModule {}
|
export class UserModule {}
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
|
import {
|
||||||
|
getPermissions,
|
||||||
|
locale,
|
||||||
|
permissions,
|
||||||
|
resetHours
|
||||||
|
} from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Currency, Prisma, Provider, User } from '@prisma/client';
|
import { Currency, Prisma, Provider, User } from '@prisma/client';
|
||||||
import { add } from 'date-fns';
|
import { add } from 'date-fns';
|
||||||
import { locale, resetHours } from 'libs/helper/src';
|
|
||||||
import { getPermissions } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
|
||||||
import { UserWithSettings } from '../interfaces/user-with-settings';
|
import { UserWithSettings } from '../interfaces/user-with-settings';
|
||||||
import { User as IUser } from './interfaces/user.interface';
|
import { User as IUser } from './interfaces/user.interface';
|
||||||
|
|
||||||
@ -14,9 +19,13 @@ const crypto = require('crypto');
|
|||||||
export class UserService {
|
export class UserService {
|
||||||
public static DEFAULT_CURRENCY = Currency.USD;
|
public static DEFAULT_CURRENCY = Currency.USD;
|
||||||
|
|
||||||
public constructor(private prisma: PrismaService) {}
|
public constructor(
|
||||||
|
private readonly configurationService: ConfigurationService,
|
||||||
|
private prisma: PrismaService
|
||||||
|
) {}
|
||||||
|
|
||||||
public async getUser({
|
public async getUser({
|
||||||
|
Account,
|
||||||
alias,
|
alias,
|
||||||
id,
|
id,
|
||||||
role,
|
role,
|
||||||
@ -30,6 +39,12 @@ export class UserService {
|
|||||||
where: { GranteeUser: { id } }
|
where: { GranteeUser: { id } }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const currentPermissions = getPermissions(role);
|
||||||
|
|
||||||
|
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
||||||
|
currentPermissions.push(permissions.accessFearAndGreedIndex);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
alias,
|
alias,
|
||||||
id,
|
id,
|
||||||
@ -39,14 +54,15 @@ export class UserService {
|
|||||||
id: accessItem.id
|
id: accessItem.id
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
permissions: getPermissions(role),
|
accounts: Account,
|
||||||
|
permissions: currentPermissions,
|
||||||
settings: {
|
settings: {
|
||||||
baseCurrency: Settings?.currency || UserService.DEFAULT_CURRENCY,
|
baseCurrency: Settings?.currency || UserService.DEFAULT_CURRENCY,
|
||||||
locale
|
locale
|
||||||
},
|
},
|
||||||
subscription: {
|
subscription: {
|
||||||
expiresAt: resetHours(add(new Date(), { days: 7 })),
|
expiresAt: resetHours(add(new Date(), { days: 7 })),
|
||||||
type: 'Diamond'
|
type: 'Trial'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -55,7 +71,7 @@ export class UserService {
|
|||||||
userWhereUniqueInput: Prisma.UserWhereUniqueInput
|
userWhereUniqueInput: Prisma.UserWhereUniqueInput
|
||||||
): Promise<UserWithSettings | null> {
|
): Promise<UserWithSettings | null> {
|
||||||
const user = await this.prisma.user.findUnique({
|
const user = await this.prisma.user.findUnique({
|
||||||
include: { Settings: true },
|
include: { Account: true, Settings: true },
|
||||||
where: userWhereUniqueInput
|
where: userWhereUniqueInput
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -102,7 +118,15 @@ export class UserService {
|
|||||||
|
|
||||||
public async createUser(data?: Prisma.UserCreateInput): Promise<User> {
|
public async createUser(data?: Prisma.UserCreateInput): Promise<User> {
|
||||||
let user = await this.prisma.user.create({
|
let user = await this.prisma.user.create({
|
||||||
data
|
data: {
|
||||||
|
...data,
|
||||||
|
Account: {
|
||||||
|
create: {
|
||||||
|
isDefault: true,
|
||||||
|
name: 'Default Account'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.provider === Provider.ANONYMOUS) {
|
if (data.provider === Provider.ANONYMOUS) {
|
||||||
@ -144,18 +168,6 @@ export class UserService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRandomString(length: number) {
|
|
||||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
||||||
const result = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
result.push(
|
|
||||||
characters.charAt(Math.floor(Math.random() * characters.length))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return result.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
public async updateUserSettings({
|
public async updateUserSettings({
|
||||||
currency,
|
currency,
|
||||||
userId
|
userId
|
||||||
@ -182,4 +194,16 @@ export class UserService {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getRandomString(length: number) {
|
||||||
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||||
|
const result = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
result.push(
|
||||||
|
characters.charAt(Math.floor(Math.random() * characters.length))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result.join('');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
PortfolioItem,
|
PortfolioItem,
|
||||||
Position
|
Position
|
||||||
} from 'apps/api/src/app/portfolio/interfaces/portfolio-item.interface';
|
} from '@ghostfolio/api/app/portfolio/interfaces/portfolio-item.interface';
|
||||||
|
|
||||||
import { Order } from '../order';
|
import { Order } from '../order';
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { PortfolioPosition } from '../../app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
|
|
||||||
import { EvaluationResult } from './evaluation-result.interface';
|
import { EvaluationResult } from './evaluation-result.interface';
|
||||||
|
|
||||||
export interface RuleInterface {
|
export interface RuleInterface {
|
||||||
|
@ -1,22 +1,28 @@
|
|||||||
|
import { baseCurrency, getUtc, getYesterday } from '@ghostfolio/helper';
|
||||||
import { Test } from '@nestjs/testing';
|
import { Test } from '@nestjs/testing';
|
||||||
import { Currency, Role, Type } from '@prisma/client';
|
import { Currency, Role, Type } from '@prisma/client';
|
||||||
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 { DataProviderService } from '../services/data-provider.service';
|
||||||
import { AlphaVantageService } from '../services/data-provider/alpha-vantage/alpha-vantage.service';
|
import { AlphaVantageService } from '../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
|
import { GhostfolioScraperApiService } from '../services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
import { RakutenRapidApiService } from '../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
import { RakutenRapidApiService } from '../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
import { YahooFinanceService } from '../services/data-provider/yahoo-finance/yahoo-finance.service';
|
import { YahooFinanceService } from '../services/data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
import { ExchangeRateDataService } from '../services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '../services/exchange-rate-data.service';
|
||||||
|
import { MarketState } from '../services/interfaces/interfaces';
|
||||||
import { PrismaService } from '../services/prisma.service';
|
import { PrismaService } from '../services/prisma.service';
|
||||||
import { RulesService } from '../services/rules.service';
|
import { RulesService } from '../services/rules.service';
|
||||||
import { Portfolio } from './portfolio';
|
import { Portfolio } from './portfolio';
|
||||||
|
|
||||||
|
const DEFAULT_ACCOUNT_ID = '693a834b-eb89-42c9-ae47-35196c25d269';
|
||||||
|
const USER_ID = 'ca6ce867-5d31-495a-bce9-5942bbca9237';
|
||||||
|
|
||||||
describe('Portfolio', () => {
|
describe('Portfolio', () => {
|
||||||
let alphaVantageService: AlphaVantageService;
|
let alphaVantageService: AlphaVantageService;
|
||||||
|
let configurationService: ConfigurationService;
|
||||||
let dataProviderService: DataProviderService;
|
let dataProviderService: DataProviderService;
|
||||||
let exchangeRateDataService: ExchangeRateDataService;
|
let exchangeRateDataService: ExchangeRateDataService;
|
||||||
|
let ghostfolioScraperApiService: GhostfolioScraperApiService;
|
||||||
let portfolio: Portfolio;
|
let portfolio: Portfolio;
|
||||||
let prismaService: PrismaService;
|
let prismaService: PrismaService;
|
||||||
let rakutenRapidApiService: RakutenRapidApiService;
|
let rakutenRapidApiService: RakutenRapidApiService;
|
||||||
@ -28,8 +34,10 @@ describe('Portfolio', () => {
|
|||||||
imports: [],
|
imports: [],
|
||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
|
GhostfolioScraperApiService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
RakutenRapidApiService,
|
RakutenRapidApiService,
|
||||||
RulesService,
|
RulesService,
|
||||||
@ -38,10 +46,14 @@ describe('Portfolio', () => {
|
|||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
alphaVantageService = app.get<AlphaVantageService>(AlphaVantageService);
|
alphaVantageService = app.get<AlphaVantageService>(AlphaVantageService);
|
||||||
|
configurationService = app.get<ConfigurationService>(ConfigurationService);
|
||||||
dataProviderService = app.get<DataProviderService>(DataProviderService);
|
dataProviderService = app.get<DataProviderService>(DataProviderService);
|
||||||
exchangeRateDataService = app.get<ExchangeRateDataService>(
|
exchangeRateDataService = app.get<ExchangeRateDataService>(
|
||||||
ExchangeRateDataService
|
ExchangeRateDataService
|
||||||
);
|
);
|
||||||
|
ghostfolioScraperApiService = app.get<GhostfolioScraperApiService>(
|
||||||
|
GhostfolioScraperApiService
|
||||||
|
);
|
||||||
prismaService = app.get<PrismaService>(PrismaService);
|
prismaService = app.get<PrismaService>(PrismaService);
|
||||||
rakutenRapidApiService = app.get<RakutenRapidApiService>(
|
rakutenRapidApiService = app.get<RakutenRapidApiService>(
|
||||||
RakutenRapidApiService
|
RakutenRapidApiService
|
||||||
@ -60,13 +72,13 @@ describe('Portfolio', () => {
|
|||||||
accessToken: null,
|
accessToken: null,
|
||||||
alias: 'Test',
|
alias: 'Test',
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
id: '',
|
id: USER_ID,
|
||||||
provider: null,
|
provider: null,
|
||||||
role: Role.USER,
|
role: Role.USER,
|
||||||
Settings: {
|
Settings: {
|
||||||
currency: Currency.CHF,
|
currency: Currency.CHF,
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
userId: ''
|
userId: USER_ID
|
||||||
},
|
},
|
||||||
thirdPartyId: null,
|
thirdPartyId: null,
|
||||||
updatedAt: new Date()
|
updatedAt: new Date()
|
||||||
@ -117,6 +129,8 @@ describe('Portfolio', () => {
|
|||||||
it('should return ["BTC"]', async () => {
|
it('should return ["BTC"]', async () => {
|
||||||
await portfolio.setOrders([
|
await portfolio.setOrders([
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.USD,
|
currency: Currency.USD,
|
||||||
fee: 0,
|
fee: 0,
|
||||||
@ -128,7 +142,7 @@ describe('Portfolio', () => {
|
|||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
unitPrice: 49631.24,
|
unitPrice: 49631.24,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -152,8 +166,8 @@ describe('Portfolio', () => {
|
|||||||
Currency.USD,
|
Currency.USD,
|
||||||
baseCurrency
|
baseCurrency
|
||||||
),
|
),
|
||||||
isMarketOpen: true,
|
|
||||||
// marketPrice: 57973.008,
|
// marketPrice: 57973.008,
|
||||||
|
marketState: MarketState.open,
|
||||||
name: 'Bitcoin USD',
|
name: 'Bitcoin USD',
|
||||||
platforms: {
|
platforms: {
|
||||||
Other: {
|
Other: {
|
||||||
@ -215,6 +229,8 @@ describe('Portfolio', () => {
|
|||||||
it('should return ["ETHUSD"]', async () => {
|
it('should return ["ETHUSD"]', async () => {
|
||||||
await portfolio.setOrders([
|
await portfolio.setOrders([
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.USD,
|
currency: Currency.USD,
|
||||||
fee: 0,
|
fee: 0,
|
||||||
@ -226,7 +242,7 @@ describe('Portfolio', () => {
|
|||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
unitPrice: 991.49,
|
unitPrice: 991.49,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -267,7 +283,7 @@ describe('Portfolio', () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
quantity: 0.2,
|
quantity: 0.2,
|
||||||
shareCurrent: 1,
|
// shareCurrent: 1,
|
||||||
shareInvestment: 1,
|
shareInvestment: 1,
|
||||||
symbol: 'ETHUSD',
|
symbol: 'ETHUSD',
|
||||||
type: 'Cryptocurrency'
|
type: 'Cryptocurrency'
|
||||||
@ -307,6 +323,8 @@ describe('Portfolio', () => {
|
|||||||
it('should return ["ETHUSD"]', async () => {
|
it('should return ["ETHUSD"]', async () => {
|
||||||
await portfolio.setOrders([
|
await portfolio.setOrders([
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.USD,
|
currency: Currency.USD,
|
||||||
fee: 0,
|
fee: 0,
|
||||||
@ -318,9 +336,11 @@ describe('Portfolio', () => {
|
|||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
unitPrice: 991.49,
|
unitPrice: 991.49,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.USD,
|
currency: Currency.USD,
|
||||||
fee: 0,
|
fee: 0,
|
||||||
@ -332,7 +352,7 @@ describe('Portfolio', () => {
|
|||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
unitPrice: 1050,
|
unitPrice: 1050,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -379,6 +399,8 @@ describe('Portfolio', () => {
|
|||||||
it('should return ["BTCUSD", "ETHUSD"]', async () => {
|
it('should return ["BTCUSD", "ETHUSD"]', async () => {
|
||||||
await portfolio.setOrders([
|
await portfolio.setOrders([
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.EUR,
|
currency: Currency.EUR,
|
||||||
date: new Date(getUtc('2017-08-16')),
|
date: new Date(getUtc('2017-08-16')),
|
||||||
@ -390,9 +412,11 @@ describe('Portfolio', () => {
|
|||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
unitPrice: 3562.089535970158,
|
unitPrice: 3562.089535970158,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.USD,
|
currency: Currency.USD,
|
||||||
fee: 2.99,
|
fee: 2.99,
|
||||||
@ -404,7 +428,7 @@ describe('Portfolio', () => {
|
|||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
unitPrice: 991.49,
|
unitPrice: 991.49,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -464,6 +488,8 @@ describe('Portfolio', () => {
|
|||||||
it('should work with buy and sell', async () => {
|
it('should work with buy and sell', async () => {
|
||||||
await portfolio.setOrders([
|
await portfolio.setOrders([
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.USD,
|
currency: Currency.USD,
|
||||||
fee: 1.0,
|
fee: 1.0,
|
||||||
@ -475,9 +501,11 @@ describe('Portfolio', () => {
|
|||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
unitPrice: 991.49,
|
unitPrice: 991.49,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.USD,
|
currency: Currency.USD,
|
||||||
fee: 1.0,
|
fee: 1.0,
|
||||||
@ -489,9 +517,11 @@ describe('Portfolio', () => {
|
|||||||
type: Type.SELL,
|
type: Type.SELL,
|
||||||
unitPrice: 1050,
|
unitPrice: 1050,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
accountId: DEFAULT_ACCOUNT_ID,
|
||||||
|
accountUserId: USER_ID,
|
||||||
createdAt: null,
|
createdAt: null,
|
||||||
currency: Currency.USD,
|
currency: Currency.USD,
|
||||||
fee: 1.0,
|
fee: 1.0,
|
||||||
@ -503,7 +533,7 @@ describe('Portfolio', () => {
|
|||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
unitPrice: 1050,
|
unitPrice: 1050,
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
userId: null
|
userId: USER_ID
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
PortfolioItem,
|
PortfolioItem,
|
||||||
Position
|
Position
|
||||||
} from 'apps/api/src/app/portfolio/interfaces/portfolio-item.interface';
|
} from '@ghostfolio/api/app/portfolio/interfaces/portfolio-item.interface';
|
||||||
|
import { getToday, getYesterday, resetHours } from '@ghostfolio/helper';
|
||||||
import {
|
import {
|
||||||
add,
|
add,
|
||||||
format,
|
format,
|
||||||
@ -18,7 +19,6 @@ import {
|
|||||||
setMonth,
|
setMonth,
|
||||||
sub
|
sub
|
||||||
} from 'date-fns';
|
} from 'date-fns';
|
||||||
import { getToday, getYesterday, resetHours } from 'libs/helper/src';
|
|
||||||
import { cloneDeep, isEmpty } from 'lodash';
|
import { cloneDeep, isEmpty } from 'lodash';
|
||||||
import * as roundTo from 'round-to';
|
import * as roundTo from 'round-to';
|
||||||
|
|
||||||
@ -79,7 +79,9 @@ export class Portfolio implements PortfolioInterface {
|
|||||||
investmentInOriginalCurrency:
|
investmentInOriginalCurrency:
|
||||||
portfolioItemsYesterday?.positions[symbol]
|
portfolioItemsYesterday?.positions[symbol]
|
||||||
?.investmentInOriginalCurrency,
|
?.investmentInOriginalCurrency,
|
||||||
marketPrice: currentData[symbol]?.marketPrice,
|
marketPrice:
|
||||||
|
currentData[symbol]?.marketPrice ??
|
||||||
|
portfolioItemsYesterday.positions[symbol]?.marketPrice,
|
||||||
quantity: portfolioItemsYesterday?.positions[symbol]?.quantity
|
quantity: portfolioItemsYesterday?.positions[symbol]?.quantity
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -158,53 +160,6 @@ export class Portfolio implements PortfolioInterface {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private convertDateRangeToDate(aDateRange: DateRange, aMinDate: Date) {
|
|
||||||
let currentDate = new Date();
|
|
||||||
|
|
||||||
const normalizedMinDate =
|
|
||||||
getDate(aMinDate) === 1
|
|
||||||
? aMinDate
|
|
||||||
: add(setDate(aMinDate, 1), { months: 1 });
|
|
||||||
|
|
||||||
const year = getYear(currentDate);
|
|
||||||
const month = getMonth(currentDate);
|
|
||||||
const day = getDate(currentDate);
|
|
||||||
|
|
||||||
currentDate = new Date(Date.UTC(year, month, day, 0));
|
|
||||||
|
|
||||||
switch (aDateRange) {
|
|
||||||
case '1d':
|
|
||||||
return sub(currentDate, {
|
|
||||||
days: 1
|
|
||||||
});
|
|
||||||
case 'ytd':
|
|
||||||
currentDate = setDate(currentDate, 1);
|
|
||||||
currentDate = setMonth(currentDate, 0);
|
|
||||||
return isAfter(currentDate, normalizedMinDate)
|
|
||||||
? currentDate
|
|
||||||
: undefined;
|
|
||||||
case '1y':
|
|
||||||
currentDate = setDate(currentDate, 1);
|
|
||||||
currentDate = sub(currentDate, {
|
|
||||||
years: 1
|
|
||||||
});
|
|
||||||
return isAfter(currentDate, normalizedMinDate)
|
|
||||||
? currentDate
|
|
||||||
: undefined;
|
|
||||||
case '5y':
|
|
||||||
currentDate = setDate(currentDate, 1);
|
|
||||||
currentDate = sub(currentDate, {
|
|
||||||
years: 5
|
|
||||||
});
|
|
||||||
return isAfter(currentDate, normalizedMinDate)
|
|
||||||
? currentDate
|
|
||||||
: undefined;
|
|
||||||
default:
|
|
||||||
// Gets handled as all data
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public get(aDate?: Date): PortfolioItem[] {
|
public get(aDate?: Date): PortfolioItem[] {
|
||||||
if (aDate) {
|
if (aDate) {
|
||||||
const filteredPortfolio = this.portfolioItems.find((item) => {
|
const filteredPortfolio = this.portfolioItems.find((item) => {
|
||||||
@ -528,12 +483,6 @@ export class Portfolio implements PortfolioInterface {
|
|||||||
return this.orders;
|
return this.orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getOrdersByType(aFilter: string[]) {
|
|
||||||
return this.orders.filter((order) => {
|
|
||||||
return aFilter.includes(order.getType());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public getValue(aDate = getToday()) {
|
public getValue(aDate = getToday()) {
|
||||||
const positions = this.getPositions(aDate);
|
const positions = this.getPositions(aDate);
|
||||||
let value = 0;
|
let value = 0;
|
||||||
@ -692,6 +641,53 @@ export class Portfolio implements PortfolioInterface {
|
|||||||
this.updatePortfolioItems();
|
this.updatePortfolioItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private convertDateRangeToDate(aDateRange: DateRange, aMinDate: Date) {
|
||||||
|
let currentDate = new Date();
|
||||||
|
|
||||||
|
const normalizedMinDate =
|
||||||
|
getDate(aMinDate) === 1
|
||||||
|
? aMinDate
|
||||||
|
: add(setDate(aMinDate, 1), { months: 1 });
|
||||||
|
|
||||||
|
const year = getYear(currentDate);
|
||||||
|
const month = getMonth(currentDate);
|
||||||
|
const day = getDate(currentDate);
|
||||||
|
|
||||||
|
currentDate = new Date(Date.UTC(year, month, day, 0));
|
||||||
|
|
||||||
|
switch (aDateRange) {
|
||||||
|
case '1d':
|
||||||
|
return sub(currentDate, {
|
||||||
|
days: 1
|
||||||
|
});
|
||||||
|
case 'ytd':
|
||||||
|
currentDate = setDate(currentDate, 1);
|
||||||
|
currentDate = setMonth(currentDate, 0);
|
||||||
|
return isAfter(currentDate, normalizedMinDate)
|
||||||
|
? currentDate
|
||||||
|
: undefined;
|
||||||
|
case '1y':
|
||||||
|
currentDate = setDate(currentDate, 1);
|
||||||
|
currentDate = sub(currentDate, {
|
||||||
|
years: 1
|
||||||
|
});
|
||||||
|
return isAfter(currentDate, normalizedMinDate)
|
||||||
|
? currentDate
|
||||||
|
: undefined;
|
||||||
|
case '5y':
|
||||||
|
currentDate = setDate(currentDate, 1);
|
||||||
|
currentDate = sub(currentDate, {
|
||||||
|
years: 5
|
||||||
|
});
|
||||||
|
return isAfter(currentDate, normalizedMinDate)
|
||||||
|
? currentDate
|
||||||
|
: undefined;
|
||||||
|
default:
|
||||||
|
// Gets handled as all data
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private updatePortfolioItems() {
|
private updatePortfolioItems() {
|
||||||
// console.time('update-portfolio-items');
|
// console.time('update-portfolio-items');
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
import { groupBy } from '@ghostfolio/helper';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
import { groupBy } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { PortfolioPosition } from '../app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '../app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from '../services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '../services/exchange-rate-data.service';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
|
||||||
import { Rule } from '../../rule';
|
import { Rule } from '../../rule';
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
||||||
|
|
||||||
import { Rule } from '../../rule';
|
import { Rule } from '../../rule';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
||||||
|
|
||||||
import { Rule } from '../../rule';
|
import { Rule } from '../../rule';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
||||||
|
|
||||||
import { Rule } from '../../rule';
|
import { Rule } from '../../rule';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
||||||
|
|
||||||
import { Rule } from '../../rule';
|
import { Rule } from '../../rule';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
|
||||||
import { Rule } from '../../rule';
|
import { Rule } from '../../rule';
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
||||||
|
|
||||||
import { Rule } from '../../rule';
|
import { Rule } from '../../rule';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from 'apps/api/src/services/exchange-rate-data.service';
|
||||||
|
|
||||||
import { Rule } from '../../rule';
|
import { Rule } from '../../rule';
|
||||||
|
34
apps/api/src/services/configuration.service.ts
Normal file
34
apps/api/src/services/configuration.service.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
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_CUSTOM_SYMBOLS: bool({ default: false }),
|
||||||
|
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),
|
||||||
|
ENABLE_FEATURE_SOCIAL_LOGIN: bool({ default: false }),
|
||||||
|
ENABLE_FEATURE_SUBSCRIPTION: 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];
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,10 @@
|
|||||||
|
import {
|
||||||
|
benchmarks,
|
||||||
|
currencyPairs,
|
||||||
|
getUtc,
|
||||||
|
isGhostfolioScraperApiSymbol,
|
||||||
|
resetHours
|
||||||
|
} from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
differenceInHours,
|
differenceInHours,
|
||||||
@ -8,16 +15,18 @@ import {
|
|||||||
isBefore,
|
isBefore,
|
||||||
subDays
|
subDays
|
||||||
} from 'date-fns';
|
} from 'date-fns';
|
||||||
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 { DataProviderService } from './data-provider.service';
|
||||||
|
import { GhostfolioScraperApiService } from './data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
import { PrismaService } from './prisma.service';
|
import { PrismaService } from './prisma.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DataGatheringService {
|
export class DataGatheringService {
|
||||||
public constructor(
|
public constructor(
|
||||||
private dataProviderService: DataProviderService,
|
private readonly configurationService: ConfigurationService,
|
||||||
|
private readonly dataProviderService: DataProviderService,
|
||||||
|
private readonly ghostfolioScraperApi: GhostfolioScraperApiService,
|
||||||
private prisma: PrismaService
|
private prisma: PrismaService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -64,9 +73,11 @@ export class DataGatheringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async gatherMax() {
|
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.log('Max data gathering has been started.');
|
||||||
console.time('data-gathering');
|
console.time('data-gathering');
|
||||||
|
|
||||||
@ -174,22 +185,18 @@ export class DataGatheringService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getSymbols7D(): Promise<{ date: Date; symbol: string }[]> {
|
public async getCustomSymbolsToGather(startDate?: Date) {
|
||||||
const startDate = subDays(resetHours(new Date()), 7);
|
const scraperConfigurations = await this.ghostfolioScraperApi.getScraperConfigurations();
|
||||||
|
|
||||||
let distinctOrders = await this.prisma.order.findMany({
|
return scraperConfigurations.map((scraperConfiguration) => {
|
||||||
distinct: ['symbol'],
|
|
||||||
orderBy: [{ symbol: 'asc' }],
|
|
||||||
select: { symbol: true }
|
|
||||||
});
|
|
||||||
|
|
||||||
const distinctOrdersWithDate = distinctOrders.map((distinctOrder) => {
|
|
||||||
return {
|
return {
|
||||||
...distinctOrder,
|
date: startDate,
|
||||||
date: startDate
|
symbol: scraperConfiguration.symbol
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private getBenchmarksToGather(startDate: Date) {
|
||||||
const benchmarksToGather = benchmarks.map((symbol) => {
|
const benchmarksToGather = benchmarks.map((symbol) => {
|
||||||
return {
|
return {
|
||||||
symbol,
|
symbol,
|
||||||
@ -197,6 +204,36 @@ export class DataGatheringService {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
const distinctOrders = await this.prisma.order.findMany({
|
||||||
|
distinct: ['symbol'],
|
||||||
|
orderBy: [{ symbol: 'asc' }],
|
||||||
|
select: { symbol: true }
|
||||||
|
});
|
||||||
|
|
||||||
|
const distinctOrdersWithDate = distinctOrders
|
||||||
|
.filter((distinctOrder) => {
|
||||||
|
return !isGhostfolioScraperApiSymbol(distinctOrder.symbol);
|
||||||
|
})
|
||||||
|
.map((distinctOrder) => {
|
||||||
|
return {
|
||||||
|
...distinctOrder,
|
||||||
|
date: startDate
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
||||||
return {
|
return {
|
||||||
symbol,
|
symbol,
|
||||||
@ -204,28 +241,24 @@ export class DataGatheringService {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const customSymbolsToGather = await this.getCustomSymbolsToGather(
|
||||||
|
startDate
|
||||||
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...benchmarksToGather,
|
...this.getBenchmarksToGather(startDate),
|
||||||
|
...customSymbolsToGather,
|
||||||
...currencyPairsToGather,
|
...currencyPairsToGather,
|
||||||
...distinctOrdersWithDate
|
...distinctOrdersWithDate
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getSymbolsMax() {
|
private async getSymbolsMax() {
|
||||||
const startDate = new Date(getUtc('2000-01-01'));
|
const startDate = new Date(getUtc('2015-01-01'));
|
||||||
|
|
||||||
let distinctOrders = await this.prisma.order.findMany({
|
const customSymbolsToGather = await this.getCustomSymbolsToGather(
|
||||||
distinct: ['symbol'],
|
startDate
|
||||||
orderBy: [{ date: 'asc' }],
|
);
|
||||||
select: { date: true, symbol: true }
|
|
||||||
});
|
|
||||||
|
|
||||||
const benchmarksToGather = benchmarks.map((symbol) => {
|
|
||||||
return {
|
|
||||||
symbol,
|
|
||||||
date: startDate
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
||||||
return {
|
return {
|
||||||
@ -234,7 +267,18 @@ export class DataGatheringService {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return [...benchmarksToGather, ...currencyPairsToGather, ...distinctOrders];
|
const distinctOrders = await this.prisma.order.findMany({
|
||||||
|
distinct: ['symbol'],
|
||||||
|
orderBy: [{ date: 'asc' }],
|
||||||
|
select: { date: true, symbol: true }
|
||||||
|
});
|
||||||
|
|
||||||
|
return [
|
||||||
|
...this.getBenchmarksToGather(startDate),
|
||||||
|
...customSymbolsToGather,
|
||||||
|
...currencyPairsToGather,
|
||||||
|
...distinctOrders
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private async isDataGatheringNeeded() {
|
private async isDataGatheringNeeded() {
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
|
import {
|
||||||
|
isCrypto,
|
||||||
|
isGhostfolioScraperApiSymbol,
|
||||||
|
isRakutenRapidApiSymbol
|
||||||
|
} from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { MarketData } from '@prisma/client';
|
import { MarketData } from '@prisma/client';
|
||||||
import { format } from 'date-fns';
|
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 { AlphaVantageService } from './data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
|
import { GhostfolioScraperApiService } from './data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
||||||
import { RakutenRapidApiService } from './data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
import { RakutenRapidApiService } from './data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
import { YahooFinanceService } from './data-provider/yahoo-finance/yahoo-finance.service';
|
import { YahooFinanceService } from './data-provider/yahoo-finance/yahoo-finance.service';
|
||||||
import { DataProviderInterface } from './interfaces/data-provider.interface';
|
import { DataProviderInterface } from './interfaces/data-provider.interface';
|
||||||
@ -17,10 +23,12 @@ import { PrismaService } from './prisma.service';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class DataProviderService implements DataProviderInterface {
|
export class DataProviderService implements DataProviderInterface {
|
||||||
public constructor(
|
public constructor(
|
||||||
private alphaVantageService: AlphaVantageService,
|
private readonly alphaVantageService: AlphaVantageService,
|
||||||
|
private readonly configurationService: ConfigurationService,
|
||||||
|
private readonly ghostfolioScraperApiService: GhostfolioScraperApiService,
|
||||||
private prisma: PrismaService,
|
private prisma: PrismaService,
|
||||||
private rakutenRapidApiService: RakutenRapidApiService,
|
private readonly rakutenRapidApiService: RakutenRapidApiService,
|
||||||
private yahooFinanceService: YahooFinanceService
|
private readonly yahooFinanceService: YahooFinanceService
|
||||||
) {
|
) {
|
||||||
this.rakutenRapidApiService.setPrisma(this.prisma);
|
this.rakutenRapidApiService.setPrisma(this.prisma);
|
||||||
}
|
}
|
||||||
@ -31,12 +39,33 @@ export class DataProviderService implements DataProviderInterface {
|
|||||||
if (aSymbols.length === 1) {
|
if (aSymbols.length === 1) {
|
||||||
const symbol = aSymbols[0];
|
const symbol = aSymbols[0];
|
||||||
|
|
||||||
if (isRakutenRapidApi(symbol)) {
|
if (isGhostfolioScraperApiSymbol(symbol)) {
|
||||||
|
return this.ghostfolioScraperApiService.get(aSymbols);
|
||||||
|
} else if (isRakutenRapidApiSymbol(symbol)) {
|
||||||
return this.rakutenRapidApiService.get(aSymbols);
|
return this.rakutenRapidApiService.get(aSymbols);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.yahooFinanceService.get(aSymbols);
|
const yahooFinanceSymbols = aSymbols.filter((symbol) => {
|
||||||
|
return !isGhostfolioScraperApiSymbol(symbol);
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await this.yahooFinanceService.get(yahooFinanceSymbols);
|
||||||
|
|
||||||
|
const ghostfolioScraperApiSymbols = aSymbols.filter((symbol) => {
|
||||||
|
return isGhostfolioScraperApiSymbol(symbol);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const symbol of ghostfolioScraperApiSymbols) {
|
||||||
|
if (symbol) {
|
||||||
|
const ghostfolioScraperApiResult = await this.ghostfolioScraperApiService.get(
|
||||||
|
[symbol]
|
||||||
|
);
|
||||||
|
response[symbol] = ghostfolioScraperApiResult[symbol];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getHistorical(
|
public async getHistorical(
|
||||||
@ -51,12 +80,12 @@ export class DataProviderService implements DataProviderInterface {
|
|||||||
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
|
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
let granularityQuery =
|
const granularityQuery =
|
||||||
aGranularity === 'month'
|
aGranularity === 'month'
|
||||||
? `AND (date_part('day', date) = 1 OR date >= TIMESTAMP 'yesterday')`
|
? `AND (date_part('day', date) = 1 OR date >= TIMESTAMP 'yesterday')`
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
let rangeQuery =
|
const rangeQuery =
|
||||||
from && to
|
from && to
|
||||||
? `AND date >= '${format(from, 'yyyy-MM-dd')}' AND date <= '${format(
|
? `AND date >= '${format(from, 'yyyy-MM-dd')}' AND date <= '${format(
|
||||||
to,
|
to,
|
||||||
@ -97,8 +126,12 @@ export class DataProviderService implements DataProviderInterface {
|
|||||||
): Promise<{
|
): Promise<{
|
||||||
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
|
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
|
||||||
}> {
|
}> {
|
||||||
|
const filteredSymbols = aSymbols.filter((symbol) => {
|
||||||
|
return !isGhostfolioScraperApiSymbol(symbol);
|
||||||
|
});
|
||||||
|
|
||||||
const dataOfYahoo = await this.yahooFinanceService.getHistorical(
|
const dataOfYahoo = await this.yahooFinanceService.getHistorical(
|
||||||
aSymbols,
|
filteredSymbols,
|
||||||
undefined,
|
undefined,
|
||||||
from,
|
from,
|
||||||
to
|
to
|
||||||
@ -107,7 +140,10 @@ export class DataProviderService implements DataProviderInterface {
|
|||||||
if (aSymbols.length === 1) {
|
if (aSymbols.length === 1) {
|
||||||
const symbol = aSymbols[0];
|
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
|
// Merge data from Yahoo with data from Alpha Vantage
|
||||||
const dataOfAlphaVantage = await this.alphaVantageService.getHistorical(
|
const dataOfAlphaVantage = await this.alphaVantageService.getHistorical(
|
||||||
[symbol],
|
[symbol],
|
||||||
@ -122,7 +158,19 @@ export class DataProviderService implements DataProviderInterface {
|
|||||||
...dataOfAlphaVantage[symbol]
|
...dataOfAlphaVantage[symbol]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else if (isRakutenRapidApi(symbol)) {
|
} else if (isGhostfolioScraperApiSymbol(symbol)) {
|
||||||
|
const dataOfGhostfolioScraperApi = await this.ghostfolioScraperApiService.getHistorical(
|
||||||
|
[symbol],
|
||||||
|
undefined,
|
||||||
|
from,
|
||||||
|
to
|
||||||
|
);
|
||||||
|
|
||||||
|
return dataOfGhostfolioScraperApi;
|
||||||
|
} else if (
|
||||||
|
isRakutenRapidApiSymbol(symbol) &&
|
||||||
|
this.configurationService.get('RAKUTEN_RAPID_API_KEY')
|
||||||
|
) {
|
||||||
const dataOfRakutenRapidApi = await this.rakutenRapidApiService.getHistorical(
|
const dataOfRakutenRapidApi = await this.rakutenRapidApiService.getHistorical(
|
||||||
[symbol],
|
[symbol],
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { isAfter, isBefore, parse } from 'date-fns';
|
import { isAfter, isBefore, parse } from 'date-fns';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../configuration.service';
|
||||||
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
||||||
import { Granularity } from '../../interfaces/granularity.type';
|
import { Granularity } from '../../interfaces/granularity.type';
|
||||||
import {
|
import {
|
||||||
@ -9,13 +10,17 @@ import {
|
|||||||
} from '../../interfaces/interfaces';
|
} from '../../interfaces/interfaces';
|
||||||
import { IAlphaVantageHistoricalResponse } from './interfaces/interfaces';
|
import { IAlphaVantageHistoricalResponse } from './interfaces/interfaces';
|
||||||
|
|
||||||
const alphaVantage = require('alphavantage')({
|
|
||||||
key: process.env.ALPHA_VANTAGE_API_KEY
|
|
||||||
});
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlphaVantageService implements DataProviderInterface {
|
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(
|
public async get(
|
||||||
aSymbols: string[]
|
aSymbols: string[]
|
||||||
@ -40,7 +45,7 @@ export class AlphaVantageService implements DataProviderInterface {
|
|||||||
try {
|
try {
|
||||||
const historicalData: {
|
const historicalData: {
|
||||||
[symbol: string]: IAlphaVantageHistoricalResponse[];
|
[symbol: string]: IAlphaVantageHistoricalResponse[];
|
||||||
} = await alphaVantage.crypto.daily(
|
} = await this.alphaVantage.crypto.daily(
|
||||||
symbol.substring(0, symbol.length - 3).toLowerCase(),
|
symbol.substring(0, symbol.length - 3).toLowerCase(),
|
||||||
'usd'
|
'usd'
|
||||||
);
|
);
|
||||||
@ -73,6 +78,6 @@ export class AlphaVantageService implements DataProviderInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public search(aSymbol: string) {
|
public search(aSymbol: string) {
|
||||||
return alphaVantage.data.search(aSymbol);
|
return this.alphaVantage.data.search(aSymbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,137 @@
|
|||||||
|
import { DataSource } from '.prisma/client';
|
||||||
|
import { getYesterday } from '@ghostfolio/helper';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import * as bent from 'bent';
|
||||||
|
import * as cheerio from 'cheerio';
|
||||||
|
import { format } from 'date-fns';
|
||||||
|
|
||||||
|
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
||||||
|
import { Granularity } from '../../interfaces/granularity.type';
|
||||||
|
import {
|
||||||
|
IDataProviderHistoricalResponse,
|
||||||
|
IDataProviderResponse,
|
||||||
|
MarketState
|
||||||
|
} from '../../interfaces/interfaces';
|
||||||
|
import { PrismaService } from '../../prisma.service';
|
||||||
|
import { ScraperConfig } from './interfaces/scraper-config.interface';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class GhostfolioScraperApiService implements DataProviderInterface {
|
||||||
|
private static NUMERIC_REGEXP = /[-]{0,1}[\d]*[.,]{0,1}[\d]+/g;
|
||||||
|
|
||||||
|
public constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
public async get(
|
||||||
|
aSymbols: string[]
|
||||||
|
): Promise<{ [symbol: string]: IDataProviderResponse }> {
|
||||||
|
if (aSymbols.length <= 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const symbol = aSymbols[0];
|
||||||
|
|
||||||
|
const scraperConfig = await this.getScraperConfigurationBySymbol(symbol);
|
||||||
|
|
||||||
|
const { marketPrice } = await this.prisma.marketData.findFirst({
|
||||||
|
orderBy: {
|
||||||
|
date: 'desc'
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
symbol
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
[symbol]: {
|
||||||
|
marketPrice,
|
||||||
|
currency: scraperConfig?.currency,
|
||||||
|
dataSource: DataSource.GHOSTFOLIO,
|
||||||
|
marketState: MarketState.delayed,
|
||||||
|
name: scraperConfig?.name
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getHistorical(
|
||||||
|
aSymbols: string[],
|
||||||
|
aGranularity: Granularity = 'day',
|
||||||
|
from: Date,
|
||||||
|
to: Date
|
||||||
|
): Promise<{
|
||||||
|
[symbol: string]: { [date: string]: IDataProviderHistoricalResponse };
|
||||||
|
}> {
|
||||||
|
if (aSymbols.length <= 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const symbol = aSymbols[0];
|
||||||
|
|
||||||
|
const scraperConfiguration = await this.getScraperConfigurationBySymbol(
|
||||||
|
symbol
|
||||||
|
);
|
||||||
|
|
||||||
|
const get = bent(scraperConfiguration?.url, 'GET', 'string', 200, {});
|
||||||
|
|
||||||
|
const html = await get();
|
||||||
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
|
const value = this.extractNumberFromString(
|
||||||
|
$(scraperConfiguration?.selector).text()
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
[symbol]: {
|
||||||
|
[format(getYesterday(), 'yyyy-MM-dd')]: {
|
||||||
|
marketPrice: value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getScraperConfigurations(): Promise<ScraperConfig[]> {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
value: scraperConfigString
|
||||||
|
} = await this.prisma.property.findFirst({
|
||||||
|
select: {
|
||||||
|
value: true
|
||||||
|
},
|
||||||
|
where: { key: 'SCRAPER_CONFIG' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return JSON.parse(scraperConfigString);
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private extractNumberFromString(aString: string): number {
|
||||||
|
try {
|
||||||
|
const [numberString] = aString.match(
|
||||||
|
GhostfolioScraperApiService.NUMERIC_REGEXP
|
||||||
|
);
|
||||||
|
return parseFloat(numberString.trim());
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getScraperConfigurationBySymbol(aSymbol: string) {
|
||||||
|
const scraperConfigurations = await this.getScraperConfigurations();
|
||||||
|
return scraperConfigurations.find((scraperConfiguration) => {
|
||||||
|
return scraperConfiguration.symbol === aSymbol;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
import { Currency } from '.prisma/client';
|
||||||
|
|
||||||
|
export interface ScraperConfig {
|
||||||
|
currency: Currency;
|
||||||
|
name: string;
|
||||||
|
selector: string;
|
||||||
|
symbol: string;
|
||||||
|
url: string;
|
||||||
|
}
|
@ -1,13 +1,16 @@
|
|||||||
|
import { DataSource } from '.prisma/client';
|
||||||
|
import { getToday, getYesterday } from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import * as bent from 'bent';
|
import * as bent from 'bent';
|
||||||
import { format, subMonths, subWeeks, subYears } from 'date-fns';
|
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 { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
||||||
import { Granularity } from '../../interfaces/granularity.type';
|
import { Granularity } from '../../interfaces/granularity.type';
|
||||||
import {
|
import {
|
||||||
IDataProviderHistoricalResponse,
|
IDataProviderHistoricalResponse,
|
||||||
IDataProviderResponse
|
IDataProviderResponse,
|
||||||
|
MarketState
|
||||||
} from '../../interfaces/interfaces';
|
} from '../../interfaces/interfaces';
|
||||||
import { PrismaService } from '../../prisma.service';
|
import { PrismaService } from '../../prisma.service';
|
||||||
|
|
||||||
@ -17,7 +20,9 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
|||||||
|
|
||||||
private prisma: PrismaService;
|
private prisma: PrismaService;
|
||||||
|
|
||||||
public constructor() {}
|
public constructor(
|
||||||
|
private readonly configurationService: ConfigurationService
|
||||||
|
) {}
|
||||||
|
|
||||||
public async get(
|
public async get(
|
||||||
aSymbols: string[]
|
aSymbols: string[]
|
||||||
@ -35,8 +40,9 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
|||||||
return {
|
return {
|
||||||
'GF.FEAR_AND_GREED_INDEX': {
|
'GF.FEAR_AND_GREED_INDEX': {
|
||||||
currency: undefined,
|
currency: undefined,
|
||||||
isMarketOpen: true,
|
dataSource: DataSource.RAKUTEN,
|
||||||
marketPrice: fgi.now.value,
|
marketPrice: fgi.now.value,
|
||||||
|
marketState: MarketState.open,
|
||||||
name: RakutenRapidApiService.FEAR_AND_GREED_INDEX_NAME
|
name: RakutenRapidApiService.FEAR_AND_GREED_INDEX_NAME
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -127,7 +133,9 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
|||||||
{
|
{
|
||||||
useQueryString: true,
|
useQueryString: true,
|
||||||
'x-rapidapi-host': 'fear-and-greed-index.p.rapidapi.com',
|
'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,6 +1,7 @@
|
|||||||
|
import { DataSource } from '.prisma/client';
|
||||||
|
import { isCrypto, isCurrency, parseCurrency } from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { isCrypto, isCurrency, parseCurrency } from 'libs/helper/src';
|
|
||||||
import * as yahooFinance from 'yahoo-finance';
|
import * as yahooFinance from 'yahoo-finance';
|
||||||
|
|
||||||
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
||||||
@ -9,6 +10,7 @@ import {
|
|||||||
IDataProviderHistoricalResponse,
|
IDataProviderHistoricalResponse,
|
||||||
IDataProviderResponse,
|
IDataProviderResponse,
|
||||||
Industry,
|
Industry,
|
||||||
|
MarketState,
|
||||||
Sector,
|
Sector,
|
||||||
Type
|
Type
|
||||||
} from '../../interfaces/interfaces';
|
} from '../../interfaces/interfaces';
|
||||||
@ -48,9 +50,12 @@ export class YahooFinanceService implements DataProviderInterface {
|
|||||||
|
|
||||||
response[symbol] = {
|
response[symbol] = {
|
||||||
currency: parseCurrency(value.price?.currency),
|
currency: parseCurrency(value.price?.currency),
|
||||||
|
dataSource: DataSource.YAHOO,
|
||||||
exchange: this.parseExchange(value.price?.exchangeName),
|
exchange: this.parseExchange(value.price?.exchangeName),
|
||||||
isMarketOpen:
|
marketState:
|
||||||
value.price?.marketState === 'REGULAR' || isCrypto(symbol),
|
value.price?.marketState === 'REGULAR' || isCrypto(symbol)
|
||||||
|
? MarketState.open
|
||||||
|
: MarketState.closed,
|
||||||
marketPrice: value.price?.regularMarketPrice || 0,
|
marketPrice: value.price?.regularMarketPrice || 0,
|
||||||
name: value.price?.longName || value.price?.shortName || symbol,
|
name: value.price?.longName || value.price?.shortName || symbol,
|
||||||
type: this.parseType(this.getType(symbol, value))
|
type: this.parseType(this.getType(symbol, value))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { getYesterday } from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { getYesterday } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { DataProviderService } from './data-provider.service';
|
import { DataProviderService } from './data-provider.service';
|
||||||
|
|
||||||
@ -15,6 +15,8 @@ export class ExchangeRateDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async initialize() {
|
public async initialize() {
|
||||||
|
this.pairs = [];
|
||||||
|
|
||||||
this.addPairs(Currency.CHF, Currency.EUR);
|
this.addPairs(Currency.CHF, Currency.EUR);
|
||||||
this.addPairs(Currency.CHF, Currency.GBP);
|
this.addPairs(Currency.CHF, Currency.GBP);
|
||||||
this.addPairs(Currency.CHF, Currency.USD);
|
this.addPairs(Currency.CHF, Currency.USD);
|
||||||
@ -25,11 +27,6 @@ export class ExchangeRateDataService {
|
|||||||
await this.loadCurrencies();
|
await this.loadCurrencies();
|
||||||
}
|
}
|
||||||
|
|
||||||
private addPairs(aCurrency1: Currency, aCurrency2: Currency) {
|
|
||||||
this.pairs.push(`${aCurrency1}${aCurrency2}`);
|
|
||||||
this.pairs.push(`${aCurrency2}${aCurrency1}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async loadCurrencies() {
|
public async loadCurrencies() {
|
||||||
const result = await this.dataProviderService.getHistorical(
|
const result = await this.dataProviderService.getHistorical(
|
||||||
this.pairs,
|
this.pairs,
|
||||||
@ -38,19 +35,34 @@ export class ExchangeRateDataService {
|
|||||||
getYesterday()
|
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.pairs.forEach((pair) => {
|
||||||
this.currencies[pair] =
|
const [currency1, currency2] = pair.match(/.{1,3}/g);
|
||||||
result[pair]?.[format(getYesterday(), 'yyyy-MM-dd')]?.marketPrice || 1;
|
const date = format(getYesterday(), 'yyyy-MM-dd');
|
||||||
|
|
||||||
if (this.currencies[pair] === 1) {
|
this.currencies[pair] = resultExtended[pair]?.[date]?.marketPrice;
|
||||||
// Calculate the other direction
|
|
||||||
const [currency1, currency2] = pair.match(/.{1,3}/g);
|
|
||||||
|
|
||||||
|
if (!this.currencies[pair]) {
|
||||||
|
// Not found, calculate indirectly via USD
|
||||||
this.currencies[pair] =
|
this.currencies[pair] =
|
||||||
1 /
|
resultExtended[`${currency1}${Currency.USD}`]?.[date]?.marketPrice *
|
||||||
result[`${currency2}${currency1}`]?.[
|
resultExtended[`${Currency.USD}${currency2}`]?.[date]?.marketPrice;
|
||||||
format(getYesterday(), 'yyyy-MM-dd')
|
|
||||||
]?.marketPrice;
|
// Calculate the opposite direction
|
||||||
|
this.currencies[`${currency2}${currency1}`] = 1 / this.currencies[pair];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -60,6 +72,11 @@ export class ExchangeRateDataService {
|
|||||||
aFromCurrency: Currency,
|
aFromCurrency: Currency,
|
||||||
aToCurrency: Currency
|
aToCurrency: Currency
|
||||||
) {
|
) {
|
||||||
|
if (isNaN(this.currencies[`${Currency.USD}${Currency.CHF}`])) {
|
||||||
|
// Reinitialize if data is not loaded correctly
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
let factor = 1;
|
let factor = 1;
|
||||||
|
|
||||||
if (aFromCurrency !== aToCurrency) {
|
if (aFromCurrency !== aToCurrency) {
|
||||||
@ -68,4 +85,9 @@ export class ExchangeRateDataService {
|
|||||||
|
|
||||||
return factor * aValue;
|
return factor * aValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private addPairs(aCurrency1: Currency, aCurrency2: Currency) {
|
||||||
|
this.pairs.push(`${aCurrency1}${aCurrency2}`);
|
||||||
|
this.pairs.push(`${aCurrency2}${aCurrency1}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
20
apps/api/src/services/interfaces/environment.interface.ts
Normal file
20
apps/api/src/services/interfaces/environment.interface.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { CleanedEnvAccessors } from 'envalid';
|
||||||
|
|
||||||
|
export interface Environment extends CleanedEnvAccessors {
|
||||||
|
ACCESS_TOKEN_SALT: string;
|
||||||
|
ALPHA_VANTAGE_API_KEY: string;
|
||||||
|
CACHE_TTL: number;
|
||||||
|
ENABLE_FEATURE_CUSTOM_SYMBOLS: boolean;
|
||||||
|
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;
|
||||||
|
ENABLE_FEATURE_SOCIAL_LOGIN: boolean;
|
||||||
|
ENABLE_FEATURE_SUBSCRIPTION: 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;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import { Currency, Platform } from '@prisma/client';
|
import { Currency, DataSource, Platform } from '@prisma/client';
|
||||||
|
|
||||||
import { OrderType } from '../../models/order-type';
|
import { OrderType } from '../../models/order-type';
|
||||||
|
|
||||||
@ -12,6 +12,12 @@ export const Industry = {
|
|||||||
Software: 'Software'
|
Software: 'Software'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const MarketState = {
|
||||||
|
closed: 'closed',
|
||||||
|
delayed: 'delayed',
|
||||||
|
open: 'open'
|
||||||
|
};
|
||||||
|
|
||||||
export const Sector = {
|
export const Sector = {
|
||||||
Consumer: 'Consumer',
|
Consumer: 'Consumer',
|
||||||
Healthcare: 'Healthcare',
|
Healthcare: 'Healthcare',
|
||||||
@ -45,12 +51,13 @@ export interface IDataProviderHistoricalResponse {
|
|||||||
|
|
||||||
export interface IDataProviderResponse {
|
export interface IDataProviderResponse {
|
||||||
currency: Currency;
|
currency: Currency;
|
||||||
|
dataSource: DataSource;
|
||||||
exchange?: string;
|
exchange?: string;
|
||||||
industry?: Industry;
|
industry?: Industry;
|
||||||
isMarketOpen: boolean;
|
|
||||||
marketChange?: number;
|
marketChange?: number;
|
||||||
marketChangePercent?: number;
|
marketChangePercent?: number;
|
||||||
marketPrice: number;
|
marketPrice: number;
|
||||||
|
marketState: MarketState;
|
||||||
name: string;
|
name: string;
|
||||||
sector?: Sector;
|
sector?: Sector;
|
||||||
type?: Type;
|
type?: Type;
|
||||||
@ -59,6 +66,8 @@ export interface IDataProviderResponse {
|
|||||||
|
|
||||||
export type Industry = typeof Industry[keyof typeof Industry];
|
export type Industry = typeof Industry[keyof typeof Industry];
|
||||||
|
|
||||||
|
export type MarketState = typeof MarketState[keyof typeof MarketState];
|
||||||
|
|
||||||
export type Sector = typeof Sector[keyof typeof Sector];
|
export type Sector = typeof Sector[keyof typeof Sector];
|
||||||
|
|
||||||
export type Type = typeof Type[keyof typeof Type];
|
export type Type = typeof Type[keyof typeof Type];
|
||||||
|
@ -2,7 +2,8 @@ import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PrismaService extends PrismaClient
|
export class PrismaService
|
||||||
|
extends PrismaClient
|
||||||
implements OnModuleInit, OnModuleDestroy {
|
implements OnModuleInit, OnModuleDestroy {
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
await this.$connect();
|
await this.$connect();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
DEFAULT_DATE_FORMAT,
|
DEFAULT_DATE_FORMAT,
|
||||||
DEFAULT_DATE_FORMAT_MONTH_YEAR
|
DEFAULT_DATE_FORMAT_MONTH_YEAR
|
||||||
} from 'libs/helper/src';
|
} from '@ghostfolio/helper';
|
||||||
|
|
||||||
export const DateFormats = {
|
export const DateFormats = {
|
||||||
display: {
|
display: {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<gf-header
|
<gf-header
|
||||||
class="position-fixed px-2 w-100"
|
class="position-fixed px-2 w-100"
|
||||||
[currentRoute]="currentRoute"
|
[currentRoute]="currentRoute"
|
||||||
|
[info]="info"
|
||||||
[user]="user"
|
[user]="user"
|
||||||
></gf-header>
|
></gf-header>
|
||||||
</header>
|
</header>
|
||||||
@ -26,7 +27,10 @@
|
|||||||
|
|
||||||
<footer class="footer d-flex justify-content-center position-absolute w-100">
|
<footer class="footer d-flex justify-content-center position-absolute w-100">
|
||||||
<div class="container text-center">
|
<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">
|
<div class="py-2 text-muted">
|
||||||
<small i18n
|
<small i18n
|
||||||
>The risk of loss in trading can be substantial. It is not advisable to
|
>The risk of loss in trading can be substantial. It is not advisable to
|
||||||
|
@ -6,11 +6,15 @@ import {
|
|||||||
OnInit
|
OnInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NavigationEnd, Router } from '@angular/router';
|
import { NavigationEnd, Router } from '@angular/router';
|
||||||
|
import { InfoItem } from '@ghostfolio/api/app/info/interfaces/info-item.interface';
|
||||||
|
import { User } from '@ghostfolio/api/app/user/interfaces/user.interface';
|
||||||
|
import {
|
||||||
|
hasPermission,
|
||||||
|
permissions,
|
||||||
|
primaryColorHex,
|
||||||
|
secondaryColorHex
|
||||||
|
} from '@ghostfolio/helper';
|
||||||
import { MaterialCssVarsService } from 'angular-material-css-vars';
|
import { MaterialCssVarsService } from 'angular-material-css-vars';
|
||||||
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';
|
import { Subject } from 'rxjs';
|
||||||
import { filter, takeUntil } from 'rxjs/operators';
|
import { filter, takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -27,8 +31,9 @@ import { TokenStorageService } from './services/token-storage.service';
|
|||||||
export class AppComponent implements OnDestroy, OnInit {
|
export class AppComponent implements OnDestroy, OnInit {
|
||||||
public canCreateAccount: boolean;
|
public canCreateAccount: boolean;
|
||||||
public currentRoute: string;
|
public currentRoute: string;
|
||||||
|
public currentYear = new Date().getFullYear();
|
||||||
|
public info: InfoItem;
|
||||||
public isLoggedIn = false;
|
public isLoggedIn = false;
|
||||||
public lastDataGathering: string;
|
|
||||||
public user: User;
|
public user: User;
|
||||||
public version = environment.version;
|
public version = environment.version;
|
||||||
|
|
||||||
@ -46,10 +51,8 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
this.dataService.fetchInfo().subscribe(({ lastDataGathering }) => {
|
this.dataService.fetchInfo().subscribe((info) => {
|
||||||
this.lastDataGathering = lastDataGathering
|
this.info = info;
|
||||||
? formatDistanceToNow(new Date(lastDataGathering), { addSuffix: true })
|
|
||||||
: '';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.router.events
|
this.router.events
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
OnInit
|
OnInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
import { Access } from 'apps/api/src/app/access/interfaces/access.interface';
|
import { Access } from '@ghostfolio/api/app/access/interfaces/access.interface';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-access-table',
|
selector: 'gf-access-table',
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
<gf-symbol-icon
|
||||||
|
*ngIf="symbolUrl"
|
||||||
|
class="mr-1"
|
||||||
|
size="large"
|
||||||
|
[url]="symbolUrl"
|
||||||
|
></gf-symbol-icon>
|
||||||
<span class="flex-grow-1 text-truncate">{{ title }}</span>
|
<span class="flex-grow-1 text-truncate">{{ title }}</span>
|
||||||
<button
|
<button
|
||||||
*ngIf="deviceType !== 'mobile'"
|
*ngIf="deviceType !== 'mobile'"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
:host {
|
:host {
|
||||||
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
})
|
})
|
||||||
export class DialogHeaderComponent implements OnInit {
|
export class DialogHeaderComponent implements OnInit {
|
||||||
@Input() deviceType: string;
|
@Input() deviceType: string;
|
||||||
|
@Input() symbolUrl: string;
|
||||||
@Input() title: string;
|
@Input() title: string;
|
||||||
|
|
||||||
@Output() closeButtonClicked = new EventEmitter<void>();
|
@Output() closeButtonClicked = new EventEmitter<void>();
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { GfSymbolIconModule } from '@ghostfolio/client/components/symbol-icon/symbol-icon.module';
|
||||||
|
|
||||||
import { DialogHeaderComponent } from './dialog-header.component';
|
import { DialogHeaderComponent } from './dialog-header.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [DialogHeaderComponent],
|
declarations: [DialogHeaderComponent],
|
||||||
exports: [DialogHeaderComponent],
|
exports: [DialogHeaderComponent],
|
||||||
imports: [CommonModule, MatButtonModule],
|
imports: [CommonModule, GfSymbolIconModule, MatButtonModule],
|
||||||
providers: [],
|
providers: [],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
})
|
})
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
OnChanges,
|
OnChanges,
|
||||||
OnInit
|
OnInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { resolveFearAndGreedIndex } from 'libs/helper/src';
|
import { resolveFearAndGreedIndex } from '@ghostfolio/helper';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-fear-and-greed-index',
|
selector: 'gf-fear-and-greed-index',
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
>Transactions</a
|
>Transactions</a
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
*ngIf="canAccessAdminAccessControl"
|
*ngIf="hasPermissionToAccessAdminControl"
|
||||||
class="d-none d-sm-block mx-1"
|
class="d-none d-sm-block mx-1"
|
||||||
[routerLink]="['/admin']"
|
[routerLink]="['/admin']"
|
||||||
i18n
|
i18n
|
||||||
@ -147,11 +147,10 @@
|
|||||||
i18n
|
i18n
|
||||||
mat-menu-item
|
mat-menu-item
|
||||||
[ngClass]="{ 'font-weight-bold': currentRoute === 'account' }"
|
[ngClass]="{ 'font-weight-bold': currentRoute === 'account' }"
|
||||||
><span>Account</span
|
>Account</a
|
||||||
><ion-icon class="ml-1 text-muted" name="diamond-outline"></ion-icon
|
>
|
||||||
></a>
|
|
||||||
<a
|
<a
|
||||||
*ngIf="canAccessAdminAccessControl"
|
*ngIf="hasPermissionToAccessAdminControl"
|
||||||
class="d-block d-sm-none"
|
class="d-block d-sm-none"
|
||||||
[routerLink]="['/admin']"
|
[routerLink]="['/admin']"
|
||||||
i18n
|
i18n
|
||||||
@ -198,6 +197,12 @@
|
|||||||
[color]="currentRoute === 'about' ? 'primary' : null"
|
[color]="currentRoute === 'about' ? 'primary' : null"
|
||||||
>About</a
|
>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>
|
<button i18n mat-flat-button (click)="openLoginDialog()">Sign in</button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
|
@ -6,16 +6,16 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { User } from 'apps/api/src/app/user/interfaces/user.interface';
|
import { InfoItem } from '@ghostfolio/api/app/info/interfaces/info-item.interface';
|
||||||
import { hasPermission, permissions } from 'libs/helper/src';
|
import { User } from '@ghostfolio/api/app/user/interfaces/user.interface';
|
||||||
|
import { LoginWithAccessTokenDialog } from '@ghostfolio/client/pages/login/login-with-access-token-dialog/login-with-access-token-dialog.component';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
||||||
|
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
|
||||||
|
import { hasPermission, permissions } from '@ghostfolio/helper';
|
||||||
import { EMPTY, Subject } from 'rxjs';
|
import { EMPTY, Subject } from 'rxjs';
|
||||||
import { catchError, takeUntil } from 'rxjs/operators';
|
import { catchError, takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
import { LoginWithAccessTokenDialog } from '../../pages/login/login-with-access-token-dialog/login-with-access-token-dialog.component';
|
|
||||||
import { DataService } from '../../services/data.service';
|
|
||||||
import { ImpersonationStorageService } from '../../services/impersonation-storage.service';
|
|
||||||
import { TokenStorageService } from '../../services/token-storage.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-header',
|
selector: 'gf-header',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
@ -24,9 +24,11 @@ import { TokenStorageService } from '../../services/token-storage.service';
|
|||||||
})
|
})
|
||||||
export class HeaderComponent implements OnChanges {
|
export class HeaderComponent implements OnChanges {
|
||||||
@Input() currentRoute: string;
|
@Input() currentRoute: string;
|
||||||
|
@Input() info: InfoItem;
|
||||||
@Input() user: User;
|
@Input() user: User;
|
||||||
|
|
||||||
public canAccessAdminAccessControl: boolean;
|
public hasPermissionToAccessAdminControl: boolean;
|
||||||
|
public hasPermissionForSocialLogin: boolean;
|
||||||
public impersonationId: string;
|
public impersonationId: string;
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
@ -47,11 +49,16 @@ export class HeaderComponent implements OnChanges {
|
|||||||
|
|
||||||
public ngOnChanges() {
|
public ngOnChanges() {
|
||||||
if (this.user) {
|
if (this.user) {
|
||||||
this.canAccessAdminAccessControl = hasPermission(
|
this.hasPermissionToAccessAdminControl = hasPermission(
|
||||||
this.user.permissions,
|
this.user.permissions,
|
||||||
permissions.accessAdminControl
|
permissions.accessAdminControl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.hasPermissionForSocialLogin = hasPermission(
|
||||||
|
this.info?.globalPermissions,
|
||||||
|
permissions.enableSocialLogin
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public impersonateAccount(aId: string) {
|
public impersonateAccount(aId: string) {
|
||||||
@ -72,7 +79,10 @@ export class HeaderComponent implements OnChanges {
|
|||||||
public openLoginDialog(): void {
|
public openLoginDialog(): void {
|
||||||
const dialogRef = this.dialog.open(LoginWithAccessTokenDialog, {
|
const dialogRef = this.dialog.open(LoginWithAccessTokenDialog, {
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
data: { accessToken: '' },
|
data: {
|
||||||
|
accessToken: '',
|
||||||
|
hasPermissionToUseSocialLogin: this.hasPermissionForSocialLogin
|
||||||
|
},
|
||||||
width: '30rem'
|
width: '30rem'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ import { MatButtonModule } from '@angular/material/button';
|
|||||||
import { MatMenuModule } from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { LoginWithAccessTokenDialogModule } from '@ghostfolio/client/pages/login/login-with-access-token-dialog/login-with-access-token-dialog.module';
|
||||||
|
|
||||||
import { LoginWithAccessTokenDialogModule } from '../../pages/login/login-with-access-token-dialog/login-with-access-token-dialog.module';
|
|
||||||
import { GfLogoModule } from '../logo/logo.module';
|
import { GfLogoModule } from '../logo/logo.module';
|
||||||
import { HeaderComponent } from './header.component';
|
import { HeaderComponent } from './header.component';
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { PortfolioItem } from 'apps/api/src/app/portfolio/interfaces/portfolio-item.interface';
|
import { PortfolioItem } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-item.interface';
|
||||||
|
import { primaryColorRgb } from '@ghostfolio/helper';
|
||||||
import {
|
import {
|
||||||
LineController,
|
LineController,
|
||||||
LineElement,
|
LineElement,
|
||||||
@ -18,7 +19,6 @@ import {
|
|||||||
TimeScale
|
TimeScale
|
||||||
} from 'chart.js';
|
} from 'chart.js';
|
||||||
import { Chart } from 'chart.js';
|
import { Chart } from 'chart.js';
|
||||||
import { primaryColorRgb } from 'libs/helper/src';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-investment-chart',
|
selector: 'gf-investment-chart',
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { primaryColorRgb, secondaryColorRgb } from '@ghostfolio/helper';
|
||||||
import {
|
import {
|
||||||
Chart,
|
Chart,
|
||||||
Filler,
|
Filler,
|
||||||
@ -18,7 +19,6 @@ import {
|
|||||||
PointElement,
|
PointElement,
|
||||||
TimeScale
|
TimeScale
|
||||||
} from 'chart.js';
|
} from 'chart.js';
|
||||||
import { primaryColorRgb, secondaryColorRgb } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { LineChartItem } from './interfaces/line-chart.interface';
|
import { LineChartItem } from './interfaces/line-chart.interface';
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ import {
|
|||||||
Inject
|
Inject
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
import { isToday, parse } from 'date-fns';
|
import { isToday, parse } from 'date-fns';
|
||||||
|
|
||||||
import { DataService } from '../../services/data.service';
|
|
||||||
import { LineChartItem } from '../line-chart/interfaces/line-chart.interface';
|
import { LineChartItem } from '../line-chart/interfaces/line-chart.interface';
|
||||||
import { PositionDetailDialogParams } from './interfaces/interfaces';
|
import { PositionDetailDialogParams } from './interfaces/interfaces';
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
></gf-line-chart>
|
></gf-line-chart>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container p-0">
|
<div *ngIf="data.fearAndGreedIndex" class="container p-0">
|
||||||
<gf-fear-and-greed-index
|
<gf-fear-and-greed-index
|
||||||
class="d-flex flex-column justify-content-center"
|
class="d-flex flex-column justify-content-center"
|
||||||
[fearAndGreedIndex]="data.fearAndGreedIndex"
|
[fearAndGreedIndex]="data.fearAndGreedIndex"
|
||||||
|
@ -2,9 +2,9 @@ import { CommonModule } from '@angular/common';
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatDialogModule } from '@angular/material/dialog';
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
|
import { GfLineChartModule } from '@ghostfolio/client/components/line-chart/line-chart.module';
|
||||||
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
|
||||||
|
|
||||||
import { GfLineChartModule } from '../../components/line-chart/line-chart.module';
|
|
||||||
import { GfDialogFooterModule } from '../dialog-footer/dialog-footer.module';
|
import { GfDialogFooterModule } from '../dialog-footer/dialog-footer.module';
|
||||||
import { GfDialogHeaderModule } from '../dialog-header/dialog-header.module';
|
import { GfDialogHeaderModule } from '../dialog-header/dialog-header.module';
|
||||||
import { GfFearAndGreedIndexModule } from '../fear-and-greed-index/fear-and-greed-index.module';
|
import { GfFearAndGreedIndexModule } from '../fear-and-greed-index/fear-and-greed-index.module';
|
||||||
|
@ -5,8 +5,8 @@ import {
|
|||||||
OnChanges,
|
OnChanges,
|
||||||
OnInit
|
OnInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { PortfolioOverview } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-overview.interface';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
import { PortfolioOverview } from 'apps/api/src/app/portfolio/interfaces/portfolio-overview.interface';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-portfolio-overview',
|
selector: 'gf-portfolio-overview',
|
||||||
|
@ -34,16 +34,16 @@
|
|||||||
<div *ngIf="showDetails" class="row">
|
<div *ngIf="showDetails" class="row">
|
||||||
<div class="d-flex col justify-content-end">
|
<div class="d-flex col justify-content-end">
|
||||||
<gf-value
|
<gf-value
|
||||||
colorizeSign="true"
|
[colorizeSign]="true"
|
||||||
isCurrency="true"
|
[isCurrency]="true"
|
||||||
[locale]="locale"
|
[locale]="locale"
|
||||||
[value]="isLoading ? undefined : performance?.currentNetPerformance"
|
[value]="isLoading ? undefined : performance?.currentNetPerformance"
|
||||||
></gf-value>
|
></gf-value>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<gf-value
|
<gf-value
|
||||||
colorizeSign="true"
|
[colorizeSign]="true"
|
||||||
isPercent="true"
|
[isPercent]="true"
|
||||||
[locale]="locale"
|
[locale]="locale"
|
||||||
[value]="
|
[value]="
|
||||||
isLoading ? undefined : performance?.currentNetPerformancePercent
|
isLoading ? undefined : performance?.currentNetPerformancePercent
|
||||||
|
@ -7,8 +7,8 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { PortfolioPerformance } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-performance.interface';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
import { PortfolioPerformance } from 'apps/api/src/app/portfolio/interfaces/portfolio-performance.interface';
|
|
||||||
import { CountUp } from 'countup.js';
|
import { CountUp } from 'countup.js';
|
||||||
import { isNumber } from 'lodash';
|
import { isNumber } from 'lodash';
|
||||||
|
|
||||||
|
@ -16,17 +16,17 @@
|
|||||||
<div class="d-flex flex-column flex-wrap justify-content-end">
|
<div class="d-flex flex-column flex-wrap justify-content-end">
|
||||||
<gf-value
|
<gf-value
|
||||||
class="justify-content-end mb-2"
|
class="justify-content-end mb-2"
|
||||||
colorizeSign="true"
|
|
||||||
position="end"
|
position="end"
|
||||||
|
[colorizeSign]="true"
|
||||||
[currency]="baseCurrency"
|
[currency]="baseCurrency"
|
||||||
[locale]="locale"
|
[locale]="locale"
|
||||||
[value]="isLoading ? undefined : performance?.currentGrossPerformance"
|
[value]="isLoading ? undefined : performance?.currentGrossPerformance"
|
||||||
></gf-value>
|
></gf-value>
|
||||||
<gf-value
|
<gf-value
|
||||||
class="justify-content-end"
|
class="justify-content-end"
|
||||||
colorizeSign="true"
|
|
||||||
isPercent="true"
|
|
||||||
position="end"
|
position="end"
|
||||||
|
[colorizeSign]="true"
|
||||||
|
[isPercent]="true"
|
||||||
[locale]="locale"
|
[locale]="locale"
|
||||||
[value]="
|
[value]="
|
||||||
isLoading ? undefined : performance?.currentGrossPerformancePercent
|
isLoading ? undefined : performance?.currentGrossPerformancePercent
|
||||||
@ -39,17 +39,17 @@
|
|||||||
<div class="d-flex flex-column flex-wrap justify-content-end">
|
<div class="d-flex flex-column flex-wrap justify-content-end">
|
||||||
<gf-value
|
<gf-value
|
||||||
class="justify-content-end mb-2"
|
class="justify-content-end mb-2"
|
||||||
colorizeSign="true"
|
|
||||||
position="end"
|
position="end"
|
||||||
|
[colorizeSign]="true"
|
||||||
[currency]="baseCurrency"
|
[currency]="baseCurrency"
|
||||||
[locale]="locale"
|
[locale]="locale"
|
||||||
[value]="isLoading ? undefined : performance?.currentNetPerformance"
|
[value]="isLoading ? undefined : performance?.currentNetPerformance"
|
||||||
></gf-value>
|
></gf-value>
|
||||||
<gf-value
|
<gf-value
|
||||||
class="justify-content-end"
|
class="justify-content-end"
|
||||||
colorizeSign="true"
|
|
||||||
isPercent="true"
|
|
||||||
position="end"
|
position="end"
|
||||||
|
[colorizeSign]="true"
|
||||||
|
[isPercent]="true"
|
||||||
[locale]="locale"
|
[locale]="locale"
|
||||||
[value]="
|
[value]="
|
||||||
isLoading ? undefined : performance?.currentNetPerformancePercent
|
isLoading ? undefined : performance?.currentNetPerformancePercent
|
||||||
|
@ -4,8 +4,8 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
OnInit
|
OnInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { PortfolioPerformance } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-performance.interface';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
import { PortfolioPerformance } from 'apps/api/src/app/portfolio/interfaces/portfolio-performance.interface';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-portfolio-performance',
|
selector: 'gf-portfolio-performance',
|
||||||
|
@ -5,13 +5,10 @@ import {
|
|||||||
Component,
|
Component,
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
OnInit,
|
OnInit
|
||||||
ViewChild
|
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { PortfolioItem } from 'apps/api/src/app/portfolio/interfaces/portfolio-item.interface';
|
import { PortfolioItem } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-item.interface';
|
||||||
import { Chart } from 'chart.js';
|
|
||||||
import { endOfDay, parseISO, startOfDay } from 'date-fns';
|
import { endOfDay, parseISO, startOfDay } from 'date-fns';
|
||||||
import { primaryColorRgb } from 'libs/helper/src';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-portfolio-positions-chart',
|
selector: 'gf-portfolio-positions-chart',
|
||||||
|
@ -7,8 +7,8 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { PortfolioPosition } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position.interface';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
import { PortfolioPosition } from 'apps/api/src/app/portfolio/interfaces/portfolio-position.interface';
|
|
||||||
import { Tooltip } from 'chart.js';
|
import { Tooltip } from 'chart.js';
|
||||||
import { LinearScale } from 'chart.js';
|
import { LinearScale } from 'chart.js';
|
||||||
import { ArcElement } from 'chart.js';
|
import { ArcElement } from 'chart.js';
|
||||||
|
@ -3,5 +3,6 @@ export interface PositionDetailDialogParams {
|
|||||||
deviceType: string;
|
deviceType: string;
|
||||||
locale: string;
|
locale: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
|
symbolUrl: string;
|
||||||
title: string;
|
title: string;
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user