Ejemplo n.º 1
0
		public override WatchlistsItems GetWatchlists(string id) {
			TkCacheData cache = null;
		
			foreach (TkCacheData c in _watchlistItems) {
				if (c.Key == id) {
					cache = c;
					break;
				}
			}
			// Add if not found
			if (cache == null) {
				cache = new TkCacheData();
				cache.Key = id;
				_watchlistItems.Add(cache);
			}
					
			TimeSpan ts = DateTime.Now - cache.AccessTime;
			if (ts.TotalMilliseconds > CacheTimeout) {
				RetryFunc(() => cache.Data = base.GetWatchlists(id), RetryCount, RetryDelay);
				cache.AccessTime = DateTime.Now;
			}
			return (WatchlistsItems)cache.Data;
		}
Ejemplo n.º 2
0
		public override Orders GetAccounts_Orders (string accountNumber) {
			TkCacheData cache = null;
		
			foreach (TkCacheData c in _accountsOrders) {
				if (c.Key == accountNumber) {
					cache = c;
					break;
				}
			}
			// Add if not found
			if (cache == null) {
				cache = new TkCacheData();
				cache.Key = accountNumber;
				_accountsOrders.Add(cache);
			}
					
			TimeSpan ts = DateTime.Now - cache.AccessTime;
			if (ts.TotalMilliseconds > CacheTimeout) {
				RetryFunc(() => cache.Data = base.GetAccounts_Orders(accountNumber), RetryCount, RetryDelay);
				cache.AccessTime = DateTime.Now;
			}
			return (Orders)cache.Data;
		}
Ejemplo n.º 3
0
		public override MarketOptionsExpirations GetMarket_OptionExpirations(string symbol) {
			TkCacheData cache = null;
			foreach (TkCacheData c in _marketOptionsExpirations) {
				if (c.Key == symbol) {
					cache = c;
					break;
				}
			}
			// Add if not found
			if (cache == null) {
				cache = new TkCacheData();
				cache.Key = symbol;
				_marketOptionsExpirations.Add(cache);
			}
			
			TimeSpan ts = DateTime.Now - cache.AccessTime;
			if (ts.TotalMilliseconds > CacheTimeout) {
				RetryFunc(() => cache.Data = base.GetMarket_OptionExpirations(symbol), RetryCount, RetryDelay);
				cache.AccessTime = DateTime.Now;
			}
			return (MarketOptionsExpirations)cache.Data;
		}
Ejemplo n.º 4
0
		public override AccountsHistory GetAccounts_History(string accountNumber, AccountsHistory_Range range, AccountsHistory_Transactions transactions) {
			TkCacheData cache = null;
			string key = accountNumber + range.ToString() + transactions.ToString();
			
			foreach (TkCacheData c in _accounts_History) {
				if (c.Key == key) {
					cache = c;
					break;
				}
			}
			// Add if not found
			if (cache == null) {
				cache = new TkCacheData();
				cache.Key = key;
				_accounts_History.Add(cache);
			}
					
			TimeSpan ts = DateTime.Now - cache.AccessTime;
			if (ts.TotalMilliseconds > CacheTimeout) {
				RetryFunc(() => cache.Data = base.GetAccounts_History(accountNumber, range, transactions), RetryCount, RetryDelay);
				cache.AccessTime = DateTime.Now;
			}
			return (AccountsHistory)cache.Data;
		}