Engine
Strategies.Strategy
— MethodInitializes a Strategy object in the Strategies module.
Strategy(
self::Module,
assets::Union{AbstractSet{String}, Tuple{Vararg{String}}, Dict, AbstractVector{String}};
load_data,
config,
params,
account,
mode,
margin,
sandbox,
timeframe
)
The Strategy
function takes the following parameters:
self
: a Module object representing the current module.assets
: a Union of a dictionary or iterable of strings representing the assets to be included in the strategy.load_data
(optional, default is true): a boolean indicating whether to load data for the assets.config
: a Config object representing the configuration settings for the strategy.mode
(optional, default is config.mode): a mode setting for the strategy.margin
(optional, default is config.margin): a margin setting for the strategy.sandbox
(optional, default is true): a boolean indicating whether to run the strategy in a sandbox environment.timeframe
(optional, default is config.min_timeframe): a timeframe setting for the strategy.
The function initializes a Strategy object with the specified settings and assets.
Base.fill!
— MethodMain.Engine.Instances.fill!
all the instances with given timeframes data...
fill!(
ac::Collections.AssetCollection,
tfs...;
kwargs...
) -> DataFrames.DataFrame
Base.fill!
— MethodPulls data from storage, or resamples from the shortest timeframe available.
fill!(ai::Instances.AssetInstance, tfs...; exc, force, from)
This fill!
function takes the following parameters:
ai
: an AssetInstance object which represents an instance of an asset.tfs...
: one or more TimeFrame objects that represent the desired timeframes to fill the data for.exc
(optional, default isai.exchange
): an Exchange object that represents the exchange to pull data from.force
(optional, default is false): a boolean that indicates whether to force the data filling, even if the data is already present.from
(optional, default is nothing): a DateTime object that represents the starting date from which to fill the data.
Fills the data for the specified timeframes. If the data is already present and force
is false, the function does nothing.
Data.stub!
— MethodReplaces the data of the asset instances with src
which should be a mapping. Used for backtesting.
stub!(ac::Collections.AssetCollection, src; fromfiat)
The stub!
function takes the following parameters:
ac
: an AssetCollection object which encapsulates a collection of assets.src
: The mapping, should be a pairTimeFrame => Dict{String, PairData}
.fromfiat
(optional, default is true): a boolean that indicates whether the assets are priced in fiat currency. If true, the assets are priced in fiat currency.
The function replaces the OHLCV data of the assets in the ac
collection with the data from the src
mapping. This is useful for backtesting trading strategies.
Example:
using Scrapers.BinanceData as bn
using Strategies
using Exchanges
setexchange!(:binanceusdm)
cfg = Config(Symbol(exc.id))
strat = strategy!(:Example, cfg)
data = bn.binanceload()
stub!(strat.universe, data)