本文整理匯總了C#中System.Contract.GetFutureCode方法的典型用法代碼示例。如果您正苦於以下問題:C# Contract.GetFutureCode方法的具體用法?C# Contract.GetFutureCode怎麽用?C# Contract.GetFutureCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Contract
的用法示例。
在下文中一共展示了Contract.GetFutureCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FindFuture
virtual protected Future FindFuture(Feed feed, TradeInfo info, IList<Contract> contracts, string ticker, out Contract contract)
{
contract = null;
try
{
//First Find Contract;
var words = ticker.Split(' ');
string symbol = ticker;
if (words.Length == 2)
symbol = words[0];
else if (words.Length == 3)
symbol = words[0] + " " + words[1];
foreach (var c in contracts)
{
if (ticker.StartsWith(c.TickerSymbol) && ticker.EndsWith(c.TickerSuffix))
{
contract = c;
break;
}
}
if (contract == null) return null;
var fromDate = info.ReportDate.AddYears(1) > info.Maturity ? info.ReportDate : info.Maturity.AddMonths(-1);
var exps = GetExpirations(feed, contract, fromDate);
if (exps == null || exps.Count == 0) return null;
foreach (var exp in exps)
{
if (contract.GetFutureCode(exp).EndsWith(symbol))
return contract.CreateFuture(exp);
}
return null;
}
catch (Exception x)
{
Logger.Error("FindFuture " + ticker, x);
return null;
}
}