本文整理汇总了C#中Ticks.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Ticks.TryGetValue方法的具体用法?C# Ticks.TryGetValue怎么用?C# Ticks.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticks
的用法示例。
在下文中一共展示了Ticks.TryGetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Creates a new <see cref="TimeSlice"/> for the specified time using the specified data
/// </summary>
/// <param name="utcDateTime">The UTC frontier date time</param>
/// <param name="algorithmTimeZone">The algorithm's time zone, required for computing algorithm and slice time</param>
/// <param name="cashBook">The algorithm's cash book, required for generating cash update pairs</param>
/// <param name="data">The data in this <see cref="TimeSlice"/></param>
/// <param name="changes">The new changes that are seen in this time slice as a result of universe selection</param>
/// <returns>A new <see cref="TimeSlice"/> containing the specified data</returns>
public static TimeSlice Create(DateTime utcDateTime, DateTimeZone algorithmTimeZone, CashBook cashBook, List<KeyValuePair<Security, List<BaseData>>> data, SecurityChanges changes)
{
int count = 0;
var security = new List<KeyValuePair<Security, BaseData>>();
var custom = new List<KeyValuePair<Security, List<BaseData>>>();
var consolidator = new List<KeyValuePair<SubscriptionDataConfig, List<BaseData>>>();
var allDataForAlgorithm = new List<BaseData>(data.Count);
var cash = new List<KeyValuePair<Cash, BaseData>>(cashBook.Count);
var cashSecurities = new HashSet<Symbol>();
foreach (var cashItem in cashBook.Values)
{
cashSecurities.Add(cashItem.SecuritySymbol);
}
Split split;
Dividend dividend;
Delisting delisting;
SymbolChangedEvent symbolChange;
var algorithmTime = utcDateTime.ConvertFromUtc(algorithmTimeZone);
var tradeBars = new TradeBars(algorithmTime);
var ticks = new Ticks(algorithmTime);
var splits = new Splits(algorithmTime);
var dividends = new Dividends(algorithmTime);
var delistings = new Delistings(algorithmTime);
var symbolChanges = new SymbolChangedEvents(algorithmTime);
foreach (var kvp in data)
{
var list = kvp.Value;
var symbol = kvp.Key.Symbol;
// keep count of all data points
if (list.Count == 1 && list[0] is BaseDataCollection)
{
count += ((BaseDataCollection) list[0]).Data.Count;
}
else
{
count += list.Count;
}
BaseData update = null;
var consolidatorUpdate = new List<BaseData>(list.Count);
for (int i = 0; i < list.Count; i++)
{
var baseData = list[i];
if (!kvp.Key.SubscriptionDataConfig.IsInternalFeed)
{
// this is all the data that goes into the algorithm
allDataForAlgorithm.Add(baseData);
if (kvp.Key.SubscriptionDataConfig.IsCustomData)
{
// this is all the custom data
custom.Add(kvp);
}
}
// don't add internal feed data to ticks/bars objects
if (baseData.DataType != MarketDataType.Auxiliary)
{
if (!kvp.Key.SubscriptionDataConfig.IsInternalFeed)
{
// populate ticks and tradebars dictionaries with no aux data
if (baseData.DataType == MarketDataType.Tick)
{
List<Tick> ticksList;
if (!ticks.TryGetValue(symbol, out ticksList))
{
ticksList = new List<Tick> {(Tick) baseData};
ticks[symbol] = ticksList;
}
ticksList.Add((Tick) baseData);
}
else if (baseData.DataType == MarketDataType.TradeBar)
{
tradeBars[symbol] = (TradeBar) baseData;
}
// this is data used to update consolidators
consolidatorUpdate.Add(baseData);
}
// this is the data used set market prices
update = baseData;
}
// include checks for various aux types so we don't have to construct the dictionaries in Slice
else if ((delisting = baseData as Delisting) != null)
{
delistings[symbol] = delisting;
}
//.........这里部分代码省略.........
示例2: PopulateDataDictionaries
/// <summary>
/// Adds the specified <see cref="BaseData"/> instance to the appropriate <see cref="DataDictionary{T}"/>
/// </summary>
private static void PopulateDataDictionaries(BaseData baseData, Ticks ticks, TradeBars tradeBars)
{
var symbol = baseData.Symbol;
// populate data dictionaries
switch (baseData.DataType)
{
case MarketDataType.Tick:
List<Tick> ticksList;
if (!ticks.TryGetValue(symbol, out ticksList))
{
ticksList = new List<Tick> {(Tick) baseData};
ticks[symbol] = ticksList;
}
ticksList.Add((Tick) baseData);
break;
case MarketDataType.TradeBar:
tradeBars[symbol] = (TradeBar) baseData;
break;
}
}