private void AnalyseSignal(TradeModel trade, SignalModel signal) { if (signal.OrderType == OrderType.Buy) { if (trade.Status == EnumStatus.WAITING) { PerformBuy(trade); } else if (trade.Status == EnumStatus.BOUGHT) { txtLogs.AppendText($"{DateTime.Now} - {signal.CurrencyPair} => BUY - Already bought{Environment.NewLine}"); } } else if (signal.OrderType == OrderType.Sell) { if (trade.Status == EnumStatus.BOUGHT) { PerformSell(trade, true); } else if (trade.Status == EnumStatus.WAITING) { txtLogs.AppendText($"{DateTime.Now} - {signal.CurrencyPair} => SELL - Already sold{Environment.NewLine}"); } } }
private Subject <SignalModel> SetManualSignal() { Subject <SignalModel> manualSignal = new Subject <SignalModel>(); this.dgvCurrentTrades.CellContentClick += (object sender, DataGridViewCellEventArgs e) => { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { TradeModel trade = (TradeModel)DataGridHelper.GetCell(dgvCurrentTrades.CurrentRow.Cells, "Trade"); OrderType orderType = OrderType.Buy; if (trade.Action == OrderType.Buy.ToString().ToUpper()) { orderType = OrderType.Buy; } else if (trade.Action == OrderType.Sell.ToString().ToUpper()) { orderType = OrderType.Sell; } SignalModel signal = new SignalModel() { CurrencyPair = trade.CurrencyPair, OrderType = orderType }; manualSignal.OnNext(signal); } }; return(manualSignal); }