本文整理汇总了C#中IResultHandler类的典型用法代码示例。如果您正苦于以下问题:C# IResultHandler类的具体用法?C# IResultHandler怎么用?C# IResultHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IResultHandler类属于命名空间,在下文中一共展示了IResultHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IMapFileProvider mapFileProvider)
{
if (algorithm.SubscriptionManager.Subscriptions.Count == 0 && algorithm.Universes.IsNullOrEmpty())
{
throw new Exception("No subscriptions registered and no universe defined.");
}
_algorithm = algorithm;
_resultHandler = resultHandler;
_mapFileProvider = mapFileProvider;
_subscriptions = new ConcurrentDictionary<Symbol, Subscription>();
_cancellationTokenSource = new CancellationTokenSource();
IsActive = true;
Bridge = new BusyBlockingCollection<TimeSlice>(100);
var ffres = Time.OneSecond;
_fillForwardResolution = Ref.Create(() => ffres, res => ffres = res);
// find the minimum resolution, ignoring ticks
ffres = ResolveFillForwardResolution(algorithm);
// add each universe selection subscription to the feed
foreach (var universe in _algorithm.Universes)
{
var startTimeUtc = _algorithm.StartDate.ConvertToUtc(_algorithm.TimeZone);
var endTimeUtc = _algorithm.EndDate.ConvertToUtc(_algorithm.TimeZone);
AddUniverseSubscription(universe, startTimeUtc, endTimeUtc);
}
}
示例2: EveryAlgorithmEndOfDay
/// <summary>
/// Creates a new <see cref="ScheduledEvent"/> that will fire before market close by the specified time
/// </summary>
/// <param name="algorithm">The algorithm instance the event is fo</param>
/// <param name="resultHandler">The result handler, used to communicate run time errors</param>
/// <param name="start">The date to start the events</param>
/// <param name="end">The date to end the events</param>
/// <param name="endOfDayDelta">The time difference between the market close and the event, positive time will fire before market close</param>
/// <param name="currentUtcTime">Specfies the current time in UTC, before which, no events will be scheduled. Specify null to skip this filter.</param>
/// <returns>The new <see cref="ScheduledEvent"/> that will fire near market close each tradeable dat</returns>
public static ScheduledEvent EveryAlgorithmEndOfDay(IAlgorithm algorithm, IResultHandler resultHandler, DateTime start, DateTime end, TimeSpan endOfDayDelta, DateTime? currentUtcTime = null)
{
if (endOfDayDelta >= Time.OneDay)
{
throw new ArgumentException("Delta must be less than a day", "endOfDayDelta");
}
// set up an event to fire every tradeable date for the algorithm as a whole
var eodEventTime = Time.OneDay.Subtract(endOfDayDelta);
// create enumerable of end of day in algorithm's time zone
var times =
// for every date any exchange is open in the algorithm
from date in Time.EachTradeableDay(algorithm.Securities.Values, start, end)
// define the time of day we want the event to fire, a little before midnight
let eventTime = date + eodEventTime
// convert the event time into UTC
let eventUtcTime = eventTime.ConvertToUtc(algorithm.TimeZone)
// perform filter to verify it's not before the current time
where !currentUtcTime.HasValue || eventUtcTime > currentUtcTime.Value
select eventUtcTime;
return new ScheduledEvent(CreateEventName("Algorithm", "EndOfDay"), times, (name, triggerTime) =>
{
try
{
algorithm.OnEndOfDay();
}
catch (Exception err)
{
resultHandler.RuntimeError(String.Format("Runtime error in {0} event: {1}", name, err.Message), err.StackTrace);
Log.Error(err, string.Format("ScheduledEvent.{0}:", name));
}
});
}
示例3: Ping
public Ping(AlgorithmManager algorithmManager, IApi api, IResultHandler resultHandler)
{
_api = api;
_resultHandler = resultHandler;
_algorithmManager = algorithmManager;
_exitEvent = new ManualResetEventSlim(false);
}
示例4: HandleMessage
/// <summary>
/// Handles a given message
/// </summary>
/// <param name="client">
/// The client.
/// </param>
/// <param name="collectionManager">
/// The collection manager.
/// </param>
/// <param name="resultHandler">
/// The result handler.
/// </param>
/// <param name="messageText">
/// The message text.
/// </param>
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
public async Task HandleMessage(
IDdpConnectionSender client,
ICollectionManager collectionManager,
IResultHandler resultHandler,
string messageText)
{
JObject message = JObject.Parse(messageText);
if (message["msg"] != null)
{
var msg = message["msg"];
if (msg != null)
{
var messageType = (string)msg;
foreach (var handler in this.handlers)
{
if (handler.CanHandle(messageType))
{
await handler.HandleMessage(client, collectionManager, resultHandler, messageText);
}
}
}
}
}
示例5: Run
public void Run(string configuration, IResultHandler resultHandler)
{
Console.WriteLine("Doing work for: " + configuration);
var t = new System.Threading.Tasks.Task(() => { resultHandler.OnSuccess(); });
t.Start();
}
示例6: Run
public void Run(string configuration, IResultHandler resultHandler)
{
TaskRunCount++;
Payloads.Add(configuration);
resultHandler.OnSuccess();
}
示例7: DbResultContext
public DbResultContext(IDbExecuteContext ctx, Type resultType, object resultInstance, IResultHandler resultHandler, IDictionary items)
: base(items)
{
this.ExecuteContext = ctx;
this.ResultType = resultType;
this.ResultInstance = resultInstance;
this.ResultHandler = resultHandler;
}
示例8: LiveTradingRealTimeHandler
/********************************************************
* PUBLIC CONSTRUCTOR
*********************************************************/
/// <summary>
/// Initialize the realtime event handler with all information required for triggering daily events.
/// </summary>
public LiveTradingRealTimeHandler(IAlgorithm algorithm, IDataFeed feed, IResultHandler results, IBrokerage brokerage, AlgorithmNodePacket job)
{
//Initialize:
_algorithm = algorithm;
_events = new List<RealTimeEvent>();
_today = new Dictionary<SecurityType, MarketToday>();
_feed = feed;
_results = results;
}
示例9: Ping
public Ping(AlgorithmManager algorithmManager, IApi api, IResultHandler resultHandler, IMessagingHandler messagingHandler, AlgorithmNodePacket job)
{
_api = api;
_job = job;
_resultHandler = resultHandler;
_messagingHandler = messagingHandler;
_algorithmManager = algorithmManager;
_exitEvent = new ManualResetEventSlim(false);
}
示例10: Initialize
/// <summary>
/// Initializes the data feed for the specified job and algorithm
/// </summary>
public void Initialize(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IMapFileProvider mapFileProvider, IFactorFileProvider factorFileProvider)
{
_algorithm = algorithm;
_resultHandler = resultHandler;
_mapFileProvider = mapFileProvider;
_factorFileProvider = factorFileProvider;
_subscriptions = new SubscriptionCollection();
_universeSelection = new UniverseSelection(this, algorithm, job.Controls);
_cancellationTokenSource = new CancellationTokenSource();
IsActive = true;
var threadCount = Math.Max(1, Math.Min(4, Environment.ProcessorCount - 3));
_controller = new ParallelRunnerController(threadCount);
_controller.Start(_cancellationTokenSource.Token);
var ffres = Time.OneMinute;
_fillForwardResolution = Ref.Create(() => ffres, res => ffres = res);
// wire ourselves up to receive notifications when universes are added/removed
algorithm.UniverseManager.CollectionChanged += (sender, args) =>
{
switch (args.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (var universe in args.NewItems.OfType<Universe>())
{
var config = universe.Configuration;
var start = _frontierUtc != DateTime.MinValue ? _frontierUtc : _algorithm.StartDate.ConvertToUtc(_algorithm.TimeZone);
var marketHoursDatabase = MarketHoursDatabase.FromDataFolder();
var exchangeHours = marketHoursDatabase.GetExchangeHours(config);
Security security;
if (!_algorithm.Securities.TryGetValue(config.Symbol, out security))
{
// create a canonical security object if it doesn't exist
security = new Security(exchangeHours, config, _algorithm.Portfolio.CashBook[CashBook.AccountCurrency], SymbolProperties.GetDefault(CashBook.AccountCurrency));
}
var end = _algorithm.EndDate.ConvertToUtc(_algorithm.TimeZone);
AddSubscription(new SubscriptionRequest(true, universe, security, config, start, end));
}
break;
case NotifyCollectionChangedAction.Remove:
foreach (var universe in args.OldItems.OfType<Universe>())
{
RemoveSubscription(universe.Configuration);
}
break;
default:
throw new NotImplementedException("The specified action is not implemented: " + args.Action);
}
};
}
示例11: ConsoleApplication
public ConsoleApplication(ICommandParser commandParser,
IResultHandler resultHandler,
IInput input,
IExceptionHandler exceptionHandler)
{
_commandParser = commandParser;
_resultHandler = resultHandler;
_input = input;
_exceptionHandler = exceptionHandler;
}
示例12: DefaultBrokerageMessageHandler
/// <summary>
/// Initializes a new instance of the <see cref="DefaultBrokerageMessageHandler"/> class
/// </summary>
/// <param name="algorithm">The running algorithm</param>
/// <param name="job">The job that produced the algorithm</param>
/// <param name="results">The result handler for the algorithm</param>
/// <param name="api">The api for the algorithm</param>
/// <param name="initialDelay"></param>
/// <param name="openThreshold">Defines how long before market open to re-check for brokerage reconnect message</param>
public DefaultBrokerageMessageHandler(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler results, IApi api, TimeSpan? initialDelay = null, TimeSpan? openThreshold = null)
{
_api = api;
_job = job;
_results = results;
_algorithm = algorithm;
_connected = true;
_openThreshold = openThreshold ?? DefaultOpenThreshold;
_initialDelay = initialDelay ?? DefaultInitialDelay;
}
示例13: Initialize
/// <summary>
/// Creates a new BacktestingTransactionHandler using the BacktestingBrokerage
/// </summary>
/// <param name="algorithm">The algorithm instance</param>
/// <param name="brokerage">The BacktestingBrokerage</param>
/// <param name="resultHandler"></param>
public override void Initialize(IAlgorithm algorithm, IBrokerage brokerage, IResultHandler resultHandler)
{
if (!(brokerage is BacktestingBrokerage))
{
throw new ArgumentException("Brokerage must be of type BacktestingBrokerage for use wth the BacktestingTransactionHandler");
}
_brokerage = (BacktestingBrokerage) brokerage;
base.Initialize(algorithm, brokerage, resultHandler);
}
示例14: UserStatusChecker
public UserStatusChecker(
IResultHandler resultHandler,
IUserInfo infoProvider,
IUserRepository repository,
IErrorLogger errorLogger)
{
_resultHandler = resultHandler;
_infoProvider = infoProvider;
_repository = repository;
_errorLogger = errorLogger;
}
示例15: UserMailInfoChecker
public UserMailInfoChecker(
IResultHandler<MailRepository.MailInfo> resultHandler,
IUserInfo infoProvider,
IMailRepository repository,
IErrorLogger errorLogger)
{
_resultHandler = resultHandler;
_repository = repository;
_errorLogger = errorLogger;
_infoProvider = infoProvider;
}