Welcome to the FinancialPortfolio project, your friendly companion for exploring and planning your financial future! š
Are you curious about the performance of your investment strategies, eager to understand how taxes impact your portfolio, or simply looking to make more informed financial decisions?
Key Features:
- š Create and manage portfolios with multiple investment strategies.
- š Calculate future values, net profits, and taxes paid for individual strategies and combined portfolios.
- š Visualize portfolio growth, net profits, and tax implications over time.
- š Compare the performance of different portfolios across various investment horizons.
Whether you're a seasoned investor or new to the world of finance, the FinancialPortfolio project is here to assist you every step of the way.
For comprehensive usage instructions and practical examples, please refer to the sections above. If you have any inquiries, ideas, or simply want to engage in discussions about finance, feel free to connect with us or become part of our welcoming community of contributors.
Here's an example of the portfolio growth chart after 10 years of investment. The chart shows the performance of the "House Portfolio 1" portfolio with two investment strategies, "Strategy A" and "Strategy B."
You can use the plot_portfolios_over_time
function to compare the performance of your portfolios over different timeframes. Below is an example of how to use it with the example_portfolios
:
plot_portfolios_over_time(example_portfolios, [8, 10, 12], use_default_size=True)
The above code will generate a plot that compares the portfolios' performance over 8, 10, and 12 years. You can customize the timeframes to suit your analysis.
In the example image above, you can see how the portfolios "House Portfolio 1" perform over different time horizons.
Feel free to use this function to analyze and visualize your portfolios' growth and compare their performance over various periods.
To use the FinancialPortfolio class, you need to have Python and the required libraries installed. You can install the necessary libraries using pip:
pip install numpy matplotlib
This project is designed to run inside a Docker container. Follow these steps to set up and run the Docker container using JetBrains DataSpell or PyCharm:
-
Ensure Docker Configuration:
- Ensure that
Run Docker.run.xml
is properly configured for your Docker environment. It should define the Docker image, volumes, ports, and the command to be executed.
- Ensure that
-
Open Your Project in DataSpell or PyCharm:
- Open the project containing the FinancialPortfolio class in DataSpell or PyCharm.
-
Import Docker Configuration into DataSpell or PyCharm:
- Navigate to "Run" > "Edit Configurations".
- Click the '+' button and select 'Import Configuration'.
- Choose the
Run Docker.run.xml
file. This step imports the Docker configuration into your IDE.
-
Run the Docker Container:
- Select the imported Docker configuration from the run configurations list.
- Click the run button. This action builds (if necessary) and runs your Docker container.
-
Access the Python Environment Inside the Docker Container:
- Once the Docker container is running, access its terminal through DataSpell or PyCharm.
- Within this terminal, you can execute scripts that utilize the FinancialPortfolio class.
-
Usage:
- Use the FinancialPortfolio class within the Docker environment as outlined in the usage section of this documentation.
Double-check that the paths and configuration names in your Run Docker.run.xml
file are correctly set for your projectās needs.
To use the FinancialPortfolio class in your Python project, you can simply import it as follows:
from financial_portfolio import FinancialPortfolio, plot_portfolios, display_initial_funds_and_contributions_table
Once imported, you can create instances of the FinancialPortfolio
class and use its functions to analyze and visualize your investment strategies.
In the provided code example, we have an example portfolio named "House Portfolio 1" with two investment strategies: "Strategy A" and "Strategy B." You can modify and expand these example portfolios to match your specific financial scenarios.
example_portfolios = [
{
"name": "House Portfolio 1",
"strategies": [
{"name": "Strategy A", "initial_funds": 0, "monthly_contribution": 800, "annual_rate": 6, "variance": 1, "is_taxable": True, "tax_rate": 10, "compounding_frequency": 6},
{"name": "Strategy B", "initial_funds": 0, "monthly_contribution": 200, "annual_rate": 8, "variance": 1.5, "is_taxable": True, "tax_rate": 10, "compounding_frequency": 6}
]
}
# Additional portfolios can be added here
]
The FinancialPortfolio
class provides several functions for simulating and visualizing investment strategies and portfolios. These functions include:
calculate_aggregated_future_value(years)
: Calculate the aggregated future value of all strategies in the portfolio over a specified number of years.calculate_future_value(strategy, years)
: Calculate the future value of an individual investment strategy over a specified number of years.plot_strategy(strategy, years, ax)
: Plot an individual investment strategy, showing its growth, net profit, and taxes paid over time.plot_combined_portfolio(years, ax)
: Plot the combined value of all strategies in the portfolio, showing the overall portfolio growth, net profit, and total taxes paid.
You can use these functions to analyze and visualize your financial portfolios.
If you have any suggestions or improvements for the FinancialPortfolio class or its documentation, feel free to contribute. You can submit issues or pull requests to help make this class even more useful.
This project is licensed under the MIT License - see the LICENSE file for details.