protected override void OnClosing(CancelEventArgs e) { StockMarketManager smm = StockMarketManager.Instance; smm.Close(); base.OnClosing(e); }
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Cancelled) { return; } string[] data = e.Result.Split(new char[] { '\n' }); Dictionary <string, Bid> dictionary2 = new Dictionary <string, Bid>(); for (int i = 0; i < data.Length; i++) { if (data[i].Length != 0) { Bid bid = Parse(data[i]); StockMarketManager.AddBid(bid); } } }
public StockMarketWindow(StockMarketManager manager) { manager.StockChanged += OnStockChanged; this.Closed += (s, e) => manager.StockChanged -= OnStockChanged; Stocks = new ObservableCollection <Stock>(); Stocks.Add(new Stock() { Name = "Tesla", Price = 750, IsUp = false, }); Stocks.Add(new Stock() { Name = "Microsoft", Price = 183, IsUp = true, }); Stocks.Add(new Stock() { Name = "Intel", Price = 183, IsUp = true, }); Stocks.Add(new Stock() { Name = "ALPHABET", Price = 66, IsUp = true, }); Stocks.Add(new Stock() { Name = "Oracle", Price = 54, IsUp = false, }); Stocks.Add(new Stock() { Name = "Apple", Price = 320, IsUp = true, }); InitializeComponent(); }
private void _Start() { StockMarketManager smm = StockMarketManager.Instance; IStrategy[] strategies = StrategyManager.Instance.ReadMyStrategies(); foreach (IStrategy strategy in strategies) { smm.RegisterStrategy(strategy); } smm.Start(); int span = int.Parse(Configure.GetStockTraderItem(Configure.KEEP_TIME_SPAN)); keepLoginTimer.Interval = span * 60000; keepLoginTimer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); keepLoginTimer.Enabled = true; }
private void sendRequest(string t_codes) { //string address = String.Format(dataurl, String.Join(",", t_codes.ToArray())); string address = String.Format(dataurl, t_codes); //Uri addr = new Uri(address); // if (client.IsBusy) return; //client = new HttpClient(); Stopwatch watch = new Stopwatch(); watch.Start(); //string resp = client.Get(address); string resp = client.Get(address); if (resp == null) { Console.WriteLine("没有获取到数据"); return; } // Console.WriteLine(resp); string[] data = resp.Split(new char[] { '\n' }); Dictionary <string, Bid> dictionary2 = new Dictionary <string, Bid>(); for (int i = 0; i < data.Length; i++) { if (data[i].Length != 0) { Bid bid = Parse(data[i]); StockMarketManager.AddBid(bid); } } Console.WriteLine("耗时{0}", watch.ElapsedMilliseconds); //client.DownloadString(address); //client.Timeout = 700; //client.DownloadStringAsyncWithTimeout(addr); //client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); //client.DownloadStringTimeout += new HttpClient.DownloadStringTimeoutEventHandler(client_DownloadStringTimeout); // string resp = client.DownloadString(address); }
void WSClient_ReceivedRealTime(string message) { Bid bid = Parse(message); StockMarketManager.AddBid(bid); }
public StockActionWindow(StockMarketManager manager) { manager.StockChanged += OnStockChanged; }