示例#1
0
        public void HistoryFuturesIntervalTimeframe(string rootSymbol, HistoryIntervalType itype, HistoryInterval interval, string beginDateTime = null, string endDateTime = null, HistoryDataDirection direction = HistoryDataDirection.Forward, string datapointsPerSend = "", string maxDatapoints = "", string beginFilterTime = "", string endFilterTime = "")
        {
            m_filename = Folders.df_path(GFile.GetDfFuturesFilename(rootSymbol, (int)interval));
            m_outfile = null;

            int addMonthsToEnd = 6;
            beginDateTime = beginDateTime ?? EARLIEST_DATE;
            endDateTime = endDateTime ?? DateTime.Now.AddMonths(addMonthsToEnd).ToString("yyyyMMdd");

            var mcList = GetMonthCodeList(beginDateTime, endDateTime);

            string sInterval = ((int)interval).ToString();
            foreach (var mYY in mcList)
            {
                m_symbol = rootSymbol + mYY;
                // use mYY and the mYY from 6 months prior to calculate a begin and end date for contract historical data
                string mYYplus1 = AddMonths(mYY, 1);
                string mYYminus6 = AddMonths(mYY, -6);
                string dt1 = GetDateTimeMYY(mYYminus6).ToYYYYMMDD();
                string dt2 = GetDateTimeMYY(mYYplus1).ToYYYYMMDD();

                HistoryIntervalTimeframe(m_symbol, itype, sInterval, dt1, dt2, direction, datapointsPerSend, maxDatapoints, beginFilterTime, endFilterTime);
            }

            if (m_outfile != null)
            {
                m_outfile.Close();
                Console.WriteLine("\nOutput to file: {0}\n", m_filename);
            }
        }
示例#2
0
 public void HistoryIntervalTimeframe(string symbol, HistoryIntervalType itype, string interval, string beginDateTime = null, string endDateTime = null, HistoryDataDirection direction = HistoryDataDirection.Forward, string datapointsPerSend = "", string maxDatapoints = "", string beginFilterTime = "", string endFilterTime = "")
 {
     beginDateTime = beginDateTime ?? EARLIEST_DATE;
     endDateTime = endDateTime ?? DateTime.Now.ToString("yyyyMMdd");
     string sRequest = GetRequestIntervalTimeframe(symbol, itype, interval, beginDateTime, endDateTime, direction, datapointsPerSend, maxDatapoints, beginFilterTime, endFilterTime);
     GetData(sRequest);
 }
示例#3
0
        /// <summary>
        /// Update / create a bar watch using the information in the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void SubscribeBars(string symbol, HistoryIntervalType intervalType, int intervalValue, int numberOfDaysBack = 1, string beginFilterTime = "", string endFilterTime = "", DateTime?beginDateTime = null)
        {
            string sBeginDateTime = "19700101000000";       // 1/1/1970 00:00:00

            if (beginDateTime != null)
            {
                sBeginDateTime = beginDateTime.Value.ToIQString();
            }

            // the command we need to send to turn on news is wSYMBOL\r\n
            string sCommand;

            sCommand = String.Format("BW,{0},{1},{2},{3},{4},{5},{6},{7},{8},,{9}\r\n",
                                     symbol,
                                     intervalValue,
                                     sBeginDateTime,
                                     numberOfDaysBack,
                                     this.MaxDatapointsToReceive,
                                     beginFilterTime,
                                     endFilterTime,
                                     this.RequestID,
                                     GetIntervalType(intervalType),
                                     this.UpdateIntervalInSeconds);

            SendRequestToIQFeed(sCommand);
        }
示例#4
0
        // Request string for HistoryType.IntervalTimeframe
        public string GetRequestIntervalTimeframe(string symbol, HistoryIntervalType itype, string interval, string beginDateTime, string endDateTime, HistoryDataDirection direction = HistoryDataDirection.Forward, string datapointsPerSend = "", string maxDatapoints = "", string beginFilterTime = "", string endFilterTime = "")
        {
            string sIntervalType = itype.ToIntervalTypeString();        // interval type: "s" for Time, "v" for Volume, "t" for Tick
            string sDirection = string.Format("{0}", (int)direction);

            // request in the format:
            // HIT,SYMBOL,INTERVAL,BEGINDATE BEGINTIME,ENDDATE ENDTIME,MAXDATAPOINTS,BEGINFILTERTIME,ENDFILTERTIME,DIRECTION,REQUESTID,DATAPOINTSPERSEND,INTERVALTYPE<CR><LF>
            return String.Format("HIT,{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}\r\n", symbol, interval, beginDateTime, endDateTime, maxDatapoints, beginFilterTime, endFilterTime, sDirection, REQUEST_ID, datapointsPerSend, sIntervalType);
        }
示例#5
0
        public static string GetIntervalType(HistoryIntervalType intervalType)
        {
            string result = "s";

            if (intervalType == HistoryIntervalType.Tick)
            {
                result = "t";
            }
            else if (intervalType == HistoryIntervalType.Volume)
            {
                result = "v";
            }
            return(result);
        }
示例#6
0
        public void HistoryContractIntervalTimeframe(string symbol, HistoryIntervalType itype, HistoryInterval interval, string beginDateTime = null, string endDateTime = null, HistoryDataDirection direction = HistoryDataDirection.Forward, string datapointsPerSend = "", string maxDatapoints = "", string beginFilterTime = "", string endFilterTime = "")
        {
            m_filename = Folders.df_path(GFile.GetDfContractFilename(symbol, (int)interval));
            m_outfile = null;

            beginDateTime = beginDateTime ?? EARLIEST_DATE;
            endDateTime = endDateTime ?? DateTime.Now.AddMonths(1).ToString("yyyyMMdd");

            string sInterval = ((int)interval).ToString();
            m_symbol = symbol;
            HistoryIntervalTimeframe(m_symbol, itype, sInterval, beginDateTime, endDateTime, direction, datapointsPerSend, maxDatapoints, beginFilterTime, endFilterTime);
            
            if (m_outfile != null)
            {
                m_outfile.Close();
                Console.WriteLine("\nOutput to file: {0}\n", m_filename);
            }
        }
示例#7
0
 // Request string for HistoryType.IntervalTimeframe
 public string GetRequestIntervalTimeframe(string symbol, HistoryIntervalType itype, HistoryInterval interval, string beginDateTime, string endDateTime, HistoryDataDirection direction = HistoryDataDirection.Forward, string datapointsPerSend = "", string maxDatapoints = "", string beginFilterTime = "", string endFilterTime = "")
 {
     return GetRequestIntervalTimeframe(symbol, itype, ((int)interval).ToString(), beginDateTime, endDateTime, direction, datapointsPerSend, maxDatapoints, beginFilterTime, endFilterTime);
 }
示例#8
0
 public void HistoryIntervalTimeframe(string symbol, HistoryIntervalType itype, HistoryInterval interval, string beginDateTime = null, string endDateTime = null, HistoryDataDirection direction = HistoryDataDirection.Forward, string datapointsPerSend = "", string maxDatapoints = "", string beginFilterTime = "", string endFilterTime = "")
 {
     string sInterval = ((int)interval).ToString();
     HistoryIntervalTimeframe(symbol, itype, sInterval, beginDateTime, endDateTime, direction, datapointsPerSend, maxDatapoints, beginFilterTime, endFilterTime);
 }
示例#9
0
 public static string ToIntervalTypeString(this HistoryIntervalType itype)
 {
     return(GetIntervalType(itype));
 }