/// <summary> /// Create a live algorithm. /// </summary> /// <param name="projectId">Id of the project on QuantConnect</param> /// <param name="compileId">Id of the compilation on QuantConnect</param> /// <param name="nodeId">Id of the node that will run the algorithm</param> /// <param name="baseLiveAlgorithmSettings">Brokerage specific <see cref="BaseLiveAlgorithmSettings">BaseLiveAlgorithmSettings</see>.</param> /// <param name="versionId">The version of the Lean used to run the algorithm. /// -1 is master, however, sometimes this can create problems with live deployments. /// If you experience problems using, try specifying the version of Lean you would like to use.</param> /// <returns>Information regarding the new algorithm <see cref="LiveAlgorithm"/></returns> public LiveAlgorithm CreateLiveAlgorithm(int projectId, string compileId, string nodeId, BaseLiveAlgorithmSettings baseLiveAlgorithmSettings, string versionId = "-1") { var request = new RestRequest("live/create", Method.POST) { RequestFormat = DataFormat.Json }; request.AddParameter("application/json", JsonConvert.SerializeObject( new LiveAlgorithmApiSettingsWrapper (projectId, compileId, nodeId, baseLiveAlgorithmSettings, versionId) ), ParameterType.RequestBody); LiveAlgorithm result; ApiConnection.TryRequest(request, out result); return(result); }
/// <summary> /// Constructor for LiveAlgorithmApiSettingsWrapper /// </summary> /// <param name="projectId">Id of project from QuantConnect</param> /// <param name="compileId">Id of compilation of project from QuantConnect</param> /// <param name="nodeId">Server type to run live Algorithm</param> /// <param name="settings"><see cref="BaseLiveAlgorithmSettings ">Live Algorithm Settings</see> for a specific brokerage</param> /// <param name="version">The version identifier</param> public LiveAlgorithmApiSettingsWrapper(int projectId, string compileId, string nodeId, BaseLiveAlgorithmSettings settings, string version = "-1") { VersionId = version; ProjectId = projectId; CompileId = compileId; NodeId = nodeId; Brokerage = settings; }
/// <summary> /// Create a live algorithm. /// </summary> /// <param name="projectId">Id of the project on QuantConnect</param> /// <param name="compileId">Id of the compilation on QuantConnect</param> /// <param name="serverType">Type of server instance that will run the algorithm</param> /// <param name="baseLiveAlgorithmSettings">Brokerage specific <see cref="BaseLiveAlgorithmSettings">BaseLiveAlgorithmSettings</see>.</param> /// <param name="versionId">The version of the Lean used to run the algorithm. /// -1 is master, however, sometimes this can create problems with live deployments. /// If you experience problems using, try specifying the version of Lean you would like to use.</param> /// <returns>Information regarding the new algorithm <see cref="LiveAlgorithm"/></returns> public LiveAlgorithm CreateLiveAlgorithm(int projectId, string compileId, string serverType, BaseLiveAlgorithmSettings baseLiveAlgorithmSettings, string versionId = "-1") { var request = new RestRequest("live/create", Method.POST); request.AddHeader("Accept", "application/json"); request.Parameters.Clear(); var body = JsonConvert.SerializeObject(new LiveAlgorithmApiSettingsWrapper(projectId, compileId, serverType, baseLiveAlgorithmSettings, versionId)); request.AddParameter("application/json", body, ParameterType.RequestBody); LiveAlgorithm result; ApiConnection.TryRequest(request, out result); return(result); }