Exemplo n.º 1
0
        private void Test01()
        {
            CSChartManager cscm = new CSChartManager();
            CSChart        csc  = cscm.GetCSChart("USDJPY");
            TTChart        ttc  = new TTChart(csc);
            MAChart        mac  = new MAChart(ttSec => ttc.GetPrice(ttSec).Mid, 10, 60);

            Console.WriteLine(mac.GetPrice(TTCommon.DateTimeToTTSec(20200401000000)));
        }
Exemplo n.º 2
0
        private void Test01_a(int dateStart, int dateEnd)
        {
            for (int maDay = 5; maDay <= 30; maDay += 5)
            {
                List <Info> infos = new List <Info>();

                CSChartManager cscm = new CSChartManager();
                CSChart        csc  = cscm.GetCSChart("USDJPY");
                TTChart        ttc  = new TTChart(csc);
                MAChart        mac  = new MAChart(ttSec => ttc.GetPrice(ttSec).Mid, 60 * 24 * maDay, 60);

                for (int date = dateStart; date <= dateEnd;)
                {
                    int nextDate = date;

                    do
                    {
                        nextDate = DateToDay.ToDate(DateToDay.ToDay(nextDate) + 1);
                    }while ("土日".Contains(DateTimeUnit.FromDate(nextDate).GetWeekday()));

                    int bNextDate = Test01_b(nextDate, date, csc);

                    long dt      = date * 1000000L + 90000;
                    long bNextDt = bNextDate * 1000000L + 90000;

                    // ----

                    infos.Add(new Info()
                    {
                        MvAvgPrice   = mac.GetPrice(TTCommon.DateTimeToTTSec(dt)),
                        Price        = csc.GetPrice(dt).Mid,
                        NextDayPrice = csc.GetPrice(bNextDt).Mid,
                    });

                    // ----

                    date = nextDate;
                }

                using (CsvFileWriter writer = new CsvFileWriter(string.Format(@"C:\temp\maDay={0}.csv", maDay)))
                {
                    foreach (Info info in infos)
                    {
                        writer.WriteCell(info.Price.ToString("F9"));
                        writer.WriteCell(info.MvAvgPrice.ToString("F9"));
                        writer.WriteCell(info.NextDayPrice.ToString("F9"));
                        writer.WriteCell((info.MvAvgPrice / info.Price).ToString("F9"));
                        writer.WriteCell((info.NextDayPrice / info.Price).ToString("F9"));
                        writer.EndRow();
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Test01()
        {
            CSChartManager cscm = new CSChartManager();
            CSChart        csc  = cscm.GetCSChart("USDJPY");
            TTChart        ttc  = new TTChart(csc);
            MAChart        mac  = new MAChart(ttSec => ttc.GetPrice(ttSec).Mid, 10, 60);

            for (int c = 0; c < 100; c++)
            {
                long ttSec = TTCommon.DateTimeToTTSec(20191101060000) + c * 60;

                Console.WriteLine(ttc.GetPrice(ttSec).Mid.ToString("F9") + " " + mac.GetPrice(ttSec).ToString("F9"));
            }
        }
Exemplo n.º 4
0
        private void MakeDataFile(string currPair)
        {
            Console.WriteLine("currPair: " + currPair);             // test cout

            CSChartManager cscm = new CSChartManager();
            CSChart        csc  = cscm.GetCSChart(currPair);
            TTChart        ttc  = new TTChart(csc);

            MAChart[] macs = new MAChart[MA_DAYS.Length];

            for (int index = 0; index < MA_DAYS.Length; index++)
            {
                macs[index] = new MAChart(ttSec => ttc.GetPrice(ttSec).Mid, 60 * 24 * MA_DAYS[index], 60);
            }

            long ttSecSt = TTCommon.DateTimeToTTSec(this.DateTimeSt);
            long ttSecEd = TTCommon.DateTimeToTTSec(this.DateTimeEd);

            Pulser pulser = new Pulser();

            using (CsvFileWriter writer = new CsvFileWriter(Path.Combine(W_DIR, currPair + ".csv")))
            {
                for (long ttSec = ttSecSt; ttSec <= ttSecEd; ttSec += 60)
                {
                    if (pulser.Invoke())
                    {
                        Console.WriteLine(TTCommon.TTSecToDateTime(ttSec) + " @ " + DateTime.Now);                         // test cout
                    }
                    writer.WriteCell(TTCommon.TTSecToDateTime(ttSec).ToString());
                    writer.WriteCell(ttSec.ToString());
                    writer.WriteCell(ttc.GetPrice(ttSec).Low.ToString("F9"));
                    writer.WriteCell(ttc.GetPrice(ttSec).Hig.ToString("F9"));
                    writer.WriteCell(ttc.GetPrice(ttSec).Mid.ToString("F9"));

                    foreach (MAChart mac in macs)
                    {
                        writer.WriteCell(mac.GetPrice(ttSec).ToString("F9"));
                    }

                    writer.EndRow();
                }
            }
            Console.WriteLine("done");             // test cout
        }
Exemplo n.º 5
0
            public MacInfo(int secSpan, int step)
            {
                if (secSpan < Consts.MA_SEC_SPAN_MIN || Consts.MA_SEC_SPAN_MAX < secSpan)
                {
                    throw new ArgumentException("Bad secSpan: " + secSpan);
                }

                if (step < Consts.MA_STEP_MIN || Consts.MA_STEP_MAX < step)
                {
                    throw new ArgumentException("Bad step: " + step);
                }

                if (secSpan % step != 0)
                {
                    throw new ArgumentException("Bad secSpan, step: " + secSpan + ", " + step);
                }

                this.Mac     = new MAChart(ttSec => ChartSrvc.I.Ttc.GetPrice(ttSec).Mid, secSpan / step, step);
                this.SecSpan = secSpan;
                this.Step    = step;
            }