public async virtual Task <Strategy> RunAsync(CancellationToken cancellationToken) { if (Strategy == null) { throw new Exception("Strategy not set."); } this.cancellationToken = cancellationToken; await TryUpdateStrategyAsync(Strategy.Parameters); while (run) { if (this.cancellationToken.IsCancellationRequested) { run = false; } else { await Task.Delay(500); } } var strategyNotification = new StrategyNotification { Name = Strategy.Name, Message = $"Stopping {Strategy.Name}", NotificationLevel = NotificationLevel.DisconnectClient }; StrategyNotification(new StrategyNotificationEventArgs { StrategyNotification = strategyNotification }); return(Strategy); }
public virtual void SubscribeStatisticsException(Exception exception) { var message = JsonConvert.SerializeObject(exception); var strategyNotification = new StrategyNotification { Name = Strategy.Name, Message = message, NotificationLevel = NotificationLevel.StatisticsError }; StrategyStatisticsNotification(new StrategyNotificationEventArgs { StrategyNotification = strategyNotification }); }
public virtual void SubscribeCandlesticks(CandlestickEventArgs candlestickEventArgs) { var message = JsonConvert.SerializeObject(candlestickEventArgs.Candlesticks); var strategyNotification = new StrategyNotification { Name = Strategy.Name, Message = message, NotificationLevel = NotificationLevel.Candlesticks }; StrategyCandlesticksNotification(new StrategyNotificationEventArgs { StrategyNotification = strategyNotification }); }
public void SubscribeOrderBookException(Exception exception) { var message = JsonConvert.SerializeObject(exception); var strategyNotification = new StrategyNotification { Name = Strategy.Name, Message = message, NotificationLevel = NotificationLevel.OrderBookError }; StrategyOrderBookNotification(new StrategyNotificationEventArgs { StrategyNotification = strategyNotification }); }
public void SubscribeOrderBook(OrderBookEventArgs orderBookEventArgs) { var message = JsonConvert.SerializeObject(orderBookEventArgs.OrderBook); var strategyNotification = new StrategyNotification { Name = Strategy.Name, Message = message, NotificationLevel = NotificationLevel.OrderBook }; StrategyOrderBookNotification(new StrategyNotificationEventArgs { StrategyNotification = strategyNotification }); }
public virtual void SubscribeTrades(TradeEventArgs tradeEventArgs) { var message = JsonConvert.SerializeObject(tradeEventArgs.Trades); var strategyNotification = new StrategyNotification { Name = Strategy.Name, Message = message, NotificationLevel = NotificationLevel.Trade }; StrategyTradeNotification(new StrategyNotificationEventArgs { StrategyNotification = strategyNotification }); }
public virtual void SubscribeAccountInfo(AccountInfoEventArgs accountInfoEventArgs) { lock (accountLock) { accountInfo = accountInfoEventArgs.AccountInfo.Clone(); placingOrder = false; if (Strategy == null) { return; } var strategyNotification = new StrategyNotification { Name = Strategy.Name, Message = "Update strategy performance.", NotificationLevel = NotificationLevel.Account }; StrategyAccountInfoNotification(new StrategyNotificationEventArgs { StrategyNotification = strategyNotification }); } }