public ActionResult <string> PostAlgoConfig(string algoName, [FromBody] AlgoMetadata config)
        {
            algoName = algoName.ToLower().Trim();
            var foundAlgo = AlgoMaster.Algos.Find(o => o.Name.ToLower().Trim() == algoName);

            if (foundAlgo == null)
            {
                if (string.IsNullOrWhiteSpace(config.Name))
                {
                    return(BadRequest("Name not specified"));
                }

                // Create a new one
                // config.Name = algoName;
                var newAlgo = AlgoMaster.CreateAlgo(config);
                newAlgo.PublishState();

                AlgoMaster.Save();
                return(Accepted());
            }
            else
            {
                foundAlgo.Metadata         = config;
                foundAlgo.Metadata.Enabled = foundAlgo.Enabled;
                AlgoMaster.Save();
                return(Accepted());
            }
        }
예제 #2
0
        public RapidAlgo(AlgoMetadata metadata, ITradingSystemAdapter adapter)
        {
            Name                  = metadata.Name;
            Adapter               = adapter;
            Metadata              = metadata;
            Stats                 = new OrderStats();
            Adapter.StatsChanged += Adapter_StatsChanged;


            _timer.Interval = 1000;
            _timer.Elapsed += Timer_Elapsed;
            _timer.Enabled  = true;
        }