Processing

Data.propagate_ohlcv!Function

Updates OHLCV data across multiple time frames.

propagate_ohlcv!(
    data::SortedDict{TimeFrames.TimeFrame, DataFrames.DataFrame}
) -> Union{Nothing, SortedDict{TimeFrames.TimeFrame, DataFrames.DataFrame}}
propagate_ohlcv!(
    data::SortedDict{TimeFrames.TimeFrame, DataFrames.DataFrame},
    update_func::Function
) -> Union{Nothing, SortedDict{TimeFrames.TimeFrame, DataFrames.DataFrame}}

This function takes a dictionary data and an aggregation function update_func. It updates the OHLCV data from the base time frame to the higher time frames in data, using update_func to aggregate the OHLCV values from the base to the target time frame. The function modifies data in place and returns it. If the base time frame data frame in data is empty, the function clears all the higher time frames data frames. Otherwise, it asynchronously updates each higher time frame data frame and ensures that the timestamps are synchronized across all time frames.

Data.propagate_ohlcv!Method

Resamples OHLCV data between different time frames.

propagate_ohlcv!(
    src::DataFrames.DataFrame,
    dst::DataFrames.DataFrame;
    src_tf,
    dst_tf,
    strict
) -> DataFrames.DataFrame

This function resamples the OHLCV data from a source DataFrame to a destination DataFrame with different timeframes. If the latest timestamp in the destination DataFrame is earlier than the earliest timestamp in the resampled source DataFrame, the function appends the resampled data to the destination DataFrame. If not, the function returns the destination DataFrame as is. Both the source and destination DataFrames must have columns named 'timestamp', 'open', 'high', 'low', 'close', and 'volume'. The source and destination timeframes must be suitable for the resampling operation.

Processing._deltasMethod

Computes the deltas for a given transformation.

_deltas(
    data,
    to_tf
) -> Union{Tuple{Float64, Float64, Float64, Any}, Tuple{Integer, Any, Any, Nothing}}

This function takes a data vector and a target transformation function, and computes the deltas (changes) in the data that would result from applying the transformation.

Processing._left_and_rightMethod

Returns the left and right indices for a given frame.

_left_and_right(
    data,
    frame_size,
    src_td,
    td
) -> Tuple{Int64, Any}

This function takes a data vector, frame size, source time delta, and target time delta, and computes the left and right indices for the frame based on these parameters.

Processing._remove_incomplete_candleMethod

Removes incomplete candles from a DataFrame.

_remove_incomplete_candle(in_df, tf) -> Any

This function takes a DataFrame in_df and a TimeFrame tf. It identifies any incomplete candles in in_df based on tf and removes them.

See isincomplete for more information.

Processing.cleanup_ohlcv!Method

Cleans up OHLCV data in a ZArray.

cleanup_ohlcv!(
    z::Zarr.ZArray,
    timeframe::AbstractString
) -> Union{Nothing, Zarr.ZArray}

This function takes a ZArray z and a string timeframe. It cleans up the OHLCV data in z by removing any incomplete candles based on timeframe and filling any missing candles using the specified filling strategy.

Processing.cleanup_ohlcv_dataMethod

Cleans up OHLCV data in a DataFrame.

cleanup_ohlcv_data(
    data,
    tf::TimeFrames.TimeFrame;
    col,
    fill_missing
) -> Any

This function takes a DataFrame data, a TimeFrame tf, and optionally a column index col and a filling strategy fill_missing. It cleans up the OHLCV data in data by removing any incomplete candles based on tf, filling any missing candles using the specified filling strategy, and sorting the data by the specified column.

Processing.fill_missing_candlesMethod

Fills missing candles in a DataFrame.

fill_missing_candles(
    df,
    timeframe::AbstractString;
    strategy
) -> Any

This function takes a DataFrame df, a string timeframe, and optionally a filling strategy strategy. It identifies the missing candles in df based on the timeframe, and fills them using the specified strategy.

