Ejemplo n.º 1
0
        private void T4_FxList(string code)
        {
            Console.WriteLine("code: " + code);

            T4_Code = code;

            TagData bid = TagData.GetTagData(this.T4_ResBody, "<span id=\"" + code + "_chart_bid\">", "</span>");
            TagData ask = TagData.GetTagData(this.T4_ResBody, "<span id=\"" + code + "_chart_ask\">", "</span>");

            //double d_bid = double.Parse(bid.GetInnerString());
            //double d_ask = double.Parse(ask.GetInnerString());
            string s_bid = bid.GetInnerString();
            string s_ask = ask.GetInnerString();

            Check_BID_ASK_String(s_bid);
            Check_BID_ASK_String(s_ask);

            using (new MutexSection(_mutexOutFile))
                using (FileStream afs = new FileStream(
                           Path.Combine(T4_OutDir, T4_Now.GetString("YMD") + "_" + code + ".csv"),
                           FileMode.Append,
                           FileAccess.Write
                           ))
                {
                    WrLine(afs, T4_Now.GetCompactString() + "," + s_bid + "," + s_ask);
                }
        }
Ejemplo n.º 2
0
        private static string RemoveTag(string str)
        {
            for (; ;)
            {
                TagData td = TagData.GetTagData(str, "<", ">");

                if (td == null)
                {
                    break;
                }

                str = str.Substring(0, td.BgnPP.BgnPos) + str.Substring(td.EndPP.EndPos);
            }
            return(str);
        }
Ejemplo n.º 3
0
        private void FxList(string code)
        {
            TagData bid = TagData.GetTagData(this.T3_ResBody, "<span id=\"" + code + "_chart_bid\">", "</span>");
            TagData ask = TagData.GetTagData(this.T3_ResBody, "<span id=\"" + code + "_chart_ask\">", "</span>");

            double d_bid = double.Parse(bid.GetInnerString());
            double d_ask = double.Parse(ask.GetInnerString());

            WrLine(
                T3_Now.GetCompactString() + "," +
                code + "," +
                d_bid + "," +
                d_ask
                );
        }
Ejemplo n.º 4
0
        private void Test02()
        {
            const int CYCLE_SEC = 20;
            long      next_t    = (TimeData.Now.T / CYCLE_SEC + 1) * CYCLE_SEC;

            for (; ;)
            {
                WrLine("----");
                WrLine("日時: " + TimeData.Now);

                // TEST_日本円/USドル
                try
                {
                    byte[] resBody = new HttpClient(
                        //////////////////////////////////////////////////////////////// $_git:secret
                        ).Perform();
                    WrLine("resBody_length: " + resBody.Length);
                    string strResBody = Encoding.UTF8.GetString(resBody);
                    WrLine("strResBody_length: " + strResBody.Length);

                    {
                        int bgn = StringTools.ExTailIndexOf(strResBody, "<td class=\"newest\">");
                        int end = StringTools.ExIndexOf(strResBody, "<span>", bgn);

                        string part = strResBody.Substring(bgn, end - bgn);

                        WrLine("$TEST_JPYUSD:" + TimeData.Now.GetCompactString() + ":" + part);
                    }
                }
                catch (Exception e)
                {
                    WrLine("" + e);
                }

                // 日本円/USドル
                try
                {
                    byte[] resBody = new HttpClient(
                        /////////////////////////////////////////////////////////////////// $_git:secret
                        ).Perform();
                    WrLine("resBody_length: " + resBody.Length);
                    string strResBody = Encoding.UTF8.GetString(resBody);
                    WrLine("strResBody_length: " + strResBody.Length);

                    {
                        string part = TagData.GetTagData(strResBody, "<td class=\"stoksPrice\">", "</td>").GetInnerString();

                        WrLine("$JPYUSD:" + TimeData.Now.GetCompactString() + ":" + part);
                    }
                }
                catch (Exception e)
                {
                    WrLine("" + e);
                }

                // 日本円/ユーロ
                try
                {
                    byte[] resBody = new HttpClient(
                        /////////////////////////////////////////////////////////////////// $_git:secret
                        ).Perform();
                    WrLine("resBody_length: " + resBody.Length);
                    string strResBody = Encoding.UTF8.GetString(resBody);
                    WrLine("strResBody_length: " + strResBody.Length);

                    {
                        string part = TagData.GetTagData(strResBody, "<td class=\"stoksPrice\">", "</td>").GetInnerString();

                        WrLine("$JPYEUR:" + TimeData.Now.GetCompactString() + ":" + part);
                    }
                }
                catch (Exception e)
                {
                    WrLine("" + e);
                }

                FxDetail("USDJPY");
                FxDetail("EURJPY");

                while (TimeData.Now.T < next_t)
                {
                    while (Console.KeyAvailable)
                    {
                        if (Console.ReadKey().KeyChar == 0x1b)                         // ? esc
                        {
                            throw new Exception("プロセス停止");
                        }
                    }
                    Thread.Sleep(2000);
                }
                next_t += CYCLE_SEC;
            }
        }
Ejemplo n.º 5
0
        private static void FxDetail(string code)         // code: "USDJPY" etc.
        {
            try
            {
                byte[] resBody = new HttpClient(
                    //////////////////////////////////////////////////////////////////// $_git:secret
                    ).Perform();
                WrLine("resBody_length: " + resBody.Length);
                string strResBody = Encoding.UTF8.GetString(resBody);
                WrLine("strResBody_length: " + strResBody.Length);

                string stamp = TimeData.Now.GetCompactString();

                {
                    string part = TagData.GetTagData(strResBody, "<dd id=\"" + code + "_detail_bid\">", "</dd>").GetInnerString();
                    part = RemoveTag(part);

                    WrLine("$" + code + "_BID:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<dd id=\"" + code + "_detail_ask\">", "</dd>").GetInnerString();
                    part = RemoveTag(part);

                    WrLine("$" + code + "_ASK:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<dd id=\"" + code + "_detail_change\">", "</dd>").GetInnerString();

                    WrLine("$" + code + "_CHANGE:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<dd id=\"" + code + "_detail_open\">", "</dd>").GetInnerString();
                    part = RemoveTag(part);

                    WrLine("$" + code + "_OPEN:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<dd id=\"" + code + "_detail_high\">", "</dd>").GetInnerString();
                    part = RemoveTag(part);

                    WrLine("$" + code + "_HIGH:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<dd id=\"" + code + "_detail_low\">", "</dd>").GetInnerString();
                    part = RemoveTag(part);

                    WrLine("$" + code + "_LOW:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<div class=\"buyBox clearFix\">", "</div>").GetInnerString();
                    part = TagData.GetTagData(part, "<strong>", "</strong>").GetInnerString();

                    WrLine("$" + code + "_BUYPCT:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<div class=\"sellBox clearFix\">", "</div>").GetInnerString();
                    part = TagData.GetTagData(part, "<strong>", "</strong>").GetInnerString();

                    WrLine("$" + code + "_SELLPCT:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<div class=\"box\">", "</div>").GetInnerString();
                    part = TagData.GetTagData(part, "<span>", "</span>").GetInnerString();

                    WrLine("$" + code + "_BUYNUM:" + stamp + ":" + part);
                }

                {
                    string part = TagData.GetTagData(strResBody, "<div class=\"box right\">", "</div>").GetInnerString();
                    part = TagData.GetTagData(part, "<span>", "</span>").GetInnerString();

                    WrLine("$" + code + "_SELLNUM:" + stamp + ":" + part);
                }
            }
            catch (Exception e)
            {
                WrLine("" + e);
            }
        }