Base Assets (Widgets)

Overview

Widgets are base (or underlying) assets for a Financial Instrument, they can also be used by themselves. Examples include the stock, bond, and commodity structs.

Creating a Widget

The following example is how to create a random dataset representing historical prices and create a Stock widget using those prices.

# creating a random 'dataset' of 15 simulated prices
historical_prices = rand(50:70, 15)

# creates a Stock widget assuming hisorical prices are daily prices
a_widget = Stock(;prices=historical_prices, name="my_widget", timesteps_per_period=252)

Interacting With a Widget

historical_prices = [1, 2, 3, 4, 5]

# creates a Stock widget
a_widget = Stock(;prices=historical_prices, name="my_widget", timesteps_per_period=252)

# price the Stock widget
stock_price = price!(a_widget, StockPrice)