private static int GetDifference(string symbol1, string symbol2)
        {
            DateTime symbol1Date = DatePool.GetSymbolDate(symbol1);
            DateTime symbol2Date = DatePool.GetSymbolDate(symbol2);

            return(DateUtil.GetMonthDifference(symbol1Date, symbol2Date));
        }
예제 #2
0
        public DatePool datepool;   //数据池


        public Form1()
        {
            InitializeComponent();
            //折线图初始化
            chart = new DrawLineChart(20, 0, 450, 300, 10, 300);
            P     = new List <int>();
            Q     = new List <int>();
            R     = new List <int>();
            //数据池初始化
            datepool = new DatePool(100000);

            //Get all port list for selection
            //获得所有的端口列表,并显示在列表内
            PortList.Items.Clear();
            string[] Ports = SerialPort.GetPortNames();

            for (int i = 0; i < Ports.Length; i++)
            {
                string s   = Ports[i].ToUpper();
                Regex  reg = new Regex("[^COM\\d]", RegexOptions.IgnoreCase | RegexOptions.Multiline);//正则表达式
                s = reg.Replace(s, "");

                PortList.Items.Add(s);
            }
            if (Ports.Length > 1)
            {
                PortList.SelectedIndex = 1;
            }
        }
예제 #3
0
        public void ShouldGetSymbolDate(string symbol, DateTime expected)
        {
            DateTime actual = DateTime.MinValue;

            actual = DatePool.GetSymbolDate(symbol);

            Assert.Equal(expected, actual);
        }
예제 #4
0
        public void ShouldGetContractMonth(string symbol, int expected)
        {
            int actual = DatePool.GetSymbolMonth(symbol);

            if (SymbolUtil.GetSymbolType(symbol) == SymbolType.Spot)
            {
                int monthDifference = DateTime.Now.Month - 7;

                actual -= monthDifference;
            }

            Assert.Equal(expected, actual);
        }
예제 #5
0
        public void ShouldGetContractYear(string symbol, int expected)
        {
            int actual = DatePool.GetSymbolYear(symbol);

            Assert.Equal(expected, actual);
        }