Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portfolio controller fixes #2610

Merged
merged 7 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions openbb_terminal/portfolio/portfolio_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ def call_load(self, other_args: List[str]):
self.portfolio.generate_portfolio_data()

# Add in the Risk-free rate
self.portfolio.set_risk_free_rate(ns_parser.risk_free_rate)
self.portfolio.set_risk_free_rate(ns_parser.risk_free_rate / 100)
self.risk_free_rate = ns_parser.risk_free_rate / 100

# Load benchmark
self.call_bench(["-b", "SPDR S&P 500 ETF Trust (SPY)"])
Expand All @@ -350,7 +351,7 @@ def call_load(self, other_args: List[str]):
f"\n[bold][param]Portfolio:[/param][/bold] {self.portfolio_name}"
)
console.print(
f"[bold][param]Risk Free Rate:[/param][/bold] {self.portfolio.risk_free_rate}"
f"[bold][param]Risk Free Rate:[/param][/bold] {self.risk_free_rate:.2%}"
)
console.print(
f"[bold][param]Benchmark:[/param][/bold] {self.benchmark_name}\n"
Expand All @@ -371,12 +372,13 @@ def call_show(self, other_args: List[str]):
export_allowed=EXPORT_BOTH_RAW_DATA_AND_FIGURES,
limit=10,
)
portfolio_view.display_orderbook(
self.portfolio,
show_index=False,
limit=ns_parser.limit,
export=ns_parser.export,
)
if ns_parser and self.portfolio is not None:
portfolio_view.display_orderbook(
self.portfolio,
show_index=False,
limit=ns_parser.limit,
export=ns_parser.export,
)

@log_start_end(log=logger)
def call_bench(self, other_args: List[str]):
Expand Down Expand Up @@ -1025,7 +1027,7 @@ def call_rsharpe(self, other_args: List[str]):
portfolio_view.display_rolling_sharpe(
self.portfolio,
window=ns_parser.period,
risk_free_rate=ns_parser.risk_free_rate,
risk_free_rate=ns_parser.risk_free_rate / 100,
export=ns_parser.export,
)

Expand Down Expand Up @@ -1065,9 +1067,9 @@ def call_rsort(self, other_args: List[str]):
self.portfolio_name, self.benchmark_name
):
portfolio_view.display_rolling_sortino(
portfolio=self.portfolio.benchmark_returns,
portfolio=self.portfolio,
window=ns_parser.period,
risk_free_rate=ns_parser.risk_free_rate,
risk_free_rate=ns_parser.risk_free_rate / 100,
export=ns_parser.export,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,6 @@ def get_ef(
method=method,
)

risk_free_rate = risk_free_rate / time_factor[freq.upper()]

# Building the portfolio object
port = rp.Portfolio(returns=stock_returns, alpha=alpha)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2204,6 +2204,8 @@ def display_ef(
Whether to plot the tickers for the assets
"""

risk_free_rate = risk_free_rate / time_factor[freq.upper()]

frontier, mu, cov, stock_returns, weights, X1, Y1, port = optimizer_model.get_ef(
symbols,
interval,
Expand Down