Beispiel #1
0
        public void OnData(QuoteBars data)
        {
            long l  = (30 * 24 * 60 * 60);
            long le = (10 * 24 * 60 * 60);

            foreach (var rule in trades)
            {
                if (data.ContainsKey(rule.Symbol))
                {
                    var candleStartTime = Utils.ToUnixTimestamp(data[rule.Symbol].Time.ConvertToUtc(Securities[rule.Symbol].Exchange.TimeZone));
                    var candleEndTime   = Utils.ToUnixTimestamp(data[rule.Symbol].EndTime.ConvertToUtc(Securities[rule.Symbol].Exchange.TimeZone));

                    if ((rule._Serie.Count == 0 && (rule.setupTime - l) > candleStartTime) || (rule._Serie.Count > 0 && (rule.exitTime + le > candleStartTime || rule.expirationTime + le > candleStartTime)))
                    {
                        List <LocalQuote> serie = new List <LocalQuote>();
                        rule._Serie.Add(new LocalQuote
                        {
                            date  = Utils.ToUnixTimestamp(data[rule.Symbol].Time.ConvertToUtc(Securities[rule.Symbol].Exchange.TimeZone)),
                            open  = data[rule.Symbol].Open,
                            close = data[rule.Symbol].Close,
                            high  = data[rule.Symbol].High,
                            low   = data[rule.Symbol].Low
                        });
                    }
                }
            }
        }
        public void OnData(QuoteBars data)
        {
            long l  = (30 * 24 * 60 * 60);
            long le = (10 * 24 * 60 * 60);

            foreach (var rule in trades)
            {
                if (data.ContainsKey(rule.Symbol))
                {
                    var candleStartTime = Utils.ToUnixTimestamp(data[rule.Symbol].Time.ConvertToUtc(Securities[rule.Symbol].Exchange.TimeZone));
                    var candleEndTime   = Utils.ToUnixTimestamp(data[rule.Symbol].EndTime.ConvertToUtc(Securities[rule.Symbol].Exchange.TimeZone));

                    if (candleStartTime > (rule.setupTime - l) && (candleStartTime < Math.Max(rule.exitTime, rule.expirationTime) + le))
                    {
                        rule.Serie.Add(new LocalQuote
                        {
                            date  = Utils.ToUnixTimestamp(data[rule.Symbol].Time.ConvertToUtc(Securities[rule.Symbol].Exchange.TimeZone)),
                            open  = data[rule.Symbol].Open,
                            close = data[rule.Symbol].Close,
                            high  = data[rule.Symbol].High,
                            low   = data[rule.Symbol].Low
                        });
                    }
                }
            }
        }
Beispiel #3
0
 public void OnData(QuoteBars data)
 {
     try
     {
         foreach (var symbol in Symbols.Where(s => data.ContainsKey(s)))
         {
             _tradingAssets[symbol].Scan(data[symbol], ((AverageTrueRangeVolatilityModel)Securities[symbol].VolatilityModel).IsWarmingUp);
         }
     }
     catch (Exception ex)
     {
         Log("Error: " + ex.Message);
     }
 }