本文整理汇总了C#中IResultHandler类的典型用法代码示例。如果您正苦于以下问题:C# IResultHandler类的具体用法?C# IResultHandler怎么用?C# IResultHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IResultHandler类属于命名空间,在下文中一共展示了IResultHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:tremblayEric,项目名称:LeanHistory,代码行数:30,代码来源:FileSystemDataFeed.cs
示例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));
}
});
}
开发者ID:AlexCatarino,项目名称:Lean,代码行数:45,代码来源:ScheduledEventFactory.cs
示例3: Ping
public Ping(AlgorithmManager algorithmManager, IApi api, IResultHandler resultHandler)
{
_api = api;
_resultHandler = resultHandler;
_algorithmManager = algorithmManager;
_exitEvent = new ManualResetEventSlim(false);
}
开发者ID:rchien,项目名称:Lean,代码行数:7,代码来源:StateCheck.cs
示例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);
}
}
}
}
}
开发者ID:Lavan,项目名称:DdpNet,代码行数:43,代码来源:MessageHandler.cs
示例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();
}
开发者ID:Timxuhj,项目名称:redis.workflow,代码行数:8,代码来源:ThreadPoolTaskHandler.cs
示例6: Run
public void Run(string configuration, IResultHandler resultHandler)
{
TaskRunCount++;
Payloads.Add(configuration);
resultHandler.OnSuccess();
}
开发者ID:timbarrass,项目名称:redis.workflow,代码行数:8,代码来源:BasicWorkflowTests.cs
示例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;
}
开发者ID:mer2,项目名称:devfx,代码行数:8,代码来源:DbResultContext.cs
示例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;
}
开发者ID:intelliBrain,项目名称:Lean,代码行数:15,代码来源:LiveTradingRealTimeHandler.cs
示例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);
}
开发者ID:tremblayEric,项目名称:LeanHistory,代码行数:9,代码来源:StateCheck.cs
示例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);
}
};
}
开发者ID:aajtodd,项目名称:Lean,代码行数:59,代码来源:FileSystemDataFeed.cs
示例11: ConsoleApplication
public ConsoleApplication(ICommandParser commandParser,
IResultHandler resultHandler,
IInput input,
IExceptionHandler exceptionHandler)
{
_commandParser = commandParser;
_resultHandler = resultHandler;
_input = input;
_exceptionHandler = exceptionHandler;
}
开发者ID:raderick,项目名称:MixPanel.CsExport,代码行数:10,代码来源:ConsoleApplication.cs
示例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;
}
开发者ID:bizcad,项目名称:LeanJJN,代码行数:19,代码来源:DefaultBrokerageMessageHandler.cs
示例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);
}
开发者ID:skyfyl,项目名称:Lean,代码行数:17,代码来源:BacktestingTransactionHandler.cs
示例14: UserStatusChecker
public UserStatusChecker(
IResultHandler resultHandler,
IUserInfo infoProvider,
IUserRepository repository,
IErrorLogger errorLogger)
{
_resultHandler = resultHandler;
_infoProvider = infoProvider;
_repository = repository;
_errorLogger = errorLogger;
}
开发者ID:alevshunov,项目名称:ForFun,代码行数:11,代码来源:UserStatusChecker.cs
示例15: UserMailInfoChecker
public UserMailInfoChecker(
IResultHandler<MailRepository.MailInfo> resultHandler,
IUserInfo infoProvider,
IMailRepository repository,
IErrorLogger errorLogger)
{
_resultHandler = resultHandler;
_repository = repository;
_errorLogger = errorLogger;
_infoProvider = infoProvider;
}
开发者ID:alevshunov,项目名称:ForFun,代码行数:11,代码来源:UserMailInfoChecker.cs
示例16: HandleMessage
/// <summary>
/// Processes the changed message
/// </summary>
/// <param name="client">
/// The connection to send replies to the server
/// </param>
/// <param name="collectionManager">
/// The CollectionManager
/// </param>
/// <param name="resultHandler">
/// The ResultHandler
/// </param>
/// <param name="message">
/// The message to process
/// </param>
/// <returns>
/// Task to process the message
/// </returns>
public override Task HandleMessage(
IDdpConnectionSender client,
ICollectionManager collectionManager,
IResultHandler resultHandler,
string message)
{
var changedMessage = JsonConvert.DeserializeObject<Changed>(message);
collectionManager.Changed(changedMessage);
return Task.FromResult(true);
}
开发者ID:Lavan,项目名称:DdpNet,代码行数:29,代码来源:ChangedHandler.cs
示例17: HandleMessage
/// <summary>
/// Processes the ping message
/// </summary>
/// <param name="client">
/// The connection to send replies to the server
/// </param>
/// <param name="collectionManager">
/// The CollectionManager
/// </param>
/// <param name="resultHandler">
/// The ResultHandler
/// </param>
/// <param name="message">
/// The message to process
/// </param>
/// <returns>
/// Task to process the message
/// </returns>
public override Task HandleMessage(
IDdpConnectionSender client,
ICollectionManager collectionManager,
IResultHandler resultHandler,
string message)
{
var pingMessage = JsonConvert.DeserializeObject<Ping>(message);
var pongReply = new Pong() { Id = pingMessage.Id };
return client.SendObject(pongReply);
}
开发者ID:Lavan,项目名称:DdpNet,代码行数:29,代码来源:PingHandler.cs
示例18: WrappedHandler
public WrappedHandler(object handler)
{
DebugCheck.NotNull(handler);
var handlerBase = handler as HandlerBase
?? new ForwardingProxy<HandlerBase>(handler).GetTransparentProxy();
_resultHandler = handler as IResultHandler
?? (handlerBase.ImplementsContract(typeof(IResultHandler).FullName)
? new ForwardingProxy<IResultHandler>(handler).GetTransparentProxy()
: null);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:WrappedHandler.cs
示例19: HandleMessage
/// <summary>
/// Processes the reply message
/// </summary>
/// <param name="client">
/// The connection to send replies to the server
/// </param>
/// <param name="collectionManager">
/// The CollectionManager
/// </param>
/// <param name="resultHandler">
/// The ResultHandler
/// </param>
/// <param name="message">
/// The message to process
/// </param>
/// <returns>
/// Task to process the message
/// </returns>
public Task HandleMessage(
IDdpConnectionSender client,
ICollectionManager collectionManager,
IResultHandler resultHandler,
string message)
{
JObject parsedObject = JObject.Parse(message);
var result = new ReturnedObject((string)parsedObject["msg"], parsedObject, message);
resultHandler.AddResult(result);
return Task.FromResult(true);
}
开发者ID:Lavan,项目名称:DdpNet,代码行数:31,代码来源:ReplyMessageHandler.cs
示例20: LeanEngineAlgorithmHandlers
/// <summary>
/// Initializes a new instance of the <see cref="LeanEngineAlgorithmHandlers"/> class from the specified handlers
/// </summary>
/// <param name="results">The result handler for communicating results from the algorithm</param>
/// <param name="setup">The setup handler used to initialize algorithm state</param>
/// <param name="dataFeed">The data feed handler used to pump data to the algorithm</param>
/// <param name="transactions">The transaction handler used to process orders from the algorithm</param>
/// <param name="realTime">The real time handler used to process real time events</param>
/// <param name="historyProvider">The history provider used to process historical data requests</param>
/// <param name="commandQueue">The command queue handler used to receive external commands for the algorithm</param>
/// <param name="mapFileProvider">The map file provider used to retrieve map files for the data feed</param>
public LeanEngineAlgorithmHandlers(IResultHandler results,
ISetupHandler setup,
IDataFeed dataFeed,
ITransactionHandler transactions,
IRealTimeHandler realTime,
IHistoryProvider historyProvider,
ICommandQueueHandler commandQueue,
IMapFileProvider mapFileProvider
)
{
if (results == null)
{
throw new ArgumentNullException("results");
}
if (setup == null)
{
throw new ArgumentNullException("setup");
}
if (dataFeed == null)
{
throw new ArgumentNullException("dataFeed");
}
if (transactions == null)
{
throw new ArgumentNullException("transactions");
}
if (realTime == null)
{
throw new ArgumentNullException("realTime");
}
if (historyProvider == null)
{
throw new ArgumentNullException("realTime");
}
if (commandQueue == null)
{
throw new ArgumentNullException("commandQueue");
}
if (mapFileProvider == null)
{
throw new ArgumentNullException("mapFileProvider");
}
_results = results;
_setup = setup;
_dataFeed = dataFeed;
_transactions = transactions;
_realTime = realTime;
_historyProvider = historyProvider;
_commandQueue = commandQueue;
_mapFileProvider = mapFileProvider;
}
开发者ID:tremblayEric,项目名称:LeanHistory,代码行数:62,代码来源:LeanEngineAlgorithmHandlers.cs
注:本文中的IResultHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论