static void Main(string[] args) { Logger = new StreamWriter("Log.log"); //全局编码 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //公司全称简称曾用名字典 CompanyNameLogic.LoadCompanyName(@"Resources" + Path.DirectorySeparatorChar + "FDDC_announcements_company_name_20180531.json"); //增减持公告日期的读入 StockChange.ImportPublishTime(); //结巴分词的地名修正词典 PosNS.ImportNS(@"Resources" + Path.DirectorySeparatorChar + "ns.dict"); CIRecord = new StreamWriter("CI.log"); //预处理 Traning(); return; Evaluator = new StreamWriter("Evaluator.log"); Score = new StreamWriter(@"Result" + Path.DirectorySeparatorChar + "Score" + Path.DirectorySeparatorChar + "score" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"); //new Contract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\1008828.html").Extract();return; Extract(); CIRecord.Close(); Score.Close(); Evaluator.Close(); Logger.Close(); }
/// <summary> /// 快速测试区 /// </summary> private static void QuickTestArea() { var t = new StockChange(); t.Init(StockChangePath_TEST + "/html/15752069.html"); var recs = t.Extract(); }
private static void Extract() { if (IsRunContract) { //合同处理 Console.WriteLine("Start To Extract Info Contract TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "hetong_train.txt", false, utf8WithoutBom); var Contract_Result = Run <Contract>(ContractPath_TRAIN, ResultCSV); Evaluate.EvaluateContract(Contract_Result.Select((x) => (ContractRec)x).ToList()); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunContract_TEST) { Console.WriteLine("Start To Extract Info Contract TEST"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "hetong.txt", false, utf8WithoutBom); var Contract_Result = Run <Contract>(ContractPath_TEST, ResultCSV); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunStockChange || IsRunStockChange_TEST) { //增减持公告日期的读入 StockChange.ImportPublishTime(); } //增减持 if (IsRunStockChange) { Console.WriteLine("Start To Extract Info StockChange TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "zengjianchi_train.txt", false, utf8WithoutBom); var StockChange_Result = Run <StockChange>(StockChangePath_TRAIN, ResultCSV); Evaluate.EvaluateStockChange(StockChange_Result.Select((x) => (StockChangeRec)x).ToList()); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunStockChange_TEST) { Console.WriteLine("Start To Extract Info StockChange TEST"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "zengjianchi.txt", false, utf8WithoutBom); var StockChange_Result = Run <StockChange>(StockChangePath_TEST, ResultCSV); Console.WriteLine("Complete Extract Info StockChange"); } //资产重组 if (IsRunReorganization) { Console.WriteLine("Start To Extract Info Reorganization TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "chongzu_train.txt", false, utf8WithoutBom); var Reorganization_Result = Run <Reorganization>(ReorganizationPath_TRAIN, ResultCSV); Evaluate.EvaluateReorganization(Reorganization_Result.Select((x) => (ReorganizationRec)x).ToList()); Console.WriteLine("Complete Extract Info Reorganization"); } if (IsRunReorganization_TEST) { Console.WriteLine("Start To Extract Info Reorganization TEST"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "chongzu.txt", false, utf8WithoutBom); var Reorganization_Result = Run <Reorganization>(ReorganizationPath_TEST, ResultCSV); Console.WriteLine("Complete Extract Info Reorganization"); } }
private StockChange GetInfoOnUpdate(StockChangeComplex source) { StockChange info = Mapper.Map <StockChange>(source.StockChange); info.LastPerson = IdentityService.GetUserData().UserID; info.LastUpdate = DateTime.Now; return(info); }
private void Send(StockChange change) { var hub = new Hub(); var client = EventHubClient.CreateFromConnectionString(hub.PublisherConnectionString); var sender = client.CreateSenderAsync(Hub.Publisher).Result; var data = hub.GetData(change); sender.SendAsync(data).Wait(); }
public EventData GetData(StockChange change) { var json = change.ToJson(); var content = Encoding.UTF8.GetBytes(json); var data = new EventData(content); return(data); }
private StockChange GetInfoOnCreate(StockChangeComplex source) { StockChange info = Mapper.Map <StockChange>(source.StockChange); // 取得詢價單號;目前由使用者自型輸入 info.StockChangeID = GenerateKey(info); //info.PostingTime = DateTime.Today; info.LastPerson = IdentityService.GetUserData().UserID; info.LastUpdate = DateTime.Now; return(info); }
public static void InitStockChange() { var sr = new StreamReader(StockChangePath_TRAIN); while (!sr.EndOfStream) { StockChangeList.Add(StockChange.ConvertFromString(sr.ReadLine())); } Console.WriteLine("增减持标准结果数:" + StockChangeList.Count); sr.Close(); }
public object GetChangeData() { var change = new StockChange { Symbol = "AAPL", Price = 110.55m, Change = 1.09m, DateTime = DateTime.UtcNow }; return(change); }
/// <summary> /// update the stock quantity of the product /// </summary> /// <param name="stockChange">the change to be applied on the product</param> public virtual void UpdateStock(StockChange stockChange) { //? Throw a exception or simply set StockQuantity to zero? int quantity = stockChange.Quantity + this.QuantityInStock; var isQuantityBiggerThanExisting = quantity < 0; if (isQuantityBiggerThanExisting) { throw new ArgumentException("the given stock change is bigger than the available product in stock"); } this.StockChanges.Add(stockChange); this.QuantityInStock += stockChange.Quantity; this.LastStockEntry = stockChange.CreatedAt; }
private List <StockChangeDetail> GetChildOnCreate(StockChange master, StockChangeComplex source) { List <StockChangeDetail> infos = new List <StockChangeDetail>(); var wanted = source.ChildList.Where(x => x.IsDirty == true); foreach (var item in wanted) { StockChangeDetail temp = Mapper.Map <StockChangeDetail>(item); temp.StockChangeID = master.StockChangeID; temp.LastPerson = IdentityService.GetUserData().UserID; temp.LastUpdate = DateTime.Now; infos.Add(temp); } return(infos); }
public void Given_negative_or_positive_stock_change_When_try_to_create_stock_change_in_system_Then_return_out_or_in_stock_change(int productId, int impactingId, int quantity) { // Given var expectedStockChange = quantity < 0 ? StockChangeType.Out : StockChangeType.In; var product = new Product { Id = productId }; var impactingEntity = new BaseEntity { Id = impactingId }; // When var stockChange = StockChange.CreateChange(quantity, product, impactingEntity); // Then Assert.Equal(expectedStockChange, stockChange.Type); }
public void Given_product_not_present_on_system_When_try_to_create_stock_change_Then_throw_a_exception() { // Given var productId = 0; var impactingId = 1; var quantity = 1; var product = new Product { Id = productId }; var posOrder = new POSOrder { Id = impactingId }; // When and Then Assert.Throws <InvalidOperationException>(() => StockChange.CreateChange(quantity, product, posOrder)); }
public void Given_negative_stock_change_When_try_update_stock_quantity_with_change_bigger_than_existing_quantity_Then_exception_is_throwed() { // Given var product = new ProductSeed().GetSeedObject(); product.Id = 1; product.UpdateStock(StockChange.CreateChange(quantity: 0, product, new StockEntry { Id = 1 })); var posOrder = new POSOrder { Id = 1 }; int quantity = -2; var stockChange = StockChange.CreateChange(quantity, product, posOrder); // When..., then Assert.Throws <ArgumentException>(() => product.UpdateStock(stockChange)); }
public void Given_stock_change_with_quantity_equal_zero_When_try_to_create_stock_change_Then_return_a_None_stock_change() { // Given var productId = 1; var impactingId = 1; var quantity = 0; var product = new Product { Id = productId }; var stockEntry = new StockEntry { Id = impactingId, }; // When var stockChange = StockChange.CreateChange(quantity, product, stockEntry); // Then Assert.Equal(StockChangeType.None, stockChange.Type); }
public void If_quantity_is_bigger_than_product_stock_use_remaining_stock() { //Given var posOrder = new POSOrder(); var product = new ProductSeed().GetSeedObject(); product.Id = 1; product.UpdateStock(StockChange.CreateChange(5, product, product)); product.UpdateStock(StockChange.CreateChange(-2, product, product)); var quantity = 4; var repository = MockRepository((mock) => { mock.Setup(m => m.GetBy(It.IsAny <int>())) .Returns(product); }); //When var posOrderItemResult = POSOrderItem.Create(product.Id, quantity, posOrder, repository); //Then Assert.NotEqual(posOrderItemResult.Value.Quantity, quantity); Assert.Equal(posOrderItemResult.Value.Quantity, product.QuantityInStock); }
public StockChangeComplex Create(StockChangeComplex source) { #region 變為Models需要之型別及邏輯資料 StockChange main = GetInfoOnCreate(source); List <StockChangeDetail> children = GetChildOnCreate(main, source); #endregion #region Models資料庫 this._Repository.Create(main); foreach (StockChangeDetail item in children) { this._DetailRepository.Create(item); } this._UnitOfWork.SaveChange(); #endregion return(this.Get(main.StockChangeID)); }
public static void ContractTest() { StockChange.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持\html\20526193.html"); StockChange.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持\html\20596890.html"); StockChange.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持\html\1018217.html"); StockChange.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持\html\314146.html"); IncreaseStock.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\定增\html\7880.html"); var x1 = Normalizer.NormalizeItemListNumber("(4)2012 年 4 月,公司与中国华西企业股份"); var x2 = Normalizer.NormalizeItemListNumber("4 、承包方式: 从深化设计、制作、运输、"); var x3 = Normalizer.NormalizeItemListNumber("4、承包方式: 从深化设计、制作、运输、"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\1153.html"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\1008828.html"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\3620.html"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\1518.html"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\1120707.html"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\1044779.html"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\1450.html"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\1042224.html"); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\917362.html"); IncreaseStock.Extract(@"E:\WorkSpace2018\FDDC_announcements_round1_train_20180518\round1_train_20180518\定增\html\7880.html"); //数字金额的测试 var TestString = "中标价为人民币共计16928.79754万元(大写:人民币壹亿陆仟玖佰贰拾捌万柒仟玖佰柒拾伍元肆角整)。"; var Result = Utility.SeekMoney(TestString); //Console.WriteLine(Result.Item1); TestString = "安徽盛运环保(集团)股份有限公司"; //Result = Utility.GetStringBefore(TestString, "有限公司"); //Console.WriteLine(Result); Contract.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同\html\5258.html"); var x0 = "在此之前,2003年6月30日,本公司曾与MICROS US和MICROS Singapore(以下简称 “MICROS”)签订了《技术许可与代理协议》,并分别于2005年11月、2006年12月和2007年 10月与MICROS相继签署了第一、二、三次补充协议。"; var t0 = EntityWordAnlayzeTool.GetMainWordSentence(x0); //在此之前,2003年6月30日,本公司曾与MICROS US和MICROS Singapore(以下简称 “MICROS”)签订了《技术许可与代理协议》,并分别于2005年11月、2006年12月和2007年 10月与MICROS相继签署了第一、二、三次补充协议。" //在此之前,2003年6月30日,本公司 与MICROS US和MICROS Singapore(以下简称 “MICROS”)签订 《技术许可与代理协议》,并 于2005年11月、2006年12月和2007年 10月与MICROS 签署 第一、二、三次补充协议。 }
public void Given_negative_stock_change_When_try_update_stock_quantity_of_a_product_Then_current_stock_quantity_should_be_actual_stock_quantity_minus_stock_change() { // Given var product = new ProductSeed().GetSeedObject(); product.Id = 1; product.UpdateStock(StockChange.CreateChange(4, product, new StockEntry { Id = 1 })); var posOrder = new POSOrder { Id = 1 }; int quantity = -2; int expectedQuantity = 2; var stockChange = StockChange.CreateChange(quantity, product, posOrder); // When product.UpdateStock(stockChange); // Then Assert.Equal(expectedQuantity, product.QuantityInStock); }
private string GenerateKey(StockChange info) { int seq = 1; string result = ""; string key = $"C{DateTime.Today.ToString(GlobalSettings.KEY_DATE_FORMAT)}"; var current = this._Repository.GetAll() .Where(x => x.StockChangeID.StartsWith(key)) .OrderByDescending(x => x.StockChangeID) .FirstOrDefault(); if (current != null) { // 移除前面日期部分留下流水號 seq = Convert.ToInt16(current.StockChangeID.Replace(key, "")); seq += 1; } result = $"{key}{seq.ToString().PadLeft(GlobalSettings.SequenceLength, '0')}"; return(result); }
public void Update(StockChangeComplex source) { #region 取資料 #endregion #region 邏輯驗證 #endregion #region 變為Models需要之型別及邏輯資料 StockChange main = GetInfoOnUpdate(source); List <StockChangeDetail> children = GetChildOnCreate(main, source); #endregion #region Models資料庫 this._Repository.Update(main); foreach (StockChangeDetail item in children) { if (item.SeqNo == 0) { this._DetailRepository.Create(item); } else { this._DetailRepository.Update(item); } } this._UnitOfWork.SaveChange(); #endregion }
private static void Extract() { var IsRunContract = true; var IsRunContract_TEST = true; var ContractPath_TRAIN = DocBase + Path.DirectorySeparatorChar + "FDDC_announcements_round1_train_20180518" + Path.DirectorySeparatorChar + "重大合同"; var ContractPath_TEST = DocBase + Path.DirectorySeparatorChar + "FDDC_announcements_round1_test_b_20180708" + Path.DirectorySeparatorChar + "重大合同"; var IsRunStockChange = true; var IsRunStockChange_TEST = true; var StockChangePath_TRAIN = DocBase + Path.DirectorySeparatorChar + "FDDC_announcements_round1_train_20180518" + Path.DirectorySeparatorChar + "增减持"; var StockChangePath_TEST = DocBase + Path.DirectorySeparatorChar + "FDDC_announcements_round1_test_b_20180708" + Path.DirectorySeparatorChar + "增减持"; var IsRunIncreaseStock = true; var IsRunIncreaseStock_TEST = true; var IncreaseStockPath_TRAIN = DocBase + Path.DirectorySeparatorChar + @"FDDC_announcements_round1_train_20180518" + Path.DirectorySeparatorChar + "定增"; var IncreaseStockPath_TEST = DocBase + Path.DirectorySeparatorChar + @"FDDC_announcements_round1_test_b_20180708" + Path.DirectorySeparatorChar + "定增"; if (IsRunContract) { //合同处理 Console.WriteLine("Start To Extract Info Contract TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "hetong_train.txt", false, utf8WithoutBom); ResultCSV.WriteLine("公告id\t甲方\t乙方\t项目名称\t合同名称\t合同金额上限\t合同金额下限\t联合体成员"); var Contract_Result = new List <struContract>(); if (IsMultiThreadMode) { var Bag = new ConcurrentBag <struContract>(); //线程安全版本 Parallel.ForEach(System.IO.Directory.GetFiles(ContractPath_TRAIN + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar), (filename) => { var contract = new Contract(filename); foreach (var item in contract.Extract()) { Bag.Add(item); } }); Contract_Result = Bag.ToList(); Contract_Result.Sort((x, y) => { return(x.id.CompareTo(y.id)); }); foreach (var item in Contract_Result) { ResultCSV.WriteLine(item.ConvertToString(item)); } } else { foreach (var filename in System.IO.Directory.GetFiles(ContractPath_TRAIN + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar)) { var contract = new Contract(filename); foreach (var item in contract.Extract()) { Contract_Result.Add(item); ResultCSV.WriteLine(item.ConvertToString(item)); } } } ResultCSV.Close(); Evaluate.EvaluateContract(Contract_Result); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunContract_TEST) { StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "hetong.txt", false, utf8WithoutBom); ResultCSV.WriteLine("公告id\t甲方\t乙方\t项目名称\t合同名称\t合同金额上限\t合同金额下限\t联合体成员"); var Contract_Result = new List <struContract>(); Console.WriteLine("Start To Extract Info Contract TEST"); if (IsMultiThreadMode) { Parallel.ForEach(System.IO.Directory.GetFiles(ContractPath_TEST + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar), (filename) => { var contract = new Contract(filename); foreach (var item in contract.Extract()) { Contract_Result.Add(item); } }); Contract_Result.Sort((x, y) => { return(x.id.CompareTo(y.id)); }); foreach (var item in Contract_Result) { ResultCSV.WriteLine(item.ConvertToString(item)); } } else { foreach (var filename in System.IO.Directory.GetFiles(ContractPath_TEST + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar)) { var contract = new Contract(filename); foreach (var item in contract.Extract()) { Contract_Result.Add(item); ResultCSV.WriteLine(item.ConvertToString(item)); } } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunStockChange) { //增减持 Console.WriteLine("Start To Extract Info StockChange TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "zengjianchi_train.txt", false, utf8WithoutBom); ResultCSV.WriteLine("公告id\t股东全称\t股东简称\t变动截止日期\t变动价格\t变动数量\t变动后持股数\t变动后持股比例"); var StockChange_Result = new List <struStockChange>(); foreach (var filename in System.IO.Directory.GetFiles(StockChangePath_TRAIN + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar)) { var stockchange = new StockChange(filename); foreach (var item in stockchange.Extract()) { StockChange_Result.Add(item); ResultCSV.WriteLine(item.ConvertToString(item)); } } ResultCSV.Close(); Evaluate.EvaluateStockChange(StockChange_Result); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunStockChange_TEST) { StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "zengjianchi.txt", false, utf8WithoutBom); ResultCSV.WriteLine("公告id\t股东全称\t股东简称\t变动截止日期\t变动价格\t变动数量\t变动后持股数\t变动后持股比例"); Console.WriteLine("Start To Extract Info StockChange TEST"); foreach (var filename in System.IO.Directory.GetFiles(StockChangePath_TEST + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar)) { var stockchange = new StockChange(filename); foreach (var item in stockchange.Extract()) { ResultCSV.WriteLine(item.ConvertToString(item)); } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunIncreaseStock) { //定增 StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "dingzeng_train.txt", false, utf8WithoutBom); ResultCSV.WriteLine("公告id\t增发对象\t增发数量\t增发金额\t锁定期\t认购方式"); Console.WriteLine("Start To Extract Info IncreaseStock TRAIN"); var Increase_Result = new List <struIncreaseStock>(); if (IsMultiThreadMode) { Parallel.ForEach(System.IO.Directory.GetFiles(IncreaseStockPath_TRAIN + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar), (filename) => { var increasestock = new IncreaseStock(filename); foreach (var item in increasestock.Extract()) { Increase_Result.Add(item); } }); Increase_Result.Sort((x, y) => { return(x.id.CompareTo(y.id)); }); foreach (var item in Increase_Result) { ResultCSV.WriteLine(item.ConvertToString(item)); } } else { foreach (var filename in System.IO.Directory.GetFiles(IncreaseStockPath_TRAIN + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar)) { var increasestock = new IncreaseStock(filename); foreach (var item in increasestock.Extract()) { Increase_Result.Add(item); ResultCSV.WriteLine(item.ConvertToString(item)); } } } ResultCSV.Close(); Evaluate.EvaluateIncreaseStock(Increase_Result); Console.WriteLine("Complete Extract Info IncreaseStock"); } if (IsRunIncreaseStock_TEST) { StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "dingzeng.txt", false, utf8WithoutBom); ResultCSV.WriteLine("公告id\t增发对象\t增发数量\t增发金额\t锁定期\t认购方式"); Console.WriteLine("Start To Extract Info IncreaseStock TEST"); foreach (var filename in System.IO.Directory.GetFiles(IncreaseStockPath_TEST + Path.DirectorySeparatorChar + "html" + Path.DirectorySeparatorChar)) { var increasestock = new IncreaseStock(filename); foreach (var item in increasestock.Extract()) { ResultCSV.WriteLine(item.ConvertToString(item)); } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info IncreaseStock"); } }
private static void Extract() { if (IsRunContract) { //合同处理 Console.WriteLine("Start To Extract Info Contract TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "hetong_train.txt", false, utf8WithoutBom); var Contract_Result = Run <Contract>(ContractPath_TRAIN, ContractPath_TRAIN, ResultCSV); Evaluate.EvaluateContract(Contract_Result.Select((x) => (ContractRec)x).ToList()); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunContract_TEST) { Console.WriteLine("Start To Extract Info Contract TEST"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "hetong.txt", false, utf8WithoutBom); var Contract_Result = Run <Contract>(ContractPath_TEST, ContractPath_TEST, ResultCSV); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunStockChange || IsRunStockChange_TEST) { //增减持公告日期的读入(这里读入的是CSV,本番使用XLSX文件) StockChange.ImportPublishTime(); } //增减持 if (IsRunStockChange) { Console.WriteLine("Start To Extract Info StockChange TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "zengjianchi_train.txt", false, utf8WithoutBom); var StockChange_Result = Run <StockChange>(StockChangePath_TRAIN, StockChangePath_TRAIN, ResultCSV); Evaluate.EvaluateStockChange(StockChange_Result.Select((x) => (StockChangeRec)x).ToList()); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunStockChange_TEST) { Console.WriteLine("Start To Extract Info StockChange TEST"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "zengjianchi.txt", false, utf8WithoutBom); var StockChange_Result = Run <StockChange>(StockChangePath_TEST, StockChangePath_TEST, ResultCSV); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunReorganization || IsRunReorganization_TEST) { //替代训练结果 Console.WriteLine("加载替代训练结果"); ReOrganizationTraning.EvaluateMethodList = new string[] { "收益法", "资产基础法", "市场法", "市场比较法", "估值法", "成本法", "现金流折现法", "现金流折现法", "内含价值调整法", "可比公司市净率法", "重置成本法", "收益现值法", "基础资产法", "假设清偿法", "成本逼近法", "单项资产加和法", "成本加和法", "基准地价修正法", "收益还原法", "现金流量法", "单项资产加总法", "折现现金流量法" }.ToList(); Console.WriteLine("加载替代训练结果:" + ReOrganizationTraning.EvaluateMethodList.Count); } //资产重组 if (IsRunReorganization) { Console.WriteLine("Start To Extract Info Reorganization TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "chongzu_train.txt", false, utf8WithoutBom); var Reorganization_Result = Run <Reorganization>(ReorganizationPath_TRAIN, "", ResultCSV); Evaluate.EvaluateReorganization(Reorganization_Result.Select((x) => (ReorganizationRec)x).ToList()); Console.WriteLine("Complete Extract Info Reorganization"); } if (IsRunReorganization_TEST) { Console.WriteLine("Start To Extract Info Reorganization TEST"); StreamWriter ResultCSV = new StreamWriter("Result" + Path.DirectorySeparatorChar + "chongzu.txt", false, utf8WithoutBom); var Reorganization_Result = Run <Reorganization>(ReorganizationPath_TEST, "", ResultCSV); Console.WriteLine("Complete Extract Info Reorganization"); } }
static void Main(string[] args) { //初始化 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); BussinessLogic.LoadCompanyName(@"Resources\FDDC_announcements_company_name_20180531.json"); //测试区 //生成PDF的TXT文件的批处理命令 //PDFToTXT.GetBatchFile(); //分词系统 //WordAnlayze.CompanyAnlayze(); //UT.RunWordAnlayze(); //UT.StockChangeTest(); //UT.IncreaseStockTest(); //UT.ContractTest(); //UT.RegularExpress(); //UT.JianchengTest(); //Logger.Close(); //Traning.InitIncreaseStock(); //StockChange.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持\html\314146.html"); //WordAnlayze.segmenter.LoadUserDict(@"Resources\dictAdjust.txt"); //return; var IsRunContract = true; var IsRunContract_TEST = false; var IsRunStockChange = false; var IsRunStockChange_TEST = false; var IsRunIncreaseStock = false; var IsRunIncreaseStock_TEST = false; var IncreaseStockPath_TEST = DocBase + @"\FDDC_announcements_round1_test_a_20180605\定增"; var ContractPath_TEST = DocBase + @"\FDDC_announcements_round1_test_a_20180605\重大合同"; var StockChangePath_TEST = DocBase + @"\FDDC_announcements_round1_test_a_20180605\增减持"; if (IsRunContract) { //合同处理 var ContractPath_TRAIN = DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同"; Console.WriteLine("Start To Extract Info Contract TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result\\hetong_train.csv", false, Encoding.GetEncoding("gb2312")); var StockChange_Result = new List <struContract>(); foreach (var filename in System.IO.Directory.GetFiles(ContractPath_TRAIN + @"\html\")) { foreach (var item in Contract.Extract(filename)) { StockChange_Result.Add(item); ResultCSV.WriteLine(Contract.ConvertToString(item)); } } ResultCSV.Close(); Traning.InitContract(); Evaluate.EvaluateContract(StockChange_Result); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunContract_TEST) { StreamWriter ResultCSV = new StreamWriter("Result\\hetong.csv", false, Encoding.GetEncoding("gb2312")); Console.WriteLine("Start To Extract Info Contract TEST"); foreach (var filename in System.IO.Directory.GetFiles(ContractPath_TEST + @"\html\")) { foreach (var item in Contract.Extract(filename)) { ResultCSV.WriteLine(Contract.ConvertToString(item)); } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunStockChange) { //增减持 Console.WriteLine("Start To Extract Info StockChange TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result\\zengjianchi_Train.csv", false, Encoding.GetEncoding("gb2312")); var StockChangePath_TRAIN = DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持"; var StockChange_Result = new List <struStockChange>(); foreach (var filename in System.IO.Directory.GetFiles(StockChangePath_TRAIN + @"\html\")) { foreach (var item in StockChange.Extract(filename)) { StockChange_Result.Add(item); ResultCSV.WriteLine(StockChange.ConvertToString(item)); } } ResultCSV.Close(); Traning.InitStockChange(); Evaluate.EvaluateStockChange(StockChange_Result); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunStockChange_TEST) { StreamWriter ResultCSV = new StreamWriter("Result\\zengjianchi.csv", false, Encoding.GetEncoding("gb2312")); Console.WriteLine("Start To Extract Info StockChange TEST"); foreach (var filename in System.IO.Directory.GetFiles(StockChangePath_TEST + @"\html\")) { foreach (var item in StockChange.Extract(filename)) { ResultCSV.WriteLine(StockChange.ConvertToString(item)); } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunIncreaseStock) { //定增 StreamWriter ResultCSV = new StreamWriter("Result\\dingzeng_train.csv", false, Encoding.GetEncoding("gb2312")); var IncreaseStockPath_TRAIN = DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\定增"; Console.WriteLine("Start To Extract Info IncreaseStock TRAIN"); var Increase_Result = new List <struIncreaseStock>(); foreach (var filename in System.IO.Directory.GetFiles(IncreaseStockPath_TRAIN + @"\html\")) { foreach (var item in IncreaseStock.Extract(filename)) { Increase_Result.Add(item); ResultCSV.WriteLine(IncreaseStock.ConvertToString(item)); } } ResultCSV.Close(); Traning.InitIncreaseStock(); Evaluate.EvaluateIncreaseStock(Increase_Result); Console.WriteLine("Complete Extract Info IncreaseStock"); } if (IsRunIncreaseStock_TEST) { StreamWriter ResultCSV = new StreamWriter("Result\\dingzeng.csv", false, Encoding.GetEncoding("gb2312")); Console.WriteLine("Start To Extract Info IncreaseStock TEST"); foreach (var filename in System.IO.Directory.GetFiles(IncreaseStockPath_TEST + @"\html\")) { foreach (var item in IncreaseStock.Extract(filename)) { ResultCSV.WriteLine(IncreaseStock.ConvertToString(item)); } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info IncreaseStock"); } Logger.Close(); }
private void OnStockChange(StockChangeEventArgs e) { StockChange?.Invoke(this, e); }
public int Save(StockChange StockChange) { throw new NotImplementedException(); }
protected virtual void OnStockChange(StockChangeEventArgs e) { StockChange?.Invoke(this, e); }
private static void Extract() { var IsRunContract = true; var IsRunContract_TEST = true; var ContractPath_TRAIN = DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\重大合同"; var ContractPath_TEST = DocBase + @"\FDDC_announcements_round1_test_a_20180605\重大合同"; var IsRunStockChange = false; var IsRunStockChange_TEST = false; var StockChangePath_TRAIN = DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持"; var StockChangePath_TEST = DocBase + @"\FDDC_announcements_round1_test_a_20180605\增减持"; var IsRunIncreaseStock = false; var IsRunIncreaseStock_TEST = false; var IncreaseStockPath_TRAIN = DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\定增"; var IncreaseStockPath_TEST = DocBase + @"\FDDC_announcements_round1_test_a_20180605\定增"; if (IsRunContract) { //合同处理 //通过训练获得各种字段的最大长度,便于抽取的时候做置信度检查 Console.WriteLine("Start To Extract Info Contract TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result\\hetong_train.csv", false, Encoding.GetEncoding("gb2312")); ResultCSV.WriteLine("公告id,甲方,乙方,项目名称,合同名称,合同金额上限,合同金额下限,联合体成员"); var StockChange_Result = new List <struContract>(); foreach (var filename in System.IO.Directory.GetFiles(ContractPath_TRAIN + @"\html\")) { foreach (var item in Contract.Extract(filename)) { StockChange_Result.Add(item); ResultCSV.WriteLine(Contract.ConvertToString(item)); } } ResultCSV.Close(); Evaluate.EvaluateContract(StockChange_Result); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunContract_TEST) { StreamWriter ResultCSV = new StreamWriter("Result\\hetong.csv", false, Encoding.GetEncoding("gb2312")); ResultCSV.WriteLine("公告id,甲方,乙方,项目名称,合同名称,合同金额上限,合同金额下限,联合体成员"); Console.WriteLine("Start To Extract Info Contract TEST"); foreach (var filename in System.IO.Directory.GetFiles(ContractPath_TEST + @"\html\")) { foreach (var item in Contract.Extract(filename)) { ResultCSV.WriteLine(Contract.ConvertToString(item)); } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info Contract"); } if (IsRunStockChange) { //增减持 Console.WriteLine("Start To Extract Info StockChange TRAIN"); StreamWriter ResultCSV = new StreamWriter("Result\\zengjianchi_train.csv", false, Encoding.GetEncoding("gb2312")); ResultCSV.WriteLine("公告id,股东全称,股东简称,变动截止日期,变动价格,变动数量,变动后持股数,变动后持股比例"); var StockChange_Result = new List <struStockChange>(); foreach (var filename in System.IO.Directory.GetFiles(StockChangePath_TRAIN + @"\html\")) { foreach (var item in StockChange.Extract(filename)) { StockChange_Result.Add(item); ResultCSV.WriteLine(StockChange.ConvertToString(item)); } } ResultCSV.Close(); Evaluate.EvaluateStockChange(StockChange_Result); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunStockChange_TEST) { StreamWriter ResultCSV = new StreamWriter("Result\\zengjianchi.csv", false, Encoding.GetEncoding("gb2312")); ResultCSV.WriteLine("公告id,股东全称,股东简称,变动截止日期,变动价格,变动数量,变动后持股数,变动后持股比例"); Console.WriteLine("Start To Extract Info StockChange TEST"); foreach (var filename in System.IO.Directory.GetFiles(StockChangePath_TEST + @"\html\")) { foreach (var item in StockChange.Extract(filename)) { ResultCSV.WriteLine(StockChange.ConvertToString(item)); } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info StockChange"); } if (IsRunIncreaseStock) { //定增 StreamWriter ResultCSV = new StreamWriter("Result\\dingzeng_train.csv", false, Encoding.GetEncoding("gb2312")); ResultCSV.WriteLine("公告id,增发对象,增发数量,增发金额,锁定期,认购方式"); Console.WriteLine("Start To Extract Info IncreaseStock TRAIN"); var Increase_Result = new List <struIncreaseStock>(); foreach (var filename in System.IO.Directory.GetFiles(IncreaseStockPath_TRAIN + @"\html\")) { foreach (var item in IncreaseStock.Extract(filename)) { Increase_Result.Add(item); ResultCSV.WriteLine(IncreaseStock.ConvertToString(item)); } } ResultCSV.Close(); Evaluate.EvaluateIncreaseStock(Increase_Result); Console.WriteLine("Complete Extract Info IncreaseStock"); } if (IsRunIncreaseStock_TEST) { StreamWriter ResultCSV = new StreamWriter("Result\\dingzeng.csv", false, Encoding.GetEncoding("gb2312")); ResultCSV.WriteLine("公告id,增发对象,增发数量,增发金额,锁定期,认购方式"); Console.WriteLine("Start To Extract Info IncreaseStock TEST"); foreach (var filename in System.IO.Directory.GetFiles(IncreaseStockPath_TEST + @"\html\")) { foreach (var item in IncreaseStock.Extract(filename)) { ResultCSV.WriteLine(IncreaseStock.ConvertToString(item)); } } ResultCSV.Close(); Console.WriteLine("Complete Extract Info IncreaseStock"); } }
public static void StockChangeTest() { StockChange.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持\html\20526193.html"); StockChange.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持\html\20596890.html"); StockChange.Extract(Program.DocBase + @"\FDDC_announcements_round1_train_20180518\round1_train_20180518\增减持\html\1018217.html"); }
/// <summary> /// Method to draw the ticker scrolling along the top of the screen /// </summary> private void DrawTicker() { Texture2D t = new Texture2D(GraphicsDevice, 1, 1); t.SetData(new Color[] { Color.Black }); Graphing.drawLine(t, spriteBatch, Color.Black, new Vector2(0, WINDOW_HEIGHT * 0.08f), new Vector2(WINDOW_WIDTH, WINDOW_HEIGHT * 0.08f), 35); gl.getAllChanges(); float FIXED_WIDTH = f_120.MeasureString("AAPL: ▲ -999.99").X * 0.17f; int number = (int)Math.Floor(WINDOW_WIDTH / FIXED_WIDTH); float offset = -FIXED_WIDTH; StockChange[] changeList = new StockChange[number]; StockChange[] changes = (from entry in gl.changes select entry.Value).ToArray(); //linq-y goodness for (int i = 0; i < number; i++) { changeList[i] = changes[(i % changes.Count())]; float xPos = WINDOW_WIDTH - (tickerScroll + offset) % WINDOW_WIDTH; Graphing.DrawTickerString(spriteBatch, f_120, new string[] { changeList[i].symbol, changeList[i].change.ToString() }, new Vector2(xPos, WINDOW_HEIGHT * 0.085f)); offset += FIXED_WIDTH; } }
public virtual void OnStockChange(StockChangeEventArgs e) { StockChange?.Invoke(this, e); }