Exemplo n.º 1
0
        public void DceTopTransactionContractTest()
        {
            DateTime date    = new DateTime(2014, 1, 6);
            string   webText = TestUtility.RetrieveWebPage(date, new DceDailyTransactionCrawler());
            var      parser  = new DceTransactionParser();

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

            string[] topContracts = new string[]
            {
                "a1405", "a1409", "c1405", "c1409", "bb1405", "fb1405",
                "fb1409", "jd1405", "jd1409", "m1405", "m1409", "y1405", "y1409"
            };

            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);
        }
Exemplo n.º 2
0
        private static void DceDataHandler(string transactionText, DateTime transactionDate, FuturesDataStore dataStore)
        {
            var dceTransactionParser = new DceTransactionParser();
            var tops = dceTransactionParser.GetTopContracts(transactionText, 2, transactionDate);

            WriteTransactionDataToStore(tops, dataStore);

            var dcePositionParser = new DceDealerPositionParser();

            foreach (var contract in tops)
            {
                var dcePositionCrawler = new DceDealerPositionCrawler(contract.Commodity, contract.Contract);
                dcePositionCrawler.RuntimeLogger = Logger;

                dcePositionCrawler.PullData(transactionDate, transactionDate, (htmlText, targetDate) =>
                {
                    HandlePositionData(dcePositionParser, htmlText, targetDate, dataStore);
                });
            }
        }