Exemplo n.º 1
0
        public string ReadAllText(string path)
        {
            string        line;
            StringBuilder sb = new StringBuilder();

            if (File.Exists(path))
            {
                StreamReader file = null;

                try
                {
                    file = new StreamReader(path);

                    while ((line = file.ReadLine()) != null)
                    {
                        sb.AppendLine(line);
                    }
                }
                finally
                {
                    if (file != null)
                    {
                        file.Close();
                    }
                }
            }
            else
            {
                GLog.Print("File not exist: " + path);
            }

            return(sb.ToString());
        }
Exemplo n.º 2
0
        public Dictionary <int, DateTime> GetTradeDates()
        {
            Dictionary <int, DateTime> days = new Dictionary <int, DateTime>();

            if (!isSqlConnetion())
            {
                return(days);
            }

            try
            {
                String       cmdText = "SELECT * FROM es_files";
                MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                cmd.Prepare();

                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        days[reader.GetDateTime(2).Day] = reader.GetDateTime(2);
                    }
                }

                cmd.ExecuteNonQuery();
            }
            catch (MySqlException e)
            {
                GLog.Print("Error GetTradeDates: " + e.ToString());
            }

            _myConn.Close();
            return(days);
        }
Exemplo n.º 3
0
        public List <LEVELS_INDEX> GetIndexLevelsDate(string date)
        {
            if (!isSqlConnetion())
            {
                return(null);
            }

            List <LEVELS_INDEX> _Levels_Index = new List <LEVELS_INDEX>();

            try
            {
                String       cmdText = "SELECT * FROM es_index WHERE tradedate=@tradedate ORDER BY open_interest DESC";
                MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@tradedate", (date == "") ? _tradeDate : date);

                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        double high  = double.Parse(reader.GetString(8).Replace("#", "").Replace("----", "0.0"), CultureInfo.InvariantCulture);
                        double low   = double.Parse(reader.GetString(10).Replace("#", "").Replace("----", "0.0"), CultureInfo.InvariantCulture);
                        double range = double.Parse(reader.GetString(12).Replace("#", "").Replace("----", "0.0"), CultureInfo.InvariantCulture);

                        Levels_Index.Add(new LEVELS_INDEX(reader.GetDateTime(2), reader.GetUInt32(4), reader.GetInt32(5), reader.GetUInt32(3), high, low, range));
                        _Levels_Index.Add(new LEVELS_INDEX(reader.GetDateTime(2), reader.GetUInt32(4), reader.GetInt32(5), reader.GetUInt32(3), high, low, range));
                    }
                }

                cmd.ExecuteNonQuery();
            }
            catch (MySqlException e)
            {
                GLog.Print("Error GetIndexLevelsDate: " + e.ToString());
            }

            _myConn.Close();
            return(_Levels_Index);
        }
