public void Start() { loggingService.Info($"Start Trading service (Virtual: {Config.VirtualTrading})..."); IsTradingSuspended = true; orderingService = Application.Resolve <IOrderingService>(); rulesService = Application.Resolve <IRulesService>(); OnTradingRulesChanged(); rulesService.RegisterRulesChangeCallback(OnTradingRulesChanged); Exchange.Start(Config.VirtualTrading); signalsService = Application.Resolve <ISignalsService>(); if (!Config.VirtualTrading) { Account = new ExchangeAccount(loggingService, notificationService, healthCheckService, signalsService, this); } else { Account = new VirtualAccount(loggingService, notificationService, healthCheckService, signalsService, this); } accountRefreshTimedTask = tasksService.AddTask( name: nameof(AccountRefreshTimedTask), task: new AccountRefreshTimedTask(loggingService, healthCheckService, this), interval: Config.AccountRefreshInterval * 1000 / Application.Speed, startDelay: Constants.TaskDelays.ZeroDelay, startTask: false, runNow: true, skipIteration: 0); if (signalsService.Config.Enabled) { signalsService.Start(); } tradingTimedTask = tasksService.AddTask( name: nameof(TradingTimedTask), task: new TradingTimedTask(loggingService, notificationService, healthCheckService, signalsService, orderingService, this), interval: Config.TradingCheckInterval * 1000 / Application.Speed, startDelay: Constants.TaskDelays.NormalDelay, startTask: false, runNow: false, skipIteration: 0); tradingRulesTimedTask = tasksService.AddTask( name: nameof(TradingRulesTimedTask), task: new TradingRulesTimedTask(loggingService, notificationService, healthCheckService, rulesService, signalsService, this), interval: RulesConfig.CheckInterval * 1000 / Application.Speed, startDelay: Constants.TaskDelays.MidDelay, startTask: false, runNow: false, skipIteration: 0); IsTradingSuspended = false; loggingService.Info("Trading service started"); }
public void Start() { loggingService.Info($"Start Backtesting service... (Replay: {this.Config.Replay})"); signalsService = Application.Resolve <ISignalsService>(); tradingService = Application.Resolve <ITradingService>(); if (this.Config.Replay) { backtestingLoadSnapshotsTimedTask = tasksService.AddTask( name: nameof(BacktestingLoadSnapshotsTimedTask), task: new BacktestingLoadSnapshotsTimedTask(loggingService, healthCheckService, tradingService, this), interval: this.Config.SnapshotsInterval / this.Config.ReplaySpeed * 1000, startDelay: Constants.TaskDelays.HighDelay, startTask: false, runNow: false, skipIteration: 0); } backtestingSaveSnapshotsTimedTask = tasksService.AddTask( name: nameof(BacktestingSaveSnapshotsTimedTask), task: new BacktestingSaveSnapshotsTimedTask(loggingService, healthCheckService, tradingService, signalsService, this), interval: this.Config.SnapshotsInterval * 1000, startDelay: Constants.TaskDelays.HighDelay, startTask: false, runNow: false, skipIteration: 0); if (this.Config.DeleteLogs) { loggingService.DeleteAllLogs(); } string virtualAccountPath = Path.Combine(Directory.GetCurrentDirectory(), tradingService.Config.VirtualAccountFilePath); if (File.Exists(virtualAccountPath) && (this.Config.DeleteAccountData || !String.IsNullOrWhiteSpace(this.Config.CopyAccountDataPath))) { File.Delete(virtualAccountPath); } if (!String.IsNullOrWhiteSpace(this.Config.CopyAccountDataPath)) { File.Copy(Path.Combine(Directory.GetCurrentDirectory(), this.Config.CopyAccountDataPath), virtualAccountPath, true); } if (this.Config.Replay) { Application.Speed = this.Config.ReplaySpeed; } Application.Resolve <ICoreService>().Started += this.OnCoreServiceStarted; loggingService.Info("Backtesting service started"); }
public IActionResult Create(TaskViewModel data) { try { data.email = User.Identity.Name; if (ModelState.IsValid) { _taskService.AddTask(data); TempData["Message"] = "Task inserted successfuly"; return(View()); } else { ModelState.AddModelError("", "Error"); return(View(data)); } } catch (Exception ex) { _logger.LogInformation("Task creation not working" + ex); return(RedirectToAction("Error", "home")); } }
public IActionResult Create(TaskViewModel data) { data.Email = User.Identity.Name; IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName()); IPAddress[] addr = ipEntry.AddressList; if (data.Deadline > DateTime.Now) { if (ModelState.IsValid) { _taskService.AddTask(data); _logger.LogInformation("IP: " + addr[1].ToString() + "\nTime: " + DateTime.Now + "\nUser: "******"\nTask inserted successfully"); TempData["message"] = "Task inserted successfully"; return(View()); } else { _logger.LogError("IP: " + addr[1].ToString() + "\nTime: " + DateTime.Now + "\nUser: "******"\nCheck your input. Operation failed"); ModelState.AddModelError("", "Check your input. Operation failed"); return(View(data)); } } else { _logger.LogError("IP: " + addr[1].ToString() + "\nTime: " + DateTime.Now + "\nUser: "******"\nIncorrect Datetime"); ModelState.AddModelError("", "Incorrect Datetime"); return(View(data)); } }
public IActionResult Create(TaskViewModel data) { try { data.email = User.Identity.Name; if (ModelState.IsValid) { if (data.deadline > DateTime.Now || data.deadline < data.issueDate) { _taskService.AddTask(data); TempData["Message"] = "Task created successfully"; _logger.LogInformation("Task created successfully |" + " ip: " + GetIpAddress() + " | Timestamp: " + DateTime.Now + " | Email: " + User.Identity.Name); return(View()); } else { ModelState.AddModelError("deadline", "Incorrect deadline date"); return(View(data)); } } else { ModelState.AddModelError("", "Error creating task"); _logger.LogError("Error creating task |" + " ip: " + GetIpAddress() + " | Timestamp: " + DateTime.Now + " | Email: " + User.Identity.Name); return(View(data)); } } catch (Exception ex) { _logger.LogError(ex.Message + " ip: " + GetIpAddress() + " | Timestamp: " + DateTime.Now + " | Email: " + User.Identity.Name); return(RedirectToAction("Error")); } }
public async Task <TaskDetailsDto> Handle(CreateNewTaskCommand request, CancellationToken cancellationToken) { var taskToAdd = _mapper.Map <Tasks>(request.TaskForCreationDto); taskToAdd.TrackerId = _authService.UserRoleAdmin() ? new Guid(_authService.GetUserIdClaimValue()) : taskToAdd.TrackerId; if (taskToAdd.TrackerId != null) { var userToMap = await _userService .GetUserAsync(taskToAdd.TrackerId ?? throw new ArgumentNullException()); taskToAdd.TrackerFirstName = userToMap.FirstName; taskToAdd.TrackerLastName = userToMap.LastName; } await _tasksService.AddTask(taskToAdd); var taskFromDbForMapping = await _tasksService.GetTaskWithEagerLoadingAsync(taskToAdd.Id); var taskToReturn = _mapper.Map <TaskDetailsDto>(taskFromDbForMapping); await _emailService.SendEmailAsync(taskFromDbForMapping); return(taskToReturn); }
public IActionResult AddTask([FromBody] TodoTask task) { try { service.AddTask(task); return(StatusCode(201)); } catch (Exception e) { return(StatusCode(406, new { message = e.Message })); } }
public async Task <IActionResult> Post([FromBody] TaskModel model) { var userId = _userManagerService.TryGetUserId(User); if (!userId.HasValue) { return(new UnauthorizedResult()); } // TODO - add validation await _tasksService.AddTask(model, userId.Value); return(new NoContentResult()); }
public void Start() { loggingService.Info("Start TradingViewCryptoSignalReceiver..."); tradingViewCryptoSignalPollingTimedTask = tasksService.AddTask( name: $"{nameof(TradingViewCryptoSignalPollingTimedTask)} [{this.SignalName}]", task: new TradingViewCryptoSignalPollingTimedTask(loggingService, healthCheckService, tradingService, this), interval: this.Config.PollingInterval * 1000 / Application.Speed, startDelay: Constants.TaskDelays.ZeroDelay, startTask: false, runNow: true, skipIteration: 0); loggingService.Info("TradingViewCryptoSignalReceiver started"); }
public void Start() { loggingService.Info($"Start Health Check service..."); healthCheckTimedTask = tasksService.AddTask( name: nameof(HealthCheckTimedTask), task: new HealthCheckTimedTask(loggingService, notificationService, this, Application.Resolve <ICoreService>(), Application.Resolve <ITradingService>()), interval: Application.Resolve <ICoreService>().Config.HealthCheckInterval * 1000 / Application.Speed, startDelay: Constants.TaskDelays.HighDelay, startTask: false, runNow: false, skipIteration: 0); loggingService.Info("Health Check service started"); }
public void Start() { loggingService.Info("Start Backtesting Signals service..."); OnSignalRulesChanged(); rulesService.RegisterRulesChangeCallback(OnSignalRulesChanged); signalRulesTimedTask = tasksService.AddTask( name: nameof(SignalRulesTimedTask), task: new SignalRulesTimedTask(loggingService, healthCheckService, tradingService, rulesService, this), interval: RulesConfig.CheckInterval * 1000 / Application.Speed, startDelay: Constants.TaskDelays.LowDelay, startTask: false, runNow: false, skipIteration: 0); loggingService.Info("Backtesting Signals service started"); }
public void Start() { loggingService.Info("Start Signals service..."); OnSignalRulesChanged(); rulesService.RegisterRulesChangeCallback(OnSignalRulesChanged); signalReceivers.Clear(); foreach (var definition in Config.Definitions) { var receiver = Application.ResolveOptionalNamed <ISignalReceiver>(definition.Receiver, new TypedParameter(typeof(string), definition.Name), new TypedParameter(typeof(IConfigurationSection), definition.Configuration)); if (receiver != null) { if (signalReceivers.TryAdd(definition.Name, receiver)) { receiver.Start(); } else { throw new Exception($"Duplicate signal definition: {definition.Name}"); } } else { throw new Exception($"Signal receiver not found: {definition.Receiver}"); } } signalRulesTimedTask = tasksService.AddTask( name: nameof(SignalRulesTimedTask), task: new SignalRulesTimedTask(loggingService, healthCheckService, tradingService, rulesService, this), interval: RulesConfig.CheckInterval * 1000 / Application.Speed, startDelay: Constants.TaskDelays.LowDelay, startTask: false, runNow: false, skipIteration: 0); loggingService.Info("Signals service started"); }
public void ConnectTickersWebsocket() { try { loggingService.Info("Connect to Exchange tickers..."); socket = Api.GetTickersWebSocket(OnTickersUpdated); loggingService.Info("Connected to Exchange tickers"); tickersMonitorTimedTask = tasksService.AddTask( name: nameof(TickersMonitorTimedTask), task: new TickersMonitorTimedTask(loggingService, this), interval: MAX_TICKERS_AGE_TO_RECONNECT_MILLISECONDS / 2, startDelay: Constants.TaskDelays.ZeroDelay, startTask: tickersStarted, runNow: false, skipIteration: 0); } catch (Exception ex) { loggingService.Error("Unable to connect to Exchange tickers", ex); } }
public IActionResult Create(TaskViewModel newTask) { newTask.Id = new Guid(); newTask.Teacher = HttpContext.User.Identity.Name; if (newTask.Deadline < DateTime.Now) { _logger.LogError("Deadline is inavlid"); return(View("Error", new ErrorViewModel() { Message = "Deadline Date cannot be in the past" })); } else if (string.IsNullOrEmpty(newTask.Title)) { _logger.LogError("Title is empty or NULL"); return(View("Error", new ErrorViewModel() { Message = "Title cannot be empty" })); } else if (string.IsNullOrEmpty(newTask.Description)) { _logger.LogError("Description is empty or NULL"); return(View("Error", new ErrorViewModel() { Message = "Description cannot be empty" })); } else { TempData["message"] = "Task created successfully"; _tasksService.AddTask(newTask); return(View()); } }
public IActionResult AddTask([FromBody] ManagedTaskDto newTask) { _tasksService.AddTask(newTask); return(Ok()); }
public void AddTask([FromBody] TaskDetails taskModel) { taskService.AddTask(taskModel); }