Beispiel #1
0
        public void CzceTopTransactionContractTest()
        {
            DateTime date    = new DateTime(2014, 1, 6);
            string   webText = TestUtility.RetrieveWebPage(date, new CzceDailyTransactionCrawler());
            var      parser  = new CzceTransactionParser();

            var listFromWeb = parser.GetTopContracts(webText, 2, date);


            string[] topContracts = new string[]
            {
                "cf405", "cf411", "fg405", "fg409", "me405", "me409",
                "pm405", "pm401", "rm405", "rm409", "ta405", "ta409",
                "wh405", "wh401"
            };

            var listOfCommodity = listFromWeb.GroupBy(c => c.Commodity);

            foreach (var contracts in listOfCommodity)
            {
                if (contracts.Count() > 2)
                {
                    Assert.Fail();
                }
            }

            var webTopContracts = listFromWeb.Select(c => c.Commodity + c.Contract);
            var joinResult      = webTopContracts.Join(topContracts, s => s, s => s, (s1, s2) => s1);
            int jc = joinResult.Count();

            Assert.IsTrue(joinResult.Count() == topContracts.Length);
        }
Beispiel #2
0
        public void CzceHolidayTransactionContractListTest()
        {
            DateTime date        = new DateTime(2015, 1, 1);
            string   webText     = TestUtility.RetrieveWebPage(date, new CzceDailyTransactionCrawler());
            var      parser      = new CzceTransactionParser();
            var      listFromWeb = parser.GetContractList(webText, date);

            Assert.IsTrue(listFromWeb.Count == 0);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var connection = ConfigurationManager.ConnectionStrings["CloudDBConnect"];
            var dataStore  = new FuturesDataStore(connection.ConnectionString);

            DateTime startDate = new DateTime(2015, 2, 1);
            DateTime endDate   = new DateTime(2015, 2, 28);;

            var dceTransactionCrawler = new DceDailyTransactionCrawler();

            dceTransactionCrawler.RuntimeLogger = Logger;
            var dceTransactionParser = new DceTransactionParser();

            dceTransactionCrawler.PullData(startDate, endDate, (text, transDate) => DceDataHandler(text, transDate.Date, dataStore));

            var shfeTransactionCrawler = new ShfeDailyTransactionCrawler();

            shfeTransactionCrawler.RuntimeLogger = Logger;
            var shfeTransactionParser = new ShfeTransactionParser();

            shfeTransactionCrawler.PullData(startDate, endDate, (text, transDate) =>
            {
                HandleDailyTransactionData(shfeTransactionParser, text, transDate.Date, dataStore);
            });
            var shfePositionCrawler = new ShfeDealerPositionCrawler();

            shfePositionCrawler.RuntimeLogger = Logger;
            var shfePositionParser = new ShfeDealerPositionParser();

            shfePositionCrawler.PullData(startDate, endDate, (text, transDate) =>
            {
                HandlePositionData(shfePositionParser, text, transDate.Date, dataStore);
            });

            var czceTransactionCrawler = new CzceDailyTransactionCrawler();

            czceTransactionCrawler.RuntimeLogger = Logger;
            var czceTransactionParser = new CzceTransactionParser();

            czceTransactionCrawler.PullData(startDate, endDate, (text, transDate) =>
            {
                HandleDailyTransactionData(czceTransactionParser, text, transDate.Date, dataStore);
            });
            var czcePositionCrawler = new CzceDealerPositionCrawler();

            czcePositionCrawler.RuntimeLogger = Logger;
            var czcePositionParser = new CzceDealerPositionParser();

            czcePositionCrawler.PullData(startDate, endDate, (text, transDate) =>
            {
                HandlePositionData(czcePositionParser, text, transDate.Date, dataStore);
            });

            System.Console.WriteLine("\n\n\n\n==================================\nFinished!!!!");
            System.Console.ReadLine();
        }
Beispiel #4
0
        public void CzceTransactionContractListTest()
        {
            DateTime date        = new DateTime(2014, 1, 6);
            string   webText     = TestUtility.RetrieveWebPage(date, new CzceDailyTransactionCrawler());
            var      parser      = new CzceTransactionParser();
            var      listFromWeb = parser.GetContractList(webText, date);

            var testData = new List <ContractTransactionInfo>();

            testData.Add(new ContractTransactionInfo(date, "czce", "cf", "401", 19080, 19080, 19080, 19080, 19080, 582, 896));
            testData.Add(new ContractTransactionInfo(date, "czce", "wH", "411", 0, 0, 0, 0, 2742, 0, 6));
            testData.Add(new ContractTransactionInfo(date, "czce", "TA", "405", 7210, 7212, 7136, 7146, 7174, 238492, 422160));
            testData.Add(new ContractTransactionInfo(date, "czce", "pm", "409", 2551, 2551, 2551, 2551, 2551, 2, 42));

            ValidateValues(testData, listFromWeb);
        }