public void CreateTrade(SignalVM signal) { if (signal != null) { //signal. } }
/// <summary> /// Selection Handler for selecting a Signal or Device /// </summary> /// <param name="e"> The EventArguments associated with the onClick Event</param> /// <param name="sender"> The <see cref="TreeViewItem"/> where this event is triggered. </param> public void OnSelectItem(object sender, RoutedPropertyChangedEventArgs <object> e) { TreeView tv = sender as TreeView; if (tv != null) { SignalVM tvi = tv.SelectedItem as SignalVM; if (tvi != null) { m_selectedSignalID = tvi.ID; m_selectedInputSignal = tvi.IsInput; } } }
public OrdersTask CreateTradeFromSignal(SignalVM signal, decimal investCapital, decimal currentPrice) { if (signal == null) { throw new ArgumentNullException("signal"); } if (signal.SellPrice?.Any() == false) { throw new InvalidOperationException(); } var sellTasks = new List <TradeTask>(signal.SellPrice.Length); decimal amount = currentPrice / investCapital; var buyTask = new TradeTask { Price = currentPrice, Amount = amount, }; decimal sellPortion = amount / signal.SellPrice.Length; foreach (var sellPrice in signal.SellPrice) { sellTasks.Add(new TradeTask { Price = sellPrice, Amount = sellPortion, }); } var result = new OrdersTask { Currency = signal.Currency, StopLoss = signal.StopLoss, BuyTask = buyTask, SellTasks = sellTasks, }; return(result); }
public async Task <IActionResult> SaveSignalAsync(SignalInputModel signal) { try { SignalDataModel data = new SignalDataModel() { AccessCode = signal.AccessCode, Area = signal.Area, CustomerName = signal.CustomerName, Description = signal.Description, SignalDate = DateTime.Now, Zone = signal.Zone }; await uow.SignalRepository.AddAsync(data); if (await uow.SaveChangesAsync() > 0) { SignalVM signalVM = new SignalVM() { AccessCode = signal.AccessCode, Area = signal.Area, CustomerName = signal.CustomerName, Description = signal.Description, SignalDate = data.SignalDate, Zone = signal.Zone }; await this.hubContext.Clients.All.SendAsync("SignalMessageReceived", signalVM); return(Ok()); } return(BadRequest(new { message = "Some error occured." })); } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } }