time_series
mainsequence.virtualfundbuilder.contrib.prices.time_series
InterpolatedPrices
Bases: TimeSerie
Handles interpolated prices for assets.
human_readable: str
property
Returns a human-readable string representation of the object.
__init__(asset_category_unique_id, bar_frequency_id, intraday_bar_interpolation_rule, markets_time_series_unique_id_list, upsample_frequency_id=None, asset_filter=None, local_kwargs_to_ignore=['asset_category_unique_id'], *args, **kwargs)
Initializes the InterpolatedPrices object.
get_upsampled_data(update_statistics)
Main method to get upsampled data for prices.
run_after_post_init_routines()
Use post init routines to configure the time series
update(update_statistics)
Updates the series from the source based on the latest value.
InterpolatedPricesLive
Handles interpolated prices for assets.
__init__(asset_list, bar_frequency_id, intraday_bar_interpolation_rule, upsample_frequency_id=None, local_kwargs_to_ignore=['asset_list'], *args, **kwargs)
Initializes the InterpolatedPricesLive object.
get_earliest_value_for_initial_update()
Get the earliest value for the initial update.
update(update_statistics)
Updates the series from the source based on the latest value.
UpsampleAndInterpolation
Handles upsampling and interpolation of bar data.
get_interpolated_upsampled_bars(calendar, tmp_df, last_observation=None)
Gets interpolated and upsampled bars based on the given parameters. First interpolates the data to fill any gaps, then upsamples it to the desired frequency.
Args: calendar (str): Trading calendar for interpolation and upsampling. tmp_df (pd.DataFrame): Dataframe containing the bars to be processed. last_observation (Union[None, pd.Series], optional): Last observed data to fill gaps.
Returns: pd.DataFrame: Interpolated and upsampled bars dataframe.
upsample_bars(bars_df, upsample_frequency_obs, upsample_frequency_td, calendar, open_to_close_time_delta, is_portfolio=False)
staticmethod
Upsamples the bars dataframe based on the given parameters. For example, it can convert 5-minute bars to 1-minute bars. Note that this method works on iloc as the underlying data should be already interpolated so should be completed
Args: bars_df (pd.DataFrame): The bars data to be upsampled. upsample_frequency_obs (int): Frequency for upsampling. upsample_frequency_td (object): Time delta for upsampling. calendar (str): Trading calendar to account for trading hours. open_to_close_time_delta (datetime.timedelta): Time delta between open and close. is_portfolio (bool): Whether the data is for a portfolio or a single asset.
Returns: pd.DataFrame: The upsampled bars dataframe.
get_interpolated_prices_timeseries(assets_configuration)
Creates a Wrapper Timeseries for an asset configuration.
get_time_serie_from_markets_unique_id(market_time_serie_unique_identifier)
Returns the appropriate bar time series based on the asset list and source.
interpolate_intraday_bars(bars_df, interpolation_rule, bars_frequency_min, calendar, last_observation=None)
Interpolates intraday bars based on the given parameters. Fills in missing data points in intraday bar data in case of gaps.