-
-
Save anthonymorast/717d17c9364795695567951c6cf22b94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
if __name__ == '__main__': | |
input_file = './lowest_risk.csv' | |
portfolios = pd.read_csv(input_file) | |
for index, row in portfolios.iterrows(): | |
print(f"Processing portfolio {index + 1}") | |
print(f"\tExpected Return: {row['return']*100:.2f}%") | |
print(f"\t\"Risk\": {row['risk']:.2f}") | |
print(f"\tSelected tickers/weigts:") | |
weight_dict = {} | |
for name, data in row.iteritems(): | |
if data > 0 and name != 'return' and name != 'risk': | |
weight_dict[(name.split(' ')[0])] = data | |
#print(f"\t\tTicker: {name.split(' ')[0]}\tWeight: {data*100:.2f}%") | |
weight_dict = sorted(weight_dict.items(), key=lambda x: x[1], reverse=True) | |
for tuple in weight_dict: | |
print(f"\t\tTicker: {tuple[0]}\tWeight: {tuple[1]*100:.2f}%") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment