├── doc └── Please Go to Wiki ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── src ├── UI │ └── Figma_link.txt └── main │ ├── java │ └── com │ │ └── portfolio │ │ └── doctor │ │ ├── payload │ │ ├── HoldingRaw.java │ │ ├── PortfolioRes.java │ │ ├── ApiResponse.java │ │ ├── Holding.java │ │ ├── TradeDto.java │ │ ├── HoldingScaled.java │ │ ├── PortfolioValueRes.java │ │ ├── Gain.java │ │ └── Trade.java │ │ ├── service │ │ ├── PortfolioService.java │ │ └── PortfolioServiceImpl.java │ │ ├── PortfolioDoctorProjectApplication.java │ │ ├── controller │ │ └── PortfolioController.java │ │ └── util │ │ └── ApplicationProperties.java │ └── resources │ └── application.properties ├── .gitignore ├── pom.xml ├── README.md ├── mvnw.cmd ├── mvnw ├── LICENSE └── Documentation.txt /doc/Please Go to Wiki: -------------------------------------------------------------------------------- 1 | 2 | https://github.com/picaYmica/Portfolio-Doctor/wiki 3 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechStuff2020/Portfolio-Doctor/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /src/UI/Figma_link.txt: -------------------------------------------------------------------------------- 1 | 2 | https://www.figma.com/file/gLt4bTDh8RTT2KAT9RZOWM/Portfolio-project?type=design&node-id=0-1&mode=design 3 | 4 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/HoldingRaw.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | public class HoldingRaw { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | api.keys=JL2FS7H0QI4PSDOC,B7FIMR5QJOONFPUF,WVYFH12V54922EZ5,JIJMXPFV5HNWN5HY,MAGLOSNZ0140E11GB70WXTRP9VH0X0FU,1TVRQVJF2RBNVSD1,DGTJGOY88W8GYMSA,9LS41X2NG4BDY2FF,AETILB69JPD6DTUK 2 | api.ticker-url=https://www.alphavantage.co/ 3 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/service/PortfolioService.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.service; 2 | 3 | import com.portfolio.doctor.payload.ApiResponse; 4 | import com.portfolio.doctor.payload.TradeDto; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.RequestBody; 7 | 8 | public interface PortfolioService { 9 | 10 | ResponseEntity processTrades(@RequestBody TradeDto tradeDto); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/PortfolioDoctorProjectApplication.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class PortfolioDoctorProjectApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(PortfolioDoctorProjectApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/PortfolioRes.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | @Data 9 | public class PortfolioRes { 10 | private List responseList = new ArrayList<>(); 11 | 12 | private Double feesPaid; 13 | private Double gainTaxValue; 14 | 15 | private Double standardDeviation; 16 | 17 | public void makeScaled(double scaleValue) { 18 | feesPaid *= scaleValue; 19 | gainTaxValue *=scaleValue; 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ApiResponse { 11 | private Boolean success; 12 | private String message; 13 | private Object data; 14 | 15 | public ApiResponse(Boolean success, String message) { 16 | this.success = success; 17 | this.message = message; 18 | } 19 | 20 | public ApiResponse(Boolean success, Object data) { 21 | this.success = success; 22 | this.data = data; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/Holding.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Objects; 6 | 7 | @Data 8 | public class Holding extends HoldingScaled{ 9 | private double quantity; 10 | 11 | public Holding(String ticker,double quantity, double value) { 12 | super(ticker, value); 13 | this.quantity=quantity; 14 | } 15 | 16 | @Override 17 | public boolean equals(Object o) { 18 | if (this == o) return true; 19 | if (!(o instanceof HoldingScaled holding)) return false; 20 | if (!super.equals(o)) return false; 21 | return Objects.equals(super.getTicker(), holding.getTicker()); 22 | } 23 | 24 | @Override 25 | public int hashCode() { 26 | return Objects.hash(super.hashCode(), super.getTicker()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/TradeDto.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | import jakarta.validation.Valid; 4 | import jakarta.validation.constraints.Min; 5 | import jakarta.validation.constraints.NotEmpty; 6 | import jakarta.validation.constraints.NotNull; 7 | import lombok.Data; 8 | 9 | import java.util.Currency; 10 | import java.util.List; 11 | 12 | @Data 13 | public class TradeDto { 14 | @Valid 15 | @NotNull 16 | @NotEmpty 17 | private List tradeList; 18 | 19 | private Currency currency; 20 | 21 | private boolean scaleOutput; 22 | 23 | private String benchmarkSymbol; 24 | 25 | @Min(value = 0, message = "return rate should be positive") 26 | private double cashReturn; 27 | 28 | @Min(value = 0, message = "tax rate should be positive") 29 | private double gainTax; 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/controller/PortfolioController.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.controller; 2 | 3 | import com.portfolio.doctor.payload.ApiResponse; 4 | import com.portfolio.doctor.payload.TradeDto; 5 | import com.portfolio.doctor.service.PortfolioService; 6 | import jakarta.validation.Valid; 7 | import lombok.RequiredArgsConstructor; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | @RestController 12 | @RequestMapping("api/v1/portfolio") 13 | @RequiredArgsConstructor 14 | @CrossOrigin("*") 15 | public class PortfolioController { 16 | 17 | private final PortfolioService portfolioService; 18 | 19 | @PostMapping 20 | public ResponseEntity processTrades(@RequestBody @Valid TradeDto tradeRequest) { 21 | return portfolioService.processTrades(tradeRequest); 22 | } 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/HoldingScaled.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.Objects; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class HoldingScaled { 13 | private String ticker; 14 | private double positionValue; 15 | 16 | @Override 17 | public boolean equals(Object o) { 18 | if (this == o) return true; 19 | if (o == null || getClass() != o.getClass()) return false; 20 | HoldingScaled holding = (HoldingScaled) o; 21 | return Objects.equals(ticker, holding.ticker); 22 | } 23 | 24 | public void makeScaled(double scaleValue) { 25 | positionValue *= scaleValue; 26 | } 27 | 28 | @Override 29 | public int hashCode() { 30 | return Objects.hash(ticker); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/PortfolioValueRes.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.time.LocalDate; 8 | import java.util.ArrayList; 9 | import java.util.HashSet; 10 | import java.util.List; 11 | import java.util.Set; 12 | 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | public class PortfolioValueRes { 17 | private Double value = 0.0; 18 | private Set holdingList = new HashSet<>(); 19 | private List gains = new ArrayList<>(); 20 | private Double portfolioCash; 21 | private Double benchmarkPrice; 22 | private Double netNewPurchase; 23 | private LocalDate date; 24 | 25 | public void makeScaled(double scaleValue) { 26 | value *= scaleValue; 27 | portfolioCash *= scaleValue; 28 | netNewPurchase *= scaleValue; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/util/ApplicationProperties.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.util; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import java.util.List; 10 | 11 | @Configuration 12 | @EnableConfigurationProperties 13 | @ConfigurationProperties(prefix = "api") 14 | @Setter 15 | public class ApplicationProperties { 16 | private List keys; 17 | @Getter 18 | private String tickerUrl; 19 | private Integer index = 0; 20 | 21 | public List getKeys() { 22 | return keys; 23 | } 24 | 25 | public void setKeys(List keys) { 26 | this.keys = keys; 27 | } 28 | public String getKey() { 29 | index = index >= keys.size() ? 0 : index; 30 | String s = keys.get(index++); 31 | return s; 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/Gain.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import lombok.Data; 5 | 6 | @Data 7 | 8 | public class Gain implements Cloneable { 9 | 10 | private String ticker; 11 | private double quantity; 12 | private double gains; 13 | private double tax; 14 | private int seqNo; 15 | private double bookedGains; 16 | 17 | @JsonIgnore 18 | private double price; 19 | 20 | 21 | public void makeScaled(double scaleValue) { 22 | gains *= scaleValue; 23 | bookedGains *= scaleValue; 24 | tax *= scaleValue; 25 | quantity=0; 26 | } 27 | 28 | public Gain(String ticker, double quantity, int seqNo, double price) { 29 | this.ticker = ticker; 30 | this.quantity = quantity; 31 | this.seqNo = seqNo; 32 | this.price = price; 33 | } 34 | 35 | public Gain() { 36 | } 37 | 38 | @Override 39 | public Gain clone() { 40 | try { 41 | return (Gain) super.clone(); 42 | } catch (CloneNotSupportedException e) { 43 | throw new AssertionError(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/payload/Trade.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.payload; 2 | 3 | import jakarta.validation.constraints.Min; 4 | import jakarta.validation.constraints.NotBlank; 5 | import jakarta.validation.constraints.NotNull; 6 | import jakarta.validation.constraints.Pattern; 7 | import lombok.Data; 8 | 9 | import java.time.LocalDate; 10 | 11 | @Data 12 | public class Trade implements Cloneable { 13 | //1 means buy and -1 means sell 14 | private byte action; 15 | 16 | private double quantity; 17 | 18 | @NotBlank 19 | private String ticker; 20 | 21 | @NotNull 22 | private LocalDate date; 23 | 24 | @Min(value = 0,message = "fixed fee must be positive") 25 | private double fixedFee; 26 | 27 | //comes as percent 28 | @Min(value = 0,message = "variable fee must be positive") 29 | private double variableFee; 30 | 31 | @Min(value = 0,message = "price must be positive") 32 | private Double price; 33 | 34 | @Override 35 | public Trade clone() { 36 | try { 37 | // TODO: copy mutable state here, so the clone can't change the internals of the original 38 | return (Trade) super.clone(); 39 | } catch (CloneNotSupportedException e) { 40 | throw new AssertionError(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.1.0 9 | 10 | 11 | com.portfolio 12 | Portfolio-Doctor 13 | 0.0.1-SNAPSHOT 14 | Portfolio-Doctor 15 | Portfolio-Doctor 16 | 17 | 17 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-validation 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-configuration-processor 35 | true 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-webflux 44 | 45 | 46 | 47 | org.postgresql 48 | postgresql 49 | runtime 50 | 51 | 52 | org.projectlombok 53 | lombok 54 | true 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-actuator 59 | compile 60 | 61 | 62 | org.springframework.boot 63 | spring-boot-configuration-processor 64 | true 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-starter-test 69 | test 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | org.projectlombok 82 | lombok 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 30 second summary 2 | It's easy to track a portfolio and calculate a performance metric such as IRR, XIRR, TWR and MWR. But it's difficult to answer a simple question: Did my frenzied stock trading beat the index? To get the right answer, we need to use a concept of **Cash-aware portfolio**. The idle cash in a portfolio, even when earning small **interest**, has an **opportunity cost**. Brokerage **fees, capital gains** tax also cut into real returns. Dividends could stay in cash (and earn interest) or be reinvested. Only after all of that is factored in, we can correctly compare a portfolio against the plain BUY and HOLD index strategy. Based on user's region, base curreency, a benchmark index can be chosen, e.g. Dow Jones, Eurostoxx 50, S&P 500, DAX, SMI, or even the 60:40 index or any ETF. 3 | 4 | ### Introduction and genesis of idea 5 | According to media, the Covid lockdowns saw a record number of first-time retail investors! A large portion of Gen-Z population is beginning to earn, have investible savings. Besides this data - which may be real or cooked up ![Image](https://user-images.githubusercontent.com/20066864/243864065-292f45a0-8d9f-4091-963b-ec8aee2791c9.png) - one can feel that, discussions in many social circles are beginning to involve "stock tips" or innocent brags about gains from Apple/ Netflix/ Tesla, etc etc. Over time, one wonders: 6 | 7 | ### Is DIY investing worth it? 8 | 9 | Again, data shows that even professional fund managers do worse than the index - let alone new beginners. Yet, pride, over confidence or plain beginner's luck, makes many people invest on their own. In other words, a majority beginners - even those with substantial investment amounts - opt for **self-service or advisory** mode, and prefer to make investment decisions themselves. Therefore, just like a routine doctor's check-up for bodily health, an investment portfolio too needs a periodic health check-up. 10 | 11 | ### My broker / bank sends me all the reports anyway. Why this? 12 | 13 | ... because 14 | 1. Their reports are wrong! This may be a hard pill to swallow, but TWR (time weighted return) is deemed to be the industry standard for portfolio tracking. This method skips the timing of inflows and ouflows, which is a crucial factor in performance. Duh! ![Image](https://user-images.githubusercontent.com/20066864/243864329-9cc0cc55-bd70-4fc0-bd2d-0f714a5a063f.png) 15 | 2. Even if the report shows MWR (money weighted returns) or IRR (internal rate of return), the evaluation is still logically wrong because - changes to cash as well as returns from cash are not accounted for. In other words, the portfolio is not "Cash aware". so, a realistic **comparision against benchmark index** is either missing or incorrectly calculated. When money market rates are hovering around 3-4% in US/EU in early 2023, this difference can be substantial. 16 | 3. They 'forget' about transaction fees or capital gains tax. A $100,000 portfolio of stocks isn't actually worth $100,000 due to fees and taxes. 17 | 4. Their incentives are against you. Brokers earn commissions with each trade. So, they will **NEVER** suggest you to quit trading and invest in a boring, low fee index fund/ETF. In fact, they'd entice clients with a new shiny stock tip. 18 | 19 | For above reasons (and many more), this project is launched in June 2023. 20 | 21 | > Please note that this is not a classic portfolio tracker. There are far too many portals and software applications doing the same already. [GetQuin](getquin.com), [Sharesight](https://www.sharesight.com), [Seeking Alpha](https://seekingalpha.com), to name a few, in addition to your broker's reports! 22 | 23 | The difference between an "off the shelf" portfolio tracker and this tool is described below. 24 | 25 | ![Image](https://user-images.githubusercontent.com/20066864/243858729-5bbe9e64-e845-442c-8245-cb283704abda.png) 26 | 27 | - Red line: classic portfolio value tracker. Note that Buy and Sell trades cause the portfolio value to change. 28 | - Blue line: this is "**Cash-aware**" portfolio tracking. Each BUY trade simulates a withdrawal from Cash. Corresponding Cash amount would stop earning interest. Also, as this cash was available at hand (it is unlikely that the investor really needed it to pay rent or food), it is factored into the initial investment size of portfolio. Similarly, each SELL trade would increase Cash, as opposed to portfolio's value suddenly dropping as seen in red line. This cash would also earn interest as per the reference rate of money market fund. 29 | 30 | > Thus, a 'tweaked' calculation method offers a better, more real-life way to assess portfolio performance. It also makes benchmarking against index more realistic. As equities should be invested with a time horizon of at least 3-5 years, practically it is fair to assume that cash dips and gains from BUY/SELL trades are done from a separate Cash account earmarked for investing, rather than an expense account. The Cash is treated as a part of investment, as it counts towards the opportunity cost of holding an index fund. More on this - [Introduction to 'Cash-aware' portfolio](https://github.com/TechStuff2020/CashPlus-Portfolio/wiki/Introduction-to-'Cash-aware'-portfolio) 31 | 32 | With benchmarking correctly done, the tool can now answer many questions and run several what-if scenarios that offer useful insights to the investor. Particularly, if users don't wish to use lumpsum investment to avoid **market timing**, there is also a feature to simulate staggered regular purchases. Users can then compare their actual performance with such What-if scenarios. 33 | 34 | ![Image](https://user-images.githubusercontent.com/20066864/243866423-378681d8-fa5b-4a51-8afd-931c68faca28.png) 35 | 36 | ![image](https://github.com/picaYmica/Portfolio-Doctor/assets/20066864/4a9c993f-2d32-4691-a3bb-404d3311db0c) 37 | 38 | ### What else does the portfolio analyzer do? 39 | 40 | Besides performance vs a benchmark, the tool can also assess the volatality of your portfolio against a reference index. It can also tell you how well the portfolio is diversified, by grouping your equities in sectors, regions and type of stocks you hold, e.g. momentum, growth, value, etc. 41 | 42 | ![image](https://github.com/TechStuff2020/CashPlus-Portfolio/assets/20066864/86be045f-a60b-407f-abe2-f72c150ea922) 43 | 44 | ### Great! Where is the technical ReadMe.txt or installation instructions? 45 | 46 | Please refer /src directory. This ReadMe is meant to be a one-pager overview of the project. The project is a REST API, with WordPress content management front-end without any need for any user data storage. User's trading data is ephemeral, so that data privacy concerns do not arise. Only the stock ticker symbols are sent to [Alpha-Vantage](https://www.alphavantage.co/#about) to get the market prices. All calculations happen local device's memory, where the API is installed. 47 | 48 | Setting up a portfolo is quite intuitive, as shown below: 49 | 50 | ![image](https://github.com/TechStuff2020/Portfolio-Doctor/assets/20066864/2da5dc15-5f68-4c6d-a6b9-fb856d2ed551) 51 | 52 | Supported benchmark indices and currencies: 53 | 54 | ![image](https://github.com/TechStuff2020/Portfolio-Doctor/assets/20066864/70482d6a-cb58-4d72-9ad2-4782b3c7d28f) ![image](https://github.com/TechStuff2020/Portfolio-Doctor/assets/20066864/6ee5e464-9ba8-4e9b-a437-2114a48e3fc3) 55 | 56 | ### I like this! How can I support this initiative? 57 | 58 | Firstly, thank you! If you're a techie, feel free to pull and contribute to the repo. It is open source. If you wish to use/customize the software, send an email to hello-(at)-portfoliodoc.app 59 | 60 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Apache Maven Wrapper startup batch script, version 3.2.0 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 28 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 29 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 30 | @REM e.g. to debug Maven itself, use 31 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 32 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 33 | @REM ---------------------------------------------------------------------------- 34 | 35 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 36 | @echo off 37 | @REM set title of command window 38 | title %0 39 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 40 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 41 | 42 | @REM set %HOME% to equivalent of $HOME 43 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 44 | 45 | @REM Execute a user defined script before this one 46 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 47 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 48 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 49 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 50 | :skipRcPre 51 | 52 | @setlocal 53 | 54 | set ERROR_CODE=0 55 | 56 | @REM To isolate internal variables from possible post scripts, we use another setlocal 57 | @setlocal 58 | 59 | @REM ==== START VALIDATION ==== 60 | if not "%JAVA_HOME%" == "" goto OkJHome 61 | 62 | echo. 63 | echo Error: JAVA_HOME not found in your environment. >&2 64 | echo Please set the JAVA_HOME variable in your environment to match the >&2 65 | echo location of your Java installation. >&2 66 | echo. 67 | goto error 68 | 69 | :OkJHome 70 | if exist "%JAVA_HOME%\bin\java.exe" goto init 71 | 72 | echo. 73 | echo Error: JAVA_HOME is set to an invalid directory. >&2 74 | echo JAVA_HOME = "%JAVA_HOME%" >&2 75 | echo Please set the JAVA_HOME variable in your environment to match the >&2 76 | echo location of your Java installation. >&2 77 | echo. 78 | goto error 79 | 80 | @REM ==== END VALIDATION ==== 81 | 82 | :init 83 | 84 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 85 | @REM Fallback to current working directory if not found. 86 | 87 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 88 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 89 | 90 | set EXEC_DIR=%CD% 91 | set WDIR=%EXEC_DIR% 92 | :findBaseDir 93 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 94 | cd .. 95 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 96 | set WDIR=%CD% 97 | goto findBaseDir 98 | 99 | :baseDirFound 100 | set MAVEN_PROJECTBASEDIR=%WDIR% 101 | cd "%EXEC_DIR%" 102 | goto endDetectBaseDir 103 | 104 | :baseDirNotFound 105 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 106 | cd "%EXEC_DIR%" 107 | 108 | :endDetectBaseDir 109 | 110 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 111 | 112 | @setlocal EnableExtensions EnableDelayedExpansion 113 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 114 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 115 | 116 | :endReadAdditionalConfig 117 | 118 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 123 | 124 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 125 | IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | if "%MVNW_VERBOSE%" == "true" ( 132 | echo Found %WRAPPER_JAR% 133 | ) 134 | ) else ( 135 | if not "%MVNW_REPOURL%" == "" ( 136 | SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 137 | ) 138 | if "%MVNW_VERBOSE%" == "true" ( 139 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 140 | echo Downloading from: %WRAPPER_URL% 141 | ) 142 | 143 | powershell -Command "&{"^ 144 | "$webclient = new-object System.Net.WebClient;"^ 145 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 146 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 147 | "}"^ 148 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ 149 | "}" 150 | if "%MVNW_VERBOSE%" == "true" ( 151 | echo Finished downloading %WRAPPER_JAR% 152 | ) 153 | ) 154 | @REM End of extension 155 | 156 | @REM If specified, validate the SHA-256 sum of the Maven wrapper jar file 157 | SET WRAPPER_SHA_256_SUM="" 158 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 159 | IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B 160 | ) 161 | IF NOT %WRAPPER_SHA_256_SUM%=="" ( 162 | powershell -Command "&{"^ 163 | "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ 164 | "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ 165 | " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ 166 | " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ 167 | " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ 168 | " exit 1;"^ 169 | "}"^ 170 | "}" 171 | if ERRORLEVEL 1 goto error 172 | ) 173 | 174 | @REM Provide a "standardized" way to retrieve the CLI args that will 175 | @REM work with both Windows and non-Windows executions. 176 | set MAVEN_CMD_LINE_ARGS=%* 177 | 178 | %MAVEN_JAVA_EXE% ^ 179 | %JVM_CONFIG_MAVEN_PROPS% ^ 180 | %MAVEN_OPTS% ^ 181 | %MAVEN_DEBUG_OPTS% ^ 182 | -classpath %WRAPPER_JAR% ^ 183 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 184 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 185 | if ERRORLEVEL 1 goto error 186 | goto end 187 | 188 | :error 189 | set ERROR_CODE=1 190 | 191 | :end 192 | @endlocal & set ERROR_CODE=%ERROR_CODE% 193 | 194 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 195 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 196 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 197 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 198 | :skipRcPost 199 | 200 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 201 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 202 | 203 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 204 | 205 | cmd /C exit /B %ERROR_CODE% 206 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.2.0 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | # e.g. to debug Maven itself, use 32 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | # ---------------------------------------------------------------------------- 35 | 36 | if [ -z "$MAVEN_SKIP_RC" ] ; then 37 | 38 | if [ -f /usr/local/etc/mavenrc ] ; then 39 | . /usr/local/etc/mavenrc 40 | fi 41 | 42 | if [ -f /etc/mavenrc ] ; then 43 | . /etc/mavenrc 44 | fi 45 | 46 | if [ -f "$HOME/.mavenrc" ] ; then 47 | . "$HOME/.mavenrc" 48 | fi 49 | 50 | fi 51 | 52 | # OS specific support. $var _must_ be set to either true or false. 53 | cygwin=false; 54 | darwin=false; 55 | mingw=false 56 | case "$(uname)" in 57 | CYGWIN*) cygwin=true ;; 58 | MINGW*) mingw=true;; 59 | Darwin*) darwin=true 60 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 61 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 62 | if [ -z "$JAVA_HOME" ]; then 63 | if [ -x "/usr/libexec/java_home" ]; then 64 | JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME 65 | else 66 | JAVA_HOME="/Library/Java/Home"; export JAVA_HOME 67 | fi 68 | fi 69 | ;; 70 | esac 71 | 72 | if [ -z "$JAVA_HOME" ] ; then 73 | if [ -r /etc/gentoo-release ] ; then 74 | JAVA_HOME=$(java-config --jre-home) 75 | fi 76 | fi 77 | 78 | # For Cygwin, ensure paths are in UNIX format before anything is touched 79 | if $cygwin ; then 80 | [ -n "$JAVA_HOME" ] && 81 | JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 82 | [ -n "$CLASSPATH" ] && 83 | CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 84 | fi 85 | 86 | # For Mingw, ensure paths are in UNIX format before anything is touched 87 | if $mingw ; then 88 | [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && 89 | JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" 90 | fi 91 | 92 | if [ -z "$JAVA_HOME" ]; then 93 | javaExecutable="$(which javac)" 94 | if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then 95 | # readlink(1) is not available as standard on Solaris 10. 96 | readLink=$(which readlink) 97 | if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then 98 | if $darwin ; then 99 | javaHome="$(dirname "\"$javaExecutable\"")" 100 | javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" 101 | else 102 | javaExecutable="$(readlink -f "\"$javaExecutable\"")" 103 | fi 104 | javaHome="$(dirname "\"$javaExecutable\"")" 105 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 106 | JAVA_HOME="$javaHome" 107 | export JAVA_HOME 108 | fi 109 | fi 110 | fi 111 | 112 | if [ -z "$JAVACMD" ] ; then 113 | if [ -n "$JAVA_HOME" ] ; then 114 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 115 | # IBM's JDK on AIX uses strange locations for the executables 116 | JAVACMD="$JAVA_HOME/jre/sh/java" 117 | else 118 | JAVACMD="$JAVA_HOME/bin/java" 119 | fi 120 | else 121 | JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" 122 | fi 123 | fi 124 | 125 | if [ ! -x "$JAVACMD" ] ; then 126 | echo "Error: JAVA_HOME is not defined correctly." >&2 127 | echo " We cannot execute $JAVACMD" >&2 128 | exit 1 129 | fi 130 | 131 | if [ -z "$JAVA_HOME" ] ; then 132 | echo "Warning: JAVA_HOME environment variable is not set." 133 | fi 134 | 135 | # traverses directory structure from process work directory to filesystem root 136 | # first directory with .mvn subdirectory is considered project base directory 137 | find_maven_basedir() { 138 | if [ -z "$1" ] 139 | then 140 | echo "Path not specified to find_maven_basedir" 141 | return 1 142 | fi 143 | 144 | basedir="$1" 145 | wdir="$1" 146 | while [ "$wdir" != '/' ] ; do 147 | if [ -d "$wdir"/.mvn ] ; then 148 | basedir=$wdir 149 | break 150 | fi 151 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 152 | if [ -d "${wdir}" ]; then 153 | wdir=$(cd "$wdir/.." || exit 1; pwd) 154 | fi 155 | # end of workaround 156 | done 157 | printf '%s' "$(cd "$basedir" || exit 1; pwd)" 158 | } 159 | 160 | # concatenates all lines of a file 161 | concat_lines() { 162 | if [ -f "$1" ]; then 163 | # Remove \r in case we run on Windows within Git Bash 164 | # and check out the repository with auto CRLF management 165 | # enabled. Otherwise, we may read lines that are delimited with 166 | # \r\n and produce $'-Xarg\r' rather than -Xarg due to word 167 | # splitting rules. 168 | tr -s '\r\n' ' ' < "$1" 169 | fi 170 | } 171 | 172 | log() { 173 | if [ "$MVNW_VERBOSE" = true ]; then 174 | printf '%s\n' "$1" 175 | fi 176 | } 177 | 178 | BASE_DIR=$(find_maven_basedir "$(dirname "$0")") 179 | if [ -z "$BASE_DIR" ]; then 180 | exit 1; 181 | fi 182 | 183 | MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR 184 | log "$MAVEN_PROJECTBASEDIR" 185 | 186 | ########################################################################################## 187 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 188 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 189 | ########################################################################################## 190 | wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" 191 | if [ -r "$wrapperJarPath" ]; then 192 | log "Found $wrapperJarPath" 193 | else 194 | log "Couldn't find $wrapperJarPath, downloading it ..." 195 | 196 | if [ -n "$MVNW_REPOURL" ]; then 197 | wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 198 | else 199 | wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 200 | fi 201 | while IFS="=" read -r key value; do 202 | # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) 203 | safeValue=$(echo "$value" | tr -d '\r') 204 | case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; 205 | esac 206 | done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 207 | log "Downloading from: $wrapperUrl" 208 | 209 | if $cygwin; then 210 | wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") 211 | fi 212 | 213 | if command -v wget > /dev/null; then 214 | log "Found wget ... using wget" 215 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" 216 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 217 | wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 218 | else 219 | wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 220 | fi 221 | elif command -v curl > /dev/null; then 222 | log "Found curl ... using curl" 223 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" 224 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 225 | curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 226 | else 227 | curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 228 | fi 229 | else 230 | log "Falling back to using Java to download" 231 | javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" 232 | javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" 233 | # For Cygwin, switch paths to Windows format before running javac 234 | if $cygwin; then 235 | javaSource=$(cygpath --path --windows "$javaSource") 236 | javaClass=$(cygpath --path --windows "$javaClass") 237 | fi 238 | if [ -e "$javaSource" ]; then 239 | if [ ! -e "$javaClass" ]; then 240 | log " - Compiling MavenWrapperDownloader.java ..." 241 | ("$JAVA_HOME/bin/javac" "$javaSource") 242 | fi 243 | if [ -e "$javaClass" ]; then 244 | log " - Running MavenWrapperDownloader.java ..." 245 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" 246 | fi 247 | fi 248 | fi 249 | fi 250 | ########################################################################################## 251 | # End of extension 252 | ########################################################################################## 253 | 254 | # If specified, validate the SHA-256 sum of the Maven wrapper jar file 255 | wrapperSha256Sum="" 256 | while IFS="=" read -r key value; do 257 | case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; 258 | esac 259 | done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 260 | if [ -n "$wrapperSha256Sum" ]; then 261 | wrapperSha256Result=false 262 | if command -v sha256sum > /dev/null; then 263 | if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then 264 | wrapperSha256Result=true 265 | fi 266 | elif command -v shasum > /dev/null; then 267 | if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then 268 | wrapperSha256Result=true 269 | fi 270 | else 271 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." 272 | echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." 273 | exit 1 274 | fi 275 | if [ $wrapperSha256Result = false ]; then 276 | echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 277 | echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 278 | echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 279 | exit 1 280 | fi 281 | fi 282 | 283 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 284 | 285 | # For Cygwin, switch paths to Windows format before running java 286 | if $cygwin; then 287 | [ -n "$JAVA_HOME" ] && 288 | JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 289 | [ -n "$CLASSPATH" ] && 290 | CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 291 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 292 | MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 293 | fi 294 | 295 | # Provide a "standardized" way to retrieve the CLI args that will 296 | # work with both Windows and non-Windows executions. 297 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" 298 | export MAVEN_CMD_LINE_ARGS 299 | 300 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 301 | 302 | # shellcheck disable=SC2086 # safe args 303 | exec "$JAVACMD" \ 304 | $MAVEN_OPTS \ 305 | $MAVEN_DEBUG_OPTS \ 306 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 307 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 308 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 309 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /src/main/java/com/portfolio/doctor/service/PortfolioServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.portfolio.doctor.service; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import com.portfolio.doctor.payload.*; 7 | import com.portfolio.doctor.util.ApplicationProperties; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.reactive.function.client.WebClient; 15 | import org.springframework.web.util.UriComponentsBuilder; 16 | 17 | import java.time.DayOfWeek; 18 | import java.time.LocalDate; 19 | import java.time.temporal.ChronoUnit; 20 | import java.util.*; 21 | import java.util.stream.Collectors; 22 | 23 | @Service 24 | public class PortfolioServiceImpl implements PortfolioService { 25 | private final WebClient webClient; 26 | 27 | private final Map companyCurrencyMap = new HashMap<>(); 28 | 29 | private final ApplicationProperties applicationProperties; 30 | 31 | @Autowired 32 | public PortfolioServiceImpl(ApplicationProperties applicationProperties) { 33 | this.applicationProperties = applicationProperties; 34 | this.webClient = WebClient.create(); 35 | 36 | } 37 | 38 | @Override 39 | public ResponseEntity processTrades(@RequestBody TradeDto tradeDto) { 40 | try { 41 | checkCompanyCurrency(tradeDto.getBenchmarkSymbol()); 42 | 43 | Map>> tickerGroupTree = new HashMap<>(); 44 | Map>> currExchangeRateMap = new HashMap<>(); 45 | TreeMap> tradesGroupedByTheirDate = groupTradesByTheirDate(tradeDto.getTradeList()); 46 | PortfolioRes actualValue = calculateResult(tradesGroupedByTheirDate, tradeDto, tickerGroupTree, currExchangeRateMap); 47 | 48 | modifyTradesForSimulation(tradeDto, tickerGroupTree, currExchangeRateMap, tradesGroupedByTheirDate, actualValue); 49 | TreeMap> simulationTradesGrouped = groupTradesByTheirDate(tradeDto.getTradeList()); 50 | PortfolioRes simulationValue = calculateResult(simulationTradesGrouped, tradeDto, tickerGroupTree, currExchangeRateMap); 51 | return ResponseEntity.ok(new ApiResponse(true, Map.of("actual", actualValue, "simulation", simulationValue))); 52 | } catch (Exception e) { 53 | 54 | throw new RuntimeException("Something went wrong please refer to documentation", e); 55 | } 56 | } 57 | 58 | private void modifyTradesForSimulation(TradeDto tradeDto, Map>> tickerGroupTree, Map>> currExchangeRateMap, TreeMap> tradesGroupedByTheirDate, PortfolioRes actualValue) { 59 | PortfolioValueRes firstDayRes = actualValue.getResponseList().get(0); 60 | double installmentAmount = (firstDayRes.getPortfolioCash() + firstDayRes.getValue()) / (tradeDto.getTradeList().size()); 61 | LocalDate first = tradesGroupedByTheirDate.firstEntry().getKey(); 62 | LocalDate last = tradesGroupedByTheirDate.lastEntry().getKey(); 63 | long daysDifference = tradeDto.getTradeList().size() == 1 ? 0 : ChronoUnit.DAYS.between(first, last) / (tradeDto.getTradeList().size() - 1); 64 | fetchCompanyReport(tradeDto.getBenchmarkSymbol()); 65 | List simulationTrades = new ArrayList<>(); 66 | for (Trade trade : tradeDto.getTradeList()) { 67 | Trade clone = trade.clone(); 68 | clone.setAction((byte) 1); 69 | clone.setTicker(tradeDto.getBenchmarkSymbol()); 70 | clone.setQuantity(installmentAmount / getClosePrice( 71 | tickerGroupTree, makeFriday(first), tradeDto, currExchangeRateMap, tradeDto.getBenchmarkSymbol())); 72 | clone.setDate(makeFriday(first)); 73 | clone.setFixedFee(0); 74 | clone.setVariableFee(0); 75 | simulationTrades.add(clone); 76 | first = first.plusDays(daysDifference); 77 | } 78 | simulationTrades.get(simulationTrades.size() - 1).setDate(last); 79 | tradeDto.setTradeList(simulationTrades); 80 | } 81 | 82 | private PortfolioRes calculateResult(TreeMap> tradesGroupedByTheirDate, 83 | TradeDto tradeDto, 84 | Map>> tickerGroupTree, 85 | Map>> currExchangeRateMap) { 86 | PortfolioRes portfolioRes = new PortfolioRes(); 87 | CashNetHolder cashNetHolder = new CashNetHolder(); 88 | Map holdingMap = new HashMap<>(); 89 | 90 | _calculateResult(tradesGroupedByTheirDate, tradeDto, portfolioRes, cashNetHolder, tickerGroupTree, currExchangeRateMap, holdingMap); 91 | 92 | cashNetHolder.setCash(portfolioRes.getResponseList().get(portfolioRes.getResponseList().size() - 1).getNetNewPurchase()); 93 | cashNetHolder.setNet(portfolioRes.getResponseList().get(0).getNetNewPurchase()); 94 | cashNetHolder.setFees(0); 95 | cashNetHolder.setTaxes(0); 96 | portfolioRes = new PortfolioRes(); 97 | holdingMap = new HashMap<>(); 98 | _calculateResult(tradesGroupedByTheirDate, tradeDto, portfolioRes, cashNetHolder, tickerGroupTree, currExchangeRateMap, holdingMap); 99 | checkScaled(tradeDto.isScaleOutput(), portfolioRes); 100 | return portfolioRes; 101 | } 102 | 103 | private void _calculateResult(TreeMap> tradesGroupedByTheirDate, TradeDto tradeDto, 104 | PortfolioRes portfolioRes, CashNetHolder cashNetHolder, 105 | Map>> tickerGroupTree, 106 | Map>> currExchangeRateMap, 107 | Map holdingMap) { 108 | //getting first trade date 109 | LocalDate tradeDate = tradesGroupedByTheirDate.firstEntry().getKey().plusDays(0); 110 | LocalDate currentDate = LocalDate.now(); 111 | List gains = new ArrayList<>(); 112 | while (!tradeDate.isAfter(currentDate)) { 113 | 114 | handleTrades(tradesGroupedByTheirDate, cashNetHolder, tickerGroupTree, holdingMap, tradeDate, tradeDto, currExchangeRateMap, gains); 115 | 116 | PortfolioValueRes portfolioValueRes = createPortfolio(cashNetHolder, holdingMap, tradeDate); 117 | 118 | portfolioValueRes.setBenchmarkPrice(getClosePrice(tickerGroupTree, tradeDate, tradeDto, currExchangeRateMap, tradeDto.getBenchmarkSymbol())); 119 | 120 | calculateValues(tickerGroupTree, tradeDate, portfolioValueRes, currExchangeRateMap, tradeDto); 121 | 122 | portfolioRes.getResponseList().add(portfolioValueRes); 123 | 124 | cashNetHolder.cash += (tradeDto.getCashReturn() * cashNetHolder.cash / 5200); 125 | 126 | portfolioValueRes.setGains(gains.stream().map(Gain::clone).toList()); 127 | 128 | tradeDate = tradeDate.plusDays(7); 129 | } 130 | handleStandardDeviationAndInitialCash(portfolioRes); 131 | portfolioRes.setFeesPaid(cashNetHolder.fees); 132 | portfolioRes.setGainTaxValue(cashNetHolder.taxes); 133 | } 134 | 135 | private void handleStandardDeviationAndInitialCash(PortfolioRes portfolioRes) { 136 | //create an empty array for standard deviation logic 137 | List standardDeviationList = new ArrayList<>(); 138 | 139 | double sum = getSumOfTotalValuesAndHandleInitialCash(portfolioRes, standardDeviationList); 140 | 141 | // get the mean of array 142 | int length = standardDeviationList.size(); 143 | double mean = sum / length; 144 | 145 | // calculate the standard deviation 146 | double standardDeviation = 0.0; 147 | for (double num : standardDeviationList) { 148 | standardDeviation += Math.pow(num - mean, 2); 149 | } 150 | 151 | portfolioRes.setStandardDeviation(Math.sqrt(standardDeviation / length)); 152 | } 153 | 154 | private static double getSumOfTotalValuesAndHandleInitialCash(PortfolioRes portfolioRes, List standardDeviationList) { 155 | double sum = 0.0; 156 | for (PortfolioValueRes portfolioValueRes : portfolioRes.getResponseList()) { 157 | 158 | double total = portfolioValueRes.getValue() + portfolioValueRes.getPortfolioCash(); 159 | standardDeviationList.add(total); 160 | sum += total; 161 | 162 | 163 | } 164 | return sum; 165 | } 166 | 167 | 168 | private void checkScaled(boolean scaleOutput, PortfolioRes portfolioRes) { 169 | if (scaleOutput) { 170 | if (portfolioRes.getResponseList().size() == 0) 171 | throw new RuntimeException("Portfolio has no data. Please check your input"); 172 | PortfolioValueRes portfolioValueRes = portfolioRes.getResponseList().get(0); 173 | double scaleValue = 100 / (portfolioValueRes.getNetNewPurchase() + portfolioValueRes.getPortfolioCash()); 174 | portfolioRes.makeScaled(scaleValue); 175 | portfolioRes.setResponseList(portfolioRes.getResponseList().stream().peek(i -> { 176 | i.makeScaled(scaleValue); 177 | for (Gain gain : i.getGains()) { 178 | gain.makeScaled(scaleValue); 179 | } 180 | i.setHoldingList(i.getHoldingList().stream().map(j -> { 181 | j.makeScaled(scaleValue); 182 | return new HoldingScaled(j.getTicker(), j.getPositionValue()); 183 | }).collect(Collectors.toSet())); 184 | }).toList()); 185 | } 186 | } 187 | 188 | private PortfolioValueRes createPortfolio(CashNetHolder cashNetHolder, Map holdingMap, LocalDate tradeDate) { 189 | PortfolioValueRes portfolioValueRes = createTestRes(tradeDate); 190 | List holdingStream = holdingMap.values().stream() 191 | .map(h -> new Holding(h.getTicker(), h.getQuantity(), 0)).toList(); 192 | portfolioValueRes.setHoldingList(new HashSet<>(holdingStream)); 193 | portfolioValueRes.setNetNewPurchase(cashNetHolder.net); 194 | portfolioValueRes.setPortfolioCash(cashNetHolder.cash); 195 | return portfolioValueRes; 196 | } 197 | 198 | private void handleTrades(TreeMap> tradesGroupedByTheirDate, 199 | CashNetHolder cashNetHolder, 200 | Map>> tickerGroupTree, 201 | Map holdingMap, 202 | LocalDate tradeDate, 203 | TradeDto tradeDto, 204 | Map>> currExchangeRateMap, 205 | List gains) { 206 | ArrayList trades = tradesGroupedByTheirDate.getOrDefault(tradeDate, new ArrayList<>()); 207 | 208 | for (Trade trade : trades) { 209 | checkCompanyCurrency(trade.getTicker()); 210 | 211 | Holding holding = holdingMap.computeIfAbsent(trade.getTicker(), i -> new Holding(i, 0, 0)); 212 | holding.setQuantity(holding.getQuantity() + (trade.getAction() * trade.getQuantity())); 213 | 214 | double closePrice = getClosePrice(tickerGroupTree, tradeDate, tradeDto, currExchangeRateMap, trade.getTicker()); 215 | 216 | handleGains(cashNetHolder, tradeDto, gains, trade, closePrice); 217 | 218 | 219 | cashNetHolder.cash -= calculateTradeCost(trade, closePrice, cashNetHolder); 220 | cashNetHolder.net += Math.max(-cashNetHolder.cash, 0); 221 | cashNetHolder.cash = Math.max(cashNetHolder.cash, 0); 222 | 223 | } 224 | for (Gain gain : gains) { 225 | double closePrice = getClosePrice(tickerGroupTree, tradeDate, tradeDto, currExchangeRateMap, gain.getTicker()); 226 | gain.setGains((closePrice - gain.getPrice()) * gain.getQuantity()); 227 | } 228 | 229 | } 230 | 231 | private void handleGains(CashNetHolder cashNetHolder, TradeDto tradeDto, List gains, Trade trade, double closePrice) { 232 | if (trade.getAction() == 1) { 233 | gains.add(new Gain(trade.getTicker(), trade.getQuantity(), gains.size() + 1, closePrice)); 234 | } else { 235 | double quantity = trade.getQuantity(); 236 | for (Gain gain : gains) { 237 | if (quantity == 0) break; 238 | if (!gain.getTicker().equals(trade.getTicker()) || gain.getQuantity() <= 0) continue; 239 | double gainInitQt = gain.getQuantity(); 240 | gain.setQuantity(Math.max(gain.getQuantity() - quantity, 0)); 241 | double gainValue = (closePrice - gain.getPrice()) * (gainInitQt - gain.getQuantity()); 242 | quantity -= gainInitQt; 243 | handleGainTax(cashNetHolder, tradeDto, gain, gainValue); 244 | gain.setBookedGains(gain.getBookedGains() + gainValue); 245 | } 246 | } 247 | } 248 | 249 | private void handleGainTax(CashNetHolder cashNetHolder, TradeDto tradeDto, Gain gain, double gainValue) { 250 | if (gainValue > 0) { 251 | double tax = gainValue * tradeDto.getGainTax() / 100; 252 | cashNetHolder.cash -= tax; 253 | cashNetHolder.taxes += tax; 254 | gain.setTax(gain.getTax() + tax); 255 | } 256 | } 257 | 258 | private double getClosePrice(Map>> tickerGroupTree, 259 | LocalDate tradeDate, 260 | TradeDto tradeDto, 261 | Map>> currExchangeRateMap, 262 | String ticker) { 263 | var tickData = 264 | getWeeklyTimeSeriesDataByTickerName( 265 | tickerGroupTree, ticker 266 | ); 267 | boolean sameCurrency = companyCurrencyMap.get(ticker).equals(tradeDto.getCurrency().getCurrencyCode()); 268 | var currencyData = sameCurrency ? null : 269 | getWeeklySeriesFXDataByCurrencyCode( 270 | currExchangeRateMap, 271 | companyCurrencyMap.get(ticker), tradeDto.getCurrency().getCurrencyCode() 272 | ); 273 | return _getClosePrice(tradeDate, tickData, currencyData, sameCurrency); 274 | } 275 | 276 | private static double _getClosePrice( 277 | LocalDate tradeDate, TreeMap> tickData, 278 | TreeMap> currencyData, boolean sameCurrency) { 279 | String closedPriceOfTrade = findResultOrReturnClosestObject(tickData, tradeDate).get("4. close"); 280 | String exchangeRate = sameCurrency ? "1" : findResultOrReturnClosestObject(currencyData, tradeDate).get("4. close"); 281 | return Double.parseDouble(closedPriceOfTrade) * Double.parseDouble(exchangeRate); 282 | } 283 | 284 | 285 | private static Map findResultOrReturnClosestObject(TreeMap> tickData, LocalDate tradeDate) { 286 | return !tickData.containsKey(tradeDate) ? tickData.floorEntry(tradeDate).getValue() : tickData.get(tradeDate); 287 | } 288 | 289 | private void checkCompanyCurrency(String ticker) { 290 | if (!companyCurrencyMap.containsKey(ticker)) { 291 | fetchCompanyReport(ticker); 292 | } 293 | } 294 | 295 | private double calculateTradeCost(Trade trade, double closePrice, CashNetHolder cashNetHolder) { 296 | closePrice = trade.getPrice() == null ? closePrice : trade.getPrice(); 297 | double costWithoutFees = trade.getAction() * trade.getQuantity() * closePrice; 298 | double fees = trade.getFixedFee() + (trade.getQuantity() * closePrice * trade.getVariableFee() / 100); 299 | cashNetHolder.fees += fees; 300 | return costWithoutFees + fees; 301 | } 302 | 303 | private PortfolioValueRes createTestRes(LocalDate date) { 304 | PortfolioValueRes portfolioValueRes = new PortfolioValueRes(); 305 | portfolioValueRes.setDate(date); 306 | return portfolioValueRes; 307 | } 308 | 309 | private void calculateValues(Map>> tickerList, LocalDate tradeDate, 310 | PortfolioValueRes portfolioValueRes1, 311 | Map>> currExchangeRateMap, TradeDto tradeDto) { 312 | for (HoldingScaled holding : portfolioValueRes1.getHoldingList()) { 313 | 314 | TreeMap> tickData = getWeeklyTimeSeriesDataByTickerName(tickerList, holding.getTicker()); 315 | 316 | Map tradeObjOfTradeDate = findResultOrReturnClosestObject(tickData, tradeDate); 317 | 318 | String exchangeRate = companyCurrencyMap.get(holding.getTicker()).equals(tradeDto.getCurrency().getCurrencyCode()) ? "1" : 319 | getExchangeRate(tradeDate, currExchangeRateMap, tradeDto, holding); 320 | 321 | double v = (Double.parseDouble(tradeObjOfTradeDate.get("4. close")) * 322 | Double.parseDouble(exchangeRate) * 323 | ((Holding) holding).getQuantity()); 324 | holding.setPositionValue(v); 325 | portfolioValueRes1.setValue(portfolioValueRes1.getValue() + v); 326 | } 327 | } 328 | 329 | private String getExchangeRate(LocalDate tradeDate, Map>> currExchangeRateMap, TradeDto tradeDto, HoldingScaled holding) { 330 | var currencyData = 331 | getWeeklySeriesFXDataByCurrencyCode( 332 | currExchangeRateMap, 333 | companyCurrencyMap.get(holding.getTicker()), tradeDto.getCurrency().getCurrencyCode() 334 | ); 335 | Map currExchangeObj = findResultOrReturnClosestObject(currencyData, tradeDate); 336 | 337 | String exchangeRate = currExchangeObj.get("4. close"); 338 | return exchangeRate; 339 | } 340 | 341 | private TreeMap> getWeeklyTimeSeriesDataByTickerName(Map>> tickerList, String ticker) { 342 | return tickerList.containsKey(ticker) ? tickerList.get(ticker) : 343 | fetchWeeklyTimeSeries(ticker, tickerList); 344 | } 345 | 346 | private TreeMap> getWeeklySeriesFXDataByCurrencyCode(Map>> tickerList, String fromCurr, String toCurr) { 347 | return tickerList.containsKey(fromCurr + "-" + toCurr) ? tickerList.get(fromCurr + "-" + toCurr) : 348 | fetchWeeklyFXexchangeRate(toCurr, fromCurr, tickerList); 349 | } 350 | 351 | private static TreeMap> groupTradesByTheirDate(List d) { 352 | for (Trade i : d) { 353 | i.setDate(makeFriday(i.getDate())); 354 | } 355 | return d.stream().sorted(Comparator.comparing(Trade::getDate)).collect(Collectors.toMap( 356 | Trade::getDate, 357 | obj -> new ArrayList<>(List.of(obj)), 358 | (list1, list2) -> { 359 | ArrayList mergedList = new ArrayList<>(); 360 | mergedList.addAll(list1); 361 | mergedList.addAll(list2); 362 | return mergedList; 363 | }, 364 | TreeMap::new 365 | )); 366 | } 367 | 368 | private static LocalDate makeFriday(LocalDate date) { 369 | return date.getDayOfWeek() != DayOfWeek.FRIDAY ? date.with(DayOfWeek.FRIDAY) : date; 370 | } 371 | 372 | 373 | private TreeMap> fetchWeeklyTimeSeries(String ticker, Map>> tickerList) { 374 | 375 | String apiUrl = getWeeklyTimeSeriesUrl(ticker); 376 | JsonNode jsonResponse = webClient.get() 377 | .uri(apiUrl) 378 | .retrieve() 379 | .bodyToFlux(JsonNode.class) 380 | .blockFirst(); 381 | assert jsonResponse != null; 382 | TreeMap> weeklyTimeSeries = convertWeeklyTimeSeriesJsonToTreeMapAndReturn(jsonResponse, "Weekly Time Series"); 383 | System.out.println(apiUrl); 384 | 385 | tickerList.put(ticker, weeklyTimeSeries); 386 | 387 | return weeklyTimeSeries; 388 | 389 | } 390 | 391 | private void fetchCompanyReport(String sym) { 392 | String apiUrl = getCompanyReportUrl(sym); 393 | JsonNode jsonResponse = webClient.get() 394 | .uri(apiUrl) 395 | .retrieve() 396 | .bodyToFlux(JsonNode.class) 397 | .blockFirst(); 398 | System.out.println(apiUrl); 399 | 400 | assert jsonResponse != null; 401 | getCurrencyAndPutIntoMap(sym, jsonResponse); 402 | 403 | } 404 | 405 | private TreeMap> fetchWeeklyFXexchangeRate(String toCurr, String fromCurr, Map>> currList) { 406 | String apiUrl = getWeeklyFXExchangeUrl(toCurr, fromCurr); 407 | JsonNode jsonResponse = webClient.get() 408 | .uri(apiUrl) 409 | .retrieve() 410 | .bodyToFlux(JsonNode.class) 411 | .blockFirst(); 412 | System.out.println(apiUrl); 413 | assert jsonResponse != null; 414 | TreeMap> weeklySeriesFX = convertWeeklyTimeSeriesJsonToTreeMapAndReturn(jsonResponse, "Time Series FX (Weekly)"); 415 | 416 | currList.put(fromCurr + "-" + toCurr, weeklySeriesFX); 417 | 418 | return weeklySeriesFX; 419 | } 420 | 421 | private void getCurrencyAndPutIntoMap(String sym, JsonNode jsonResponse) { 422 | JsonNode bestMatchesNode = jsonResponse.get("bestMatches"); 423 | 424 | if (bestMatchesNode.isArray()) { 425 | for (JsonNode matchNode : bestMatchesNode) { 426 | if (matchNode.get("1. symbol").textValue().equals(sym)) { 427 | companyCurrencyMap.put(sym, matchNode.get("8. currency").textValue()); 428 | } 429 | } 430 | } 431 | companyCurrencyMap.get(sym); 432 | } 433 | 434 | private static TreeMap> convertWeeklyTimeSeriesJsonToTreeMapAndReturn(JsonNode jsonResponse, String targetKey) { 435 | // Convert the "Weekly Time Series" data into a TreeMap 436 | TreeMap> weeklyTimeSeriesMap = new TreeMap<>(); 437 | JsonNode weeklyTimeSeries = jsonResponse.get(targetKey); 438 | ObjectMapper objectMapper = new ObjectMapper(); 439 | if (weeklyTimeSeries == null) { 440 | System.out.println(jsonResponse); 441 | } 442 | assert weeklyTimeSeries != null; 443 | 444 | weeklyTimeSeries.fields().forEachRemaining(entry -> { 445 | LocalDate date = LocalDate.parse(entry.getKey()); 446 | JsonNode data = entry.getValue(); 447 | Map weeklyTimeSeriesConverted = objectMapper.convertValue(data, new TypeReference<>() { 448 | }); 449 | 450 | weeklyTimeSeriesMap.put(date, weeklyTimeSeriesConverted); 451 | }); 452 | return weeklyTimeSeriesMap; 453 | } 454 | 455 | 456 | private String getCompanyReportUrl(String sym) { 457 | try { 458 | Thread.sleep(30000); 459 | } catch (InterruptedException e) { 460 | throw new RuntimeException(e); 461 | } 462 | return UriComponentsBuilder.fromUriString(applicationProperties.getTickerUrl()) 463 | .path("query") 464 | .queryParam("function", "SYMBOL_SEARCH") 465 | .queryParam("keywords", sym) 466 | .queryParam("apikey", applicationProperties.getKey()).build() 467 | .toUriString(); 468 | } 469 | 470 | private String getWeeklyTimeSeriesUrl(String ticker) { 471 | try { 472 | Thread.sleep(30000); 473 | } catch (InterruptedException e) { 474 | throw new RuntimeException(e); 475 | } 476 | return UriComponentsBuilder.fromUriString(applicationProperties.getTickerUrl()) 477 | .path("query") 478 | .queryParam("function", "TIME_SERIES_WEEKLY") 479 | .queryParam("symbol", ticker) 480 | .queryParam("apikey", applicationProperties.getKey()).build() 481 | .toUriString(); 482 | } 483 | 484 | private String getWeeklyFXExchangeUrl(String toCurr, String fromCurr) { 485 | try { 486 | Thread.sleep(30000); 487 | } catch (InterruptedException e) { 488 | throw new RuntimeException(e); 489 | } 490 | return UriComponentsBuilder.fromUriString(applicationProperties.getTickerUrl()) 491 | .path("query") 492 | .queryParam("function", "FX_WEEKLY") 493 | .queryParam("from_symbol", fromCurr) 494 | .queryParam("to_symbol", toCurr) 495 | .queryParam("apikey", applicationProperties.getKey()).build() 496 | .toUriString(); 497 | } 498 | 499 | 500 | @Getter 501 | @Setter 502 | static class CashNetHolder { 503 | double cash = 0; 504 | double net = 0; 505 | double fees = 0; 506 | double taxes = 0; 507 | } 508 | } 509 | -------------------------------------------------------------------------------- /Documentation.txt: -------------------------------------------------------------------------------- 1 | By default, project runs in port 8080 and for now we have only one api there. 2 | api is called api/v1/portfolio. 3 | In order to call this api use postman or any provider that manipulates with apis; 4 | http://localhost:8081/api/v1/portfolio and it should be post request 5 | Your request Json looks like following: 6 | { 7 | "currency": "USD", 8 | "cashReturn": 0, 9 | "scaleOutput": false, 10 | "gainTax": 50, 11 | "benchmarkSymbol": "VOO", 12 | "tradeList": [ 13 | { 14 | "date": "2023-01-01", 15 | "quantity": 10, 16 | "action": 1, 17 | "ticker": "AAPL", 18 | "fixedFee": 0, 19 | "variableFee": 20 20 | }, 21 | { 22 | "date": "2023-06-01", 23 | "quantity": 10, 24 | "action": -1, 25 | "ticker": "AAPL", 26 | "fixedFee": 0, 27 | "variableFee": 20 28 | } 29 | ] 30 | } 31 | currency (required) - it is the currency of your portfolio 32 | cashReturn (optional,0 by default ) - annual cash return. 33 | tradeList (required) - list of trades 34 | date (required) , 35 | quantity (required), 36 | action (required, 1/-1 ), 37 | ticker (required), 38 | price (optional, gets closed value if you don't send ), 39 | fixedFee (optional,0 by default ), 40 | variableFee (optional,0 by default ) 41 | 42 | 43 | Following JSON is the response of that request 44 | 45 | { 46 | "success": true, 47 | "message": null, 48 | "data": { 49 | "actual": { 50 | "responseList": [ 51 | { 52 | "value": 1299.3000000000002, 53 | "holdingList": [ 54 | { 55 | "ticker": "AAPL", 56 | "positionValue": 1299.3000000000002, 57 | "quantity": 10.0 58 | } 59 | ], 60 | "gains": [ 61 | { 62 | "ticker": "AAPL", 63 | "quantity": 10.0, 64 | "gains": 0.0, 65 | "tax": 0.0, 66 | "seqNo": 1, 67 | "bookedGains": 0.0 68 | } 69 | ], 70 | "portfolioCash": 0.0, 71 | "benchmarkPrice": 351.34, 72 | "netNewPurchase": 1559.1600000000003, 73 | "date": "2022-12-30" 74 | }, 75 | { 76 | "value": 1296.2, 77 | "holdingList": [ 78 | { 79 | "ticker": "AAPL", 80 | "positionValue": 1296.2, 81 | "quantity": 10.0 82 | } 83 | ], 84 | "gains": [ 85 | { 86 | "ticker": "AAPL", 87 | "quantity": 10.0, 88 | "gains": -3.1000000000000227, 89 | "tax": 0.0, 90 | "seqNo": 1, 91 | "bookedGains": 0.0 92 | } 93 | ], 94 | "portfolioCash": 0.0, 95 | "benchmarkPrice": 356.59, 96 | "netNewPurchase": 1559.1600000000003, 97 | "date": "2023-01-06" 98 | }, 99 | { 100 | "value": 1347.6, 101 | "holdingList": [ 102 | { 103 | "ticker": "AAPL", 104 | "positionValue": 1347.6, 105 | "quantity": 10.0 106 | } 107 | ], 108 | "gains": [ 109 | { 110 | "ticker": "AAPL", 111 | "quantity": 10.0, 112 | "gains": 48.29999999999984, 113 | "tax": 0.0, 114 | "seqNo": 1, 115 | "bookedGains": 0.0 116 | } 117 | ], 118 | "portfolioCash": 0.0, 119 | "benchmarkPrice": 366.23, 120 | "netNewPurchase": 1559.1600000000003, 121 | "date": "2023-01-13" 122 | }, 123 | { 124 | "value": 1378.7, 125 | "holdingList": [ 126 | { 127 | "ticker": "AAPL", 128 | "positionValue": 1378.7, 129 | "quantity": 10.0 130 | } 131 | ], 132 | "gains": [ 133 | { 134 | "ticker": "AAPL", 135 | "quantity": 10.0, 136 | "gains": 79.39999999999998, 137 | "tax": 0.0, 138 | "seqNo": 1, 139 | "bookedGains": 0.0 140 | } 141 | ], 142 | "portfolioCash": 0.0, 143 | "benchmarkPrice": 363.71, 144 | "netNewPurchase": 1559.1600000000003, 145 | "date": "2023-01-20" 146 | }, 147 | { 148 | "value": 1459.3000000000002, 149 | "holdingList": [ 150 | { 151 | "ticker": "AAPL", 152 | "positionValue": 1459.3000000000002, 153 | "quantity": 10.0 154 | } 155 | ], 156 | "gains": [ 157 | { 158 | "ticker": "AAPL", 159 | "quantity": 10.0, 160 | "gains": 160.0, 161 | "tax": 0.0, 162 | "seqNo": 1, 163 | "bookedGains": 0.0 164 | } 165 | ], 166 | "portfolioCash": 0.0, 167 | "benchmarkPrice": 372.87, 168 | "netNewPurchase": 1559.1600000000003, 169 | "date": "2023-01-27" 170 | }, 171 | { 172 | "value": 1545.0, 173 | "holdingList": [ 174 | { 175 | "ticker": "AAPL", 176 | "positionValue": 1545.0, 177 | "quantity": 10.0 178 | } 179 | ], 180 | "gains": [ 181 | { 182 | "ticker": "AAPL", 183 | "quantity": 10.0, 184 | "gains": 245.69999999999993, 185 | "tax": 0.0, 186 | "seqNo": 1, 187 | "bookedGains": 0.0 188 | } 189 | ], 190 | "portfolioCash": 0.0, 191 | "benchmarkPrice": 378.85, 192 | "netNewPurchase": 1559.1600000000003, 193 | "date": "2023-02-03" 194 | }, 195 | { 196 | "value": 1510.1, 197 | "holdingList": [ 198 | { 199 | "ticker": "AAPL", 200 | "positionValue": 1510.1, 201 | "quantity": 10.0 202 | } 203 | ], 204 | "gains": [ 205 | { 206 | "ticker": "AAPL", 207 | "quantity": 10.0, 208 | "gains": 210.79999999999984, 209 | "tax": 0.0, 210 | "seqNo": 1, 211 | "bookedGains": 0.0 212 | } 213 | ], 214 | "portfolioCash": 0.0, 215 | "benchmarkPrice": 375.02, 216 | "netNewPurchase": 1559.1600000000003, 217 | "date": "2023-02-10" 218 | }, 219 | { 220 | "value": 1525.5, 221 | "holdingList": [ 222 | { 223 | "ticker": "AAPL", 224 | "positionValue": 1525.5, 225 | "quantity": 10.0 226 | } 227 | ], 228 | "gains": [ 229 | { 230 | "ticker": "AAPL", 231 | "quantity": 10.0, 232 | "gains": 226.20000000000005, 233 | "tax": 0.0, 234 | "seqNo": 1, 235 | "bookedGains": 0.0 236 | } 237 | ], 238 | "portfolioCash": 0.0, 239 | "benchmarkPrice": 374.22, 240 | "netNewPurchase": 1559.1600000000003, 241 | "date": "2023-02-17" 242 | }, 243 | { 244 | "value": 1467.1000000000001, 245 | "holdingList": [ 246 | { 247 | "ticker": "AAPL", 248 | "positionValue": 1467.1000000000001, 249 | "quantity": 10.0 250 | } 251 | ], 252 | "gains": [ 253 | { 254 | "ticker": "AAPL", 255 | "quantity": 10.0, 256 | "gains": 167.8, 257 | "tax": 0.0, 258 | "seqNo": 1, 259 | "bookedGains": 0.0 260 | } 261 | ], 262 | "portfolioCash": 0.0, 263 | "benchmarkPrice": 364.23, 264 | "netNewPurchase": 1559.1600000000003, 265 | "date": "2023-02-24" 266 | }, 267 | { 268 | "value": 1510.3, 269 | "holdingList": [ 270 | { 271 | "ticker": "AAPL", 272 | "positionValue": 1510.3, 273 | "quantity": 10.0 274 | } 275 | ], 276 | "gains": [ 277 | { 278 | "ticker": "AAPL", 279 | "quantity": 10.0, 280 | "gains": 210.99999999999994, 281 | "tax": 0.0, 282 | "seqNo": 1, 283 | "bookedGains": 0.0 284 | } 285 | ], 286 | "portfolioCash": 0.0, 287 | "benchmarkPrice": 371.28, 288 | "netNewPurchase": 1559.1600000000003, 289 | "date": "2023-03-03" 290 | }, 291 | { 292 | "value": 1485.0, 293 | "holdingList": [ 294 | { 295 | "ticker": "AAPL", 296 | "positionValue": 1485.0, 297 | "quantity": 10.0 298 | } 299 | ], 300 | "gains": [ 301 | { 302 | "ticker": "AAPL", 303 | "quantity": 10.0, 304 | "gains": 185.69999999999993, 305 | "tax": 0.0, 306 | "seqNo": 1, 307 | "bookedGains": 0.0 308 | } 309 | ], 310 | "portfolioCash": 0.0, 311 | "benchmarkPrice": 354.68, 312 | "netNewPurchase": 1559.1600000000003, 313 | "date": "2023-03-10" 314 | }, 315 | { 316 | "value": 1550.0, 317 | "holdingList": [ 318 | { 319 | "ticker": "AAPL", 320 | "positionValue": 1550.0, 321 | "quantity": 10.0 322 | } 323 | ], 324 | "gains": [ 325 | { 326 | "ticker": "AAPL", 327 | "quantity": 10.0, 328 | "gains": 250.69999999999993, 329 | "tax": 0.0, 330 | "seqNo": 1, 331 | "bookedGains": 0.0 332 | } 333 | ], 334 | "portfolioCash": 0.0, 335 | "benchmarkPrice": 359.88, 336 | "netNewPurchase": 1559.1600000000003, 337 | "date": "2023-03-17" 338 | }, 339 | { 340 | "value": 1602.5, 341 | "holdingList": [ 342 | { 343 | "ticker": "AAPL", 344 | "positionValue": 1602.5, 345 | "quantity": 10.0 346 | } 347 | ], 348 | "gains": [ 349 | { 350 | "ticker": "AAPL", 351 | "quantity": 10.0, 352 | "gains": 303.19999999999993, 353 | "tax": 0.0, 354 | "seqNo": 1, 355 | "bookedGains": 0.0 356 | } 357 | ], 358 | "portfolioCash": 0.0, 359 | "benchmarkPrice": 363.56, 360 | "netNewPurchase": 1559.1600000000003, 361 | "date": "2023-03-24" 362 | }, 363 | { 364 | "value": 1649.0, 365 | "holdingList": [ 366 | { 367 | "ticker": "AAPL", 368 | "positionValue": 1649.0, 369 | "quantity": 10.0 370 | } 371 | ], 372 | "gains": [ 373 | { 374 | "ticker": "AAPL", 375 | "quantity": 10.0, 376 | "gains": 349.7, 377 | "tax": 0.0, 378 | "seqNo": 1, 379 | "bookedGains": 0.0 380 | } 381 | ], 382 | "portfolioCash": 0.0, 383 | "benchmarkPrice": 376.07, 384 | "netNewPurchase": 1559.1600000000003, 385 | "date": "2023-03-31" 386 | }, 387 | { 388 | "value": 1646.6, 389 | "holdingList": [ 390 | { 391 | "ticker": "AAPL", 392 | "positionValue": 1646.6, 393 | "quantity": 10.0 394 | } 395 | ], 396 | "gains": [ 397 | { 398 | "ticker": "AAPL", 399 | "quantity": 10.0, 400 | "gains": 347.2999999999999, 401 | "tax": 0.0, 402 | "seqNo": 1, 403 | "bookedGains": 0.0 404 | } 405 | ], 406 | "portfolioCash": 0.0, 407 | "benchmarkPrice": 375.95, 408 | "netNewPurchase": 1559.1600000000003, 409 | "date": "2023-04-07" 410 | }, 411 | { 412 | "value": 1652.1000000000001, 413 | "holdingList": [ 414 | { 415 | "ticker": "AAPL", 416 | "positionValue": 1652.1000000000001, 417 | "quantity": 10.0 418 | } 419 | ], 420 | "gains": [ 421 | { 422 | "ticker": "AAPL", 423 | "quantity": 10.0, 424 | "gains": 352.8, 425 | "tax": 0.0, 426 | "seqNo": 1, 427 | "bookedGains": 0.0 428 | } 429 | ], 430 | "portfolioCash": 0.0, 431 | "benchmarkPrice": 378.99, 432 | "netNewPurchase": 1559.1600000000003, 433 | "date": "2023-04-14" 434 | }, 435 | { 436 | "value": 1650.2, 437 | "holdingList": [ 438 | { 439 | "ticker": "AAPL", 440 | "positionValue": 1650.2, 441 | "quantity": 10.0 442 | } 443 | ], 444 | "gains": [ 445 | { 446 | "ticker": "AAPL", 447 | "quantity": 10.0, 448 | "gains": 350.90000000000003, 449 | "tax": 0.0, 450 | "seqNo": 1, 451 | "bookedGains": 0.0 452 | } 453 | ], 454 | "portfolioCash": 0.0, 455 | "benchmarkPrice": 378.59, 456 | "netNewPurchase": 1559.1600000000003, 457 | "date": "2023-04-21" 458 | }, 459 | { 460 | "value": 1696.8000000000002, 461 | "holdingList": [ 462 | { 463 | "ticker": "AAPL", 464 | "positionValue": 1696.8000000000002, 465 | "quantity": 10.0 466 | } 467 | ], 468 | "gains": [ 469 | { 470 | "ticker": "AAPL", 471 | "quantity": 10.0, 472 | "gains": 397.5, 473 | "tax": 0.0, 474 | "seqNo": 1, 475 | "bookedGains": 0.0 476 | } 477 | ], 478 | "portfolioCash": 0.0, 479 | "benchmarkPrice": 382.05, 480 | "netNewPurchase": 1559.1600000000003, 481 | "date": "2023-04-28" 482 | }, 483 | { 484 | "value": 1735.6999999999998, 485 | "holdingList": [ 486 | { 487 | "ticker": "AAPL", 488 | "positionValue": 1735.6999999999998, 489 | "quantity": 10.0 490 | } 491 | ], 492 | "gains": [ 493 | { 494 | "ticker": "AAPL", 495 | "quantity": 10.0, 496 | "gains": 436.39999999999986, 497 | "tax": 0.0, 498 | "seqNo": 1, 499 | "bookedGains": 0.0 500 | } 501 | ], 502 | "portfolioCash": 0.0, 503 | "benchmarkPrice": 378.97, 504 | "netNewPurchase": 1559.1600000000003, 505 | "date": "2023-05-05" 506 | }, 507 | { 508 | "value": 1725.6999999999998, 509 | "holdingList": [ 510 | { 511 | "ticker": "AAPL", 512 | "positionValue": 1725.6999999999998, 513 | "quantity": 10.0 514 | } 515 | ], 516 | "gains": [ 517 | { 518 | "ticker": "AAPL", 519 | "quantity": 10.0, 520 | "gains": 426.39999999999986, 521 | "tax": 0.0, 522 | "seqNo": 1, 523 | "bookedGains": 0.0 524 | } 525 | ], 526 | "portfolioCash": 0.0, 527 | "benchmarkPrice": 378.15, 528 | "netNewPurchase": 1559.1600000000003, 529 | "date": "2023-05-12" 530 | }, 531 | { 532 | "value": 1751.6, 533 | "holdingList": [ 534 | { 535 | "ticker": "AAPL", 536 | "positionValue": 1751.6, 537 | "quantity": 10.0 538 | } 539 | ], 540 | "gains": [ 541 | { 542 | "ticker": "AAPL", 543 | "quantity": 10.0, 544 | "gains": 452.2999999999999, 545 | "tax": 0.0, 546 | "seqNo": 1, 547 | "bookedGains": 0.0 548 | } 549 | ], 550 | "portfolioCash": 0.0, 551 | "benchmarkPrice": 384.57, 552 | "netNewPurchase": 1559.1600000000003, 553 | "date": "2023-05-19" 554 | }, 555 | { 556 | "value": 1754.3000000000002, 557 | "holdingList": [ 558 | { 559 | "ticker": "AAPL", 560 | "positionValue": 1754.3000000000002, 561 | "quantity": 10.0 562 | } 563 | ], 564 | "gains": [ 565 | { 566 | "ticker": "AAPL", 567 | "quantity": 10.0, 568 | "gains": 455.0, 569 | "tax": 0.0, 570 | "seqNo": 1, 571 | "bookedGains": 0.0 572 | } 573 | ], 574 | "portfolioCash": 0.0, 575 | "benchmarkPrice": 385.87, 576 | "netNewPurchase": 1559.1600000000003, 577 | "date": "2023-05-26" 578 | }, 579 | { 580 | "value": 0.0, 581 | "holdingList": [ 582 | { 583 | "ticker": "AAPL", 584 | "positionValue": 0.0, 585 | "quantity": 0.0 586 | } 587 | ], 588 | "gains": [ 589 | { 590 | "ticker": "AAPL", 591 | "quantity": 0.0, 592 | "gains": 0.0, 593 | "tax": 255.09999999999994, 594 | "seqNo": 1, 595 | "bookedGains": 510.1999999999998 596 | } 597 | ], 598 | "portfolioCash": 1192.5, 599 | "benchmarkPrice": 393.26, 600 | "netNewPurchase": 1559.1600000000003, 601 | "date": "2023-06-02" 602 | }, 603 | { 604 | "value": 0.0, 605 | "holdingList": [ 606 | { 607 | "ticker": "AAPL", 608 | "positionValue": 0.0, 609 | "quantity": 0.0 610 | } 611 | ], 612 | "gains": [ 613 | { 614 | "ticker": "AAPL", 615 | "quantity": 0.0, 616 | "gains": 0.0, 617 | "tax": 255.09999999999994, 618 | "seqNo": 1, 619 | "bookedGains": 510.1999999999998 620 | } 621 | ], 622 | "portfolioCash": 1192.5, 623 | "benchmarkPrice": 395.03, 624 | "netNewPurchase": 1559.1600000000003, 625 | "date": "2023-06-09" 626 | }, 627 | { 628 | "value": 0.0, 629 | "holdingList": [ 630 | { 631 | "ticker": "AAPL", 632 | "positionValue": 0.0, 633 | "quantity": 0.0 634 | } 635 | ], 636 | "gains": [ 637 | { 638 | "ticker": "AAPL", 639 | "quantity": 0.0, 640 | "gains": 0.0, 641 | "tax": 255.09999999999994, 642 | "seqNo": 1, 643 | "bookedGains": 510.1999999999998 644 | } 645 | ], 646 | "portfolioCash": 1192.5, 647 | "benchmarkPrice": 405.25, 648 | "netNewPurchase": 1559.1600000000003, 649 | "date": "2023-06-16" 650 | }, 651 | { 652 | "value": 0.0, 653 | "holdingList": [ 654 | { 655 | "ticker": "AAPL", 656 | "positionValue": 0.0, 657 | "quantity": 0.0 658 | } 659 | ], 660 | "gains": [ 661 | { 662 | "ticker": "AAPL", 663 | "quantity": 0.0, 664 | "gains": 0.0, 665 | "tax": 255.09999999999994, 666 | "seqNo": 1, 667 | "bookedGains": 510.1999999999998 668 | } 669 | ], 670 | "portfolioCash": 1192.5, 671 | "benchmarkPrice": 399.61, 672 | "netNewPurchase": 1559.1600000000003, 673 | "date": "2023-06-23" 674 | }, 675 | { 676 | "value": 0.0, 677 | "holdingList": [ 678 | { 679 | "ticker": "AAPL", 680 | "positionValue": 0.0, 681 | "quantity": 0.0 682 | } 683 | ], 684 | "gains": [ 685 | { 686 | "ticker": "AAPL", 687 | "quantity": 0.0, 688 | "gains": 0.0, 689 | "tax": 255.09999999999994, 690 | "seqNo": 1, 691 | "bookedGains": 510.1999999999998 692 | } 693 | ], 694 | "portfolioCash": 1192.5, 695 | "benchmarkPrice": 407.28, 696 | "netNewPurchase": 1559.1600000000003, 697 | "date": "2023-06-30" 698 | }, 699 | { 700 | "value": 0.0, 701 | "holdingList": [ 702 | { 703 | "ticker": "AAPL", 704 | "positionValue": 0.0, 705 | "quantity": 0.0 706 | } 707 | ], 708 | "gains": [ 709 | { 710 | "ticker": "AAPL", 711 | "quantity": 0.0, 712 | "gains": 0.0, 713 | "tax": 255.09999999999994, 714 | "seqNo": 1, 715 | "bookedGains": 510.1999999999998 716 | } 717 | ], 718 | "portfolioCash": 1192.5, 719 | "benchmarkPrice": 402.89, 720 | "netNewPurchase": 1559.1600000000003, 721 | "date": "2023-07-07" 722 | } 723 | ], 724 | "feesPaid": 621.76, 725 | "gainTaxValue": 255.09999999999994, 726 | "standardDeviation": 194.14609452782761 727 | }, 728 | "simulation": { 729 | "responseList": [ 730 | { 731 | "value": 649.6500000000001, 732 | "holdingList": [ 733 | { 734 | "ticker": "VOO", 735 | "positionValue": 649.6500000000001, 736 | "quantity": 1.8490635851312123 737 | } 738 | ], 739 | "gains": [ 740 | { 741 | "ticker": "VOO", 742 | "quantity": 1.8490635851312123, 743 | "gains": 0.0, 744 | "tax": 0.0, 745 | "seqNo": 1, 746 | "bookedGains": 0.0 747 | } 748 | ], 749 | "portfolioCash": 649.6500000000001, 750 | "benchmarkPrice": 351.34, 751 | "netNewPurchase": 649.6500000000001, 752 | "date": "2022-12-30" 753 | }, 754 | { 755 | "value": 659.357583821939, 756 | "holdingList": [ 757 | { 758 | "ticker": "VOO", 759 | "positionValue": 659.357583821939, 760 | "quantity": 1.8490635851312123 761 | } 762 | ], 763 | "gains": [ 764 | { 765 | "ticker": "VOO", 766 | "quantity": 1.8490635851312123, 767 | "gains": 9.707583821938865, 768 | "tax": 0.0, 769 | "seqNo": 1, 770 | "bookedGains": 0.0 771 | } 772 | ], 773 | "portfolioCash": 649.6500000000001, 774 | "benchmarkPrice": 356.59, 775 | "netNewPurchase": 649.6500000000001, 776 | "date": "2023-01-06" 777 | }, 778 | { 779 | "value": 677.1825567826039, 780 | "holdingList": [ 781 | { 782 | "ticker": "VOO", 783 | "positionValue": 677.1825567826039, 784 | "quantity": 1.8490635851312123 785 | } 786 | ], 787 | "gains": [ 788 | { 789 | "ticker": "VOO", 790 | "quantity": 1.8490635851312123, 791 | "gains": 27.53255678260383, 792 | "tax": 0.0, 793 | "seqNo": 1, 794 | "bookedGains": 0.0 795 | } 796 | ], 797 | "portfolioCash": 649.6500000000001, 798 | "benchmarkPrice": 366.23, 799 | "netNewPurchase": 649.6500000000001, 800 | "date": "2023-01-13" 801 | }, 802 | { 803 | "value": 672.5229165480732, 804 | "holdingList": [ 805 | { 806 | "ticker": "VOO", 807 | "positionValue": 672.5229165480732, 808 | "quantity": 1.8490635851312123 809 | } 810 | ], 811 | "gains": [ 812 | { 813 | "ticker": "VOO", 814 | "quantity": 1.8490635851312123, 815 | "gains": 22.872916548073103, 816 | "tax": 0.0, 817 | "seqNo": 1, 818 | "bookedGains": 0.0 819 | } 820 | ], 821 | "portfolioCash": 649.6500000000001, 822 | "benchmarkPrice": 363.71, 823 | "netNewPurchase": 649.6500000000001, 824 | "date": "2023-01-20" 825 | }, 826 | { 827 | "value": 689.4603389878752, 828 | "holdingList": [ 829 | { 830 | "ticker": "VOO", 831 | "positionValue": 689.4603389878752, 832 | "quantity": 1.8490635851312123 833 | } 834 | ], 835 | "gains": [ 836 | { 837 | "ticker": "VOO", 838 | "quantity": 1.8490635851312123, 839 | "gains": 39.810338987875056, 840 | "tax": 0.0, 841 | "seqNo": 1, 842 | "bookedGains": 0.0 843 | } 844 | ], 845 | "portfolioCash": 649.6500000000001, 846 | "benchmarkPrice": 372.87, 847 | "netNewPurchase": 649.6500000000001, 848 | "date": "2023-01-27" 849 | }, 850 | { 851 | "value": 700.5177392269599, 852 | "holdingList": [ 853 | { 854 | "ticker": "VOO", 855 | "positionValue": 700.5177392269599, 856 | "quantity": 1.8490635851312123 857 | } 858 | ], 859 | "gains": [ 860 | { 861 | "ticker": "VOO", 862 | "quantity": 1.8490635851312123, 863 | "gains": 50.867739226959735, 864 | "tax": 0.0, 865 | "seqNo": 1, 866 | "bookedGains": 0.0 867 | } 868 | ], 869 | "portfolioCash": 649.6500000000001, 870 | "benchmarkPrice": 378.85, 871 | "netNewPurchase": 649.6500000000001, 872 | "date": "2023-02-03" 873 | }, 874 | { 875 | "value": 693.4358256959072, 876 | "holdingList": [ 877 | { 878 | "ticker": "VOO", 879 | "positionValue": 693.4358256959072, 880 | "quantity": 1.8490635851312123 881 | } 882 | ], 883 | "gains": [ 884 | { 885 | "ticker": "VOO", 886 | "quantity": 1.8490635851312123, 887 | "gains": 43.78582569590712, 888 | "tax": 0.0, 889 | "seqNo": 1, 890 | "bookedGains": 0.0 891 | } 892 | ], 893 | "portfolioCash": 649.6500000000001, 894 | "benchmarkPrice": 375.02, 895 | "netNewPurchase": 649.6500000000001, 896 | "date": "2023-02-10" 897 | }, 898 | { 899 | "value": 691.9565748278023, 900 | "holdingList": [ 901 | { 902 | "ticker": "VOO", 903 | "positionValue": 691.9565748278023, 904 | "quantity": 1.8490635851312123 905 | } 906 | ], 907 | "gains": [ 908 | { 909 | "ticker": "VOO", 910 | "quantity": 1.8490635851312123, 911 | "gains": 42.30657482780224, 912 | "tax": 0.0, 913 | "seqNo": 1, 914 | "bookedGains": 0.0 915 | } 916 | ], 917 | "portfolioCash": 649.6500000000001, 918 | "benchmarkPrice": 374.22, 919 | "netNewPurchase": 649.6500000000001, 920 | "date": "2023-02-17" 921 | }, 922 | { 923 | "value": 673.4844296123415, 924 | "holdingList": [ 925 | { 926 | "ticker": "VOO", 927 | "positionValue": 673.4844296123415, 928 | "quantity": 1.8490635851312123 929 | } 930 | ], 931 | "gains": [ 932 | { 933 | "ticker": "VOO", 934 | "quantity": 1.8490635851312123, 935 | "gains": 23.834429612341406, 936 | "tax": 0.0, 937 | "seqNo": 1, 938 | "bookedGains": 0.0 939 | } 940 | ], 941 | "portfolioCash": 649.6500000000001, 942 | "benchmarkPrice": 364.23, 943 | "netNewPurchase": 649.6500000000001, 944 | "date": "2023-02-24" 945 | }, 946 | { 947 | "value": 686.5203278875165, 948 | "holdingList": [ 949 | { 950 | "ticker": "VOO", 951 | "positionValue": 686.5203278875165, 952 | "quantity": 1.8490635851312123 953 | } 954 | ], 955 | "gains": [ 956 | { 957 | "ticker": "VOO", 958 | "quantity": 1.8490635851312123, 959 | "gains": 36.87032788751637, 960 | "tax": 0.0, 961 | "seqNo": 1, 962 | "bookedGains": 0.0 963 | } 964 | ], 965 | "portfolioCash": 649.6500000000001, 966 | "benchmarkPrice": 371.28, 967 | "netNewPurchase": 649.6500000000001, 968 | "date": "2023-03-03" 969 | }, 970 | { 971 | "value": 655.8258723743384, 972 | "holdingList": [ 973 | { 974 | "ticker": "VOO", 975 | "positionValue": 655.8258723743384, 976 | "quantity": 1.8490635851312123 977 | } 978 | ], 979 | "gains": [ 980 | { 981 | "ticker": "VOO", 982 | "quantity": 1.8490635851312123, 983 | "gains": 6.175872374338308, 984 | "tax": 0.0, 985 | "seqNo": 1, 986 | "bookedGains": 0.0 987 | } 988 | ], 989 | "portfolioCash": 649.6500000000001, 990 | "benchmarkPrice": 354.68, 991 | "netNewPurchase": 649.6500000000001, 992 | "date": "2023-03-10" 993 | }, 994 | { 995 | "value": 665.4410030170206, 996 | "holdingList": [ 997 | { 998 | "ticker": "VOO", 999 | "positionValue": 665.4410030170206, 1000 | "quantity": 1.8490635851312123 1001 | } 1002 | ], 1003 | "gains": [ 1004 | { 1005 | "ticker": "VOO", 1006 | "quantity": 1.8490635851312123, 1007 | "gains": 15.791003017020591, 1008 | "tax": 0.0, 1009 | "seqNo": 1, 1010 | "bookedGains": 0.0 1011 | } 1012 | ], 1013 | "portfolioCash": 649.6500000000001, 1014 | "benchmarkPrice": 359.88, 1015 | "netNewPurchase": 649.6500000000001, 1016 | "date": "2023-03-17" 1017 | }, 1018 | { 1019 | "value": 672.2455570103035, 1020 | "holdingList": [ 1021 | { 1022 | "ticker": "VOO", 1023 | "positionValue": 672.2455570103035, 1024 | "quantity": 1.8490635851312123 1025 | } 1026 | ], 1027 | "gains": [ 1028 | { 1029 | "ticker": "VOO", 1030 | "quantity": 1.8490635851312123, 1031 | "gains": 22.595557010303466, 1032 | "tax": 0.0, 1033 | "seqNo": 1, 1034 | "bookedGains": 0.0 1035 | } 1036 | ], 1037 | "portfolioCash": 649.6500000000001, 1038 | "benchmarkPrice": 363.56, 1039 | "netNewPurchase": 649.6500000000001, 1040 | "date": "2023-03-24" 1041 | }, 1042 | { 1043 | "value": 695.377342460295, 1044 | "holdingList": [ 1045 | { 1046 | "ticker": "VOO", 1047 | "positionValue": 695.377342460295, 1048 | "quantity": 1.8490635851312123 1049 | } 1050 | ], 1051 | "gains": [ 1052 | { 1053 | "ticker": "VOO", 1054 | "quantity": 1.8490635851312123, 1055 | "gains": 45.72734246029491, 1056 | "tax": 0.0, 1057 | "seqNo": 1, 1058 | "bookedGains": 0.0 1059 | } 1060 | ], 1061 | "portfolioCash": 649.6500000000001, 1062 | "benchmarkPrice": 376.07, 1063 | "netNewPurchase": 649.6500000000001, 1064 | "date": "2023-03-31" 1065 | }, 1066 | { 1067 | "value": 695.1554548300792, 1068 | "holdingList": [ 1069 | { 1070 | "ticker": "VOO", 1071 | "positionValue": 695.1554548300792, 1072 | "quantity": 1.8490635851312123 1073 | } 1074 | ], 1075 | "gains": [ 1076 | { 1077 | "ticker": "VOO", 1078 | "quantity": 1.8490635851312123, 1079 | "gains": 45.50545483007916, 1080 | "tax": 0.0, 1081 | "seqNo": 1, 1082 | "bookedGains": 0.0 1083 | } 1084 | ], 1085 | "portfolioCash": 649.6500000000001, 1086 | "benchmarkPrice": 375.95, 1087 | "netNewPurchase": 649.6500000000001, 1088 | "date": "2023-04-07" 1089 | }, 1090 | { 1091 | "value": 700.7766081288781, 1092 | "holdingList": [ 1093 | { 1094 | "ticker": "VOO", 1095 | "positionValue": 700.7766081288781, 1096 | "quantity": 1.8490635851312123 1097 | } 1098 | ], 1099 | "gains": [ 1100 | { 1101 | "ticker": "VOO", 1102 | "quantity": 1.8490635851312123, 1103 | "gains": 51.12660812887808, 1104 | "tax": 0.0, 1105 | "seqNo": 1, 1106 | "bookedGains": 0.0 1107 | } 1108 | ], 1109 | "portfolioCash": 649.6500000000001, 1110 | "benchmarkPrice": 378.99, 1111 | "netNewPurchase": 649.6500000000001, 1112 | "date": "2023-04-14" 1113 | }, 1114 | { 1115 | "value": 700.0369826948256, 1116 | "holdingList": [ 1117 | { 1118 | "ticker": "VOO", 1119 | "positionValue": 700.0369826948256, 1120 | "quantity": 1.8490635851312123 1121 | } 1122 | ], 1123 | "gains": [ 1124 | { 1125 | "ticker": "VOO", 1126 | "quantity": 1.8490635851312123, 1127 | "gains": 50.386982694825534, 1128 | "tax": 0.0, 1129 | "seqNo": 1, 1130 | "bookedGains": 0.0 1131 | } 1132 | ], 1133 | "portfolioCash": 649.6500000000001, 1134 | "benchmarkPrice": 378.59, 1135 | "netNewPurchase": 649.6500000000001, 1136 | "date": "2023-04-21" 1137 | }, 1138 | { 1139 | "value": 706.4347426993796, 1140 | "holdingList": [ 1141 | { 1142 | "ticker": "VOO", 1143 | "positionValue": 706.4347426993796, 1144 | "quantity": 1.8490635851312123 1145 | } 1146 | ], 1147 | "gains": [ 1148 | { 1149 | "ticker": "VOO", 1150 | "quantity": 1.8490635851312123, 1151 | "gains": 56.7847426993796, 1152 | "tax": 0.0, 1153 | "seqNo": 1, 1154 | "bookedGains": 0.0 1155 | } 1156 | ], 1157 | "portfolioCash": 649.6500000000001, 1158 | "benchmarkPrice": 382.05, 1159 | "netNewPurchase": 649.6500000000001, 1160 | "date": "2023-04-28" 1161 | }, 1162 | { 1163 | "value": 700.7396268571756, 1164 | "holdingList": [ 1165 | { 1166 | "ticker": "VOO", 1167 | "positionValue": 700.7396268571756, 1168 | "quantity": 1.8490635851312123 1169 | } 1170 | ], 1171 | "gains": [ 1172 | { 1173 | "ticker": "VOO", 1174 | "quantity": 1.8490635851312123, 1175 | "gains": 51.08962685717549, 1176 | "tax": 0.0, 1177 | "seqNo": 1, 1178 | "bookedGains": 0.0 1179 | } 1180 | ], 1181 | "portfolioCash": 649.6500000000001, 1182 | "benchmarkPrice": 378.97, 1183 | "netNewPurchase": 649.6500000000001, 1184 | "date": "2023-05-05" 1185 | }, 1186 | { 1187 | "value": 699.2233947173679, 1188 | "holdingList": [ 1189 | { 1190 | "ticker": "VOO", 1191 | "positionValue": 699.2233947173679, 1192 | "quantity": 1.8490635851312123 1193 | } 1194 | ], 1195 | "gains": [ 1196 | { 1197 | "ticker": "VOO", 1198 | "quantity": 1.8490635851312123, 1199 | "gains": 49.573394717367805, 1200 | "tax": 0.0, 1201 | "seqNo": 1, 1202 | "bookedGains": 0.0 1203 | } 1204 | ], 1205 | "portfolioCash": 649.6500000000001, 1206 | "benchmarkPrice": 378.15, 1207 | "netNewPurchase": 649.6500000000001, 1208 | "date": "2023-05-12" 1209 | }, 1210 | { 1211 | "value": 711.0943829339103, 1212 | "holdingList": [ 1213 | { 1214 | "ticker": "VOO", 1215 | "positionValue": 711.0943829339103, 1216 | "quantity": 1.8490635851312123 1217 | } 1218 | ], 1219 | "gains": [ 1220 | { 1221 | "ticker": "VOO", 1222 | "quantity": 1.8490635851312123, 1223 | "gains": 61.44438293391022, 1224 | "tax": 0.0, 1225 | "seqNo": 1, 1226 | "bookedGains": 0.0 1227 | } 1228 | ], 1229 | "portfolioCash": 649.6500000000001, 1230 | "benchmarkPrice": 384.57, 1231 | "netNewPurchase": 649.6500000000001, 1232 | "date": "2023-05-19" 1233 | }, 1234 | { 1235 | "value": 713.4981655945809, 1236 | "holdingList": [ 1237 | { 1238 | "ticker": "VOO", 1239 | "positionValue": 713.4981655945809, 1240 | "quantity": 1.8490635851312123 1241 | } 1242 | ], 1243 | "gains": [ 1244 | { 1245 | "ticker": "VOO", 1246 | "quantity": 1.8490635851312123, 1247 | "gains": 63.84816559458081, 1248 | "tax": 0.0, 1249 | "seqNo": 1, 1250 | "bookedGains": 0.0 1251 | } 1252 | ], 1253 | "portfolioCash": 649.6500000000001, 1254 | "benchmarkPrice": 385.87, 1255 | "netNewPurchase": 649.6500000000001, 1256 | "date": "2023-05-26" 1257 | }, 1258 | { 1259 | "value": 1376.8127454887006, 1260 | "holdingList": [ 1261 | { 1262 | "ticker": "VOO", 1263 | "positionValue": 1376.8127454887006, 1264 | "quantity": 3.5010241201462153 1265 | } 1266 | ], 1267 | "gains": [ 1268 | { 1269 | "ticker": "VOO", 1270 | "quantity": 1.8490635851312123, 1271 | "gains": 77.51274548870045, 1272 | "tax": 0.0, 1273 | "seqNo": 1, 1274 | "bookedGains": 0.0 1275 | }, 1276 | { 1277 | "ticker": "VOO", 1278 | "quantity": 1.651960535015003, 1279 | "gains": 0.0, 1280 | "tax": 0.0, 1281 | "seqNo": 2, 1282 | "bookedGains": 0.0 1283 | } 1284 | ], 1285 | "portfolioCash": 0.0, 1286 | "benchmarkPrice": 393.26, 1287 | "netNewPurchase": 649.6500000000001, 1288 | "date": "2023-06-02" 1289 | }, 1290 | { 1291 | "value": 1383.0095581813594, 1292 | "holdingList": [ 1293 | { 1294 | "ticker": "VOO", 1295 | "positionValue": 1383.0095581813594, 1296 | "quantity": 3.5010241201462153 1297 | } 1298 | ], 1299 | "gains": [ 1300 | { 1301 | "ticker": "VOO", 1302 | "quantity": 1.8490635851312123, 1303 | "gains": 80.78558803438266, 1304 | "tax": 0.0, 1305 | "seqNo": 1, 1306 | "bookedGains": 0.0 1307 | }, 1308 | { 1309 | "ticker": "VOO", 1310 | "quantity": 1.651960535015003, 1311 | "gains": 2.9239701469765254, 1312 | "tax": 0.0, 1313 | "seqNo": 2, 1314 | "bookedGains": 0.0 1315 | } 1316 | ], 1317 | "portfolioCash": 0.0, 1318 | "benchmarkPrice": 395.03, 1319 | "netNewPurchase": 649.6500000000001, 1320 | "date": "2023-06-09" 1321 | }, 1322 | { 1323 | "value": 1418.7900246892539, 1324 | "holdingList": [ 1325 | { 1326 | "ticker": "VOO", 1327 | "positionValue": 1418.7900246892539, 1328 | "quantity": 3.5010241201462153 1329 | } 1330 | ], 1331 | "gains": [ 1332 | { 1333 | "ticker": "VOO", 1334 | "quantity": 1.8490635851312123, 1335 | "gains": 99.6830178744237, 1336 | "tax": 0.0, 1337 | "seqNo": 1, 1338 | "bookedGains": 0.0 1339 | }, 1340 | { 1341 | "ticker": "VOO", 1342 | "quantity": 1.651960535015003, 1343 | "gains": 19.8070068148299, 1344 | "tax": 0.0, 1345 | "seqNo": 2, 1346 | "bookedGains": 0.0 1347 | } 1348 | ], 1349 | "portfolioCash": 0.0, 1350 | "benchmarkPrice": 405.25, 1351 | "netNewPurchase": 649.6500000000001, 1352 | "date": "2023-06-16" 1353 | }, 1354 | { 1355 | "value": 1399.0442486516292, 1356 | "holdingList": [ 1357 | { 1358 | "ticker": "VOO", 1359 | "positionValue": 1399.0442486516292, 1360 | "quantity": 3.5010241201462153 1361 | } 1362 | ], 1363 | "gains": [ 1364 | { 1365 | "ticker": "VOO", 1366 | "quantity": 1.8490635851312123, 1367 | "gains": 89.2542992542837, 1368 | "tax": 0.0, 1369 | "seqNo": 1, 1370 | "bookedGains": 0.0 1371 | }, 1372 | { 1373 | "ticker": "VOO", 1374 | "quantity": 1.651960535015003, 1375 | "gains": 10.489949397345306, 1376 | "tax": 0.0, 1377 | "seqNo": 2, 1378 | "bookedGains": 0.0 1379 | } 1380 | ], 1381 | "portfolioCash": 0.0, 1382 | "benchmarkPrice": 399.61, 1383 | "netNewPurchase": 649.6500000000001, 1384 | "date": "2023-06-23" 1385 | }, 1386 | { 1387 | "value": 1425.8971036531505, 1388 | "holdingList": [ 1389 | { 1390 | "ticker": "VOO", 1391 | "positionValue": 1425.8971036531505, 1392 | "quantity": 3.5010241201462153 1393 | } 1394 | ], 1395 | "gains": [ 1396 | { 1397 | "ticker": "VOO", 1398 | "quantity": 1.8490635851312123, 1399 | "gains": 103.43661695224002, 1400 | "tax": 0.0, 1401 | "seqNo": 1, 1402 | "bookedGains": 0.0 1403 | }, 1404 | { 1405 | "ticker": "VOO", 1406 | "quantity": 1.651960535015003, 1407 | "gains": 23.16048670091031, 1408 | "tax": 0.0, 1409 | "seqNo": 2, 1410 | "bookedGains": 0.0 1411 | } 1412 | ], 1413 | "portfolioCash": 0.0, 1414 | "benchmarkPrice": 407.28, 1415 | "netNewPurchase": 649.6500000000001, 1416 | "date": "2023-06-30" 1417 | }, 1418 | { 1419 | "value": 1410.5276077657086, 1420 | "holdingList": [ 1421 | { 1422 | "ticker": "VOO", 1423 | "positionValue": 1410.5276077657086, 1424 | "quantity": 3.5010241201462153 1425 | } 1426 | ], 1427 | "gains": [ 1428 | { 1429 | "ticker": "VOO", 1430 | "quantity": 1.8490635851312123, 1431 | "gains": 95.31922781351402, 1432 | "tax": 0.0, 1433 | "seqNo": 1, 1434 | "bookedGains": 0.0 1435 | }, 1436 | { 1437 | "ticker": "VOO", 1438 | "quantity": 1.651960535015003, 1439 | "gains": 15.908379952194473, 1440 | "tax": 0.0, 1441 | "seqNo": 2, 1442 | "bookedGains": 0.0 1443 | } 1444 | ], 1445 | "portfolioCash": 0.0, 1446 | "benchmarkPrice": 402.89, 1447 | "netNewPurchase": 649.6500000000001, 1448 | "date": "2023-07-07" 1449 | } 1450 | ], 1451 | "feesPaid": 0.0, 1452 | "gainTaxValue": 0.0, 1453 | "standardDeviation": 32.42678049372441 1454 | } 1455 | } 1456 | } 1457 | --------------------------------------------------------------------------------