filling strategies:

  • :close: fill with the close price of the previous candle.
  • :open: fill with the open price of the next candle.
  • :linear: linearly interpolate between the close price of the previous candle and the open price of the next candle.
Processing.iscompleteMethod

Checks if a candle is old enough to be complete.

iscomplete(v, tf) -> Any
Processing.isincompleteMethod

Checks if a candle is too new.

isincomplete(
    candle::Data.Candle,
    tf::TimeFrames.TimeFrame
) -> Any
Processing.isincompleteMethod

Checks if a DateTime is incomplete based on a TimeFrame.

isincomplete(
    d::Dates.DateTime,
    tf::TimeFrames.TimeFrame
) -> Any
Processing.islastMethod

Checks if the last row of a smaller DataFrame is also the last row of a larger DataFrame.

islast(
    larger::DataFrames.DataFrame,
    smaller::DataFrames.DataFrame
) -> Any
Processing.islastMethod

Checks if a candle is exactly the latest candle.

islast(d::Dates.DateTime, tf, _::Val{:raw}) -> Any
Processing.isleftadjMethod

a is left adjacent to b if in order ..ab..

isleftadj(a, b, tf::TimeFrames.TimeFrame) -> Any
Processing.isrightadjMethod

a is right adjacent to b if in order ..ba..

isrightadj(a, b, tf::TimeFrames.TimeFrame) -> Any
Processing.maptfMethod

Apply a function over data, resampling data to each timeframe in tfs.

maptf(
    tfs::AbstractVector{T} where T<:String,
    data,
    f::Function;
    tfsum,
    kwargs...
) -> Any
  • f: signature is (data; kwargs...)::DataFrame
  • tfsum: sum the scores across multiple timeframes for every pair.
Processing.normalize!Method

Applies either a unitrange transform or a zscore tranform over the data in place.

normalize!(arr; unit, dims) -> Any
Processing.resampleFunction
resample(
    df::DataFrames.AbstractDataFrame,
    tf::TimeFrames.TimeFrame;
    ...
) -> Any
resample(
    df::DataFrames.AbstractDataFrame,
    tf::TimeFrames.TimeFrame,
    b::Bool,
    args...;
    kwargs...
) -> Any

. See resample.

Processing.resampleFunction

Resamples data based on transformation functions.

resample(data, from_tf, to_tf) -> Any
resample(data, from_tf, to_tf, cleanup) -> Any
resample(data, from_tf, to_tf, cleanup, style) -> Any
resample(data, from_tf, to_tf, cleanup, style, chop)

This function takes a data vector, a source transformation function from_tf, a target transformation function to_tf, and optionally a boolean cleanup and a style style. It resamples the data from the source time frame to the target time frame. If cleanup is true, it removes any invalid data points after resampling. The resampling style is determined by style. If chop is true, it removes the leftovers at the end of the data that can't fill a complete frame.

Processing.resampleMethod

Resamples data, and saves to storage.

resample(args...; exc_name, name, dosave) -> Any
Usually not worth it

Resampling is quite fast, so it is simpler to keep only the smaller timeframe on storage, and resample the longer ones on demand.

Processing.resampleMethod
resample(
    mkts::AbstractDict{String, Data.PairData},
    timeframe;
    progress,
    lk
) -> Dict{String, Data.PairData}

. See resample.

Processing.resample_styleMethod

Resamples a style based on a transformation function.

resample_style(style, tf) -> Any

This function takes a style and a transformation function tf, and resamples the style based on the transformation.

Processing.trail!Method

Applies trailing operation on a DataFrame based on a time frame.

trail!(df, tf::TimeFrames.TimeFrame; to, from, cap)

This function takes a DataFrame df, a TimeFrame tf, and optionally a timestamp to, a timestamp from, and a cap cap. It applies a trailing window operation on df for the specified tf. The operation starts from the timestamp specified by from (default is the last timestamp in the DataFrame) and ends at the timestamp specified by to. The cap argument determines the maximum number of rows to keep in the dataframe.