Misc
PlanarCore.Misc.ATOL — Constant
The margin of error to use [2eps].
PlanarCore.Misc.DEFAULT_ASSETS — Constant
The default asset pairs, configurable via PLANAR_DEFAULT_ASSETS env var (comma-separated).
PlanarCore.Misc.Iterable — Type
An union of iterable types.
PlanarCore.Misc.ONE — Constant
Static one(DFT)
PlanarCore.Misc.QUOTE_CURRENCY — Constant
The default quote currency, configurable via PLANAR_QUOTE_CURRENCY env var.
PlanarCore.Misc.WithMargin — Type
Any margin mode.
PlanarCore.Misc.ZERO — Constant
Static zero(DFT)
PlanarCore.Misc.config — Constant
Global configuration instance.
PlanarCore.Misc.fetch_limits — Constant
Exchange ohlcv candles limits.
PlanarCore.Misc.futures_exchange — Constant
Some exchanges are split into different classes in ccxt.
PlanarCore.Misc.results — Constant
Holds recently evaluated statements.
PlanarCore.Misc.Config — Type
Creates a Config object from a profile and path.
Config(profile::Union{Module, String, Symbol}; ...) -> Any
Config(
profile::Union{Module, String, Symbol},
path::String;
hasentry,
kwargs...
) -> Any
This function creates a Config object using the provided profile and path. The profile can be a Symbol, Module, or String representing a specific configuration setup or a user/project profile. If hasentry is true, it also checks for an entry point.
PlanarCore.Misc.Config — Type
Strategy config.
path: File path that loaded this config.mode: Execution mode (Sim,Paper,Live)exchange: A symbol to instantiate an exchange (a raw ExchangeID symbol)account: Different accounts have different api keysparams: Parameters for exchange constructorsandbox: Exchange sandbox mode flagqc: The quote currency for the strategy cash.margin: Configures the margin mode of the strategy (NoMargin,IsolatedorCross)leverage: The default leverage that should be used when opening position with margin mode.min_vol: A minimum acceptable volume, e.g. for filtering markets.initial_cash: Starting cash, used when instantiating a strategy.min_size: Default order size.min_timeframe: The default (shortest) timeframe of the candles.timeframes: Vector of sorted timeframes that the strategy uses (for loading data).window: The default number of candles (OHLCV).sources: Mapping of modules symbols name to (.jl) file pathsattrs: Generic metadata container.toml: Raw toml that instantiated this config.defaults
PlanarCore.Misc.ContiguityException — Type
An exception that is thrown when the data stored ends before the new data starts (or vice versa).
PlanarCore.Misc.Cross — Type
NotHedged CrossMargin mode.
PlanarCore.Misc.CrossHedged — Type
Hedged CrossMargin mode.
PlanarCore.Misc.CrossMargin — Type
Cross margin mode handles margin across all assets (NOT IMPLEMENTED).
PlanarCore.Misc.DFT — Type
The floating point number type to use.
PlanarCore.Misc.ExecAction — Type
An ExecAction is any holy trait singleton used to dispatch call! and call! functions.
PlanarCore.Misc.ExecMode — Type
ExecMode is one of Sim, Paper, Live.
PlanarCore.Misc.Hedged — Type
Hedged implies both short and long positions can be held.
PlanarCore.Misc.HedgedMode — Type
HedgedMode is one of Hedged, NotHedged.
PlanarCore.Misc.Isolated — Type
NotHedged IsolatedMargin mode.
PlanarCore.Misc.IsolatedHedged — Type
Hedged IsolatedMargin mode.
PlanarCore.Misc.IsolatedMargin — Type
Isolated margin mode handles margin for each asset separately.
PlanarCore.Misc.LeftContiguityException — Type
An exception that is thrown when the data stored starts before the new data ends.
PlanarCore.Misc.Live — Type
Live execution.
PlanarCore.Misc.Long — Type
Long position side.
PlanarCore.Misc.MM — Type
Min, max named tuple
PlanarCore.Misc.MarginMode — Type
Margin mode is one of Isolated, Cross, NoMargin.
PlanarCore.Misc.NoMargin — Type
No margin mode, margin handling is disabled (usually in simple spot markets).
PlanarCore.Misc.NotHedged — Type
NotHedged implies only one position side can be held.
PlanarCore.Misc.Paper — Type
Paper execution.
PlanarCore.Misc.PositionSide — Type
Position side is one of Long, Short.
PlanarCore.Misc.RightContiguityException — Type
An exception that is thrown when the data stored ends before the new data starts.
PlanarCore.Misc.Short — Type
Short position side.
PlanarCore.Misc.Sim — Type
Simulated execution.
PlanarCore.Misc.TaskFlag — Type
Used to indicate that a task is still running.
f: The function that indicates that the task is still running (returns aBool).
PlanarCore.Misc.TaskFlag — Method
The default task flag
Uses the task local storage to communicate if the task is still running.
PlanarCore.Misc.UniqueIterator — Type
Returns an iterator that yields unique elements from an iterable.
PlanarCore.Misc._find_module — Method
Finds the module corresponding to a given symbol.
_find_module(sym) -> Any
This function takes a symbol sym and attempts to find the corresponding module in the loaded modules.
PlanarCore.Misc._instantiate_workers — Method
Instantiates worker processes for a given module.
_instantiate_workers(
mod;
force,
num
) -> Union{Nothing, Int64}
This function takes a module mod and optionally a boolean force and an integer num. It spawns num worker processes for mod. If force is true, it first kills any existing worker processes for mod.
PlanarCore.Misc._options! — Method
Sets the options in cfg based on provided name.
_options!(cfg, name) -> Any
This function iterates over the options defined in the cfg object's TOML and sets each option according to the values provided under the given name.
PlanarCore.Misc._path! — Method
Sets the path in cfg if the file exists.
_path!(cfg, path) -> Any
This function sets the path field of the cfg object to the provided path if a file exists at that location.
PlanarCore.Misc._sources! — Method
Sets the sources in cfg based on provided name.
_sources!(cfg, name)
This function iterates over the sources defined in the cfg object's TOML and sets each source according to the values provided under the given name.
PlanarCore.Misc._toml! — Method
Sets the TOML config in cfg if the file exists.
_toml!(cfg, name; check)
This function sets the toml field of the cfg object to the parsed contents of a TOML file with the provided name, if the file exists.
PlanarCore.Misc.after — Method
Returns a view of the vector after a specified value.
after(v::AbstractVector, d; kwargs...) -> Any
This function returns a view of the vector v starting from the position after the first occurrence of d. The behavior can be adjusted using keyword arguments passed to rangeafter.
PlanarCore.Misc.approxzero — Method
Checks if a value is approximately zero.
approxzero(v; atol) -> Any
This function takes a value v and a tolerance atol. It returns true if the absolute difference between v and zero is less than or equal to atol, and false otherwise.
PlanarCore.Misc.attr! — Method
Get k from the attrs field of the input object, or v if k is not present, setting k to v.
attr!(d, k, v) -> Any
PlanarCore.Misc.attr — Method
Get k from the attrs field of the input object, or v if k is not present.
attr(d, k, v) -> Any
PlanarCore.Misc.attr — Method
Get k from the attrs field of the input object.
attr(d, k) -> Any
PlanarCore.Misc.attrs — Method
Get all keys... from the attrs field of the input object.
attrs(d, keys...) -> Dict{Any, Any}
PlanarCore.Misc.attrs — Method
Get the attrs field of the input object.
PlanarCore.Misc.before — Method
Complement of after.
PlanarCore.Misc.between — Method
Returns a view of the sorted vector v, indexed using rangebetween.
between(v::AbstractVector, left, right; kwargs...) -> Any
julia> between([1, 2, 3, 3, 3], 3, 3; strict=true)
0-element view(::Vector{Int64}, 6:5) with eltype Int64
julia> between([1, 2, 3, 3, 3], 1, 3; strict=true)
1-element view(::Vector{Int64}, 2:2) with eltype Int64:
2
julia> between([1, 2, 3, 3, 3], 2, 3; strict=false)
2-element view(::Vector{Int64}, 3:4) with eltype Int64:
3
3PlanarCore.Misc.config! — Method
Parses the toml file and populates the config cfg.
config!(
name::String;
cfg,
path,
check
) -> PlanarCore.Misc.Config{Float64}
This function updates the configuration object cfg by parsing the TOML file specified by name and path. If check is true, the function validates the config.
PlanarCore.Misc.config_path — Method
Determines the config file path.
This function attempts to find the configuration file using find_config(). If it doesn't exist in the default directory, it falls back to the active project directory.
PlanarCore.Misc.dec! — Method
Decrement an integer reference by one
PlanarCore.Misc.default_dir — Method
Returns the default directory path for the project.
default_dir() -> String
This function returns the directory of the active project if it exists. Otherwise, it uses the JULIA_PROJECT from the environment variables. If neither exist, it defaults to the current directory.
PlanarCore.Misc.default_local_dir — Method
Returns the default local directory.
PlanarCore.Misc.drop — Method
Returns a NamedTuple without the given keys.
PlanarCore.Misc.exchange_keys — Method
Retrieves the API keys for a specific exchange.
exchange_keys(name; sandbox, account)
This function tries to open and parse a JSON file named after the exchange name, which should contain the API keys.
PlanarCore.Misc.execmode — Method
Returns the execution mode of the arguments.
PlanarCore.Misc.find_config — Function
Finds the configuration file in the given path.
find_config(; ...) -> Union{Nothing, String}
find_config(cur_path; name, dir) -> Any
This function recursively searches for a file with the specified name starting from cur_path. It stops once the file is found or when it reaches the root directory.
PlanarCore.Misc.gtxzero — Method
Checks if a value is greater than or approximately equal to zero.
gtxzero(v; atol) -> Any
This function takes a value v and a tolerance atol. It returns true if v is greater than zero or if the absolute difference between v and zero is less than or equal to atol, and false otherwise.
PlanarCore.Misc.hasattr — Method
Check if k is present in the attrs field of the input object.
PlanarCore.Misc.hasattr — Method
Check if any of keys... is present in the attrs field of the input object.
PlanarCore.Misc.inc! — Method
Increment an integer reference by one
PlanarCore.Misc.init_task — Method
Initializes a task with a given state.
init_task(t::Task, state) -> Task
This function initializes a task t with a given state. It sets up the task's storage dictionary which includes running flag, state, and a condition variable for notification.
PlanarCore.Misc.isdirempty — Method
Checks if a directory is empty.
isdirempty(path::AbstractString) -> Bool
This function takes a path and returns true if the directory at the given path is empty, and false otherwise.
PlanarCore.Misc.isstrictlysorted — Method
Checks if an iterable is strictly sorted.
isstrictlysorted(itr...) -> Bool
This function takes an iterable itr and returns true if the elements in itr are strictly increasing, and false otherwise.
PlanarCore.Misc.istaskrunning — Method
Check if a task is running.
istaskrunning(t::Task) -> Bool
This function checks if a task (t) is running. A task is considered running if it has started and is not yet done.
PlanarCore.Misc.istaskrunning — Method
Checks if the current task is running.
This function checks if the current task is running by accessing the task's local storage.
PlanarCore.Misc.keys_path — Method
Generates the path for the JSON keys file.
keys_path(exc_name::AbstractString) -> String
This function constructs a filename from the given exc_name, replacing any existing .json extension, and joins it with the user directory path.
PlanarCore.Misc.marginmode — Method
Returns the margin mode of the arguments.
PlanarCore.Misc.modifyattr! — Method
Set k in the attrs field of the input object to v.
modifyattr!(d, v, op, keys...)
PlanarCore.Misc.negative — Method
negate(abs(v))
PlanarCore.Misc.opposite — Method
The opposite position side (Long -> Short, Short -> Long)
PlanarCore.Misc.positive — Method
Alias to abs
PlanarCore.Misc.queryfromstruct — Function
Creates a query from a struct type.
queryfromstruct(T::Type; ...) -> Dict{Any, Any}
queryfromstruct(T::Type, sep; kwargs...) -> Dict{Any, Any}
This function takes a struct type T and a separator sep, and creates a query string using the fields and their values in T.
PlanarCore.Misc.rangeafter — Method
Finds the range after a specified value in a vector.
rangeafter(v::AbstractVector, d; strict, kwargs...) -> Any
This function takes a vector v and a value d, and returns a range that starts after the first occurrence of d in v. If strict is true, the range starts after d, otherwise it starts at d.
PlanarCore.Misc.rangebefore — Method
Complement of rangeafter.
PlanarCore.Misc.rangebetween — Method
Finds the range between two specified values in a vector.
rangebetween(
v::AbstractVector,
left,
right;
kwargs...
) -> Any
This function takes a vector v and two values left and right, and returns a range that starts from the position of left and ends at the position of right in v.
PlanarCore.Misc.reset! — Method
Resets the Config object to its default values.
reset!(c::PlanarCore.Misc.Config)
This function iterates over the fields of the Config object c and resets each field to its default value. (stored in the defaults field)
PlanarCore.Misc.rewritekeys! — Method
Rewrites keys in a dictionary based on a function.
rewritekeys!(dict::AbstractDict, f) -> AbstractDict
This function takes a dictionary dict and a function f, and rewrites each key in the dictionary by applying the function f to it.
PlanarCore.Misc.setattr! — Method
Set k in the attrs field of the input object to v.
PlanarCore.Misc.setoffline! — Method
Sets the offline mode.
setoffline!() -> Bool
This function sets the offline mode based on the PLANAR_OFFLINE environment variable. If the environment variable is set, it parses its value as a boolean to set the offline mode. It is used to skip some errors during precompilation, if precompiling offline.
PlanarCore.Misc.shift! — Function
Shifts elements in a vector.
shift!(
arr::Vector{<:AbstractFloat}
) -> Vector{<:AbstractFloat}
shift!(
arr::Vector{<:AbstractFloat},
n
) -> Vector{<:AbstractFloat}
shift!(
arr::Vector{<:AbstractFloat},
n,
def
) -> Vector{<:AbstractFloat}
This function shifts the elements in arr by n positions to the left. The new elements added to the end of the array are set to the value of def.
PlanarCore.Misc.start_task — Method
Initializes and starts a task with a given state.
start_task(t::Task, state) -> Task
This function initializes a task t with a given state, schedules the task, and then returns the task.
PlanarCore.Misc.stop_task — Method
Stops a task if it's running.
stop_task(t::Task) -> Bool
This function attempts to stop a running task t. It sets the task's running flag to false and notifies any waiting threads if applicable.
PlanarCore.Misc.swapkeys — Method
Swaps keys in a dictionary based on a function and new key type.
swapkeys(
dict::AbstractDict{K, V},
k_type::Type,
f;
dict_type
) -> Any
This function takes a dictionary dict, a function f, and a new key type k_type. It returns a new dictionary of type dict_type where each key is transformed by the function f and cast to k_type.
PlanarCore.Misc.task_sem — Method
Retrieves or initializes a semaphore for a task.
task_sem(task) -> Any
This function retrieves or initializes a semaphore for a task task. If the semaphore doesn't exist, it initializes a new one with an empty queue and a condition variable.
PlanarCore.Misc.toprecision — Method
When precision is a Integer it represents the number of decimals.
toprecision(n::AbstractFloat, prec::Int64) -> Any
PlanarCore.Misc.toprecision — Method
Round a float to a given precision (SIGNIFICANT_DIGITS).
toprecision(n::AbstractFloat, prec::UInt64) -> Any
SIGNIFICANT_DIGITS precision mode is similar to DECIMAL_PLACES except that the last digit is the one that is rounded
PlanarCore.Misc.toprecision — Method
When precision is a float it represents the pip.
toprecision(
n::Union{AbstractFloat, Integer},
prec::AbstractFloat
) -> Any
PlanarCore.Misc.truncate_file — Method
Truncate a file to contain only the last nlines lines.
truncate_file(filename, nlines) -> Any
Opens the file for reading, keeps only the last nlines lines, then opens the file again for writing and overwrites it with those last lines. Throws an error if nlines is not a positive integer.
PlanarCore.Misc.waitforcond — Method
Waits for a certain condition for a specified time.
waitforcond(cond, time) -> Int64
This function waits for a certain condition cond to be met within a specified time. The condition cond is a function that returns a boolean value. The function continuously checks the condition until it's true or until the specified time has passed.
PlanarCore.Misc.waitforcond — Method
Waits for a condition function to return true for a specified time.
waitforcond(cond::Function, time) -> Int64
This function waits for a condition function cond to return true. It keeps checking the condition for a specified time.
PlanarCore.Misc.@as_dfdict — Macro
Binds a mrkts variable to a Dict{String, DataFrame} where the keys are the pairs names and the data is the OHLCV data of the pair.
PlanarCore.Misc.@istaskrunning — Macro
Checks if the current task is running (Macro).
Equivalent to istaskrunning() but should be used within other macros.
PlanarCore.Misc.@lev! — Macro
Toggle config leverage flag
PlanarCore.Misc.@margin! — Macro
Toggle config margin flag.
PlanarCore.Misc.@skipoffline — Macro
Same as the Lang.@ignoremacro, but only ifPLANAR_OFFLINE` is set.
PlanarCore.Misc.@start_task — Macro
Starts a task with a given state and code block.
This macro initializes and starts a task with a given state and code block. It creates a task with the provided code, initializes it with the state, and schedules the task for running.