예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
                }
            }
        }