a4f66628fd
* initial commit * run parametrized algorithm with command line parameters * skeleton: top level structure * OptimizationNodePacket scheme * pass parameters as HashSet * run Lean and read results * call method on optimization completion * refactor public interfaces - close ParameterSet collection; allow only get operations - explicit method to start LeanOptimizer * synchronize RunLean method; the result could come in before the backtest id is set in the collections * another portion of refactoring and interface changes * comments * comments & tests for Extremum, Minimization and Maximization classes * unify optimization paramater values (min, max, step) & mode GridSearch tests - swap min&max if necessary - iterate left => right (negate step value if necessary) & provide default step value if step == 0 - no StackOverflow Exception - parameterSet Id should be global for current generator and retain between steps - test signle point boundary (min == max) * BruteForceStrategy tests * more comments * Update Optimizer assembly information - Update Optimizer projects assembly information to match behavior of the other projects * Tweaks - Adding comments - Replace OnComplete for Ended event - Replace Abort for Dispose - ConsoleLeanOptimizer will keep track of running processes - Each backtest will store results in a separated directory, so they don't fight for the log.txt file. - Adding cmdline option for lean to close automatically - Adding concurrent execution backtest limit - Console optimizer will start Lean minimized - Escape spaces in Json path * remove parameter set generator abstraction layer we don't need this flexibility now. * refactor public methods; Step shouldn't be public * constraints: wip * define contract * comparison operators and tests * specify JsonProperty values * Move SafeMultiply100 to extensions * Throw exception on failed Optimizer.Start * constraints: wip * change finish & dispose process * minor fixes - handle force lean abort - notify consumer if target has been reached * target & constraints; adapt unit tests * Minor Tweaks and fixes - Some logging improvements - Remove Public since not required * Ignore empty ParameterValue * simplify condition * avoid reinitialization * reduce type; force immutable * unit tests for constraints and target value * parse & normalize percent values, i.e. 20% => 0.2 * fixup * Target & Constraint & OptimizationNodePacket unit tests * Add more json unit tests - Adding more json conversion unit tests. Fix bug for Extremum which wasn't using the converter. * LeanOptimizer tests * Estimation results * User thread safe counters * LeanOptimizer unit tests; push OptimizationResult on Ended event * more unit tests * Minor tweaks -Estimate ToString in a single line. -Typos and missing header file * Add base SendUpdate method - Add base SendUpdate method for LeanOptimizer * fix LeanOptimizer test; rely on internal Update rather than timer * Add OptimizationStatus - Add missing commments and OptimizationStatus * EulerSearch implementation: wip * OptimizationParameter custom converter * change the type * make step optional * change folder structure * enumerate optimization parameter using IEnumerable & IEnumerator * unit tests: parameters & objectives * unit tests: strategies * remove redundant TODO * change Euler search boundaries * more Euler tests * prevent race condition * Add account/read endpoint - Adding account/read endpoint. Adding unit test * Add status check before running lean * Minor self review - Adding missing comments, minor changes * remove array parameters * minor changes - tidy up config file, rename variable - accept min less or equal than max * move OptimizationParameter methods to strategies * Minor improvements for BaseResultHandler derivates * minor changes - strict requirements for Step and MinStep values - strategy specific settigs * Add TotalRuntime to estimate Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
139 lines
7.9 KiB
C#
139 lines
7.9 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.Extensions.CommandLineUtils;
|
|
|
|
namespace QuantConnect.Configuration
|
|
{
|
|
/// <summary>
|
|
/// Command Line arguments parser for Lean configuration
|
|
/// </summary>
|
|
public static class LeanArgumentParser
|
|
{
|
|
private const string ApplicationName = "Lean Platform";
|
|
|
|
private const string ApplicationDescription =
|
|
"Lean Engine is an open-source algorithmic trading engine built for easy strategy research, backtesting and live trading. We integrate with common data providers and brokerages so you can quickly deploy algorithmic trading strategies.";
|
|
|
|
private const string ApplicationHelpText =
|
|
"If you are looking for help, please go to https://www.quantconnect.com/lean/docs";
|
|
|
|
private static readonly List<CommandLineOption> Options = new List<CommandLineOption>
|
|
{
|
|
// the location of the configuration to use
|
|
new CommandLineOption("config", CommandOptionType.SingleValue),
|
|
|
|
// true will close lean console automatically without waiting for input
|
|
new CommandLineOption("close-automatically", CommandOptionType.SingleValue),
|
|
|
|
// the result destination folder this algorithm should use for logging and result.json
|
|
new CommandLineOption("results-destination-folder", CommandOptionType.SingleValue),
|
|
|
|
// the unique algorithm id
|
|
new CommandLineOption("algorithm-id", CommandOptionType.SingleValue),
|
|
|
|
// Options grabbed from json file
|
|
new CommandLineOption("environment", CommandOptionType.SingleValue),
|
|
|
|
// algorithm class selector
|
|
new CommandLineOption("algorithm-type-name", CommandOptionType.SingleValue),
|
|
|
|
// Algorithm language selector - options CSharp, FSharp, VisualBasic, Python, Java
|
|
new CommandLineOption("algorithm-language", CommandOptionType.SingleValue),
|
|
|
|
//Physical DLL location
|
|
new CommandLineOption("algorithm-location", CommandOptionType.SingleValue),
|
|
|
|
//Research notebook
|
|
new CommandLineOption("composer-dll-directory", CommandOptionType.SingleValue),
|
|
|
|
// engine
|
|
new CommandLineOption("data-folder", CommandOptionType.SingleValue),
|
|
|
|
// handlers
|
|
new CommandLineOption("log-handler", CommandOptionType.SingleValue),
|
|
new CommandLineOption("messaging-handler", CommandOptionType.SingleValue),
|
|
new CommandLineOption("job-queue-handler", CommandOptionType.SingleValue),
|
|
new CommandLineOption("api-handler", CommandOptionType.SingleValue),
|
|
new CommandLineOption("map-file-provider", CommandOptionType.SingleValue),
|
|
new CommandLineOption("factor-file-provider", CommandOptionType.SingleValue),
|
|
new CommandLineOption("data-provider", CommandOptionType.SingleValue),
|
|
new CommandLineOption("alpha-handler", CommandOptionType.SingleValue),
|
|
|
|
// limits on number of symbols to allow
|
|
new CommandLineOption("symbol-minute-limit", CommandOptionType.SingleValue),
|
|
new CommandLineOption("symbol-second-limit", CommandOptionType.SingleValue),
|
|
new CommandLineOption("symbol-tick-limit", CommandOptionType.SingleValue),
|
|
|
|
// if one uses true in following token, market hours will remain open all hours and all days.
|
|
// if one uses false will make lean operate only during regular market hours.
|
|
new CommandLineOption("force-exchange-always-open", CommandOptionType.NoValue),
|
|
|
|
// save list of transactions to the specified csv file
|
|
new CommandLineOption("transaction-log", CommandOptionType.SingleValue),
|
|
|
|
// To get your api access token go to quantconnect.com/account
|
|
new CommandLineOption("job-user-id", CommandOptionType.SingleValue),
|
|
new CommandLineOption("api-access-token", CommandOptionType.SingleValue),
|
|
|
|
// live data configuration
|
|
new CommandLineOption("live-data-url", CommandOptionType.SingleValue),
|
|
new CommandLineOption("live-data-port", CommandOptionType.SingleValue),
|
|
|
|
// interactive brokers configuration
|
|
new CommandLineOption("ib-account", CommandOptionType.SingleValue),
|
|
new CommandLineOption("ib-user-name", CommandOptionType.SingleValue),
|
|
new CommandLineOption("ib-password", CommandOptionType.SingleValue),
|
|
new CommandLineOption("ib-host", CommandOptionType.SingleValue),
|
|
new CommandLineOption("ib-port", CommandOptionType.SingleValue),
|
|
new CommandLineOption("ib-agent-description", CommandOptionType.SingleValue),
|
|
new CommandLineOption("ib-tws-dir", CommandOptionType.SingleValue),
|
|
new CommandLineOption("ib-trading-mode", CommandOptionType.SingleValue),
|
|
|
|
// tradier configuration
|
|
new CommandLineOption("tradier-account-id", CommandOptionType.SingleValue),
|
|
new CommandLineOption("tradier-access-token", CommandOptionType.SingleValue),
|
|
new CommandLineOption("tradier-refresh-token", CommandOptionType.SingleValue),
|
|
new CommandLineOption("tradier-issued-at", CommandOptionType.SingleValue),
|
|
new CommandLineOption("tradier-lifespan", CommandOptionType.SingleValue),
|
|
new CommandLineOption("tradier-refresh-session", CommandOptionType.NoValue),
|
|
|
|
// oanda configuration
|
|
new CommandLineOption("oanda-environment", CommandOptionType.SingleValue),
|
|
new CommandLineOption("oanda-access-token", CommandOptionType.SingleValue),
|
|
new CommandLineOption("oanda-account-id", CommandOptionType.SingleValue),
|
|
|
|
// fxcm configuration
|
|
new CommandLineOption("fxcm-server", CommandOptionType.SingleValue),
|
|
new CommandLineOption("fxcm-terminal", CommandOptionType.SingleValue), //Real or Demo
|
|
new CommandLineOption("fxcm-user-name", CommandOptionType.SingleValue),
|
|
new CommandLineOption("fxcm-password", CommandOptionType.SingleValue),
|
|
new CommandLineOption("fxcm-account-id", CommandOptionType.SingleValue),
|
|
|
|
// iqfeed configuration
|
|
new CommandLineOption("iqfeed-username", CommandOptionType.SingleValue),
|
|
new CommandLineOption("iqfeed-password", CommandOptionType.SingleValue),
|
|
new CommandLineOption("iqfeed-productName", CommandOptionType.SingleValue),
|
|
new CommandLineOption("iqfeed-version", CommandOptionType.SingleValue),
|
|
|
|
// gdax configuration
|
|
new CommandLineOption("gdax-api-secret", CommandOptionType.SingleValue),
|
|
new CommandLineOption("gdax-api-key", CommandOptionType.SingleValue),
|
|
new CommandLineOption("gdax-passphrase", CommandOptionType.SingleValue),
|
|
|
|
// Required to access data from Quandl
|
|
// To get your access token go to https://www.quandl.com/account/api
|
|
new CommandLineOption("quandl-auth-token", CommandOptionType.SingleValue),
|
|
|
|
// parameters to set in the algorithm (the below are just samples)
|
|
new CommandLineOption("parameters", CommandOptionType.MultipleValue),
|
|
new CommandLineOption("environments", CommandOptionType.MultipleValue)
|
|
};
|
|
|
|
/// <summary>
|
|
/// Argument parser contructor
|
|
/// </summary>
|
|
public static Dictionary<string, object> ParseArguments(string[] args)
|
|
{
|
|
return ApplicationParser.Parse(ApplicationName, ApplicationDescription, ApplicationHelpText, args, Options);
|
|
}
|
|
}
|
|
} |