Example #1
0
        private void 急変日時_Click(object sender, EventArgs e)
        {
            RunTask(sender, (report) => {
                using (DBUtils.OpenThreadConnection()) {
                    report.Version         = 1;
                    report.IsForceOverride = true;
                    report.Comment         = "";
                    report.SetHeader("datetime", "isUp", "price", "2584date", "2584price");

                    var candles = new CandlesticksGetter()
                    {
                        Granularity = "M1",
                        Start       = DateTime.Today.AddYears(-5),
                        End         = DateTime.Today
                    }.Execute().ToList();
                    foreach (int i in GetOverMoveCandles(candles))
                    {
                        if (i + 2584 >= candles.Count())
                        {
                            break;
                        }
                        report.WriteLine(
                            candles[i].DateTime.ToString("yyyy年MM月dd日(dddd) h:mm"),
                            candles[i].IsUp(),
                            candles[i].Close,
                            candles[i + 2584].DateTime.ToString("yyyy年MM月dd日(dddd) h:mm"),
                            candles[i + 2584].Close);
                    }
                }
            });
        }
Example #2
0
        private void 因果USD_JPY_Click(object sender, EventArgs e)
        {
            RunTask(sender, (Report report) => {
                using (DBUtils.OpenThreadConnection()) {
                    report.Version         = 1;
                    report.IsForceOverride = true;
                    report.Comment         = "";
                    report.SetHeader("↑↓↓↓↓->↓", "total");

                    DateTime start = DateTime.Today.AddTicks(-new TimeSpan(365, 0, 0, 0).Ticks);
                    DateTime end   = DateTime.Today;

                    var causeContexts = new List <CauseContext>();
                    var instruments   = new string[] { "USD_JPY", "WTICO_USD", "US30_USD", "JP225_USD", "EUR_USD" };
                    var isUps         = new bool[] { true, false, false, false, false };
                    foreach (var t in instruments.Zip(isUps, (i, isUp) => new Tuple <string, bool>(i, isUp)))
                    {
                        var causeCandles = new CandlesticksGetter()
                        {
                            Instrument  = t.Item1,
                            Granularity = "M1",
                            Start       = start,
                            End         = end
                        }.Execute().ToArray();
                        causeContexts.Add(new CauseContext()
                        {
                            Candles = causeCandles,
                            IsUp    = t.Item2
                        });
                    }
                    ReportEffectAndCauseCombination(report, causeContexts, false);
                }
            });
        }
Example #3
0
        private void 因果EUR_USD_Click(object sender, EventArgs e)
        {
            RunTask(sender, (Report report) => {
                using (DBUtils.OpenThreadConnection()) {
                    report.Version         = 1;
                    report.IsForceOverride = true;
                    report.Comment         = "";
                    report.SetHeader("↑↑↑↑->↓", "total");

                    DateTime start = DateTime.Today.AddTicks(-new TimeSpan(365 * 5, 0, 0, 0).Ticks);
                    DateTime end   = DateTime.Today;

                    var causeContexts = new List <CauseContext>();
                    foreach (var cause in new string[] { "EUR_USD", "WTICO_USD", "US30_USD", "JP225_USD" })
                    {
                        var causeCandles = new CandlesticksGetter()
                        {
                            Instrument  = cause,
                            Granularity = "D",
                            Start       = start,
                            End         = end
                        }.Execute().ToArray();
                        causeContexts.Add(new CauseContext()
                        {
                            Candles = causeCandles,
                            IsUp    = true
                        });
                    }
                    ReportEffectAndCauseCombination(report, causeContexts, false);
                }
            });
        }
Example #4
0
        private static void ReportCauseAndEffect(Tuple <string, TimeSpan> granularityTuple, string effect, string cause, Report report)
        {
            DateTime start         = DateTime.Today.AddTicks(-granularityTuple.Item2.Ticks);
            DateTime end           = DateTime.Today;
            var      effectCandles = new CandlesticksGetter()
            {
                Instrument  = effect,
                Granularity = granularityTuple.Item1,
                Start       = start,
                End         = end
            }.Execute().ToList();
            var causeCandles = new CandlesticksGetter()
            {
                Instrument  = cause,
                Granularity = granularityTuple.Item1,
                Start       = start,
                End         = end
            }.Execute().ToList();
            int i = 0, j = 0;

            Dictionary <int, int> summary = new Dictionary <int, int>();
            int prevUpDown = -1;

            while (i < effectCandles.Count() && j < causeCandles.Count())
            {
                var effectCandle = effectCandles[i];
                var causeCandle  = causeCandles[j];
                if (effectCandle.IsNull || effectCandle.DateTime < causeCandle.DateTime || effectCandle.Close == effectCandle.Open)
                {
                    i++;
                    continue;
                }
                if (causeCandle.IsNull || effectCandle.DateTime > causeCandle.DateTime || causeCandle.Close == causeCandle.Open)
                {
                    j++;
                    continue;
                }
                if (prevUpDown != -1)
                {
                    int key = prevUpDown + (effectCandle.IsUp() ? 0 : 4);
                    if (summary.ContainsKey(key) == false)
                    {
                        summary[key] = 0;
                    }
                    summary[key]++;
                }
                prevUpDown = (effectCandle.IsUp() ? 0 : 2) + (causeCandle.IsUp() ? 0 : 1);
                i++;
                j++;
            }
            report.Write(effect, cause, granularityTuple.Item1);
            for (int updown = 0; updown < 8; updown++)
            {
                report.Write(summary.ContainsKey(updown) ? summary[updown] : 0);
            }
            report.WriteLine();
        }
Example #5
0
        private void 急変戻り戻り_Click(object sender, EventArgs e)
        {
            RunTask(sender, (report) => {
                using (DBUtils.OpenThreadConnection()) {
                    report.Version         = 1;
                    report.IsForceOverride = true;
                    report.Comment         = "";
                    report.SetHeader("t", "upc1", "upc2", "uptotal", "downc1", "downc2", "downtotal");

                    var candles = new CandlesticksGetter()
                    {
                        Granularity = "M1",
                        Start       = DateTime.Today.AddYears(-5),
                        End         = DateTime.Today
                    }.Execute().ToList();

                    List <int> indexList = GetOverMoveCandles(candles).ToList();

                    foreach (var t in Fibs().Take(20))
                    {
                        int upc1      = 0;
                        int upc2      = 0;
                        int uptotal   = 0;
                        int downc1    = 0;
                        int downc2    = 0;
                        int downtotal = 0;
                        foreach (var i in indexList)
                        {
                            if (i + t + 15 >= candles.Count())
                            {
                                break;
                            }
                            var candleOrg     = candles[i];
                            var candleArter15 = candles[i + t];
                            var candleArter30 = candles[i + t + 15];
                            if (candleOrg.IsNull || candleArter15.IsNull || candleArter30.IsNull)
                            {
                                continue;
                            }
                            if (candleOrg.IsUp())
                            {
                                if (candleOrg.Close > candleArter15.Close)
                                {
                                    upc1++;
                                    if (candleArter15.Close < candleArter30.Close)
                                    {
                                        upc2++;
                                    }
                                }
                                uptotal++;
                            }
                            else
                            {
                                if (candleOrg.Close < candleArter15.Close)
                                {
                                    downc1++;
                                    if (candleArter15.Close > candleArter30.Close)
                                    {
                                        downc2++;
                                    }
                                }
                                downtotal++;
                            }
                        }
                        report.WriteLine(t, upc1, upc2, uptotal, downc1, downc2, downtotal);
                    }
                }
            });
        }