/ StrategyStats / src / module.jl
module.jl
 1  using ExchangeTypes: Exchange, exc
 2  using Data: @to_mat, save_ohlcv, PairData, empty_ohlcv, DataFrames, Misc
 3  using .Misc.TimeTicks: td_tf, timefloat, @as_td
 4  using .Misc.DocStringExtensions
 5  using .DataFrames: DataFrame, groupby, combine, Not, select!, index, rename!
 6  using Logging: NullLogger, with_logger
 7  
 8  # InformationMeasures, EffectSizes...
 9  function _doinit()
10  end
11  
12  @doc """Filters and sorts a list of pairs using a predicate function.
13  
14  $(TYPEDSIGNATURES)
15  
16  This function takes a list of pairs and a predicate function. It filters the list by applying the predicate function to each pair and keeping only those pairs for which the function returns a `Real` number. The function then sorts the filtered list based on the returned `Real` numbers.
17  
18  """
19  function filterminmax(pred::Function, pairs::AbstractDict, min_v::Real, max_v::Real)
20      flt = Tuple{AbstractFloat,PairData}[]
21      for (_, p) in pairs
22          v = pred(p.data)
23          if !ismissing(v) && max_v > v > min_v
24              push!(flt, (v, p))
25          end
26      end
27      sort!(flt; by=x -> x[1])
28  end
29  
30  @doc """Generates a summary of a vector of tuples containing Floats and PairData.
31  
32  $(TYPEDSIGNATURES)
33  
34  This function takes a vector `flt` of tuples, where each tuple contains an AbstractFloat and a PairData. It generates a summary of `flt`, providing insights into the characteristics of the Floats and PairData in the vector.
35  
36  """
37  function fltsummary(flt::AbstractVector{Tuple{AbstractFloat,PairData}})
38      [(x[1], x[2].name) for x in flt]
39  end
40  
41  fltsummary(flt::AbstractVector{PairData}) = [p.name for p in flt]
42  
43  include("explore.jl")
44  include("queries.jl")
45  
46  using .Query
47  
48  export fltsummary