Type System
Types
Base Assets (Widgets)
Bruno.Instruments.Widget — TypeWidgets 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.Stock — TypeStock <: WidgetWidget subtype. Used as a base or root asset for financial instrument.
Bruno.Instruments.Commodity — TypeCommodity <: WidgetWidget subtype. Used as a base or root asset for FinancialInstrument.
Bruno.Instruments.Bond — TypeBond <: WidgetWidget subtype. Used as a base or root asset for FinancialInstrument.
Financial Instruments (Derivatives)
Abstract Types
Bruno.Instruments.FinancialInstrument — TypeFinancialInstrument is the supertype for any instrument that uses a base asset (widget) in its definition (like a financial derivative).
Bruno.Instruments.Option — TypeOption <: FinancialInstrumentAbstract FinancialInstrument subtype. Supertype of all options contract types.
Bruno.Instruments.CallOption — TypeCallOption{T <: Widget} <: OptionAbstract option subtype. Super type for all call options types.
Bruno.Instruments.PutOption — TypePutOption{T <: Widget} <: OptionAbstract option subtype. Super type for all put options types.
Concrete Types
Bruno.Instruments.Future — TypeFuture{T <: Widget} <: FinancialInstrumentFuture contract with underlying asset 'T'.
Bruno.Instruments.EuroCallOption — TypeEuroCallOption{T <: Widget} <: CallOption{T}European call option with underlying asset T.
Bruno.Instruments.AmericanCallOption — TypeAmericanCallOption{T <: Widget} <: CallOption{T}American call option with underlying asset of type T
Bruno.Instruments.EuroPutOption — TypeEuroPutOption{T <: Widget} <: CallOption{T}European put option with underlying asset T.
Bruno.Instruments.AmericanPutOption — TypeAmericanPutOption{T <: Widget} <: CallOption{T}American put option with underlying asset T.
Constructors
Base Asset Constructors
Bruno.Instruments.Stock — MethodStock(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<: Realname::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. Default 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.Commodity — MethodCommodity(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<: Realname: 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. Default 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.Bond — MethodBond(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<: Realname: 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.EuroCallOption — MethodEuroCallOption(;kwargs...)
EuroCallOption(widget, strike_price, maturity, risk_free_rate, values_library)Construct a EuroCallOption with underlying asset of type Widget
Arguments
widget: underlying assetstrike_price: Contracted price to buy underlying asset at maturitymaturity: 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.AmericanCallOption — MethodAmericanCallOption(widget, strike_price; kwargs...)
AmericanCallOption(;kwargs...)Construct a AmericanCallOption with underlying asset of type Widget
Arguments
widget: The underlying assetstrike_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.EuroPutOption — MethodEuroPutOption(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.AmericanPutOption — MethodAmericanPutOption(widget, strike_price; kwargs...)
AmericanPutOption(;kwargs...)Construct an AmericanPutOption with underlying asset of type Widget
Arguments
widget: underlying assetstrike_price: Contracted price to buy underlying asset at maturitymaturity: 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...)