Exemple #1
0
        public static ttapiTicker ConvertFromDbTicker2ttapiTicker(string dbTicker, string productType)
        {
            ttapiTicker ttapiTickerOut = new ttapiTicker();
            string      ProductType    = productType.ToUpper();
            string      exchangeName;

            if (ProductType == "FUTURE")
            {
                ContractUtilities.ContractSpecs contractSpecsOut = ContractUtilities.ContractMetaInfo.GetContractSpecs(dbTicker);
                ttapiTickerOut.productName = TA.TickerheadConverters.ConvertFromDB2TT(contractSpecsOut.tickerHead);
                ttapiTickerOut.productType = "FUTURE";

                exchangeName = ContractUtilities.ContractMetaInfo.GetExchange4Tickerhead(contractSpecsOut.tickerHead);

                ttapiTickerOut.SeriesKey = ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
            }
            else if (ProductType == "SPREAD")
            {
                string[] TickerList = dbTicker.Split(new char[] { '-' });
                ContractUtilities.ContractSpecs contractSpecsOut = ContractUtilities.ContractMetaInfo.GetContractSpecs(TickerList[0]);
                ttapiTickerOut.productName = TA.TickerheadConverters.ConvertFromDB2TT(contractSpecsOut.tickerHead);
                ttapiTickerOut.productType = "SPREAD";
                string SeriesKey;

                exchangeName = ContractUtilities.ContractMetaInfo.GetExchange4Tickerhead(contractSpecsOut.tickerHead);

                if (exchangeName == "CME")
                {
                    SeriesKey = "Calendar: 1x" + ttapiTickerOut.productName + " " + ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
                    for (int i = 1; i < TickerList.Length; i++)
                    {
                        contractSpecsOut = ContractUtilities.ContractMetaInfo.GetContractSpecs(TickerList[i]);
                        SeriesKey        = SeriesKey + ":-1x" + ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
                    }
                }
                else if (exchangeName == "ICE")
                {
                    SeriesKey = ttapiTickerOut.productName + " Spread " + ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
                    for (int i = 1; i < TickerList.Length; i++)
                    {
                        contractSpecsOut = ContractUtilities.ContractMetaInfo.GetContractSpecs(TickerList[i]);
                        SeriesKey        = SeriesKey + "/" + ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
                    }
                }
                else
                {
                    SeriesKey = "";
                }

                ttapiTickerOut.SeriesKey = SeriesKey;
            }
            else
            {
                return(ttapiTickerOut);
            }

            ttapiTickerOut.marketKey = "";
            if (exchangeName == "ICE")
            {
                ttapiTickerOut.marketKey = "ICE_IPE";
            }
            else if (exchangeName == "CME")
            {
                ttapiTickerOut.marketKey = "CME";
            }

            ttapiTickerOut.instrumentName = ttapiTickerOut.marketKey + " " +
                                            ttapiTickerOut.productName + " " +
                                            ttapiTickerOut.SeriesKey;
            return(ttapiTickerOut);
        }
        public static ttapiTicker ConvertFromDbTicker2ttapiTicker(string dbTicker, string productType)
        {
            ttapiTicker ttapiTickerOut = new ttapiTicker();
            string ProductType = productType.ToUpper();
            string exchangeName;

            if (ProductType=="FUTURE")
            {
                ContractUtilities.ContractSpecs contractSpecsOut = ContractUtilities.ContractMetaInfo.GetContractSpecs(dbTicker);
                ttapiTickerOut.productName = TA.TickerheadConverters.ConvertFromDB2TT(contractSpecsOut.tickerHead);
                ttapiTickerOut.productType = "FUTURE";

                exchangeName = ContractUtilities.ContractMetaInfo.GetExchange4Tickerhead(contractSpecsOut.tickerHead);
                
                ttapiTickerOut.SeriesKey = ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();

            }
            else if (ProductType=="SPREAD")
            {
                string[] TickerList = dbTicker.Split(new char[] {'-'});
                ContractUtilities.ContractSpecs contractSpecsOut = ContractUtilities.ContractMetaInfo.GetContractSpecs(TickerList[0]);
                ttapiTickerOut.productName = TA.TickerheadConverters.ConvertFromDB2TT(contractSpecsOut.tickerHead);
                ttapiTickerOut.productType = "SPREAD";
                string SeriesKey;

                exchangeName = ContractUtilities.ContractMetaInfo.GetExchange4Tickerhead(contractSpecsOut.tickerHead);

                if (exchangeName == "CME")
                {
                    SeriesKey = "Calendar: 1x" + ttapiTickerOut.productName + " " + ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
                    for (int i = 1; i < TickerList.Length; i++)
                    {
                        contractSpecsOut = ContractUtilities.ContractMetaInfo.GetContractSpecs(TickerList[i]);
                        SeriesKey = SeriesKey + ":-1x" + ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
                    }
                }
                else if (exchangeName == "ICE")
                {
                    SeriesKey = ttapiTickerOut.productName + " Spread " + ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
                    for (int i = 1; i < TickerList.Length; i++)
                    {
                        contractSpecsOut = ContractUtilities.ContractMetaInfo.GetContractSpecs(TickerList[i]);
                        SeriesKey = SeriesKey + "/" + ConvertMonthFromDB2TT(contractSpecsOut.tickerMonthStr) + (contractSpecsOut.tickerYear % 100).ToString();
                    }
                }
                else
                {
                    SeriesKey = "";
                }
                
                ttapiTickerOut.SeriesKey = SeriesKey;
            }
            else
            {
                return ttapiTickerOut;
            }

            ttapiTickerOut.marketKey = "";
            if (exchangeName == "ICE")
                ttapiTickerOut.marketKey = "ICE_IPE";
            else if (exchangeName == "CME")
                ttapiTickerOut.marketKey = "CME";

            ttapiTickerOut.instrumentName = ttapiTickerOut.marketKey + " " +
                                        ttapiTickerOut.productName + " " +
                                        ttapiTickerOut.SeriesKey;
            return ttapiTickerOut;

        }