Specification - Functions
TFire.Specification
— MethodSpecification(;
tickers::Vector{String}, # Required - Assets to include
start_date::Union{Date,DateTime}, # Required - Start of analysis period
end_date::Union{Date,DateTime}, # Required - End of analysis period
resolution::String="1d", # "1d", "1m", etc.
mode::Symbol=:continuous, # :continuous or :discrete
market_hours::String="", # "", "NY", etc.
extend_back::Int=100, # How far back to look
data_fields::Union{Nothing,Vector{Symbol}}=nothing # Optional specific fields
)
Creates a Specification for a collection of assets with specified time ranges and structure.
The specification determines:
- Which assets (tickers) to include
- The time period to analyze
- How the data should be structured (continuous vs discrete)
- What market hours to use (for discrete mode)
- What data fields to include
Examples:
# Basic daily data
spec = Specification(
tickers=["AAPL", "MSFT"],
start_date=Date(2023,1,1),
end_date=Date(2024,1,1)
)
# Intraday crypto data
spec = Specification(
tickers=["BTC-USD"],
start_date=Date(2023,1,1),
end_date=Date(2024,1,1),
resolution="1m",
mode=:discrete,
market_hours="NY"
)
TFire.constituents_continuous
— Methodconstituents_continuous(tickers::Vector{String}, dates_vect::Vector{Tuple{D,D}},
resolution::String) where {D<:Union{Date,DateTime}}
resolution::String)
Constructs ConstituentsConstinues from a list of tickers and a
TFire.constituents_continuous
— Methodconstituents_continuous(tickers::Vector{String}, eval_dates::Vector{D},
extend_back::Integer; resolution="1d") where {D<:Union{Date,DateTime}}
Constructs a ConstituentsContinuous from a vector of tickers, evaluation dates, and an extend back period. The extend back determines how far before each evaluation date to include data. The resolution determines the type of the eval_dates and how to calculate the extend back.
TFire.extend_sfdb_constituents!
— Methodextend_sfdb_constituents!(rc::ConstituentsContinuous{D,T}; extend_first=Day(0),
extend_last=Day(0)) where {D<:Date,T<:SFDBSpecification}
extend_last=Day(0))
Extends the date range for each ticker in the given ConstituentsContinuous with SFDBSpecification by shifting the start date back by extend_first
and the end date forward by extend_last
. Doesnt extend past current date.
TFire.extend_sfdb_constituents!
— Methodextend_sfdb_constituents!(rc::ConstituentsContinuous{D,T}; extend_first=Day(0),
extend_last=Day(0)) where {D<:DateTime,T<:SFDBSpecification}
extend_last=Day(0))
Extends the date range for each ticker in the given ConstituentsContinuous with SFDBSpecification by shifting the start date back by extend_first
and the end date forward by extend_last
.
TFire.preset_data_fields
— Methodpreset_data_fields(sym::Symbol, s::Type{S}) where S <: SpecificationType
Presets the data fields for a CollectionSpecification based on the symbol sym. Allows selecting common preset configurations like :normal, :reduced etc.
TFire.sfdb_constituents
— Methodsfdb_constituents(cons::ConstituentsDiscrete{CollectionSpecification})
Converts a ConstituentsDiscrete with CollectionSpecification to one with SFDBSpecification by collapsing the date ranges for each ticker on each date into a single range from the start of the day to the end of the day.
TFire.sfdb_constituents
— Methodsfdb_constituents(cons::ConstituentsContinuous{D,CollectionSpecification}) where {D<:Union{Date,DateTime}}
Converts a ConstituentsContinuous with CollectionSpecification to one with SFDBSpecification by collapsing the date ranges for each ticker into a single range from the earliest start date to the latest end date.
TFire.specification_external
— Methodspecification_external(spec::Specification{C,T}) where {C<:AssetConstituents,T<:SFDBSpecification}
Converts a Specification with SFDBSpecification to one with ExternalSpecification by converting the constituents to use ExternalSpecification and converting the data fields to use non logarithmized versions.
TFire.specification_sfdb
— Methodspecification_sfdb(spec::Specification{C,T}; extend_first=Day(1000),
extend_last=Day(1000)) where {C<:ConstituentsContinuous,T<:CollectionSpecification}
Converts a Specification with CollectionSpecification to one with SFDBSpecification by collapsing the date ranges for each ticker into a single range from the earliest start date to the latest end date.
TFire.trading_datetimes
— Methodtrading_datetimes(dates::Vector{Date}; opening_hours="")
Constructs a TradingDates
object containing the trading datetimes for the given vector of dates.
The opening_hours
parameter can be used to specify the trading hours. If set to "NY", the trading hours will be set to the NYSE opening hours. Otherwise, the trading hours will be set to the full day from midnight to 11:59 PM.
Args: dates::Vector{Date}: The vector of dates to get the trading datetimes for. opening_hours::String="": Specifies the trading hours to use. Can be "NY" for NYSE hours or left empty for full day.
Returns: TradingDates: An object containing the trading datetimes for the given dates.