Exemple #1
0
        private static void AddBar(CQGTimedBar timedBar, string symbol, DateTime runDateTime, string tType, string userName)
        {
            try
            {
                string MonthChar = "";
                string Year      = "";
                foreach (var monthCharYearModel in monthCharYearlList)
                {
                    if (symbol == monthCharYearModel.Symbol)
                    {
                        MonthChar = monthCharYearModel.MonthChar;
                        Year      = monthCharYearModel.Year;
                    }
                }
                var str5 = symbol.Trim();
                var str  = str5.Split('.');
                str5 = str[str.Length - 1];

                if (GetValueAsString(timedBar.Open) == "N/A")
                {
                }
                else
                {
                    GetValueAsString(timedBar.Open);
                }
                GetValueAsString(timedBar.Timestamp);
                var str3 = "'" + symbol + "'," +
                           GetValueAsString(Math.Max(timedBar.Open, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.High, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.Low, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.Close, 0)) + "," +

                           GetValueAsString(Math.Max(timedBar.TickVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.ActualVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.AskVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.BidVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.OpenInterest, 0)) + "," +

                           GetValueAsString(timedBar.Timestamp) + "," +
                           GetValueAsString(runDateTime) + ",'" +
                           _continuationType + "','" +
                           userName + "','" +
                           MonthChar + "','" +
                           Year + "'";

                var sql = "INSERT IGNORE INTO B_" + str5 + "_" + tType + " (Symbol, OpenValue, HighValue, LowValue, CloseValue," +
                          " TickVol, ActualVol, AskVol, BidVol, OpenInterest," +
                          "BarTime, SystemTime, ContinuationType, UserName, MonthChar, Year) VALUES (" + str3 + ");";

                ClientDatabaseManager.AddToQueue(sql, 5);
            }
            catch (Exception ex)
            {
                Console.WriteLine("AddBar." + ex.Message);
            }
        }
Exemple #2
0
        private void AddBar(CQGTimedBar timedBar, string symbol, DateTime runDateTime, string tType, string userName)
        {
            if (_shouldStop) return;
            try
            {
                var str5 = symbol.Trim();
                var str = str5.Split('.');
                str5 = str[str.Length - 1];

                if (GetValueAsString(timedBar.Open) == "N/A")
                {
                }
                else
                {
                    GetValueAsString(timedBar.Open);
                }
                GetValueAsString(timedBar.Timestamp);
                var str3 = "'" + symbol + "'," +
                           GetValueAsString(Math.Max(timedBar.Open, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.High, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.Low, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.Close, 0)) + "," +

                           GetValueAsString(Math.Max(timedBar.TickVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.ActualVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.AskVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.BidVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.OpenInterest, 0)) + "," +

                           GetValueAsString(timedBar.Timestamp) + "," +
                           GetValueAsString(runDateTime) + ",'" +
                           _aContinuationType + "','" +
                           userName + "'";

                var sql = "INSERT IGNORE INTO B_" + str5 + "_" + tType + " (Symbol, OpenValue, HighValue, LowValue, CloseValue,"+
                    " TickVol, ActualVol, AskVol, BidVol, OpenInterest," +
                             "BarTime, SystemTime, ContinuationType, UserName) VALUES (" + str3 + ");";

                DatabaseManager.AddToQueue(sql,1);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _logger.LogAdd("AddBar. " + ex, Category.Error);
            }
        }
        private static void AddBar(CQGTimedBar timedBar, string symbol, DateTime runDateTime, string tType, string userName)
        {
            try
            {
                string MonthChar = "def";
                string Year = "def";
                foreach (var monthCharYearModel in monthCharYearlList)
                {
                    if (symbol == monthCharYearModel.Symbol)
                    {
                        MonthChar = monthCharYearModel.MonthChar;
                        Year = monthCharYearModel.Year;
                    }
                }
                var str5 = symbol.Trim();
                var str = str5.Split('.');
                str5 = str[str.Length - 1];

                if (GetValueAsString(timedBar.Open) == "N/A")
                {
                }
                else
                {
                    GetValueAsString(timedBar.Open);
                }
                GetValueAsString(timedBar.Timestamp);
                var str3 = "'" + symbol + "'," +
                           GetValueAsString(Math.Max(timedBar.Open, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.High, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.Low, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.Close, 0)) + "," +

                           GetValueAsString(Math.Max(timedBar.TickVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.ActualVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.AskVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.BidVolume, 0)) + "," +
                           GetValueAsString(Math.Max(timedBar.OpenInterest, 0)) + "," +

                           GetValueAsString(timedBar.Timestamp) + "," +
                           GetValueAsString(runDateTime) + ",'" +
                           _continuationType + "','" +
                           userName + "','" +
                           MonthChar + "','" +
                           Year + "'";

                var sql = "INSERT IGNORE INTO B_" + str5 + "_" + tType + " (Symbol, OpenValue, HighValue, LowValue, CloseValue," +
                    " TickVol, ActualVol, AskVol, BidVol, OpenInterest," +
                             "BarTime, SystemTime, ContinuationType, UserName, MonthChar, YearChar) VALUES (" + str3 + ");";

                DatabaseManager.AddToQueue(sql, 5);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// Copies the data from a CQG Timed Bar into a KaiTrade standatd bar
        /// </summary>
        /// <param name="myItem"></param>
        /// <param name="mySet"></param>
        /// <param name="myBar"></param>
        /// <param name="myIndex"></param>
        private void CopyBar(KaiTrade.Interfaces.ITSItem myItem, KaiTrade.Interfaces.ITSSet mySet, CQGTimedBar myBar, long myIndex)
        {
            try
            {
                // get a new TS item
                myItem.ItemType = KaiTrade.Interfaces.TSItemType.time;
                myItem.Index = myIndex;
                myItem.TimeStamp = myBar.Timestamp;
                myItem.Open = myBar.Open;
                myItem.High = myBar.High;
                myItem.Low = myBar.Low;
                myItem.Close = myBar.Close;
                myItem.Mid = myBar.Mid;
                myItem.HLC3 = myBar.HLC3;
                myItem.Avg = myBar.Avg;
                myItem.TrueHigh = myBar.TrueHigh;
                myItem.TrueLow = myBar.TrueLow;
                myItem.Range = myBar.Range;
                myItem.TrueRange = myBar.TrueRange;
                myItem.AskVolume = myBar.AskVolume;
                myItem.BidVolume = myBar.BidVolume;
                myItem.Volume = myBar.ActualVolume;

            }
            catch (Exception myE)
            {
                log.Error("DumpRecord", myE);
            }
        }