Portfolio Analysis, methods for portfolio optimization
Project description
pyPortfolioAnalysis
pyPortfolioAnalysis is a Python library for numeric method for portfolio optimisation.
Installation
Use the package manager pip to install foobar.
pip install pyPortfolioAnalysis
Usage
import pyPortfolioAnalysis
#Sample portfolio optimisation
import pandas_datareader as pdr
aapl = pdr.get_data_yahoo('AAPL')
msft = pdr.get_data_yahoo('MSFT')
tsla = pdr.get_data_yahoo('TSLA')
uber = pdr.get_data_yahoo('UBER')
amzn = pdr.get_data_yahoo('AMZN')
port = pd.DataFrame({'aapl': pd.DataFrame.reset_index(aapl).iloc[:,6], 'msft':pd.DataFrame.reset_index(msft).iloc[:,6],
'tsla': pd.DataFrame.reset_index(tsla).iloc[:,6], 'uber': pd.DataFrame.reset_index(uber).iloc[:,6],
'amzn': pd.DataFrame.reset_index(amzn).iloc[:,6]})
p1 = portfolio_spec(assets = ['AAPL', 'MSFT', 'TSLA', 'UBER', 'AMZN'])
add_constraint(p1, 'long_only')
add_constraint(p1, 'full_investment')
add_objective(p1, kind='return', name = 'mean', target = 0.002)
add_objective(p1, kind='risk', name = 'std', target = .018)
p1.port_summary()
constraints = get_constraints(p1)
p1.port_summary()
optimize_portfolio(R, p1, optimize_method = 'DEoptim', disp = False)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Authors
Anurag Agrawal
Contributors
Saloni Mangla
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyPortfolioAnalysis-1.0.0.tar.gz
(28.5 kB
view hashes)
Built Distribution
Close
Hashes for pyPortfolioAnalysis-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55d625762ab9531aae5e697b7bfbca0d26c65d0f1ee97369fc7dad523ccdc677 |
|
MD5 | 0fec6d313db427c2a83905b3571cf3c4 |
|
BLAKE2b-256 | 17275e1074b6a2360942b6a0b7b9e630b7f98b9c633a5661e0006f2572fbdae1 |
Close
Hashes for pyPortfolioAnalysis-1.0.0-py3.8.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50e9c6228ca20405854b08af5eaa4eb0de8a7a32e6adc43727543d075188dc0b |
|
MD5 | b30318ddc6c8b00c72526d449f9d0376 |
|
BLAKE2b-256 | 8efaaade398ad9292e43a069f531865d95f2c5cd0d42bbc8022c82c6a3f07f30 |