/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using QuantConnect.Brokerages; namespace QuantConnect.Api { /// /// Helper class to put BaseLiveAlgorithmSettings in proper format. /// public class LiveAlgorithmApiSettingsWrapper { /// /// Constructor for LiveAlgorithmApiSettingsWrapper /// /// Id of project from QuantConnect /// Id of compilation of project from QuantConnect /// Server type to run live Algorithm /// Dictionary with brokerage specific settings. Each brokerage requires certain specific credentials /// in order to process the given orders. Each key in this dictionary represents a required field/credential /// to provide to the brokerage API and its value represents the value of that field. For example: "brokerageSettings: { /// "id": "Binance", "binance-api-secret": "123ABC", "binance-api-key": "ABC123"}. It is worth saying, /// that this dictionary must always contain an entry whose key is "id" and its value is the name of the brokerage /// (see ) /// The version identifier /// Dictionary with data providers credentials. Each data provider requires certain credentials /// in order to retrieve data from their API. Each key in this dictionary describes a data provider name /// and its corresponding value is another dictionary with the required key-value pairs of credential /// names and values. For example: "dataProviders: {InteractiveBrokersBrokerage : { "id": 12345, "environement" : "paper", /// "username": "testUsername", "password": "testPassword"}}" /// Dictionary to specify the parameters for the live algorithm /// Dictionary with the lists of events and targets public LiveAlgorithmApiSettingsWrapper( int projectId, string compileId, string nodeId, Dictionary settings, string version = "-1", Dictionary dataProviders = null, Dictionary parameters = null, Dictionary> notification = null) { VersionId = version; ProjectId = projectId; CompileId = compileId; NodeId = nodeId; Brokerage = settings; var quantConnectDataProvider = new Dictionary { { "id", "QuantConnectBrokerage" }, }; DataProviders = dataProviders ?? new Dictionary() { { "QuantConnectBrokerage", quantConnectDataProvider }, }; Signature = CompileId.Split("-").LastOrDefault(); Parameters = parameters ?? new Dictionary(); Notification = notification ?? new Dictionary>(); AutomaticRedeploy = false; } /// /// -1 is master /// [JsonProperty(PropertyName = "versionId")] public string VersionId { get; set; } /// /// Project id for the live instance /// [JsonProperty(PropertyName = "projectId")] public int ProjectId { get; private set; } /// /// Compile Id for the live algorithm /// [JsonProperty(PropertyName = "compileId")] public string CompileId { get; private set; } /// /// Id of the node being used to run live algorithm /// [JsonProperty(PropertyName = "nodeId")] public string NodeId { get; private set; } /// /// Signature of the live algorithm /// [JsonProperty(PropertyName = "signature")] public string Signature { get; private set; } /// /// True to enable Automatic Re-Deploy of the live algorithm, /// false otherwise /// [JsonProperty(PropertyName = "automaticRedeploy")] public bool AutomaticRedeploy { get; private set; } /// /// The API expects the settings as part of a brokerage object /// [JsonProperty(PropertyName = "brokerage")] public Dictionary Brokerage { get; private set; } /// /// Dictionary with the data providers and their corresponding credentials /// [JsonProperty(PropertyName = "dataProviders")] public Dictionary DataProviders { get; private set; } /// /// Dictionary with the parameters to be used in the live algorithm /// [JsonProperty(PropertyName = "parameters")] public Dictionary Parameters { get; private set; } /// /// Dictionary with the lists of events and targets /// [JsonProperty(PropertyName = "notification")] public Dictionary> Notification { get; private set; } } }