mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-24 18:22:43 +00:00
Portfolio to Po now works well and removed cash
This commit is contained in:
@@ -276,13 +276,49 @@ class PortfolioController(BaseController):
|
||||
if OPTIMIZATION_TOOLKIT_ENABLED:
|
||||
if self.portfolio is None:
|
||||
tickers = []
|
||||
categories = None
|
||||
else:
|
||||
tickers = self.portfolio.tickers_list
|
||||
transactions = self.portfolio.get_transactions()
|
||||
|
||||
categories = {
|
||||
"ASSET_CLASS": {},
|
||||
"SECTOR": {},
|
||||
"INDUSTRY": {},
|
||||
"COUNTRY": {},
|
||||
"CURRENT_INVESTED_AMOUNT": {},
|
||||
"CURRENCY": {},
|
||||
}
|
||||
for _, transaction in transactions.iterrows():
|
||||
if transaction["Ticker"] not in categories["ASSET_CLASS"]:
|
||||
categories["ASSET_CLASS"][transaction["Ticker"]] = transaction[
|
||||
"Type"
|
||||
]
|
||||
categories["SECTOR"][transaction["Ticker"]] = transaction[
|
||||
"Sector"
|
||||
]
|
||||
categories["INDUSTRY"][transaction["Ticker"]] = transaction[
|
||||
"Industry"
|
||||
]
|
||||
categories["COUNTRY"][transaction["Ticker"]] = transaction[
|
||||
"Country"
|
||||
]
|
||||
categories["CURRENT_INVESTED_AMOUNT"][
|
||||
transaction["Ticker"]
|
||||
] = transactions[
|
||||
transactions["Ticker"] == transaction["Ticker"]
|
||||
][
|
||||
"Investment"
|
||||
].sum()
|
||||
categories["CURRENCY"][transaction["Ticker"]] = transaction[
|
||||
"Currency"
|
||||
]
|
||||
|
||||
self.queue = self.load_class(
|
||||
po_controller.PortfolioOptimizationController,
|
||||
tickers,
|
||||
None,
|
||||
None,
|
||||
categories,
|
||||
self.queue,
|
||||
)
|
||||
else:
|
||||
|
||||
@@ -236,6 +236,9 @@ class PortfolioOptimizationController(BaseController):
|
||||
if categories:
|
||||
self.categories = dict(categories)
|
||||
self.available_categories = list(self.categories.keys())
|
||||
|
||||
if "CURRENT_INVESTED_AMOUNT" in self.available_categories:
|
||||
self.available_categories.remove("CURRENT_INVESTED_AMOUNT")
|
||||
else:
|
||||
self.categories = dict()
|
||||
self.available_categories = list()
|
||||
|
||||
@@ -26,7 +26,7 @@ Note that the Excel sheet requires the following columns:
|
||||
|
||||
- **Date** - The date the trade occurred
|
||||
- **Name** - The name of the security
|
||||
- **Type** - The type of the security. Use Cash/Stock/Crypto/ETF as appropriate
|
||||
- **Type** - The type of the security. Use Stock/Crypto/ETF as appropriate
|
||||
- **Price** - The price the security was added or removed at, on a per-unit
|
||||
basis
|
||||
- **Quantity** - How much of the security in question was added or removed
|
||||
|
||||
Reference in New Issue
Block a user