Lean  $LEAN_TAG$
LeanArgumentParser.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System.Collections.Generic;
17 using McMaster.Extensions.CommandLineUtils;
18 
20 {
21  /// <summary>
22  /// Command Line arguments parser for Lean configuration
23  /// </summary>
24  public static class LeanArgumentParser
25  {
26  private const string ApplicationName = "Lean Platform";
27 
28  private const string ApplicationDescription =
29  "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.";
30 
31  private const string ApplicationHelpText =
32  "If you are looking for help, please go to https://www.quantconnect.com/lean/docs";
33 
34  private static readonly List<CommandLineOption> Options = new List<CommandLineOption>
35  {
36  // the location of the configuration to use
37  new CommandLineOption("config", CommandOptionType.SingleValue),
38 
39  // true will close lean console automatically without waiting for input
40  new CommandLineOption("close-automatically", CommandOptionType.SingleValue),
41 
42  // the result destination folder this algorithm should use for logging and result.json
43  new CommandLineOption("results-destination-folder", CommandOptionType.SingleValue),
44 
45  // the algorithm name
46  new CommandLineOption("backtest-name", CommandOptionType.SingleValue),
47 
48  // the unique algorithm id
49  new CommandLineOption("algorithm-id", CommandOptionType.SingleValue),
50 
51  // the unique optimization id
52  new CommandLineOption("optimization-id", CommandOptionType.SingleValue),
53 
54  // Options grabbed from json file
55  new CommandLineOption("environment", CommandOptionType.SingleValue),
56 
57  // algorithm class selector
58  new CommandLineOption("algorithm-type-name", CommandOptionType.SingleValue),
59 
60  // Algorithm language selector - options CSharp, Python
61  new CommandLineOption("algorithm-language", CommandOptionType.SingleValue),
62 
63  //Physical DLL location
64  new CommandLineOption("algorithm-location", CommandOptionType.SingleValue),
65 
66  //Research notebook
67  new CommandLineOption("composer-dll-directory", CommandOptionType.SingleValue),
68 
69  // engine
70  new CommandLineOption("data-folder", CommandOptionType.SingleValue),
71 
72  // handlers
73  new CommandLineOption("log-handler", CommandOptionType.SingleValue),
74  new CommandLineOption("messaging-handler", CommandOptionType.SingleValue),
75  new CommandLineOption("job-queue-handler", CommandOptionType.SingleValue),
76  new CommandLineOption("api-handler", CommandOptionType.SingleValue),
77  new CommandLineOption("map-file-provider", CommandOptionType.SingleValue),
78  new CommandLineOption("factor-file-provider", CommandOptionType.SingleValue),
79  new CommandLineOption("data-provider", CommandOptionType.SingleValue),
80  new CommandLineOption("alpha-handler", CommandOptionType.SingleValue),
81  new CommandLineOption("history-provider", CommandOptionType.SingleValue),
82 
83  // limits on number of symbols to allow
84  new CommandLineOption("symbol-minute-limit", CommandOptionType.SingleValue),
85  new CommandLineOption("symbol-second-limit", CommandOptionType.SingleValue),
86  new CommandLineOption("symbol-tick-limit", CommandOptionType.SingleValue),
87 
88  // if one uses true in following token, market hours will remain open all hours and all days.
89  // if one uses false will make lean operate only during regular market hours.
90  new CommandLineOption("force-exchange-always-open", CommandOptionType.NoValue),
91 
92  // save list of transactions to the specified csv file
93  new CommandLineOption("transaction-log", CommandOptionType.SingleValue),
94 
95  // To get your api access token go to quantconnect.com/account
96  new CommandLineOption("job-user-id", CommandOptionType.SingleValue),
97  new CommandLineOption("api-access-token", CommandOptionType.SingleValue),
98  new CommandLineOption("job-organization-id", CommandOptionType.SingleValue),
99 
100  // live data configuration
101  new CommandLineOption("live-data-url", CommandOptionType.SingleValue),
102  new CommandLineOption("live-data-port", CommandOptionType.SingleValue),
103 
104  // interactive brokers configuration
105  new CommandLineOption("ib-account", CommandOptionType.SingleValue),
106  new CommandLineOption("ib-user-name", CommandOptionType.SingleValue),
107  new CommandLineOption("ib-password", CommandOptionType.SingleValue),
108  new CommandLineOption("ib-host", CommandOptionType.SingleValue),
109  new CommandLineOption("ib-port", CommandOptionType.SingleValue),
110  new CommandLineOption("ib-agent-description", CommandOptionType.SingleValue),
111  new CommandLineOption("ib-tws-dir", CommandOptionType.SingleValue),
112  new CommandLineOption("ib-trading-mode", CommandOptionType.SingleValue),
113 
114  // tradier configuration
115  new CommandLineOption("tradier-account-id", CommandOptionType.SingleValue),
116  new CommandLineOption("tradier-access-token", CommandOptionType.SingleValue),
117  new CommandLineOption("tradier-refresh-token", CommandOptionType.SingleValue),
118  new CommandLineOption("tradier-issued-at", CommandOptionType.SingleValue),
119  new CommandLineOption("tradier-lifespan", CommandOptionType.SingleValue),
120  new CommandLineOption("tradier-refresh-session", CommandOptionType.NoValue),
121 
122  // oanda configuration
123  new CommandLineOption("oanda-environment", CommandOptionType.SingleValue),
124  new CommandLineOption("oanda-access-token", CommandOptionType.SingleValue),
125  new CommandLineOption("oanda-account-id", CommandOptionType.SingleValue),
126 
127  // fxcm configuration
128  new CommandLineOption("fxcm-server", CommandOptionType.SingleValue),
129  new CommandLineOption("fxcm-terminal", CommandOptionType.SingleValue), //Real or Demo
130  new CommandLineOption("fxcm-user-name", CommandOptionType.SingleValue),
131  new CommandLineOption("fxcm-password", CommandOptionType.SingleValue),
132  new CommandLineOption("fxcm-account-id", CommandOptionType.SingleValue),
133 
134  // coinbase configuration
135  new CommandLineOption("coinbase-rest-api", CommandOptionType.SingleValue),
136  new CommandLineOption("coinbase-url", CommandOptionType.SingleValue),
137  new CommandLineOption("coinbase-api-key", CommandOptionType.SingleValue),
138  new CommandLineOption("coinbase-api-secret", CommandOptionType.SingleValue),
139 
140  // Required to access data from Quandl
141  // To get your access token go to https://www.quandl.com/account/api
142  new CommandLineOption("quandl-auth-token", CommandOptionType.SingleValue),
143 
144  // parameters to set in the algorithm (the below are just samples)
145  new CommandLineOption("parameters", CommandOptionType.MultipleValue),
146  new CommandLineOption("environments", CommandOptionType.MultipleValue)
147  };
148 
149  /// <summary>
150  /// Argument parser contructor
151  /// </summary>
152  public static Dictionary<string, object> ParseArguments(string[] args)
153  {
154  return ApplicationParser.Parse(ApplicationName, ApplicationDescription, ApplicationHelpText, args, Options);
155  }
156  }
157 }