protected override void Buy(float closePrice, DateTime time, string pair, StrategyProperties properties) { Console.WriteLine("Trying to buy " + pair + " at " + closePrice); properties.lastBuyPrice = closePrice; properties.lastBuyTime = time; properties.boughtOnDowntrend = IsDownTrend(pair, properties); BitfinexHandler.Buy(pair, closePrice, BuyQty); }
protected override void Sell(float closePrice, DateTime time, string pair, StrategyProperties properties) { Console.WriteLine("Trying to sell " + pair + " at " + closePrice); float pl = closePrice - properties.lastBuyPrice; properties.boughtOnDowntrend = false; BitfinexHandler.Sell(pair); Console.WriteLine("Sold! - P/L: " + pl); }
private void ExecuteStrategy(Candle c) { StrategyProperties props = PairProperties[c.Pair]; float close = c.Close; BitfinexHandler.RetrieveBalances(); if (Portfolio[c.Symbol] <= 0 && Portfolio["USD"] > BuyQty) { if (ShouldBuy(c.Pair, props)) { Buy(close, c.time, c.Pair, props); } } else if (Portfolio[c.Symbol] > 0) { if (ShouldSell(c.time, c.Pair, props)) { Sell(close, c.time, c.Pair, props); } } }