Skip to content

Commit

Permalink
Read parameters from config in JobQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
mchandschuh committed Dec 10, 2015
1 parent ad3b4a2 commit e31fd9d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Launcher/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
"fxcm-password": "",
"fxcm-account-id": "",

// parameters to set in the algorithm (the below are just samples)
"parameters": {
"ema-fast": 10,
"ema-slow": 20
},

"environments": {

// defines the 'backtesting' environment
Expand Down
16 changes: 14 additions & 2 deletions Queues/JobQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*/

using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using QuantConnect.Configuration;
using QuantConnect.Interfaces;
using QuantConnect.Logging;
Expand Down Expand Up @@ -61,6 +63,14 @@ public AlgorithmNodePacket NextJob(out string location)
location = AlgorithmLocation;
Log.Trace("JobQueue.NextJob(): Selected " + location);

// check for parameters in the config
var parameters = new Dictionary<string, string>();
var parametersConfigString = Config.Get("parameters");
if (parametersConfigString != string.Empty)
{
parameters = JsonConvert.DeserializeObject<Dictionary<string, string>>(parametersConfigString);
}

//If this isn't a backtesting mode/request, attempt a live job.
if (_liveMode)
{
Expand All @@ -73,7 +83,8 @@ public AlgorithmNodePacket NextJob(out string location)
UserId = Config.GetInt("job-user-id"),
Version = Constants.Version,
DeployId = Config.Get("algorithm-type-name"),
RamAllocation = int.MaxValue
RamAllocation = int.MaxValue,
Parameters = parameters
};

try
Expand All @@ -98,7 +109,8 @@ public AlgorithmNodePacket NextJob(out string location)
Version = Constants.Version,
BacktestId = Config.Get("algorithm-type-name"),
RamAllocation = int.MaxValue,
Language = (Language)Enum.Parse(typeof(Language), Config.Get("algorithm-language"))
Language = (Language)Enum.Parse(typeof(Language), Config.Get("algorithm-language")),
Parameters = parameters
};

return backtestJob;
Expand Down

0 comments on commit e31fd9d

Please sign in to comment.