protected internal override void OnReceiveData(string szTrCode) { var enumerable = GetOutBlocks(); int i = 0, count = enumerable.Count - 1; string[] temp = new string[count]; while (enumerable.Count > 0) { var param = enumerable.Dequeue(); if (count > enumerable.Count) { temp[i++] = GetFieldData(param.Block, param.Field, 0); } } var codes = ConnectAPI.Codes.First(o => o.Code.Equals(temp[0x3C])); var refresh = new Codes { Code = temp[0x3C], Name = codes.Code.StartsWith("1") ? temp[0].Split('F')[0].Trim() : temp[0].Remove(temp[0].Length - 2, 2), MarginRate = codes.MarginRate, MaturityMarketCap = temp[0x17].Substring(2), Price = temp[1] }; if (ConnectAPI.Codes.Remove(codes) && ConnectAPI.Codes.Add(refresh) && GoblinBatClient.GetInstance().PutContext <Codes>(refresh).Result is int statusCode && statusCode == 0xC8 && GetTRCountRequest(szTrCode) == 1) { Delay.Milliseconds = 0x3E8 / GetTRCountPerSec(szTrCode); } }
protected internal override void OnReceiveData(string szTrCode) { var enumerable = GetOutBlocks(); int i = 0, count = enumerable.Count - 1; string[] temp = new string[count]; while (enumerable.Count > 0) { var param = enumerable.Dequeue(); if (count > enumerable.Count) { temp[i++] = GetFieldData(param.Block, param.Field, 0); } } var codes = ConnectAPI.Codes.First(o => o.Code.Equals(Code)); var refresh = new Codes { Code = Code, Name = temp[0x33].Trim(), MarginRate = codes.MarginRate * (double.TryParse(temp[62], out double transactionMutiplier) ? transactionMutiplier : 0), MaturityMarketCap = temp[0x16].Substring(2), Price = temp[1] }; if (ConnectAPI.Codes.Remove(codes) && ConnectAPI.Codes.Add(refresh) && GoblinBatClient.GetInstance().PutContext <Codes>(refresh).Result is int statusCode && statusCode == 0xC8 && GetTRCountRequest(szTrCode) == 1) { Delay.Milliseconds = 0x3E8 / GetTRCountPerSec(szTrCode); } }
internal Temporary(int length) { client = GoblinBatClient.GetInstance(); if (CodeStorage == null) { CallUpTheCodesAsync(length).Wait(); } }
public GoblinBat(dynamic cookie) { this.cookie = cookie; InitializeComponent(); random = new Random(); client = GoblinBatClient.GetInstance(cookie); strip.ItemClicked += OnItemClick; StartProgress(new Catalog.Privacies { Security = cookie }); }
static void Main(string[] args) { var secrecy = new Secrecy(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args != null && args.Length > 0) { var api = secrecy.GetPrivacyShare(args[0]); StartProgress(GoblinBatClient.GetInstance(args), api.Item1 ?? secrecy.GetAPI(GetResult(secrecy.Choose, secrecy.Name), args[0]), api.Item2); } GC.Collect(); Process.GetCurrentProcess().Kill(); }
internal IEnumerable <string> GetInformationOfCode(List <string> list, string[] market) { string exclusion, date = DistinctDate; Delay.Milliseconds = 0x259; for (int i = 2; i < 4; i++) { foreach (var om in axAPI.GetActPriceList().Split(';')) { exclusion = axAPI.GetOptionCode(om.Insert(3, "."), i, date); if (list.Exists(o => o.Equals(exclusion))) { continue; } list.Add(exclusion); } } Parallel.ForEach(Enum.GetNames(typeof(Market)), new ParallelOptions { MaxDegreeOfParallelism = (int)(Environment.ProcessorCount * 0.5) }, new Action <string>(async(sMarket) => { if (Enum.TryParse(sMarket, out Market param)) { switch (param) { case Market.장내: case Market.코스닥: case Market.ETF: for (int i = 0; i < market.Length; i++) { var state = axAPI.GetMasterStockState(market[i]); if (state.Contains("거래정지") && await GoblinBatClient.GetInstance().PutContext <Codes>(new Codes { Code = market[i], Name = axAPI.GetMasterCodeName(market[i]), MaturityMarketCap = state, Price = axAPI.GetMasterLastPrice(market[i]) }) < int.MaxValue) { market[i] = string.Empty; } } break; default: foreach (var str in axAPI.GetCodeListByMarket(((int)param).ToString()).Split(';')) { var index = Array.FindIndex(market, o => o.Equals(str)); if (index > -1) { market[index] = string.Empty; } } break; } } })); var stack = CatalogStocksCode(market.OrderByDescending(o => o)); list[1] = axAPI.GetFutureCodeByIndex(0x18); list.Add(axAPI.GetFutureCodeByIndex(0xD)); foreach (var str in axAPI.GetSFutureList(string.Empty).Split('|')) { if (string.IsNullOrEmpty(str) == false) { var temp = str.Split('^'); if (temp[2].Equals(date) == false) { list.Add(temp[0]); } date = temp[2]; } } while (stack.Count > 0) { yield return(stack.Pop()); } foreach (var code in list) { yield return(code); } }
protected async Task MoveStorageSpace(char initial) { try { var client = GoblinBatClient.GetInstance(initial.ToString()); var stack = new Stack <string>(); using (var db = new GoblinBatDbContext(key)) foreach (var temp in db.Codes.OrderBy(o => o.Code).Select(o => new { o.Code, o.Name, o.Info }).AsNoTracking()) { stack.Push(temp.Code); } while (stack.Count > 0) { Catalog.Retention retention; var code = stack.Pop(); var stocks = new Queue <Emergency.Stocks>(1024); var options = new Queue <Emergency.Options>(1024); var futures = new Queue <Emergency.Futures>(1024); if (code.Length == 8 && (code.StartsWith("101") || code.StartsWith("106"))) { using (var db = new GoblinBatDbContext(key)) foreach (var f in db.Futures.Where(o => o.Code.Equals(code)).AsNoTracking().OrderBy(o => o.Date)) { futures.Enqueue(new Emergency.Futures { Code = f.Code, Date = f.Date.ToString(), Price = f.Price.ToString(), Volume = f.Volume, Retention = f.Date.ToString().Substring(0, 12) }); if (futures.Count > 2000000) { retention = await client.EmergencyContext(futures); futures.Clear(); } } retention = await client.EmergencyContext(futures); } if (code.Length == 8 && (code.StartsWith("2") || code.StartsWith("3"))) { using (var db = new GoblinBatDbContext(key)) foreach (var o in db.Options.Where(o => o.Code.Equals(code)).AsNoTracking().OrderBy(o => o.Date)) { options.Enqueue(new Emergency.Options { Code = o.Code, Date = o.Date.ToString(), Price = o.Price.ToString(), Volume = o.Volume, Retention = o.Date.ToString().Substring(0, 12) }); if (options.Count > 2000000) { retention = await client.EmergencyContext(options); options.Clear(); } } retention = await client.EmergencyContext(options); } if (code.Length == 6) { using (var db = new GoblinBatDbContext(key)) foreach (var s in db.Stocks.Where(o => o.Code.Equals(code)).AsNoTracking().OrderBy(o => o.Date)) { stocks.Enqueue(new Emergency.Stocks { Code = s.Code, Date = s.Date.ToString(), Price = s.Price.ToString(), Volume = s.Volume, Retention = s.Date.ToString().Substring(0, 12) }); if (stocks.Count > 2000000) { retention = await client.EmergencyContext(stocks); stocks.Clear(); } } retention = await client.EmergencyContext(stocks); } SendMessage(stack.Count); } } catch (Exception ex) { new ExceptionMessage(ex.StackTrace); } }
internal Temporary(int length) { client = GoblinBatClient.GetInstance(); CallUpTheCodesAsync(length).Wait(); }