Beispiel #1
0
        public static KeyPrice[] keyprice(string code, string ktype)
        {
            var d      = new kdatadb().kdata(code, ktype);
            var peak_h = new PEAK(d, PEAK_TYPE.high);
            var peak_l = new PEAK(d, PEAK_TYPE.low);
            //var peak_h_volume = new PEAK(d, k => k.volume, PEAK_TYPE.high);
            //var peak_l_volume = new PEAK(d, k => k.volume, PEAK_TYPE.low);

            var keyprices = d.Select(p =>
            {
                var h = peak_h[p.date];
                var l = peak_l[p.date];
                //var h_volume = peak_h_volume[p.date];
                //var l_volume = peak_l_volume[p.date];
                //if (h > 0 && h_volume > 0) return KeyPrice.high(code, p.date, h, true);
                //else if (l > 0 && l_volume > 0) return KeyPrice.low(code, p.date, l, true);
                if (h > 0)
                {
                    return(KeyPrice.high(code, p.date, h, true));
                }
                else if (l > 0)
                {
                    return(KeyPrice.low(code, p.date, l, true));
                }
                return(null);
            })
                            .Where(p => p != null)
                            .ToArray();

            return(keyprices);
        }
Beispiel #2
0
        KeyPrice[] keyprice(IEnumerable <kdatapoint> k, string id, string ktype)
        {
            var keyprices = Trade.analytic.keyprice(id, ktype);

            if (k.Any())
            {
                var cur = new[]
                {
                    KeyPrice.low(id, k.Last().date, k.Last().low, true),
                    KeyPrice.high(id, k.Last().date, k.Last().high, true)
                };
                keyprices = keyprices.Concat(cur).ToArray();
            }
            return(keyprices);
        }