public void RecordNewDataForCIAPI() { var rpcClient = new Client(new Uri("https://ciapi.cityindex.com/tradingapi"), new Uri("https://push.cityindex.com"), "foobardotnet"); // start recording requests var stream = new MemoryStream(); var streamRecorder = new StreamRecorder(rpcClient, stream); streamRecorder.Start(); rpcClient.LogIn("secret", "secret"); var accountInfo = rpcClient.AccountInformation.GetClientAndTradingAccount(); rpcClient.SpreadMarkets.ListSpreadMarkets("", "", accountInfo.ClientAccountId, 100, false); rpcClient.News.ListNewsHeadlinesWithSource("dj", "UK", 10); rpcClient.Market.GetMarketInformation(MarketId.ToString()); rpcClient.PriceHistory.GetPriceBars(MarketId.ToString(), "MINUTE", 1, "20"); rpcClient.TradesAndOrders.ListOpenPositions(accountInfo.SpreadBettingAccount.TradingAccountId); rpcClient.LogOut(); streamRecorder.Stop(); stream.Position = 0; using (var fileStream = File.Create("recorded_requests.txt")) { stream.WriteTo(fileStream); } }
private void StopRecorder(StreamRecorder recorder) { timer.Cancel(); Debug.WriteLine("\nRecorder stopped"); var missedRecordingsCount = recorder.NumberOfMissedRecordings; Debug.WriteLine("Number of missed recordings:" + missedRecordingsCount); }
/// <summary> /// Handles the MediaClosed event of the Media control /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void OnMediaClosed(object sender, RoutedEventArgs e) { // Always close the recorder so that the file trailer is written. lock (RecorderSyncLock) { StreamRecorder?.Close(); StreamRecorder = null; } }
/// <summary> /// Handles the MediaClosed event of the Media control. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void OnMediaClosed(object sender, EventArgs e) { // Always close the recorder so that the file trailer is written. lock (RecorderSyncLock) { StreamRecorder?.Close(); StreamRecorder = null; } ViewModel.NotificationMessage = "Media closed."; }