public UpdateHandler(DataTrade trade, DataFeed feed, Action<SymbolInfo[], AccountInfo, Quote> updateCallback, Processor processor) { if (trade == null) throw new ArgumentNullException(nameof(trade)); if (feed == null) throw new ArgumentNullException(nameof(feed)); if (updateCallback == null) throw new ArgumentNullException(nameof(updateCallback)); if (processor == null) throw new ArgumentNullException(nameof(processor)); this.updateCallback = updateCallback; this.processor = processor; this.SyncRoot = new object(); feed.SymbolInfo += this.OnSymbolInfo; feed.Tick += this.OnTick; trade.AccountInfo += this.OnAccountInfo; trade.BalanceOperation += this.OnBalanceOperation; trade.ExecutionReport += this.OnExecutionReport; trade.PositionReport += this.OnPositionReport; }
/// <summary> /// Creates and initializes a new data feed storage. /// </summary> /// <param name="location">Specified location for data feed history local cache.</param> /// <param name="storageProviderType">Type of storage provider.</param> /// <param name="storageVersion">Storage version.</param> /// <param name="dataFeed">Can be null, in this case you can use storage in offline mode only.</param> /// <param name="flushOnDispose">If true, then quotes cache in memory will be flushed to hard drive.</param> /// <param name="saveTickLevel2History">Save incomning ticks as level2 history or not</param> /// <exception cref="System.ArgumentNullException">If location is null.</exception> public DataFeedStorage(string location, Type storageProviderType, int storageVersion, DataFeed dataFeed, bool flushOnDispose, bool saveTickLevel2History) { if (location == null) throw new ArgumentNullException(nameof(location), "Location argument can not be null."); if (location.Length == 0) throw new ArgumentException("Location argument can not be empty string", nameof(location)); if (location[location.Length - 1] == Path.DirectorySeparatorChar) location = location.Substring(0, location.Length - 1); this.saveTickLevel2History = saveTickLevel2History; this.storageVersion = storageVersion; this.historyFeed = dataFeed; this.Location = location; this.flushOnDispose = flushOnDispose; this.store = StorageProvider.CreateStore(storageProviderType, location, NullMonitoringService); var status = this.store.OpenOrCreate(storageVersion, forceCreateNewVersion: true); if (dataFeed != null) this.source = new DataFeedHistorySource(dataFeed, attemptsNumber: 1); this.Bind(dataFeed); this.continueMonitoring = true; this.thread = new Thread(this.Loop); this.thread.Start(); this.Offline = new SmartStorage(this); if (this.source != null) this.Online = new SmartStorage(this, this.source); }
private DataFeed[] GetDataFeedsFromResponse(JObject jsonResponse, int resultsFeedNumber, int maxResults) { List<DataFeed> feeds = new List<DataFeed>(); for (int i = 0; i < Math.Min(resultsFeedNumber, maxResults); i++) { DataFeed feed; try { var result = jsonResponse["results"][i]; feed = new DataFeed { Link = (string) result["url"], Title = (string) result["title"], PublishTime = DateTime.Parse((string) result["created_date"]), Source = (string) result["source"], Text = (string) result["abstract"], Image = GetUrlOfLargestImage(result) }; } catch(Exception e) { continue; } feeds.Add(feed); } return feeds.ToArray(); }
/// <summary> /// Creates new financial state of account calculator. /// </summary> /// <param name="trade">valid instance of not started data trade</param> /// <param name="feed">valid instance of not started data feed</param> public StateCalculator(DataTrade trade, DataFeed feed) { if (trade == null) throw new ArgumentNullException(nameof(trade), "Data trade argument can not be null"); if (trade.IsStarted) throw new ArgumentException("Started data trade can not be used for creating state calculator.", nameof(trade)); if (feed == null) throw new ArgumentNullException(nameof(feed), "Data feed argument can not be null"); if (feed.IsStarted) throw new ArgumentException("Started data feed can not be used for creating state calculator.", nameof(feed)); this.quotes = new Dictionary<string, Quote>(); this.calculatorQuotes = new Dictionary<string, Quote>(); this.calculator = new FinancialCalculator(); this.account = new AccountEntry(calculator); this.calculator.Accounts.Add(this.account); this.trade = trade; this.feed = feed; this.processor = new Processor(this.Calculate); this.processor.Exception += this.OnException; this.processor.Executed += this.OnExecuted; this.updateHandler = new UpdateHandler(trade, feed, this.OnUpdate, processor); }
public LiveFeed(string InstrumentName) { datafeed = new DataFeed(); _Instrument = InstrumentName; createHiSatEvents(); Login(); }
private DataFeed[] GenerateResponseFromString(string response,int maxResults) { List<DataFeed> feeds = new List<DataFeed>(); JObject jsonResponse = JObject.Parse(response); if (jsonResponse["status"].ToString() == "ERROR") return null; JArray x = (JArray) jsonResponse["result"]["docs"]; int resultsFeedNumber = x.Count; for (int i = 0; i < Math.Min(resultsFeedNumber, maxResults); i++) { var result = jsonResponse["result"]["docs"][i]; var title = (string)result["source"]["enriched"]["url"]["title"]; DataFeed feed = new DataFeed { Link =(string)result["source"]["enriched"]["url"]["url"], Title = title, PublishTime = UnixTimeStampToDateTime((string)result["timestamp"]), Source = getSource(title), Image = null }; feeds.Add(feed); } return feeds.ToArray(); }
public System.Collections.Generic.List<DataFeed> GetDataFeed(PricingLibrary.FinancialProducts.IOption option, System.DateTime fromDate) { System.Collections.Generic.List<DataFeed> result = new System.Collections.Generic.List<DataFeed>() ; using (DataBaseDataContext mtdc = new DataBaseDataContext()) { var result1 = (from s in mtdc.HistoricalShareValues where ((option.UnderlyingShareIds.Contains(s.id)) && (s.date >= fromDate)&&(s.date<=option.Maturity)) select s).OrderByDescending(d => d.date).ToList(); System.DateTime curentdate = result1[result1.Count() - 1].date; System.Collections.Generic.Dictionary<String, decimal> priceList = new System.Collections.Generic.Dictionary<String, decimal>(); for (int i = result1.Count() - 1; i >= 0 ; i--) { if (result1[i].date==curentdate) { priceList.Add(result1[i].id.Trim(), result1[i].value); } else { DataFeed datafeed = new DataFeed(curentdate, priceList); result.Add(datafeed); curentdate = result1[i].date; priceList = new System.Collections.Generic.Dictionary<String, decimal>(); priceList.Add(result1[i].id.Trim(), result1[i].value); } if (i == 0) { DataFeed datafeedOut = new DataFeed(curentdate, priceList); result.Add(datafeedOut); } } return result; } }
private void datafeed_StatusUpdate(object sender, DataFeed.HSEventArgs e) { Debug.WriteLine("STATUS UPDATE " + e.theString); if (e.theString == "Logged on to server") { StartFeed(_Instrument); } }
private void Initialize() { // Initialize classes that create displays and handle data pageManager = new PageManager(); dataFeed = new DataFeed(this.UnitsPivot.Name); // Better way? // Load the page titles pageNames = dataFeed.GetPageTitles(); }
public StreamingDataViewModel(DataFeed dataFeed) { AllValues = new ReactiveList<int>(); AllValuesViewModels = AllValues.CreateDerivedCollection(x => x); StartRecievingData = new ReactiveCommand(); var s = StartRecievingData.RegisterAsync(x => dataFeed.GetInfiniteSequence(1000)) .Subscribe(d => { TheValue = d; //this works how I expect //AllValues.Add(d); //this crashes. Why? }); }
public async Task CreateAndUpdateBlobDataFeed() { var adminClient = GetMetricsAdvisorAdministrationClient(); InitDataFeedSources(); DataFeed createdDataFeed = await adminClient.CreateDataFeedAsync(_blobFeedName, _blobSource, _dailyGranularity, _dataFeedSchema, _dataFeedIngestionSettings, _dataFeedOptions).ConfigureAwait(false); Assert.That(createdDataFeed.Id, Is.Not.Null); createdDataFeed.Options.Description = Recording.GenerateAlphaNumericId("desc"); await adminClient.UpdateDataFeedAsync(createdDataFeed.Id, createdDataFeed).ConfigureAwait(false); await adminClient.DeleteDataFeedAsync(createdDataFeed.Id); }
static DataFeed CreateDataFeed() { var builder = new FixConnectionStringBuilder { SecureConnection = true, Port = 5003, Address = Settings.Default.DataSources_FDK_Server, Username = Settings.Default.DataSources_FDK_Username, Password = Settings.Default.DataSources_FDK_Password, }; var dataFeed = new DataFeed(builder.ToString()); return(dataFeed); }
internal async Task <MetricAnomalyDetectionConfiguration> CreateMetricAnomalyDetectionConfiguration(MetricsAdvisorAdministrationClient adminClient) { DataFeed feed = await GetFirstDataFeed(adminClient).ConfigureAwait(false); var config = new MetricAnomalyDetectionConfiguration( feed.MetricIds.First(), Recording.GenerateAlphaNumericId("Name"), new MetricAnomalyDetectionConditions( DetectionConditionsOperator.And, new SmartDetectionCondition(42, AnomalyDetectorDirection.Both, new SuppressCondition(1, 67)), new HardThresholdCondition(23, 45, AnomalyDetectorDirection.Both, new SuppressCondition(1, 50)), new ChangeThresholdCondition(12, 5, true, AnomalyDetectorDirection.Both, new SuppressCondition(1, 1)))); return(await adminClient.CreateMetricAnomalyDetectionConfigurationAsync(config).ConfigureAwait(false)); }
internal static async Task <DataFeed> GetFirstDataFeed(MetricsAdvisorAdministrationClient adminClient) { DataFeed feed = null; IAsyncEnumerable <Page <DataFeed> > pages = adminClient.GetDataFeedsAsync(new GetDataFeedsOptions { TopCount = 1 }).AsPages(); await foreach (var page in pages) { //Only perform a single iteration. feed = page.Values?.FirstOrDefault(); break; } return(feed); }
protected void Page_Load(object sender, EventArgs e) { GooglePageBase google = Page as GooglePageBase; DataQuery query = new DataQuery(); query.Ids = "ga:" + google.Settings.Current.Id;; query.Metrics = "ga:visits,ga:pageviews,ga:timeOnSite,ga:exits"; query.Dimensions = "ga:source,ga:medium"; query.Sort = "-ga:visits"; query.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-1).ToString("yyyy-MM-dd"); query.GAEndDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); if (google.Referringpage != null) { query.Filters = "ga:pagePath==" + google.Referringpage; } DataFeed actual = google.Analytics.Query(query); System.Data.DataTable dt = new System.Data.DataTable("Usage"); dt.Columns.Add("Visits", typeof(int)); dt.Columns.Add("Page Views", typeof(int)); dt.Columns.Add("Time On Site", typeof(int)); dt.Columns.Add("Exits", typeof(int)); dt.Columns.Add("Source"); //, typeof(int)); dt.Columns.Add("Medium"); //, typeof(int)); foreach (DataEntry entry in actual.Entries) { try { int visits = int.Parse(entry.Metrics[0].Value); int pageviews = int.Parse(entry.Metrics[1].Value); float timeOnSite = float.Parse(entry.Metrics[2].Value); int exits = int.Parse(entry.Metrics[3].Value); string source = entry.Dimensions[0].Value.ToString(); string medium = entry.Dimensions[1].Value.ToString(); dt.Rows.Add(new object[] { visits, pageviews, timeOnSite, exits, source, medium }); } catch (Exception ex) { Response.Write(ex.ToString()); } } this.tbl_Usage.ChartData(dt); }
public override void LoadDataFeed(DataFeed dataFeed) { base.LoadDataFeed(dataFeed); this.SetTextBoxBinding( this.TextBoxMaxIterations, Shared.DATASHEET_RUN_CONTROL_NAME, Shared.DATASHEET_RUN_CONTROL_MAX_ITERATION_COLUMN_NAME); MultiRowDataFeedView v = (MultiRowDataFeedView)this.PanelJurisdictions.Controls[0]; v.LoadDataFeed(dataFeed, Shared.DATASHEET_RUNTIME_JURISDICTION_NAME); this.RefreshDateTimeControls(); this.m_IsLoaded = true; }
public DataFeedHistorySource(DataFeed dataFeed, int attemptsNumber, int timeoutInMilliseconds) { if (dataFeed == null) { throw new ArgumentNullException(nameof(dataFeed), "Data feed can not be null"); } if (attemptsNumber < 1) { throw new ArgumentOutOfRangeException(nameof(attemptsNumber), attemptsNumber, "Attempts number shuld be more than zero"); } this.dataFeed = dataFeed; this.attemptsNumber = attemptsNumber; this.Timeout = timeoutInMilliseconds; }
public IEnumerable <DataFeed> GetFeeds(IVkDataProvider dataProvider, VkGroup vkGroup) { var memberFeed = dataProvider.GetGroupMemberIds(vkGroup.Id.ToString(), 0); this.log.DebugFormat("Users feed is received: {0}", memberFeed.Feed); DataFeed dataFeed = new DataFeed { ReceivedAt = this.dateTimeHelper.GetDateTimeNow(), Feed = memberFeed.Feed, VkGroupId = vkGroup.Id, Type = DataFeedType.MembersCount }; yield return(dataFeed); }
private static void InitializeCalculator(FinancialCalculator calculator, DataFeed dataFeed, SymbolInfo[] symbols) { var dtUtcNow = DateTime.UtcNow; var currenciesHashSet = new HashSet <string>(); symbols.ToList().ForEach(s => { var symbolEntry = new SymbolEntry(calculator, s.Name, s.SettlementCurrency, s.Currency) { ContractSize = s.RoundLot, MarginFactor = s.MarginFactor, Hedging = s.MarginHedge }; calculator.Symbols.Add(symbolEntry); if (currenciesHashSet.Add(s.Currency)) { calculator.Currencies.Add(s.Currency); } if (currenciesHashSet.Add(s.SettlementCurrency)) { calculator.Currencies.Add(s.SettlementCurrency); } try { double priceBid = 0; double priceAsk = 0; TryGetBidAsk(dataFeed, s.Name, ref priceBid, ref priceAsk); try { calculator.Prices.Update(s.Name, priceBid, priceAsk); } catch (Exception ex) { Log.Error(string.Format("Failed to update calculator for symbol: {0} exception: {1}", s.Name, ex)); } } catch (Exception ex) { Log.Error(string.Format("Failed to get bid/ask for symbol {0}", s.Name)); } }); currenciesHashSet.Clear(); }
public IEnumerable <DataFeed> GetFeeds(IVkDataProvider dataProvider, VkGroup vkGroup) { int offsetCounter = 0; while (true) { var memberFeed = dataProvider.GetGroupMemberIds(vkGroup.Id.ToString(), offsetCounter); this.log.DebugFormat("Users feed is received: {0}", memberFeed.Feed); if (memberFeed.users == null || memberFeed.users.Length == 0) { break; } if (memberFeed.users[0].uid == null || memberFeed.users[0].uid.Length == 0) { break; } var userIds = memberFeed.users[0].uid.Select(u => u.Value).ToList(); var maxFetches = (int)Math.Floor((double)userIds.Count / CONST_MembersToFetchAtOnce); for (int i = 0; i < maxFetches; i++) { List <string> ids = userIds.Skip(i * CONST_MembersToFetchAtOnce).Take(CONST_MembersToFetchAtOnce).ToList(); if (ids.Count == 0) { break; } var userProfiles = dataProvider.GetUserProfiles(ids); DataFeed dataFeed = new DataFeed { ReceivedAt = this.dateTimeHelper.GetDateTimeNow(), Feed = userProfiles.Feed, VkGroupId = vkGroup.Id, Type = DataFeedType.MembersInfo }; yield return(dataFeed); } offsetCounter += userIds.Count; } }
/// <summary> /// Initializes a new instance of the <see cref="PortfolioImplementations"/> class. /// </summary> /// <param name="actionsScheduler">The actions scheduler.</param> /// <param name="api">The API.</param> /// <param name="brokerconnection">The brokerconnection.</param> /// <param name="cluster">The cluster.</param> /// <param name="datafeed">The datafeed.</param> /// <param name="datafilter">The datafilter.</param> /// <param name="eventrunner">The eventrunner.</param> /// <param name="exceptionhandler">The exceptionhandler.</param> /// <param name="messagequeue">The messagequeue.</param> /// <param name="ordertickethandler">The ordertickethandler.</param> /// <param name="currency">The currency.</param> public PortfolioImplementations(ActionsScheduler actionsScheduler, Benchmark benchmark, BrokerConnection brokerconnection, Cluster cluster, DataFeed datafeed, DataFilter datafilter, EventRunner eventrunner, ExceptionHandler exceptionhandler, MessageQueue messagequeue, OrderTicketHandler ordertickethandler, Currency currency) { ActionsScheduler = actionsScheduler; Benchmark = benchmark; BrokerConnection = brokerconnection; Cluster = cluster; DataFeed = datafeed; DataFilter = datafilter; EventRunner = eventrunner; ExceptionHandler = exceptionhandler; MessageQueue = messagequeue; OrderTicketHandler = ordertickethandler; Currency = currency; }
public static List <DataFeed> getDBDataFeed(IOption option, DateTime from) { List <DataFeed> feeds = new List <DataFeed>(); using (SqlConnection connection1 = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataReader reader; cmd.CommandText = "SELECT DISTINCT * FROM HistoricalShareValues WHERE date >= @param1 ORDER BY date, id"; cmd.Parameters.Add(new SqlParameter("@param1", from)); cmd.CommandType = CommandType.Text; cmd.Connection = connection1; connection1.Open(); reader = cmd.ExecuteReader(); string id; DateTime lastDate = from; DateTime date; decimal value; Dictionary <string, decimal> priceList = new Dictionary <string, decimal>(); while (reader.Read()) { id = !reader.IsDBNull(0) ? reader.GetString(0) : ""; date = !reader.IsDBNull(1) ? reader.GetDateTime(1) : new DateTime(0); value = !reader.IsDBNull(2) ? reader.GetDecimal(2) : 0; if (date != lastDate) { DataFeed feed = new DataFeed(lastDate, priceList); feeds.Add(feed); priceList = new Dictionary <string, decimal>(); lastDate = date; } if (option.UnderlyingShareIds.Contains(id)) { priceList.Add(id, value); } } connection1.Close(); return(feeds); } }
protected async Task <DisposableDataFeed> CreateTempDataFeedAsync(MetricsAdvisorAdministrationClient adminClient) { var dataFeed = new DataFeed() { Name = Recording.GenerateAlphaNumericId("dataFeed"), DataSource = new SqlServerDataFeedSource("connString", "query"), Granularity = new DataFeedGranularity(DataFeedGranularityType.Daily), Schema = new DataFeedSchema() { MetricColumns = { new DataFeedMetric(TempDataFeedMetricName) }, DimensionColumns = { new DataFeedDimension(TempDataFeedDimensionNameA), new DataFeedDimension(TempDataFeedDimensionNameB) } }, IngestionSettings = new DataFeedIngestionSettings(SamplingStartTime) }; return(await DisposableDataFeed.CreateDataFeedAsync(adminClient, dataFeed)); }
private void DoDispose() { DataFeed feed = m_feed; m_feed = null; if ((null != feed) && IsInitialized) { feed.Stop(); feed.Dispose(); } m_continue = false; m_event.Set(); if (null != m_thread) { m_thread.Join(); m_thread = null; } }
public async Task GetMetricDimensionValues() { var adminClient = GetMetricsAdvisorAdministrationClient(); var client = GetMetricsAdvisorClient(); DataFeed feed = await GetFirstDataFeed(adminClient); foreach (var metricId in feed.MetricIds) { foreach (MetricDimension dimension in feed.Schema.DimensionColumns) { await foreach (string value in client.GetMetricDimensionValuesAsync(metricId, dimension.DimensionName)) { Assert.That(!string.IsNullOrEmpty(value)); } } } }
public void SetupPathsAndConnect(string rootPath) { if (Initialized) { throw new InvalidOperationException("Fdk seems to be initialized for second time"); } Initialized = true; // create and specify log directory string root; if (string.IsNullOrEmpty(rootPath)) { var assembly = Assembly.GetEntryAssembly(); root = assembly == null?Directory.GetCurrentDirectory() : assembly.Location; root = Path.GetDirectoryName(root); if (root == null) { throw new InvalidDataException("FDK assembly's directory seems to be invalid"); } } else { root = rootPath; } var logsPath = Path.Combine(root, "Logs\\Fix"); Directory.CreateDirectory(logsPath); Builder.FixLogDirectory = logsPath; Feed = new DataFeed(Builder.ToString()) { SynchOperationTimeout = 18000 }; var storagePath = Path.Combine(root, "Storage"); Directory.CreateDirectory(storagePath); Storage = new DataFeedStorage(storagePath, StorageProvider.Ntfs, Feed, true); }
protected void Page_Load(object sender, EventArgs e) { google = Page as GooglePageBase; try { //dimensions=ga:operatingSystem,ga:operatingSystemVersion,ga:browser,ga:browserVersion //metrics=ga:visits DataQuery query = new DataQuery(); query.Ids = "ga:" + google.Settings.Current.Id;; query.Dimensions = "ga:operatingSystem,ga:operatingSystemVersion"; query.Metrics = "ga:visits"; query.Sort = "-ga:visits"; query.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-1).ToString("yyyy-MM-dd"); query.GAEndDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); if (google.Referringpage != null) { query.Filters = "ga:pagePath==" + google.Referringpage; } DataFeed actual = google.Analytics.Query(query); System.Data.DataTable dt = new System.Data.DataTable("Operating Systems"); dt.Columns.Add("Operating System"); dt.Columns.Add("System Version"); dt.Columns.Add("Visits", typeof(int)); foreach (DataEntry entry in actual.Entries) { int visits = int.Parse(entry.Metrics[0].Value); string os = entry.Dimensions[0].Value.ToString(); string osVersion = entry.Dimensions[1].Value.ToString(); dt.Rows.Add(new object[] { os, osVersion, visits }); } this.tbl_OS.ChartData(dt); } catch (Exception ex) { ex.ToString(); //TextBox1.Text = ex.ToString(); } }
void CorrectSubscribeToQuotes(ConnectionStringBuilder builder) { var connectionString = builder.ToString(); this.dataFeed = new DataFeed(connectionString); this.dataFeed.Logon += this.OnLogon; this.dataFeed.Start(); var status = this.logonEvent.WaitOne(LogonWaitingTimeout); Assert.IsTrue(status, "Timeout of logon event"); var symbols = new[] { "EURUSD" }; this.dataFeed.Server.SubscribeToQuotes(symbols, 0); this.dataFeed.Stop(); this.dataFeed.Logon -= this.OnLogon; }
public IHttpActionResult Get() { var data = StorageHelper.Read <DataSet>(Constants.FileName) ?? new DataSet(); Guid?lastOperationId = null; if (data.Operations.Count > 0) { lastOperationId = data.Operations.Last().Id; } var feed = new DataFeed { Items = data.Items, LastOperationId = lastOperationId }; return(Ok(feed)); }
public void UpdateDataFeedRespectsTheCancellationToken() { MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient(); var dataSource = new AzureTableDataFeedSource("connectionString", "table", "query"); var granularity = new DataFeedGranularity(DataFeedGranularityType.Daily); var schema = new DataFeedSchema(new List <DataFeedMetric>() { new DataFeedMetric("metricName") }); var ingestionSettings = new DataFeedIngestionSettings(DateTimeOffset.UtcNow); var dataFeed = new DataFeed("dataFeedName", dataSource, granularity, schema, ingestionSettings); using var cancellationSource = new CancellationTokenSource(); cancellationSource.Cancel(); Assert.That(() => adminClient.UpdateDataFeedAsync(FakeGuid, dataFeed, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>()); Assert.That(() => adminClient.UpdateDataFeed(FakeGuid, dataFeed, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>()); }
public ActionResult ViewHtml(FeedModel model) { //model.App = "view"; model.Provider = Provider; model.CurrentPage = "Feed"; model.CurrentSubMenuItem = "list"; DataFeed feed = model.GetFeed(); if (feed != null) { if (feed.FeedType == DataFeedType.Python) { try { var result = _engine.Run(feed.FeedQuery, GetParameters(feed)); if (result.Exception != null) { throw result.Exception; } model.Title = result.Title; model.Html = new HtmlString(result.Html.ToString()); } catch (Exception ex) { //model.App = "ViewHtml"; model.ErrorMessage = ex.Message; return(View("Launcher", model)); } } else { model.ErrorMessage = "Feed type does not support HTML viewing"; } } else { model.ErrorMessage = "Could not find feed: " + model.Alias; } return(View(model)); }
public override MarketDataFrame Tick() { var dataPoint = DataFeed.Tick(); foreach (var order in pendingOrders) { switch (order.Type) { case OrderType.LimitOrder: ProcessLimitOrder(order, dataPoint[order.Security]); break; default: throw new Exception($"Unsupported order type: {order.Type}"); } } return(dataPoint); }
public DataFeed_KeywordsCost(DateTime Start, DateTime Finish, string GALogin, string GAPassword, string ids) { string start = Start.ToString("yyyy-MM-dd"); AnalyticsService asv = new AnalyticsService("gaExportAPI_acctSample_v2.0"); asv.setUserCredentials(GALogin, GAPassword); String baseUrl = "https://www.google.com/analytics/feeds/data"; DataQuery query = new DataQuery(baseUrl); query.Ids = "ga:" + ids; query.Dimensions = "ga:adGroup,ga:keyword"; query.Metrics = "ga:CPC"; query.GAStartDate = Start.ToString("yyyy-MM-dd"); query.NumberToRetrieve = 10000; query.GAEndDate = Start.ToString("yyyy-MM-dd"); feed = asv.Query(query); }
public List <String> getProfileIdList() { try { List <String> profilesIdList = new List <String>(); GDataGAuthRequestFactory requestFactory = new GDataGAuthRequestFactory("analytics", "GTGATracker"); requestFactory.AccountType = "GOOGLE"; AnalyticsProxy = new AnalyticsProxy(requestFactory); this.RequestFactory = requestFactory; this.setUserCredentials(GetEmail(), GetPassword()); string queri = ConfigurationManager.AppSettings["FeedAccountsUri"] + ConfigurationManager.AppSettings["API_Key"]; string webProfileId = ""; string webPropertie = ""; string profileIdUrl = ""; List <String> webProfilesList = new List <String>(); List <String> idList = new List <String>(); DataQuery query = new DataQuery(queri); DataFeed feedWebProperty = this.Query(query); foreach (AtomEntry entry in feedWebProperty.Entries) { webProfileId = entry.Links[1].HRef.Content; DataQuery propertyQuery = new DataQuery(webProfileId); DataFeed feedProfile = this.Query(propertyQuery); foreach (DataEntry entri in feedProfile.Entries) { webPropertie = entri.Links[2].HRef.Content; DataQuery profileIdQuery = new DataQuery(webPropertie); DataFeed feedProfileId = this.Query(profileIdQuery); foreach (DataEntry entrie in feedProfileId.Entries) { idList.Add(entrie.Links[0].HRef.Content); profileIdUrl = entrie.Links[0].HRef.Content; } } } return(idList); } catch (GDataRequestException e) { throw e; } }
public async Task DataFeedSourceGetsUnknownDataFeed() { MockResponse getResponse = new MockResponse(200); getResponse.SetContent(UnknownDataFeedContent); MetricsAdvisorAdministrationClient adminClient = CreateInstrumentedAdministrationClient(getResponse); DataFeed dataFeed = await adminClient.GetDataFeedAsync(FakeGuid); Assert.That(dataFeed.Id, Is.EqualTo(FakeGuid)); Assert.That(dataFeed.Name, Is.EqualTo("unknownDataFeedName")); Assert.That(dataFeed.MissingDataPointFillSettings.FillType, Is.EqualTo(DataFeedMissingDataPointFillType.NoFilling)); Assert.That(dataFeed.Description, Is.EqualTo("unknown data feed description")); DataFeedMetric metric = dataFeed.Schema.MetricColumns.Single(); Assert.That(metric.Id, Is.EqualTo(FakeGuid)); Assert.That(metric.Name, Is.EqualTo("cost")); }
public void QuerySiteStatsResultForPeriod() { AnalyticsService service = new AnalyticsService(this.ApplicationName); service.Credentials = new GDataCredentials(this.userName, this.passWord); DataQuery query = new DataQuery(DataFeedUrl); query.Ids = this.accountId; query.Metrics = "ga:pageviews,ga:visits,ga:newVisits,ga:transactions,ga:uniquePageviews"; query.GAStartDate = new DateTime(2009, 04, 19).ToString("yyyy-MM-dd"); query.GAEndDate = new DateTime(2009, 04, 25).ToString("yyyy-MM-dd"); query.StartIndex = 1; DataFeed actual = service.Query(query); Assert.IsNotNull(actual.Aggregates); Assert.AreEqual(5, actual.Aggregates.Metrics.Count); }
private DataFeed CreateDataFeed() { string data; using (StreamReader streamReader = File.OpenText(@"C:\1.xml")) { data = streamReader.ReadToEnd(); } DataFeed dataFeed = new DataFeed() { ReceivedAt = this.dateTimeHelper.GetDateTimeNow(), Feed = data, VkGroupId = 14721677, Type = DataFeedType.WallPosts }; return(dataFeed); }
private void SubscribeSymbolfromDB() { IList <OptionProcessingService.Types.Symbol> symbollist = DB.GetSymbols(); foreach (var dbsymbol in symbollist) { //var symbol=TimestampUtility.BuildSymbolName(dbsymbol.ShortName, dbsymbol.Type == SecurityType.Forex ? //CommonObjects.Unitity.Instrument.Forex : CommonObjects.Unitity.Instrument.Equity); subscribesymbolList.Add(new ServerMess.SymbolItem() { Symbol = dbsymbol.ShortName, Type = dbsymbol.Type == Enums.SecurityType.Currency?Instrument.Forex:Instrument.Equity, DataFeed = DataFeed.Where(x => x.Name == feedName).FirstOrDefault().Name }); System.Console.WriteLine("Subscribing for Symbol : " + dbsymbol.ShortName); Logger.Info("Subscribing for Symbol : " + dbsymbol.ShortName); } SubscribeSymbolList(subscribesymbolList); }
public void QueryTransactionIdReturnAllResults() { AnalyticsService service = new AnalyticsService(this.ApplicationName); service.Credentials = new GDataCredentials(this.userName, this.passWord); int currentIndex = 1; const int resultsPerPage = 1000; List <DataFeed> querys = new List <DataFeed>(); DataQuery query = new DataQuery(DataFeedUrl); query.Ids = this.accountId; query.Dimensions = "ga:transactionId,ga:date"; query.Metrics = "ga:transactionRevenue"; query.Sort = "ga:date"; query.GAStartDate = new DateTime(2009, 04, 01).ToString("yyyy-MM-dd"); query.GAEndDate = new DateTime(2009, 04, 30).ToString("yyyy-MM-dd"); query.NumberToRetrieve = resultsPerPage; query.StartIndex = currentIndex; DataFeed actual = service.Query(query); querys.Add(actual); double totalPages = Math.Round(((double)actual.TotalResults / (double)resultsPerPage) + 0.5); for (int i = 1; i < totalPages; i++) { currentIndex += resultsPerPage; query.StartIndex = currentIndex; actual = service.Query(query); querys.Add(actual); } for (int i = 0; i < querys.Count; i++) { foreach (DataEntry entry in querys[i].Entries) { Assert.IsNotNull(entry.Id); } } }
public async Task ReadLatestDataFeed() { var mapper = new DataFeedMapper(); var configuration = new Mock <IDataFeedRepositoryConfiguration>(); configuration.Setup(c => c.StorageFolderPath).Returns(storageFolderPath); var repository = new DataFeedRepository(configuration.Object, mapper); var dataFeed1 = new DataFeed() { Base = "EUR", Success = true, Timestamp = 1541819346, Rates = new Dictionary <string, decimal>() { { "ETB", 31.813406m }, { "EUR", 1m }, { "GBP", 0.873592m } } }; await repository.SaveAsync(dataFeed1); var dataFeed2 = new DataFeed() { Base = "EUR", Success = true, Timestamp = 1541819446, Rates = new Dictionary <string, decimal>() { { "ETB", 31.813406m }, { "EUR", 1m }, { "GBP", 0.873592m } } }; await repository.SaveAsync(dataFeed2); var dataFeed = await repository.LoadAsync(); Assert.AreEqual(dataFeed2.Timestamp, dataFeed.Timestamp, "Should load latest DataFeed"); }
static string DataTypeToURL(DataFeed.DataType dataType) { switch (dataType) { case DataType.Daily: return "d"; case DataType.Monthly: return "m"; case DataType.Weekly: return "w"; case DataType.Dividends: return "v"; default: return ""; } }
/// <summary> /// Creates and initializes a new data feed storage Ver.1. /// </summary> /// <param name="location">Specified location for data feed history local cache.</param> /// <param name="storageProviderType">Type of storage provider.</param> /// <param name="dataFeed">Can be null, in this case you can use storage in offline mode only.</param> /// <param name="flushOnDispose">If true, then quotes cache in memory will be flushed to hard drive.</param> /// <exception cref="System.ArgumentNullException">If location is null.</exception> public DataFeedStorage(string location, Type storageProviderType, DataFeed dataFeed, bool flushOnDispose) : this(location, storageProviderType, 1, dataFeed, flushOnDispose) { }
/// <summary> /// Binds / unbinds data feed for tick events. /// Storage uses tick events, if newDataFeed is not null /// Storage does not use tick events, if newDataFeed is null /// </summary> /// <param name="newDataFeed">A data feed instance or null</param> public void Bind(DataFeed newDataFeed) { lock (this.synchronizer) { if (this.updateFeed != newDataFeed) { this.DoBind(newDataFeed); } } }
private void datafeed_onError(object sender, DataFeed.HSEventArgs e) { Debug.WriteLine(e.theString); }
private void datafeed_onBidask(object sender, DataFeed.aBidAsk e) { LivePrice.Bid = (double)e.BidPrice; LivePrice.Offer = (double)e.AskPrice; LivePrice.LastUpdate = DateTime.UtcNow.AddHours(2); }
/// <summary> /// Example /// MMM Apr 5, 1970 - 27 Feb,2009, daily /// http://ichart.finance.yahoo.com/table.csv?s=MMM&a=03&b=5&c=1970&d=01&e=27&f=2009&g=d&ignore=.csv /// </summary> static bool buildURL(string symbol, DateTime start, DateTime end, DataFeed.DataType dataType, out string url) { url = ""; string dataTypeURL = DataTypeToURL(dataType); if (dataTypeURL == "") { return false; } symbol = symbol.ToUpper(); url = "http://ichart.finance.yahoo.com/table.csv?s=" + symbol + "&a=" + Month2Str(start.Month) + "&b=" + start.Day + "&c=" + start.Year + "&d=" + end.Month + "&e=" + end.Day + "&e=" + end.Year + "&g=" + dataTypeURL + "&ignore=.csv"; return true; }
void DoBind(DataFeed newDataFeed) { if (this.updateFeed != null) { this.updateFeed.Tick -= this.OnTick; this.updateFeed.Logout -= this.OnLogout; this.updateFeed = null; } if (newDataFeed != null) { newDataFeed.Logout += this.OnLogout; } try { if (newDataFeed != null) { newDataFeed.Tick += this.OnTick; } this.updateFeed = newDataFeed; } catch { if (newDataFeed != null) { newDataFeed.Logout -= this.OnLogout; } throw; } }
/// <summary> /// Creates and initializes a new data feed storage. /// </summary> /// <param name="location">Specified location for data feed history local cache.</param> /// <param name="storageProviderType">Type of storage provider.</param> /// <param name="storageVersion">Storage version.</param> /// <param name="dataFeed">Can be null, in this case you can use storage in offline mode only.</param> /// <param name="flushOnDispose">If true, then quotes cache in memory will be flushed to hard drive.</param> /// <exception cref="System.ArgumentNullException">If location is null.</exception> public DataFeedStorage(string location, Type storageProviderType, int storageVersion, DataFeed dataFeed, bool flushOnDispose) : this(location, storageProviderType, storageVersion, dataFeed, flushOnDispose, true) { }
private void datafeed_StatusUpdate(object sender, DataFeed.HSEventArgs e) { Debug.WriteLine("STATUS UPDATE " + e.theString); }
private void datafeed_onTrade(object sender, DataFeed.aTrade e) { Debug.WriteLine("TRADE" + e.TradePrice); }
private void datafeed_onAsk(object sender, DataFeed.aAsk e) { Debug.WriteLine("ASK " + e.AskPrice); }
private void datafeed_onBid(object sender, DataFeed.aBid e) { Debug.WriteLine("BID " + e.BidPrice); }
IEnumerable<DataSample> AllSamples(bool logging) { if (dataFeed == null) dataFeed = new DataFeed(iRacingMemory.Accessor); var nextTickCount = 0; var lastTickTime = DateTime.Now; var watchProcessingTime = new Stopwatch(); var watchWaitingTime = new Stopwatch(); while (true) { watchWaitingTime.Restart(); iRacingMemory.WaitForData(); waitingTime = watchWaitingTime.ElapsedTicks; watchProcessingTime.Restart(); var data = dataFeed.GetNextDataSample(nextTickCount, logging); if (data != null) { if (data.IsConnected) { if (data.Telemetry.TickCount == nextTickCount - 1) continue; //Got the same sample - try again. if (logging && data.Telemetry.TickCount != nextTickCount && nextTickCount != 0) Debug.WriteLine("Warning dropped DataSample from {0} to {1}. Over time of {2}", nextTickCount, data.Telemetry.TickCount - 1, (DateTime.Now - lastTickTime).ToString(@"s\.fff"), "WARN"); nextTickCount = data.Telemetry.TickCount + 1; lastTickTime = DateTime.Now; } processingTime = watchProcessingTime.ElapsedTicks; watchProcessingTime.Restart(); yield return data; yieldTime = watchProcessingTime.ElapsedTicks; } } }
public bool GetSeries(DateTime start, DateTime end, Equity equity, DataFeed.DataType dataType, out TA.PriceVolumeSeries series) { string symbol = equity.Symbol; bool result = false; series = null; do { int size = (int)Math.Round((end - start).TotalDays); if (size <= 0) { break; } // preallocate some memory series = new TA.PriceVolumeSeries(size); string url; result = buildURL(symbol, start, end, dataType, out url); if (!result) { break; } Console.WriteLine("Get data from URL " + url + " between " + start + " and " + end); HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse(); Stream readStream = httpResponse.GetResponseStream(); result = fillDataArray(readStream, series); } while (false); return result; }
private void datafeed_onBidask(object sender, DataFeed.aBidAsk e) { Debug.WriteLine("BIDask " + " BID " + e.BidPrice + " " + e.AskPrice + " ASK"); }
private void datafeed_onTrade(object sender, DataFeed.aTrade e) { // DataBase.insertTicks(e.TradeTime, Convert.ToInt32(e.TradePrice)); LivePrice.Last = (double)e.TradePrice; LivePrice.LastUpdate = DateTime.UtcNow.AddHours(2); }