Struct
Asset
These structs contain the price or return values, the timestamp information, the scaling factor to annualize the returns, the frequency of returns, the id, and the exchange the asset is traded on.
If AssetReturn(ticker::String,from::TimeType,to::TimeType,freq::String) is called data is automatically downloaded using YFinance.jl and the exchange, freq, and scale are automatically stored/calculated. The package calculates the scale assuming 252 trading days in a year. Furthermore, the exchange is important to accurately aggregate intra-day data (the trading hours in a day are different for exchanges across the world).
PerformanceAnalytics.AssetPrice
— TypeAssetPrice(ticker::String,from::TimeType,to::TimeType,freq::String;exchange_local_time=true)
Generates a AssetPrice struct using YFinance.jl.
Arguments
- ticker the Yahoo Finance ticker
- from a start time/date (either a
::Date
or::DateTime
) - to a end time/date (either a
::Date
or::DateTime
) - freq the frequency of data. One of "3mo","1mo","1wk","5d","1d",1h","90m","60m","30m","15m","5m","2m","1m"
- exchangelocaltime use the local time of the exchange as the timestamp (defaults to true)
Returns
AssetPrice
PerformanceAnalytics.AssetReturn
— TypeAssetReturn(x::AssetPrice)
Calculates the return from the price series of the AssetPrice and returns a AssetReturn.
AssetReturn(ticker::String,from::TimeType,to::TimeType,freq::String)
Generates a AssetReturn struct using YFinance.jl. Internally calls AssetPrice and then calculates returns from the price series.
Arguments
- ticker the Yahoo Finance ticker
- from a start time/date (either a
::Date
or::DateTime
) - to a end time/date (either a
::Date
or::DateTime
) - freq the frequency of data. One of "3mo","1mo","1wk","5d","1d",1h","90m","60m","30m","15m","5m","2m","1m"
- exchangelocaltime use the local time of the exchange as the timestamp (defaults to true)
Returns
AssetReturn
Accessing Items
Base.values
— FunctionBase.values(x::AssetPrice)
Returns a vector of prices of the asset.
Base.values(x::AssetReturn)
Returns a vector of returns of the asset.
PerformanceAnalytics.timestamp
— Functiontimestamp(x::AssetPrice)
Returns a vector of the timestamps of the asset.
timestamp(x::AssetReturn)
Returns a vector of the timestamps of the asset.
PerformanceAnalytics.scale
— Functionscale(x::AssetPrice)
Returns the scaling number for the asset. Used to for annualization.
scale(x::AssetReturn)
Returns the scaling number for the asset. Used to for annualization.
PerformanceAnalytics.id
— Functionid(x::AssetPrice)
Returns the id (ticker) of the asset.
id(x::AssetReturn)
Returns the id (ticker) of the asset.