/// <summary> /// Check if stop loss percent has been reached /// Sell if so /// </summary> /// <returns>Boolean true if hit, false otherwise</returns> private bool StopLossCheck() { if (_tradeType == TradeType.SELL) { var candleStick = _trader.GetCandlesticks(_botSettings.tradingPair, Interval.OneM, 1); var stopPrice = _lastBuy - (_lastBuy * (decimal)(_botSettings.stopLoss / 100)); if (stopPrice >= candleStick[0].close && _lastBuy > 0.00000000M) { _trader.CancelOpenOrders(); candleStick = _trader.GetCandlesticks(_botSettings.tradingPair, Interval.OneM, 1); _trader.SellCrypto(candleStick[0].close, TradeType.STOPLOSS); var signal = new TradeSignal { lastBuy = _lastBuy, lastSell = _lastSell, pair = _symbol, price = candleStick[0].close, signal = SignalType.OrderBook, tradeType = TradeType.STOPLOSS, transactionDate = DateTime.UtcNow }; _fileRepo.LogSignal(signal); return(true); } } return(false); }
/// <summary> /// Cancel all open orders /// </summary> /// <returns>Boolean when complete</returns> public bool CancelAllOpenOrders() { ServiceReady(); try { _tradeBuilder.CancelOpenOrders(); return(true); } catch { return(false); } }