Exemplo n.º 4
0
        private void parserIndex(string _tradeDate, string[] _strIndex)
        {
            if (!isSqlConnetion())
            {
                return;
            }

            GLog.Print("PARSER INDEX: start " + _tradeDate);

            #region DELETE ES_INDEX
            try
            {
                MySqlCommand cmd = new MySqlCommand("DELETE FROM es_index WHERE tradedate=@tradedate", _myConn);

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                cmd.ExecuteNonQuery();
                GLog.Print("--PARSER: DELETE ES_INDEX " + _tradeDate);
            }
            catch (MySqlException e)
            {
                GLog.Print("--Error DELETE ES_INDEX: " + e.ToString());
            }
            #endregion

            for (int i = 0; i < _strIndex.Length; i++)
            {
                if (isFut(_strIndex[i]))
                {
                    for (int k = 0; k < 3; k++)
                    {
                        i++;

                        #region INSERT ES_INDEX
                        string[] tstr = _strIndex[i].Split(' ');
                        GLog.Print("--PARSER: INSERT ES_INDEX " + _strIndex[i]);
                        try
                        {
                            String       cmdText = "INSERT INTO es_index (month, tradedate, volume, open_interest, open_interest_ch, high_contract, low_contract, pit_high, pit_high_a_b, pit_low, pit_low_a_b, pit_open_range) VALUES (@month, @tradedate, @volume, @open_interest, @open_interest_ch, @high_contract, @low_contract, @pit_high, @pit_high_a_b, @pit_low, @pit_low_a_b, @pit_open_range)";
                            MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                            cmd.Prepare();
                            cmd.Parameters.AddWithValue("@month", tstr[0]);
                            cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                            cmd.Parameters.AddWithValue("@pit_open_range", tstr[1]);

                            string s = tstr[2];
                            string t = "";

                            if (s.Contains("."))
                            {
                                if (s.Contains("A"))
                                {
                                    t = s.Remove(7);
                                    cmd.Parameters.AddWithValue("@pit_high_a_b", "A");
                                }
                                else if (s.Contains("B"))
                                {
                                    t = s.Remove(7);
                                    cmd.Parameters.AddWithValue("@pit_high_a_b", "B");
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@pit_high_a_b", "-");
                                }
                            }
                            else
                            {
                                cmd.Parameters.AddWithValue("@pit_high_a_b", "-");
                            }


                            cmd.Parameters.AddWithValue("@pit_high", ((t != "") ? t : s));

                            string s1 = tstr[3];
                            string t1 = "";

                            if (s1.Contains("."))
                            {
                                if (s1.Contains("A"))
                                {
                                    t1 = s1.Remove(7);
                                    cmd.Parameters.AddWithValue("@pit_low_a_b", "A");
                                }
                                else if (s1.Contains("B"))
                                {
                                    t1 = s1.Remove(7);
                                    cmd.Parameters.AddWithValue("@pit_low_a_b", "B");
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@pit_low_a_b", "-");
                                }
                            }
                            else
                            {
                                cmd.Parameters.AddWithValue("@pit_low_a_b", "-");
                            }

                            cmd.Parameters.AddWithValue("@pit_low", ((t1 != "") ? t1 : s1));

                            cmd.Parameters.AddWithValue("@volume", (tstr[8] == "----") ? "0" : tstr[8]);

                            if (tstr[10] == "----")
                            {
                                cmd.Parameters.AddWithValue("@open_interest", 0);
                                cmd.Parameters.AddWithValue("@open_interest_ch", tstr[11] + tstr[12]);
                                cmd.Parameters.AddWithValue("@high_contract", tstr[13]);
                                cmd.Parameters.AddWithValue("@low_contract", tstr[14]);
                            }
                            else if (tstr[10] == "-")
                            {
                                cmd.Parameters.AddWithValue("@open_interest", "0");
                                cmd.Parameters.AddWithValue("@open_interest_ch", tstr[10] + tstr[11]);
                                cmd.Parameters.AddWithValue("@high_contract", tstr[12]);
                                cmd.Parameters.AddWithValue("@low_contract", tstr[13]);
                            }
                            else
                            {
                                cmd.Parameters.AddWithValue("@open_interest", tstr[10]);

                                if (tstr[11] == "UNCH")
                                {
                                    cmd.Parameters.AddWithValue("@open_interest_ch", 0);
                                    cmd.Parameters.AddWithValue("@high_contract", tstr[12]);
                                    cmd.Parameters.AddWithValue("@low_contract", tstr[13]);
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@open_interest_ch", tstr[11] + tstr[12]);
                                    cmd.Parameters.AddWithValue("@high_contract", tstr[13]);
                                    cmd.Parameters.AddWithValue("@low_contract", tstr[14]);
                                }
                            }

                            cmd.ExecuteNonQuery();
                        }
                        catch (MySqlException e)
                        {
                            GLog.Print("Error INSERT ES_INDEX: " + e.ToString());
                        }
                        #endregion
                    }

                    GLog.Print("--PARSER: INSERT ES_INDEX " + _tradeDate);
                    break;
                }
            }

            GLog.Print("PARSER INDEX: stop " + _tradeDate);
            SqlClose();
        }
