Processing
Processing.Processing
— ModuleModule for data resampling, cleaning, aligning, etc.
Data.propagate_ohlcv!
— FunctionUpdates 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!
— MethodResamples 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._deltas
— MethodComputes 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._fill_missing_candles!
— Method_fill_missing_candles!(
df,
timeframe::AbstractString;
strategy
) -> Any
See fill_missing_candles
.
Processing._left_and_right
— MethodReturns 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_candle
— MethodRemoves 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!
— MethodCleans 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_data
— Methodcleanup_ohlcv_data(
data,
tf::AbstractString;
kwargs...
) -> Any
See cleanup_ohlcv_data
.
Processing.cleanup_ohlcv_data
— MethodCleans 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_candles!
— Methodfill_missing_candles!(
df,
prd::Dates.Period;
strategy
) -> Any
See fill_missing_candles
.
Processing.fill_missing_candles
— MethodFills 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.isadjacent
— Methoda
is adjacent to b
if either isleftadj
or isrightadj
.
Processing.iscomplete
— MethodChecks if a candle is old enough to be complete.
iscomplete(v, tf) -> Any
Processing.isincomplete
— MethodChecks if a candle is too new.
isincomplete(
candle::Data.Candle,
tf::TimeFrames.TimeFrame
) -> Any
Processing.isincomplete
— MethodChecks if a DateTime is incomplete based on a TimeFrame.
isincomplete(
d::Dates.DateTime,
tf::TimeFrames.TimeFrame
) -> Any
Processing.islast
— MethodChecks 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.islast
— MethodChecks if a candle is exactly the latest candle.
islast(d::Dates.DateTime, tf, _::Val{:raw}) -> Any
Processing.isleftadj
— Methoda
is left adjacent to b
if in order ..ab..
isleftadj(a, b, tf::TimeFrames.TimeFrame) -> Any
Processing.isrightadj
— Methoda
is right adjacent to b
if in order ..ba..
isrightadj(a, b, tf::TimeFrames.TimeFrame) -> Any
Processing.maptf
— MethodApply 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...)::DataFrametfsum
: sum the scores across multiple timeframes for every pair.
Processing.normalize!
— MethodApplies either a unitrange transform or a zscore tranform over the data in place.
normalize!(arr; unit, dims) -> Any
Processing.normalize
— MethodSee normalize!
. Copies.
Processing.resample
— Functionresample(
df::DataFrames.AbstractDataFrame,
tf::TimeFrames.TimeFrame;
...
) -> Any
resample(
df::DataFrames.AbstractDataFrame,
tf::TimeFrames.TimeFrame,
b::Bool,
args...;
kwargs...
) -> Any
. See resample
.
Processing.resample
— FunctionResamples 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.resample
— MethodProcessing.resample
— Methodresample(
mkts::AbstractDict{String, Data.PairData},
timeframe;
progress,
lk
) -> Dict{String, Data.PairData}
. See resample
.
Processing.resample
— Methodresample(pair::Data.PairData, to_tf) -> Any
. See resample
.
Processing.resample_style
— MethodResamples 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!
— MethodApplies 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.
Processing.@resample
— Macro. See resample
.