private async void Sure_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(BookIDBox.Text) || string.IsNullOrEmpty(SaleNumberBox.Text)) { return; } Models.Stock stock = StockUtil.QueryStock(BookIDBox.Text); if (stock != null) { int n = int.Parse(SaleNumberBox.Text); SaleNumberBox.Text = ""; if (n < 0) { await new MessageDialog("还书的数值不正确!").ShowAsync(); return; } // 库存记录 StockViewModel.GetInstance().UpdateStock(stock.Book.BId, n); // 还书记录 Models.Return @return = new Models.Return { Book = stock.Book, Number = n, Time = DateTimeOffset.Now, TotalPrice = stock.SalePrice * n }; ReturnUtil.AddReturn(@return); await new MessageDialog("归还成功!").ShowAsync(); } else { await new MessageDialog("本店没有进过这种书,不必归还到此!").ShowAsync(); } BookIDBox.Text = ""; }
static void Main(string[] args) { Dictionary <string, string> dic = ProcessParam(args); string stock = dic["-stock"]; //"002693"; string startDate = dic["-start"]; //"2013-05-01"; string endDate, filter; if (dic.ContainsKey("-end")) { endDate = dic["-end"]; } else { endDate = StockUtil.FormatDate(DateTime.Now); } if (dic.ContainsKey("-filter")) { filter = dic["-filter"]; } else { filter = "500"; } StockLog.Log.Info(stock + " " + startDate + " " + endDate + " " + filter); Analyze(stock, startDate, endDate, filter); }
protected override TraderResult internalBuyStock(string code, float price, int num) { const int BUY_TXT_CODE = 0x0408; const int BUY_TXT_PRICE = 0x0409; const int BUY_TXT_NUM = 0x040A; const int BUY_BTN_OK = 0x3EE; ClickBuyTreeViewItem(); // 设定代码,价格,数量 IntPtr hPanel = GetDetailPanel(); IntPtr hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_CODE); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, StockUtil.GetShortCode(code)); hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_PRICE); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, price.ToString()); hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_NUM); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, num.ToString()); // 点击买入按钮 hCtrl = Win32API.GetDlgItem(hPanel, BUY_BTN_OK); Win32API.PostMessage(hCtrl, Win32Code.WM_LBUTTONDOWN, 0, 0); Win32API.PostMessage(hCtrl, Win32Code.WM_LBUTTONUP, 0, 0); ClickQueryDrcjTreeViewItem(); TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return(result); }
private async void Sure_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(SaleNumberBox.Text) || string.IsNullOrEmpty(BookIDBox.Text)) { return; } Models.Stock stock = StockUtil.QueryStock(BookIDBox.Text); if (stock != null) { int n = int.Parse(SaleNumberBox.Text); SaleNumberBox.Text = ""; if (n > stock.Number) { await new MessageDialog("这种书没有多么多了!").ShowAsync(); return; } // 库存记录 StockViewModel.GetInstance().UpdateStock(stock.Book.BId, 0 - n); // 销售记录 Models.Sale sale = new Models.Sale { Book = stock.Book, Number = n, Time = DateTimeOffset.Now, TotalPrice = n * stock.SalePrice }; SalesUtil.AddSale(sale); await new MessageDialog("销售成功!").ShowAsync(); } else { await new MessageDialog("没有这种书,请重新输入书籍编号!").ShowAsync(); } BookIDBox.Text = ""; }
/// <summary> /// 生成所有的股票的 /// </summary> public static void generateAll() { string stock = "sh600036"; DateTime startDate = new DateTime(2013, 6, 01); DateTime stopDate = new DateTime(2013, 6, 28); int interval = 1; //上海股票 for (int i = 600000; i < 602000; i++) { stock = "sh" + i; //Console.WriteLine(stock.Substring(2)); //return; for (DateTime dateTime = startDate; dateTime < stopDate; dateTime += TimeSpan.FromDays(interval)) { if (!(dateTime.Date.DayOfWeek == DayOfWeek.Saturday || dateTime.Date.DayOfWeek == DayOfWeek.Sunday)) { //Console.WriteLine(toDate(dateTime.Date)); generateFile(stock, StockUtil.FormatDate(dateTime.Date)); } } } return; }
public static void Main(string[] args) { //List<DateUnit> u=DateUtil.ConvertMonthlyDateUnit(DateTime.Parse("2012-09-03"), DateTime.Now); StockInfo info = new StockInfo(); info.stock = StockUtil.FormatStock(GetPara(args, "-stock")); info.startDate = GetPara(args, "-start"); if (info.startDate.Equals("")) { info.startDate = "2013-03-01"; } //info.startDate = "2013-03-01"; String[] bigDeal = GetPara(args, "-big").Split(','); if (bigDeal[0].Equals("")) { bigDeal = new String[] { "500", "1000", "2000" }; } info.filterList = bigDeal; //info.filterList = new String[] { "500", "1000", "2000" }; List <IStockModule> list = new List <IStockModule>(); list.Add(new DownloadModule()); list.Add(new AnalyzeModule()); list.Add(new ReportModule()); foreach (IStockModule module in list) { module.Execute(info); } }
public static List <DailyData> ConvertDailyList(List <EntryData> entryList) { if (entryList.Count == 0) { return(null); } List <DailyData> list = new List <DailyData>(); for (DateTime dateTime = DateTime.Parse(StockUtil.FormatDate(entryList[0].time)); dateTime <= DateTime.Parse(StockUtil.FormatDate(entryList[entryList.Count - 1].time)); dateTime += TimeSpan.FromDays(1)) { IEnumerable <EntryData> querySet = from d in entryList where StockUtil.FormatDate(d.time) == StockUtil.FormatDate(dateTime) select d; if (querySet.Count <EntryData>() > 0) { DailyData dd = new DailyData() { Date = dateTime, entryList = querySet.ToList <EntryData>() }; dd.Init(); list.Add(dd); } } return(list); }
public bool Execute(StockInfo info) { string startDate = info.startDate.Equals("") ? Constant.ANALYZE_START_DATE : info.startDate; //string endDate = info.endDate.Equals("") ? StockUtil.FormatDate(DateTime.Now) : info.endDate; Analyzer.Analyze(info.stock, startDate, StockUtil.FormatDate(DateTime.Now), info.filterList); return(true); }
public void UpdateStock(int booid, int number) { for (int i = 0; i < stocks.Count(); i++) { if (stocks[i].Book.BId == booid) { stocks[i].Number += number; } } StockUtil.UpdateStock(booid, number); }
protected override void Login() { string loginUrl = "https://service.htsc.com.cn/service/loginAction.do?method=login"; this.httpClient.DownloadString(loginUrl); string verifyCode = this.GetVerifyCode(); if (verifyCode == "") { MessageBox.Show("获取验证码失败"); } LoginPostInfo t = new LoginPostInfo { // TODO: 自动获取MAC, HDD INFO macaddr = "00:0C:29:1A:B4:32", hddInfo = "CVCV434102MF120BGN++", servicePwd = fivc.txtServicePwd.Text, trdpwd = fivc.txtTrdpwd.GetEncPswAes(), trdpwdEns = fivc.txtTrdpwd.GetEncPswAes(), userName = fivc.txtUsername.Text, vcode = verifyCode }; string postString = URLHelper.GetData <LoginPostInfo>(t, this.encoding); byte[] postData = Encoding.UTF8.GetBytes(postString); this.httpClient.Encoding = this.encoding; // string str4 = this.httpClient.UploadString(address, data); httpClient.Timeout = 0xea90; byte[] responseData = this.httpClient.UploadData(loginUrl, "POST", postData); string resp = Encoding.UTF8.GetString(responseData);//解码 if (resp.IndexOf("上次登录时间") != -1) { string input = this.httpClient.DownloadString("https://service.htsc.com.cn/service/flashbusiness_new3.jsp?etfCode="); String infoStr = StockUtil.Base64Decode(this.GetData(input), this.GB2312); Console.WriteLine(infoStr); resAccountInfo = JsonConvert.DeserializeObject <RespAccountInfo>(infoStr); } else if (resp.IndexOf("系统升级中") != -1) { MessageBox.Show("系统升级中"); return; } else { Login(); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null && value.GetType() == typeof(TextBlock)) { var dataContext = ((TextBlock)value).DataContext; if (dataContext != null && dataContext.GetType() == typeof(Stock)) { return(StockUtil.GetStockForgroundColor((Stock)dataContext)); } } return(null); }
public static void DownloadSingle(string sid) { string startDate = BizApi.QueryExtractLastUpdate(sid).AddDays(1).ToString("yyyy-MM-dd"); string endDate = StockUtil.FormatDate(DateTime.Now); DataDownload.DownloadDataToCsvByReader(sid, startDate, endDate); if (!Constant.CLEAN) { StockUtil.UpdateDownloadTimeStamp(sid, endDate); } StockLog.Log.Info(sid + " updated " + startDate + " " + endDate); }
/// <summary> /// 在行情市场中登记一个策略,每个ticket,调用一次策略。 /// </summary> /// <param name="strategy">策略实例</param> public void RegisterStrategy(IStrategy strategy) { foreach (string s in strategy.StockPool) { string code = StockUtil.GetFullCode(s); if (!StockMarketManager.bidCache.ContainsKey(code)) { StockMarketManager.bidCache.Add(code, new BidCacheQueue()); } StockMarketManager.bidCache[code].OnBidChange += strategy.OnStockDataChanged; } // 调用策略 this.OnTicket += strategy.OnTicket; }
public string CompareDaily() { if (data1.DailyList.Count != data2.DailyList.Count) { return(null); } StringBuilder sb = new StringBuilder(); sb.Append(String.Format("{0},{1},{2},{3}\n", "time", "bigSellShareRate", "bigBuyShareRate", "Average")); for (int i = 0; i < data1.DailyList.Count; i++) { sb.Append(String.Format("{0},{1},{2},{3}\n", StockUtil.FormatDate(data1.DailyList[i].Date), StockUtil.FormatRate(data1.DailyList[i].TotalBuyMoney / data2.DailyList[i].TotalBuyMoney), StockUtil.FormatRate(data1.DailyList[i].TotalSellMoney / data2.DailyList[i].TotalSellMoney), StockUtil.FormatRate(data1.DailyList[i].TotalMoney / data2.DailyList[i].TotalMoney))); } return(sb.ToString()); }
////download from one csv file //public static void DownloadDataToCsvByReaderFromCsvFile(string csvFile, string startDate, string endDate) //{ // List<string> list = Common.StockUtil.ParseListFromCsvFile(csvFile); // foreach (string stock in list) // { // if (!Directory.Exists(Constant.ROOT_FOLDER + stock)) Directory.CreateDirectory(Constant.ROOT_FOLDER + stock); // for (DateTime dateTime = DateTime.Parse(startDate); // dateTime <= DateTime.Parse(endDate); // dateTime += TimeSpan.FromDays(1)) // { // if (!(dateTime.Date.DayOfWeek == DayOfWeek.Saturday || dateTime.Date.DayOfWeek == DayOfWeek.Sunday)) // DownloadDataToCsvByReader(stock, StockUtil.FormatDate(dateTime.Date)); // } // } //} public static string DownloadDataToCsvByReader(string stock, string startDate, string endDate) { for (DateTime dateTime = DateTime.Parse(startDate); dateTime <= DateTime.Parse(endDate); dateTime += TimeSpan.FromDays(1)) { if (!(dateTime.Date.DayOfWeek == DayOfWeek.Saturday || dateTime.Date.DayOfWeek == DayOfWeek.Sunday)) { //LOG.Info(toDate(dateTime.Date)); DownloadDataToCsvByReader(stock, StockUtil.FormatDate(dateTime.Date)); } } return(Constant.ROOT_FOLDER + stock); }
public static string Analyze(string stock, string filter, string startDate, string endDate) { stock = StockUtil.FormatStock(stock); string analyzePath; List <DailyData> dds = Csv.ReadCsv(stock, startDate, endDate, true); StringBuilder str = new StringBuilder(); str.Append("date,bigBuyShare,bigSellShare,toalShare,bigBuyMoney,bigSellMoney,toalMoney,Open,Close,Average,Hightest,WhenHighest,Lowest,WhenLowest,BigBuyShareRate,BigSellShareRate,BigBuyMoneyRate,BigSellMoneyRate\n"); foreach (DailyData ds in dds) { BigDeal fd = new BigDeal(ds, filter); fd.Analye(); str.Append(StockUtil.FormatDate(fd.set.Date) + ","); str.Append(fd.TotalBuyShareByBigDeal + ","); str.Append(fd.TotalSellShareByBigDeal + ","); str.Append(fd.set.TotalShare + ","); str.Append(fd.TotalBuyMoneyByBigDeal + ","); str.Append(fd.TotalSellMoneyByBigDeal + ","); str.Append(fd.set.TotalMoney + ","); str.Append(fd.set.OpenPrice + ","); str.Append(fd.set.ClosePrice + ","); str.Append(fd.set.Average + ","); str.Append(fd.set.HighestPrice + ","); str.Append(StockUtil.FormatTime(fd.set.TimeWhenHighest) + ","); str.Append(fd.set.LowestPrice + ","); str.Append(StockUtil.FormatTime(fd.set.TimeWhenLowest) + ","); str.Append(fd.RateOfBuyShareByTotal + ","); str.Append(fd.RateOfSellShareByTotal + ","); str.Append(fd.RateOfBuyMoneyByTotal + ","); str.Append(fd.RateOfSellMoneyByTotal + ","); str.Append("\n"); } analyzePath = Constant.ANALYZE_FOLDER + stock + "_" + startDate + "_" + endDate + "_" + filter + ".csv"; if (File.Exists(analyzePath)) { File.Delete(analyzePath); } using (StreamWriter outfile = new StreamWriter(Constant.ANALYZE_FOLDER + stock + "_" + startDate + "_" + endDate + "_" + filter + ".csv")) { outfile.Write(str); Console.WriteLine("Analyzed: " + Constant.ANALYZE_FOLDER + stock + "_" + startDate + "_" + endDate + "_" + filter + ".csv"); } return(analyzePath); }
private T getResp <T, R>(R request) { string queryParams = StockUtil.Base64Encode(URLHelper.GetDataWithOutEncode <R>(request), this.GB2312); string sellUrl = "https://tradegw.htsc.com.cn/?" + queryParams; Stopwatch watch = new Stopwatch(); watch.Start(); string strResp = this.httpClient.DownloadString(sellUrl); Console.WriteLine("请求耗时:{0}ms", watch.ElapsedMilliseconds); string resp = StockUtil.Base64Decode(strResp, this.GB2312); Console.WriteLine("Web操作返回结果", resp); T ret = JsonConvert.DeserializeObject <T>(resp); return(ret); }
public static string Compare(Dictionary <string, FilterData> big, Dictionary <string, FilterData> small) { StringBuilder sb = new StringBuilder(); sb.Append("Date,BuyShare,SellShare,BuyMoney,SellMoney,increDiffShare,increDiffMoney, BuyRate,SellRate, Change\n"); decimal incrementalComShare = 0, incrementalComMoney = 0; foreach (string a in big.Keys) { decimal rateOfBuy = 0, rateOfSell = 0, rateOfChange = 0; decimal rateOfBuySell = 0; decimal totalBuyShare = 0, totalSellShare = 0, totalBuyMoney = 0, totalSellMoney = 0; if (small.ContainsKey(a)) { rateOfBuy = StockUtil.FormatRate(small[a].TotalBuyMoney / big[a].TotalMoney); rateOfSell = StockUtil.FormatRate(small[a].TotalSellMoney / big[a].TotalMoney); totalBuyShare = small[a].TotalBuyShare; totalSellShare = small[a].TotalSellShare; totalBuyMoney = small[a].TotalBuyMoney; totalSellMoney = small[a].TotalSellMoney; incrementalComShare += totalBuyShare - totalSellShare; incrementalComMoney += totalBuyMoney - totalSellMoney; //incrementalBuyMoney += totalBuyMoney; //incrementalSellMoney += totalSellMoney; } rateOfChange = StockUtil.FormatRate((big[a].Close - big[a].Open) / big[a].Open); //rateOfBuySell = StockUtil.FormatRate((big[a].TotalBuyMoney - big[a].TotalSellMoney) / big[a].TotalSellMoney); sb.Append(a + ","); sb.Append(totalBuyShare + ","); sb.Append(totalSellShare + ","); sb.Append(totalBuyMoney / 10000 + ","); sb.Append(totalSellMoney / 10000 + ","); sb.Append(incrementalComShare + ","); sb.Append(incrementalComMoney / 10000 + ","); //sb.Append(0 + ","); sb.Append(rateOfBuy + ","); sb.Append(rateOfSell + ","); // sb.Append(rateOfBuySell + ","); sb.Append(rateOfChange + "\n"); } return(sb.ToString()); }
private void init() { if (_dataset == null) { _dataset = Csv.ReadCsv(StockUtil.FormatStock(stock), startDate, endDate, isDownload); } if (_entrydata == null) { _entrydata = new List <EntryData>(); foreach (DailyData daily in DailyList) { foreach (EntryData entry in daily.entryList) { _entrydata.Add(entry); } } } }
private void AddList(Dictionary <String, FilterData> dic, DateUnit unit) { FilterData f1 = new FilterData(); IEnumerable <EntryData> querySet = from d in _filterData.EntryList where d.time > unit.Start && d.time < unit.End select d; if (querySet.Count <EntryData>() > 0) { f1.EntryList = querySet.ToList <EntryData>(); f1.DailyList = DataUtil.ConvertDailyList(f1.EntryList); //if (_type == (int)RangeType.Hourly) //{ // dic.Add(StockUtil.FormatAllTime(unit.Start, true) + "_" + StockUtil.FormatAllTime(unit.End, true), f1); // } //else //{ dic.Add(StockUtil.FormatAllTime(unit.Start) + "_" + StockUtil.FormatAllTime(unit.End), f1); // } } }
private async void Sure_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(BookIDBox.Text) || string.IsNullOrEmpty(SaleNumberBox.Text) || string.IsNullOrEmpty(SalePriceBox.Text)) { return; } if (select != null) { int n = int.Parse(SaleNumberBox.Text); float n2 = float.Parse(SalePriceBox.Text); SaleNumberBox.Text = ""; SalePriceBox.Text = ""; if (n > select.Number) { await new MessageDialog("这种书没有多么多了!").ShowAsync(); return; } // 库存记录 if (StockUtil.QueryStock(select.Book.BId.ToString()) == null) { StockViewModel.GetInstance().AddStock(new Models.Stock { Book = select.Book, Number = 0, OfferPrice = select.Price, SalePrice = n2 }); } StockViewModel.GetInstance().UpdateStock(select.Book.BId, n); SupplierStockUtil.UpdateSupplierStock(select.Supplier.SId, select.Book.BId, 0 - n); // 进货记录 Models.Purchase purchase = new Models.Purchase { Book = select.Book, Number = n, Time = DateTimeOffset.Now, Supplier = select.Supplier, Price = select.Price }; PurchaseUtil.AddPurchase(purchase); await new MessageDialog("进货成功了!").ShowAsync(); } else { await new MessageDialog("没有这种书供应,请重新输入书籍编号!").ShowAsync(); } BookIDBox.Text = ""; }
/// <summary> /// 生成csv 文件 /// </summary> /// <param name="date"></param> /// <param name="stock"></param> /// <returns></returns> public static bool downloadDataToCsv(string stock, string startDate, string endDate) { if (!Directory.Exists(Constant.ROOT_FOLDER + stock)) { Directory.CreateDirectory(Constant.ROOT_FOLDER + stock); } for (DateTime dateTime = DateTime.Parse(startDate); dateTime < DateTime.Parse(endDate); dateTime += TimeSpan.FromDays(1)) { if (!(dateTime.Date.DayOfWeek == DayOfWeek.Saturday || dateTime.Date.DayOfWeek == DayOfWeek.Sunday)) { //Console.WriteLine(toDate(dateTime.Date)); downloadDataToCsv(stock, StockUtil.FormatDate(dateTime.Date)); } } return(true); }
public bool Execute(StockInfo info) { string startDate; if (Constant.DOWNLOAD_ALL.Equals("0")) { startDate = StockUtil.ReadUpdateFile(info.stock); } else { startDate = "2014-01-01"; } string endDate = StockUtil.FormatDate(DateTime.Now); //DataDownload.DownloadDataToCsv(info.stock, startDate, endDate); StockUtil.UpdateDownloadTimeStamp(info.stock, endDate); StockLog.Log.Info(info.stock + " updated " + startDate + " " + endDate); return(true); }
public static List <DailyData> ReadCsv(string stock, string startDate, string endDate, bool isDownload) { List <DailyData> dds = new List <DailyData>();; for (DateTime dateTime = DateTime.Parse(startDate); dateTime <= DateTime.Parse(endDate); dateTime += TimeSpan.FromDays(1)) { if (!(dateTime.Date.DayOfWeek == DayOfWeek.Saturday || dateTime.Date.DayOfWeek == DayOfWeek.Sunday)) { //LOG.Info(toDate(dateTime.Date)); DailyData s = ReadCsv(stock, StockUtil.FormatDate(dateTime.Date), isDownload); if (s != null) { dds.Add(s); } } } return(dds); }
private void SearchId_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(BookIDBox.Text)) { return; } Models.Stock stock = StockUtil.QueryStock(BookIDBox.Text); if (stock != null) { BookDetail.Visibility = Visibility.Visible; BookId.Text = stock.Book.BId.ToString(); BookName.Text = stock.Book.BName; BookAuthor.Text = stock.Book.BAuthor; BookNumber.Text = stock.Number.ToString(); BookSalePrice.Text = stock.SalePrice.ToString(); BookBuyPrice.Text = stock.OfferPrice.ToString(); } else { BookDetail.Visibility = Visibility.Collapsed; } }
private void internalRun() { while (true) { Thread.Sleep(2000); bool isSent = false; int n = 150; if (s_codes.Count == 0 && codes.Count != 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < codes.Count; i++) { if ((i % n) < n) { isSent = false; sb.Append(StockUtil.GetFullCode(codes[i])); sb.Append(","); } if (i % n == (n - 1)) { sb.Remove(sb.Length - 1, 1); s_codes.Add(sb.ToString()); sb.Clear(); isSent = true; } } if (!isSent) { sb.Remove(sb.Length - 1, 1); s_codes.Add(sb.ToString()); } } foreach (string item in s_codes) { sendRequest(item); } } }
public static void Analyze(String stock, string startDate, string endDate, string[] filterList) { //IApplicationContext ctx = ContextRegistry.GetContext(); StockLog.Log.Info("start to create stock data"); StockData data1 = new StockData(stock, startDate, endDate, true);//(StockData)ctx.GetObject("StockData"); StockLog.Log.Info("start to create normal data"); NormalData gd = new NormalData(data1);//(NormalData)ctx.GetObject("NormalData"); StockUtil.CreateStockFolder(stock); foreach (String filter in filterList) { BigDealData bdd = new BigDealData(data1, filter); StockLog.Log.Info("start to create big deal data " + filter); //(BigDealData)ctx.GetObject("BigDealData"); //RangeData bigdeal = new RangeData(bdd, type); //(RangeData)ctx.GetObject("BigRangeData"); // RangeData alldeal = new RangeData(gd, type);//(RangeData)ctx.GetObject("AllRangeData"); foreach (int type in Enum.GetValues(typeof(RangeType))) { //String filePath = string.Format(@"{0}{1}\{1}_{2}_{3}_{4}_{5}.csv", Constant.ANALYZE_FOLDER, stock, startDate, endDate, filter, (RangeType)type); String filePath = string.Format(@"{0}{1}\{1}_{3}_{2}.csv", Constant.ANALYZE_FOLDER, stock, (RangeType)type, filter); StockLog.Log.Info("start to analyze " + (RangeType)type); if (!File.Exists(filePath)) { RangeData bigdeal = new RangeData(bdd, type); //(RangeData)ctx.GetObject("BigRangeData"); RangeData alldeal = new RangeData(gd, type); //(RangeData)ctx.GetObject("AllRangeData"); Dictionary <string, FilterData> big = bigdeal.DataList; Dictionary <string, FilterData> all = alldeal.DataList; FileUtil.WriteFile(filePath, DataUtil.Compare(all, big)); } StockLog.Log.Info("End to analyze " + (RangeType)type); } } }
public void Init() { _startTime = entryList[0].time; _endTime = entryList[entryList.Count - 1].time; _date = DateTime.Parse(StockUtil.FormatDate(_startTime)); int index = 0; decimal current; if (entryList.Count == 0) { return; } foreach (EntryData data in entryList) { current = data.price; if (index == 0) { _close = current; _highest = current; _lowest = current; } if (_highest < current) { _highest = current; _timeWhenHighest = data.time; } if (_lowest > current) { _lowest = current; _timeWhenLowest = data.time; } _open = current; index++; } }
protected override TraderResult internalBuyStock(string code, float price, int num) { int exchange_type = StockUtil.GetExchangeType(code); AccountInfoItem holder = GetStockHolder(exchange_type); StockBuyRequest t = new StockBuyRequest { branch_no = this.resAccountInfo.branch_no, custid = this.resAccountInfo.fund_account, fund_account = this.resAccountInfo.fund_account, op_branch_no = this.resAccountInfo.branch_no, op_station = this.resAccountInfo.op_station, password = this.resAccountInfo.trdpwd, uid = this.resAccountInfo.uid, exchange_type = exchange_type.ToString(), stock_account = holder.stock_account, stock_code = StockUtil.GetShortCode(code), entrust_amount = num, entrust_price = price }; StockBuyResp resp = getResp <StockBuyResp, StockBuyRequest>(t); TraderResult ret = new TraderResult(); if (resp.cssweb_code == SuccessCode) { ret.Code = TraderResultEnum.SUCCESS; ret.EntrustNo = resp.Item[0].entrust_no; } else { ret.Code = TraderResultEnum.ERROR; ret.Message = String.Format("错误代码{0}, 错误内容{1}", resp.cssweb_code, resp.cssweb_msg); } return(ret); }
public static string Analyze(string stock, string startDate, string endDate) { return(Analyze(stock, Constant.BIG_DEAL, startDate, StockUtil.FormatDate(DateTime.Now))); }