Beispiel #1
0
        private static HashSet <model.ShortParameters> GenerateShortParameterSpace()
        {
            var result = new HashSet <model.ShortParameters>();

            var bollWindowConfig = "9:50:10";
            var bollDevConfig    = "1.0:5.0:0.1";
            var cciWindowConfig  = "5:50:5";
            var atrWindowConfig  = "5:50:5";

            var bollWindowRange = bollWindowConfig.Split(':').Select(x => Convert.ToInt32(x)).ToList();
            var bollDevRange    = bollDevConfig.Split(':').Select(x => Convert.ToDecimal(x)).ToList();
            var cciWindowRange  = cciWindowConfig.Split(':').Select(x => Convert.ToInt32(x)).ToList();
            var atrWindowRange  = atrWindowConfig.Split(':').Select(x => Convert.ToInt32(x)).ToList();

            int steps = 0;

            while (bollWindowRange[0] + steps * bollWindowRange[2] <= bollWindowRange[1] &&
                   bollDevRange[0] + steps * bollDevRange[2] <= bollDevRange[1] &&
                   cciWindowRange[0] + steps * cciWindowRange[2] <= cciWindowRange[1] &&
                   atrWindowRange[0] + steps * atrWindowRange[2] <= atrWindowRange[1])
            {
                var param = new model.ShortParameters()
                {
                    bollWindow = bollWindowRange[0] + steps * bollWindowRange[2],
                    bollDev    = bollDevRange[0] + steps * bollDevRange[2],
                    cciWindow  = cciWindowRange[0] + steps * cciWindowRange[2],
                    atrWindow  = atrWindowRange[0] + steps * atrWindowRange[2]
                };
                result.Add(param);
                steps++;
            }

            return(result);
        }
Beispiel #2
0
        //public void Publish(model.Parameters parameters)
        public void Publish(model.ShortParameters parameters, string queueName)
        {
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    // Declaring a queue is idempotent - it will only be created if it doesn't exist already
                    channel.QueueDeclare(queue: queueName,
                                         durable: true,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);

                    var properties = channel.CreateBasicProperties();
                    // this will mark the msg persistent by writing it to cache and disk
                    properties.Persistent = true;

                    // create the message; msg is a byte array, encode whatever u like
                    var message = parameters.ToString();
                    var body    = Encoding.UTF8.GetBytes(message);

                    // publish is the key action for producer; send to the queue
                    // the task will only send once. once the task is sent to the queue, it will out of the channel.
                    channel.BasicPublish(exchange: "",
                                         routingKey: queueName,
                                         basicProperties: properties,
                                         body: body);
                    Console.WriteLine("Published a parameter set to worker queue --- " + message);
                }
        }