Exemplo n.º 5
0
        public GTxtParser(string iniFile)
        {
            _months = new List <string>();
            _months.Add("NON");
            _months.Add("JAN");
            _months.Add("FEB");
            _months.Add("MAR");
            _months.Add("APR");
            _months.Add("MAY");
            _months.Add("JUN");
            _months.Add("JUL");
            _months.Add("AUG");
            _months.Add("SEP");
            _months.Add("OCT");
            _months.Add("NOV");
            _months.Add("DEC");

            _loadDate    = DateTime.Today.ToString();
            _iniParser   = new GIniParser(iniFile);
            _pathTxtData = _iniParser.GetSetting("es", "txtdata");
            _database    = _iniParser.GetSetting("options", "database");
            _username    = _iniParser.GetSetting("options", "username");
            _password    = _iniParser.GetSetting("options", "password");

            _pathCall  = _iniParser.GetSetting("options", "call");
            _pathPut   = _iniParser.GetSetting("options", "put");
            _pathIndex = _iniParser.GetSetting("options", "index");

            _diCall  = new Dictionary <string, string[]>();
            _diPut   = new Dictionary <string, string[]>();
            _diIndex = new Dictionary <string, string[]>();

            Dates = GetTradeDates();

            try
            {
                List <string> adirs = new List <string>();

                _dirs = new DirectoryInfo(@_pathTxtData).GetDirectories("????-??-??");

                if (Dates.Count > 0)
                {
                    foreach (DirectoryInfo diNext in _dirs)
                    {
                        adirs.Add(diNext.ToString());
                    }
                }
                else
                {
                    foreach (DirectoryInfo diNext in _dirs)
                    {
                        adirs.Add(diNext.ToString());
                    }
                }

                foreach (string s in adirs)
                {
                    if (File.Exists(@_pathTxtData + s + @"\" + _pathCall + ".txt"))
                    {
                        _diCall.Add(s, ReadAllText(@_pathTxtData + s + @"\" + _pathCall + ".txt").Split('\n'));
                    }

                    if (File.Exists(@_pathTxtData + s + @"\" + _pathPut + ".txt"))
                    {
                        _diPut.Add(s, ReadAllText(@_pathTxtData + s + @"\" + _pathPut + ".txt").Split('\n'));
                    }

                    if (File.Exists(@_pathTxtData + s + @"\" + _pathIndex + ".txt"))
                    {
                        _diIndex.Add(s, ReadAllText(@_pathTxtData + s + @"\" + _pathIndex + ".txt").Split('\n'));
                    }
                }
            }
            catch (Exception e)
            {
                GLog.Print("The process failed: " + e.ToString());
            }

            Levels_Call  = new List <LEVELS_CALL_PUT>();
            Levels_Put   = new List <LEVELS_CALL_PUT>();
            Levels_Index = new List <LEVELS_INDEX>();
        }
Exemplo n.º 6
0
        private void parserCall(string _tradeDate, string[] _strCall)
        {
            if (!isSqlConnetion())
            {
                return;
            }

            GLog.Print("PARSER CALL: start " + _tradeDate);

            #region DELETE ES_FILES, ES_CALL, ES_FUT, ES_EO
            try
            {
                MySqlCommand cmd = new MySqlCommand("DELETE FROM es_files WHERE tradedate=@tradedate and name=@name", _myConn);

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@name", "CALL");
                cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                cmd.ExecuteNonQuery();
                GLog.Print("--PARSER: DELETE ES_FILES " + _tradeDate);
            }
            catch (MySqlException e)
            {
                GLog.Print("--Error DELETE ES_FILES: " + e.ToString());
            }

            try
            {
                MySqlCommand cmd = new MySqlCommand("DELETE FROM es_call WHERE tradedate=@tradedate", _myConn);

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                cmd.ExecuteNonQuery();
                GLog.Print("--PARSER: DELETE ES_CALL " + _tradeDate);
            }
            catch (MySqlException e)
            {
                GLog.Print("--Error DELETE ES_CALL: " + e.ToString());
            }

            try
            {
                MySqlCommand cmd = new MySqlCommand("DELETE FROM es_fut WHERE tradedate=@tradedate", _myConn);

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                cmd.ExecuteNonQuery();
                GLog.Print("--PARSER: DELETE ES_FUT " + _tradeDate);
            }
            catch (MySqlException e)
            {
                GLog.Print("--Error DELETE ES_FUT: " + e.ToString());
            }

            try
            {
                MySqlCommand cmd = new MySqlCommand("DELETE FROM es_eo WHERE tradedate=@tradedate", _myConn);

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                cmd.ExecuteNonQuery();
                GLog.Print("--PARSER: DELETE ES_EO " + _tradeDate);
            }
            catch (MySqlException e)
            {
                GLog.Print("--Error DELETE ES_EO: " + e.ToString());
            }
            #endregion

            #region INSERT ES_FILES
            try
            {
                String       cmdText = "INSERT INTO es_files (name, tradedate, date) VALUES (@name, @tradedate, @date)";
                MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@name", "CALL");
                cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                cmd.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));
                cmd.ExecuteNonQuery();
                GLog.Print("--PARSER: INSERT ES_FILES " + _tradeDate);
            }
            catch (MySqlException e)
            {
                GLog.Print("--Error INSERT ES_FILES: " + e.ToString());
            }
            #endregion

            bool   fstart = false;
            string ss     = "";
            string smonth = "";
            string sname  = "";
            string sm_d   = "";

            for (int i = 0; i < _strCall.Length; i++)
            {
                if (isCallOptions(_strCall[i]))
                {
                    fstart = true;
                }
                else
                {
                    if (fstart)
                    {
                        if ((isPreliminary(_strCall[i]) && isFutC(_strCall[i + 2])) || (isFinal(_strCall[i]) && isFutC(_strCall[i + 2])))
                        {
                            i += 2;

                            string tstr = _strCall[i - 1].Split(' ')[0];

                            i++;
                            string[] teom = _strCall[i].Trim().Split(' ');

                            i++;
                            string[] teow1 = _strCall[i].Trim().Split(' ');

                            i++;
                            string[] teow2 = _strCall[i].Trim().Split(' ');

                            i++;
                            string[] teow4 = _strCall[i].Trim().Split(' ');

                            #region INSERT ES_EO
                            try
                            {
                                for (int p = 4; p < teom.Length; p++)
                                {
                                    String       cmdText = "INSERT INTO es_eo (tradedate, month, name, m_d, m, d) VALUES (@tradedate, @month, @name, @m_d, @m, @d)";
                                    MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                                    cmd.Parameters.AddWithValue("@name", "EOM");
                                    cmd.Parameters.AddWithValue("@month", tstr);
                                    cmd.Parameters.AddWithValue("@m_d", teom[p]);
                                    cmd.Parameters.AddWithValue("@m", Convert.ToUInt16(teom[p].Split('/')[0]));
                                    cmd.Parameters.AddWithValue("@d", Convert.ToUInt16(teom[p].Split('/')[1]));
                                    cmd.ExecuteNonQuery();
                                }

                                for (int p = 4; p < teow1.Length; p++)
                                {
                                    String       cmdText = "INSERT INTO es_eo (tradedate, month, name, m_d, m, d) VALUES (@tradedate, @month, @name, @m_d, @m, @d)";
                                    MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                                    cmd.Parameters.AddWithValue("@name", "EOW1");
                                    cmd.Parameters.AddWithValue("@month", tstr);
                                    cmd.Parameters.AddWithValue("@m_d", teow1[p]);
                                    cmd.Parameters.AddWithValue("@m", Convert.ToUInt16(teow1[p].Split('/')[0]));
                                    cmd.Parameters.AddWithValue("@d", Convert.ToUInt16(teow1[p].Split('/')[1]));
                                    cmd.ExecuteNonQuery();
                                }

                                for (int p = 4; p < teow2.Length; p++)
                                {
                                    String       cmdText = "INSERT INTO es_eo (tradedate, month, name, m_d, m, d) VALUES (@tradedate, @month, @name, @m_d, @m, @d)";
                                    MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                                    cmd.Parameters.AddWithValue("@name", "EOW2");
                                    cmd.Parameters.AddWithValue("@month", tstr);
                                    cmd.Parameters.AddWithValue("@m_d", teow2[p]);
                                    cmd.Parameters.AddWithValue("@m", Convert.ToUInt16(teow2[p].Split('/')[0]));
                                    cmd.Parameters.AddWithValue("@d", Convert.ToUInt16(teow2[p].Split('/')[1]));
                                    cmd.ExecuteNonQuery();
                                }

                                for (int p = 4; p < teow4.Length; p++)
                                {
                                    String       cmdText = "INSERT INTO es_eo (tradedate, month, name, m_d, m, d) VALUES (@tradedate, @month, @name, @m_d, @m, @d)";
                                    MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                                    cmd.Parameters.AddWithValue("@name", "EOW4");
                                    cmd.Parameters.AddWithValue("@month", tstr);
                                    cmd.Parameters.AddWithValue("@m_d", teow4[p]);
                                    cmd.Parameters.AddWithValue("@m", Convert.ToUInt16(teow4[p].Split('/')[0]));
                                    cmd.Parameters.AddWithValue("@d", Convert.ToUInt16(teow4[p].Split('/')[1]));
                                    cmd.ExecuteNonQuery();
                                }

                                GLog.Print("--PARSER: INSERT ES_EO " + _tradeDate);
                            }
                            catch (MySqlException e)
                            {
                                GLog.Print("Error INSERT ES_EO: " + e.ToString());
                            }
                            #endregion

                            #region SELECT ES_EO
                            try
                            {
                                DateTime     dt      = Convert.ToDateTime(_tradeDate);
                                String       cmdText = "SELECT * FROM es_eo WHERE tradedate=@tradedate and m=@m and d>=@d ORDER BY m, d ASC LIMIT 1";
                                MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                                cmd.Prepare();
                                cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                                cmd.Parameters.AddWithValue("@m", dt.Month);
                                cmd.Parameters.AddWithValue("@d", dt.Day);

                                using (MySqlDataReader reader = cmd.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        smonth = reader.GetString(2);
                                        sname  = reader.GetString(3);
                                        sm_d   = reader.GetString(4);
                                        ss     = smonth + " " + sname;
                                    }
                                }

                                cmd.ExecuteNonQuery();
                                GLog.Print("--PARSER: SELECT ES_EO " + _tradeDate + "_" + ss);
                            }
                            catch (MySqlException e)
                            {
                                GLog.Print("Error SELECT ES_EO: " + e.ToString());
                            }
                            #endregion
                        }

                        if (isFutures(_strCall[i]) && isFut(_strCall[i + 11]))
                        {
                            i += 11;

                            for (int k = 0; k < 4; k++)
                            {
                                i++;

                                #region INSERT ES_FUT
                                string[] tstr = _strCall[i].Split(' ');

                                try
                                {
                                    String       cmdText = "INSERT INTO es_fut (month, tradedate, open_range, high, low, sett_price, gl_volume, open_interest, oi_modif) VALUES (@month, @tradedate, @open_range, @high, @low, @sett_price, @gl_volume, @open_interest, @oi_modif)";
                                    MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@month", tstr[0]);
                                    cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                                    cmd.Parameters.AddWithValue("@open_range", tstr[1]);
                                    cmd.Parameters.AddWithValue("@high", tstr[2]);
                                    cmd.Parameters.AddWithValue("@low", tstr[3]);
                                    cmd.Parameters.AddWithValue("@sett_price", tstr[5] + ";" + tstr[6] + ";" + tstr[7]);
                                    cmd.Parameters.AddWithValue("@gl_volume", tstr[9]);
                                    cmd.Parameters.AddWithValue("@open_interest", tstr[10]);

                                    string s = tstr[12];
                                    string t = "";

                                    if (s.Contains("."))
                                    {
                                        if (s.Contains("A") || s.Contains("B"))
                                        {
                                            t = s.Remove(s.Length - 8);
                                        }
                                        else
                                        {
                                            t = s.Remove(s.Length - 7);
                                        }
                                    }

                                    cmd.Parameters.AddWithValue("@oi_modif", tstr[11] + ((t != "") ? t : s));
                                    cmd.ExecuteNonQuery();
                                }
                                catch (MySqlException e)
                                {
                                    GLog.Print("Error INSERT ES_FUT: " + e.ToString());
                                }
                                #endregion
                            }

                            GLog.Print("--PARSER: INSERT ES_FUT " + _tradeDate);
                        }

                        if (isCall(ss, _strCall[i]))
                        {
                            GLog.Print("--CALL parsing str: " + ss);

                            while (!isTotal(_strCall[i]))
                            {
                                Regex regex = new Regex(@"^[0-9]{4}\s");

                                if (regex.IsMatch(_strCall[i]) && !isDaily(_strCall[i]))
                                {
                                    #region INSERT ES_CALL
                                    string[] tstr = _strCall[i].Split(' ');

                                    try
                                    {
                                        String       cmdText = "INSERT INTO es_call (strike, tradedate, month, open_range, high, low, sett_price, sett_price_ch, delta, volume, open_interest, open_interest_ch, high_contract, low_contract, oi_sp, eo_name, eo_m_d) VALUES (@strike, @tradedate, @month, @open_range, @high, @low, @sett_price, @sett_price_ch, @delta, @volume, @open_interest, @open_interest_ch, @high_contract, @low_contract, @oi_sp, @eo_name, @eo_m_d)";
                                        MySqlCommand cmd     = new MySqlCommand(cmdText, _myConn);

                                        cmd.Prepare();
                                        cmd.Parameters.AddWithValue("@eo_name", sname);
                                        cmd.Parameters.AddWithValue("@eo_m_d", sm_d);
                                        cmd.Parameters.AddWithValue("@strike", tstr[0]);
                                        cmd.Parameters.AddWithValue("@tradedate", _tradeDate);
                                        cmd.Parameters.AddWithValue("@month", smonth.Substring(0, 3));
                                        cmd.Parameters.AddWithValue("@open_range", tstr[1]);
                                        cmd.Parameters.AddWithValue("@high", tstr[2]);
                                        cmd.Parameters.AddWithValue("@low", tstr[3]);
                                        cmd.Parameters.AddWithValue("@sett_price", tstr[5]);

                                        if (tstr[5] != "CAB")
                                        {
                                            cmd.Parameters.AddWithValue("@sett_price_ch", (tstr[6] != "UNCH" ? tstr[5][tstr[5].Length - 1] + tstr[6] : ""));

                                            string st   = tstr[5];
                                            int    last = st.Length - 1;

                                            cmd.Parameters.AddWithValue("@oi_sp", float.Parse((st[last] == '-' || st[last] == '+') ? st.Remove(last) : st, CultureInfo.InvariantCulture) * (tstr[10] == "----" ? 0 : int.Parse(tstr[10])));
                                        }
                                        else
                                        {
                                            cmd.Parameters.AddWithValue("@sett_price_ch", 0);
                                            cmd.Parameters.AddWithValue("@oi_sp", 0);
                                        }

                                        cmd.Parameters.AddWithValue("@delta", tstr[7]);
                                        cmd.Parameters.AddWithValue("@volume", tstr[9]);

                                        if (tstr[10] == "----")
                                        {
                                            cmd.Parameters.AddWithValue("@open_interest", 0);
                                            cmd.Parameters.AddWithValue("@open_interest_ch", tstr[11]);
                                            cmd.Parameters.AddWithValue("@high_contract", tstr[12]);
                                            cmd.Parameters.AddWithValue("@low_contract", tstr[13]);
                                        }
                                        else
                                        {
                                            cmd.Parameters.AddWithValue("@open_interest", tstr[10]);

                                            if (tstr[11] == "UNCH")
                                            {
                                                cmd.Parameters.AddWithValue("@open_interest_ch", 0);
                                                cmd.Parameters.AddWithValue("@high_contract", tstr[12]);
                                                cmd.Parameters.AddWithValue("@low_contract", tstr[13]);
                                            }
                                            else
                                            {
                                                cmd.Parameters.AddWithValue("@open_interest_ch", tstr[11] + tstr[12]);
                                                cmd.Parameters.AddWithValue("@high_contract", tstr[13]);
                                                cmd.Parameters.AddWithValue("@low_contract", tstr[14]);
                                            }
                                        }

                                        cmd.ExecuteNonQuery();
                                    }
                                    catch (MySqlException e)
                                    {
                                        GLog.Print("Error INSERT ES_CALL: " + e.ToString());
                                    }
                                    #endregion
                                }

                                i++;
                            }
                        }
                    }
                }
            }

            GLog.Print("PARSER CALL: stop " + _tradeDate);
            SqlClose();
        }