Ejemplo n.º 1
0
def submit_custom_portfolio(portfolio):
    opening_value = portfolio_opening_value(portfolio)
    if (opening_value > 10000):
        raise Exception("Opening value should be no more than $10,000")
    custom_returns = portfolio_returns(portfolio)
    print("Your returns are {:.2f}%!".format(custom_returns))
    print("Your ending balance is ${:,.2f}".format(portfolio_value(portfolio)))
    submit_leaderboard(username(), 3, str(portfolio_value(portfolio)))
Ejemplo n.º 2
0
from lab1 import parse_portfolio, portfolio_value
from lab2 import username, portfolio_returns, benchmark_returns, adjusted_returns
from leaderboard import submit_leaderboard, submit_portfolio_returns, submit_benchmark_returns
from datetime import datetime

if username() == "username":
  raise Exception("Fill in a username for our leaderboard.")

portfolio = parse_portfolio()
value = portfolio_value(portfolio)

returns = portfolio_returns(portfolio)
submit_portfolio_returns(returns)

benchmark_returns = benchmark_returns(portfolio.openDate)
submit_benchmark_returns(benchmark_returns)

adjusted_returns = adjusted_returns(returns, benchmark_returns)
print("{:.2f}% adjusted returns".format(adjusted_returns))


print("Congratulations, you have completed the second lab.")
submit_leaderboard(username(),2,str(datetime.now()))
print("Visit http://leaderboard to view the leaderboard")
Ejemplo n.º 3
0
def portfolio_returns(portfolio):
    return round(
        (portfolio_value(portfolio) / portfolio_opening_value(portfolio) - 1) *
        100, 2)