示例#1
0
data = set_values(get_data(Simfonia.URL), Simfonia.UNITS)

# Gain refers to actual gain over the invested amount.
gain = data[0] - Simfonia.INVESTED
max_gain = max(data) - Simfonia.INVESTED

# We plot the latest date.
latest_date = get_latest_date(Simfonia.URL)

# To correctly plot any range of values we use a pixel delimiter defined in Graph constants.
# In short, we set the maximum height for the highest value and 50 pixels for lowest value.
# Each plot has a gradient so we define a start and end color.
plot = Plot(Graph.PLOT_MAX_PIXELS, Simfonia.START_COLOR, Simfonia.END_COLOR)

# Instantiate portfolio.
simfonia = Portfolio(name, data, gain, max_gain, Simfonia.INVESTED,
                     latest_date, plot)

# ----- Diverso -----

# Name will be used to print the plot name.
name = Diverso.NAME

# Data is a list of integers calculated by multiplying VUAN and UNITS.
data = set_values(get_data(Diverso.URL), Diverso.UNITS)

# Gain refers to actual gain over the invested amount.
gain = data[0] - Diverso.INVESTED
max_gain = max(data) - Diverso.INVESTED

# We plot the latest date.
latest_date = get_latest_date(Diverso.URL)
data = set_values(get_data(Simfonia.URL), Simfonia.UNITS)

# Gain refers to actual gain over the invested amount.
gain = data[0] - Simfonia.INVESTED
max_gain = max(data) - Simfonia.INVESTED

# We plot the latest date.
latest_date = get_latest_date(Simfonia.URL)

# To correctly plot any range of values we use a pixel delimiter defined in Graph constants.
# In short, we set the maximum height for the highest value and 50 pixels for lowest value.
# Each plot has a gradient so we define a start and end color.
plot = Plot(Graph.PLOT_MAX_PIXELS, Simfonia.START_COLOR, Simfonia.END_COLOR)

# Instantiate portfolio.
simfonia = Portfolio(name, data, gain, max_gain, latest_date, plot)

# ----- Diverso -----

# Name will be used to print the plot name.
name = Diverso.NAME

# Data is a list of integers calculated by multiplying VUAN and UNITS.
data = set_values(get_data(Diverso.URL), Diverso.UNITS)

# Gain refers to actual gain over the invested amount.
gain = data[0] - Diverso.INVESTED
max_gain = max(data) - Diverso.INVESTED

# We plot the latest date.
latest_date = get_latest_date(Diverso.URL)