Type System

Types

Base Assets (Widgets)

Bruno.Instruments.WidgetType

Widgets are the root asset at the heart of the package. A 'widget' can be any real world financial object such as a stock or commodity. For a list of possible subtypes use subtypes(Widget).

Bruno.Instruments.StockType
Stock <: Widget

Widget subtype. Used as a base or root asset for financial instrument.

Bruno.Instruments.BondType
Bond <: Widget

Widget subtype. Used as a base or root asset for FinancialInstrument.

Financial Instruments (Derivatives)

Abstract Types

Bruno.Instruments.OptionType
Option <: FinancialInstrument

Abstract FinancialInstrument subtype. Supertype of all options contract types.

Concrete Types

Constructors

Base Asset Constructors

Bruno.Instruments.StockMethod
Stock(prices, name, timesteps_per_period, volatility)
Stock(price; kwargs...)
Stock(;kwargs)

Construct a Stock type to use as a base asset for FinancialInstrument.

Arguments

  • prices:Historical prices (input as a 1-D array) or the current price input as a number <: Real
  • name::String: Name of the stock or stock ticker symbol. Default "".
  • timesteps_per_period::Int64: For the size of a timestep in the data, the number of

time steps for a given period of time, cannot be negative. For example, if the period of interest is a year, and daily stock data is used, timesteps_per_period=252. Defualt is length of the prices array or 0 for single price (static) stock. Note: If timesteps_per_period=0, the Stock represents a 'static' element and cannot be used in the strategy_returns() method.

  • volatility: Return volatility, measured in the standard deviation of continuous returns.

Defaults to using get_volatility() on the input prices array. Note: if a single number is given for prices volatility must be given.

Examples

Stock([1,2,3,4,5], "Example", 252, .05)

kwargs = Dict(
    :prices => [1, 2, 3, 4, 5], 
    :name => "Example", 
    :timesteps_per_period => 252, 
    :volatility => .05
);

Stock(;kwargs...)

Stock(40; volatility=.05)
Bruno.Instruments.CommodityMethod
Commodity(prices, name, timesteps_per_period, volatility)
commodity(price; kwargs...)
Commodity(;kwargs)

Construct a Commodity type to use as a base asset for FinancialInstrument.

Arguments

  • prices:Historical prices (input as a 1-D array) or the current price input as a number <: Real
  • name: String name of the commodity or commodity ticker symbol. Default "".
  • timesteps_per_period: For the size of a timestep in the data, the number of

time steps for a given period of time, cannot be negative. For example, if the period of interest is a year, and daily commodity price data is used, timesteps_per_period=252. Defualt is the length of the prices array or 0 for a single price (static) Commodity. Note: If timesteps_per_period=0, the Commodity represents a 'static' element and cannot be used in the strategy_returns() method.

  • volatility: Return volatility, measured in the standard deviation of continuous returns.

Defaults to using get_volatility() on the input prices array. Note: if a single number is given for prices volatility must be given.

Examples

Commodity([1,2,3,4,5], "Example", 252, .05)

kwargs = Dict(
    :prices => [1, 2, 3, 4, 5], 
    :name => "Example", 
    :timesteps_per_period => 252, 
    :volatility => .05
);

Commodity(;kwargs...)

Commodity(40; volatility=.05)
Bruno.Instruments.BondMethod
Bond(prices, name, time_mat, coupon_rate)
Bond(price; kwargs...)
Bond(;kwargs)

Construct a Bond type to use as a base asset for FinancialInstrument.

Arguments

  • prices:Historical prices (input as a 1-D array) or the current price input as a number <: Real
  • name: String name of the Bond or issuing company. Default "".
  • time_mat: Time until the bond expires (matures) in years. Default 1.
  • coupon_rate: The coupon rate for the bond. Default .03.

Examples

Bond([1,2,3,4,5], "Example", .5, .05)

kwargs = Dict(:prices => [1, 2, 3, 4, 5], :name => "Example", :time_mat => .5, :coupon_rate => .05);
Bond(;kwargs...)

Bond(2; coupon_rate=.05)

Financial Instrument Constructors

Bruno.Instruments.EuroCallOptionMethod
EuroCallOption(;kwargs...)
EuroCallOption(widget, strike_price, maturity, risk_free_rate, values_library)

Construct a EuroCallOption with underlying asset of type Widget

Arguments

  • widget: underlying asset
  • strike_price: Contracted price to buy underlying asset at maturity
  • maturity: time to maturity of the option with respect to implicit time period. Default 1.
  • risk_free_rate: market risk free interest rate. Default is .02.
  • values_library: A dictionary of values returned from pricing functions. Default initializes

to an empty dictionary. use price!() function to load theoretical option prices.

Examples

stock = Stock([1,2,4,3,5,3]);

EuroCallOption(stock, 10)

kwargs = Dict(:widget=>stock, :strike_price=>10, :maturity=>1, :risk_free_rate=>.02);
EuroCallOption(;kwargs...)
Bruno.Instruments.AmericanCallOptionMethod
AmericanCallOption(widget, strike_price; kwargs...)
AmericanCallOption(;kwargs...)

Construct a AmericanCallOption with underlying asset of type Widget

Arguments

  • widget: The underlying asset
  • strike_price: Contracted price to buy underlying asset at maturity.
  • maturity: time to maturity of the option with respect to implicit time period. Default 1.
  • risk_free_rate: market risk free interest rate. Default is .02.
  • values_library: The values returned from pricing models. Default initializes

to an empty dictionary. use price!() function to load theoretical option prices.

Examples

stock = Stock([1,2,4,3,5,3]);

AmericanCallOption(stock, 10)

kwargs= Dict(:widget=>stock, :strike_price=>10, :maturity=>1, :risk_free_rate=>.02);
AmericanCallOption(;kwargs...)
Bruno.Instruments.EuroPutOptionMethod
EuroPutOption(widget, strike_price; kwargs...)
EuroPutOption(;kwargs...)

Construct a EuroPutOption with underlying asset of type Widget

Arguments

  • widget: The underlying asset.
  • strike_price: Contracted price to buy underlying asset at maturity.
  • maturity: time to maturity of the option with respect to implicit time period. Default 1.
  • risk_free_rate: market risk free interest rate. Default is .02.
  • values_library: The values returned from pricing models. Default initializes

to an empty dictionary. use price!() function to load theoretical option prices.

Examples

stock = Stock([1,2,4,3,5,3]);

EuroPutOption(stock, 10)

kwargs= Dict(:widget=>stock, :strike_price=>10, :maturity=>1, :risk_free_rate=>.02);
EuroPutOption(;kwargs...)
Bruno.Instruments.AmericanPutOptionMethod
AmericanPutOption(widget, strike_price; kwargs...)
AmericanPutOption(;kwargs...)

Construct an AmericanPutOption with underlying asset of type Widget

Arguments

  • widget: underlying asset
  • strike_price: Contracted price to buy underlying asset at maturity
  • maturity: time to maturity of the option with respect to implicit time period. Default 1.
  • risk_free_rate: market risk free interest rate. Default is .02.
  • values_library: The values returned from pricing models. Default initializes

to an empty dictionary. use price!() function to load theoretical option prices

Examples

stock = Stock([1,2,4,3,5,3]);

AmericanPutOption(stock, 10)

kwargs = Dict(:widget=>stock, :strike_price=>10, :maturity=>1, :risk_free_rate=>.02);
AmericanPutOption(;kwargs...)