예제 #1
0
 private void CalculateSymbolTrend(ExtendedSymbol symbol)
 {
     for (int i = 0; i < symbol.Trends.Length; i++)
     {
         decimal diff            = symbol.Trends[i].Candle.ClosePrice - symbol.Trends[i].Candle.OpenPrice;
         decimal trendPercentage = (diff / symbol.Trends[i].Candle.OpenPrice) * 100M;
         symbol.Trends[i].TrendRaw = trendPercentage;
     }
 }
예제 #2
0
        /// <summary>
        /// Downloads all symbols from the exchanges and filters out the coins with enough 24hr Volume
        /// </summary>
        /// <returns></returns>
        private void FindCoinsWithEnoughVolume()
        {
            _symbols = new List <ExtendedSymbol>();
            var allSymbolsMeta = _api.GetMarketSymbolsMetadataAsync().Result;
            var allTickers     = _api.GetTickersAsync().Result;

            // for each symbol
            foreach (var metadata in allSymbolsMeta)
            {
                string symbol = metadata.MarketSymbol.ToUpperInvariant();
                if (!IsValidCurrency(symbol))
                {
                    // ignore, symbol has wrong currency
                    continue;
                }

                // check 24hr volume
                var ticker = allTickers.FirstOrDefault(e => e.Key == symbol).Value;
                var volume = ticker.Volume.QuoteCurrencyVolume;
                if (_api is ExchangeBittrexAPI)
                {
                    // bittrex reports wrong volume :-(
                    volume = ticker.Volume.BaseCurrencyVolume;
                }

                if (volume < _settings.Min24HrVolume)
                {
                    // ignore since 24hr volume is too low
                    continue;
                }

                if (ticker.Ask < _settings.MinPrice)
                {
                    Trace.WriteLine($"Ignoring because price is too low: {ticker.Ask}");
                    continue;
                }

                SymbolTrend fourHourTrend = new SymbolTrend(4);
                SymbolTrend oneHourTrend  = new SymbolTrend(1);

                // add to list
                ExtendedSymbol extendedSymbol = new ExtendedSymbol()
                {
                    Symbol = metadata,
                    Ticker = ticker,
                    Trends = new SymbolTrend[2]
                };

                extendedSymbol.Trends[0] = fourHourTrend;
                extendedSymbol.Trends[1] = oneHourTrend;

                _symbols.Add(extendedSymbol);
            }
            _symbols = _symbols.OrderBy(e => e.Symbol.MarketSymbol).ToList();
        }
예제 #3
0
        public async Task <bool> GetSymbolTrendCandles(ExtendedSymbol symbol)
        {
            try
            {
                List <MarketCandle> candles = await GetTrendCandles(symbol.Symbol.MarketSymbol);

                symbol.Trends[0].Candle = CalculateFourHourCandle(candles);
                symbol.Trends[1].Candle = candles[0];
            } catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
            return(symbol.Trends[0].Candle != null && symbol.Trends[1].Candle != null);
        }
예제 #4
0
        /// <summary>
        /// Performs a scan for all filtered symbols
        /// </summary>
        /// <returns></returns>
        public async Task <Signal> ScanAsync(ExtendedSymbol symbol, int minutes)
        {
            try
            {
                // download the new candles
                var candles = (await _api.GetCandlesAsync(symbol.Symbol.MarketSymbol, 60 * minutes, DateTime.Now.AddMinutes(-5 * 50))).Reverse().ToList();
                candles = AddMissingCandles(candles, minutes);
                // scan candles for buy/sell signal
                TradeType tradeType = TradeType.Long;

                var strategy = new DayTradingStrategy(symbol.Symbol.MarketSymbol, _settings);
                if (strategy.IsValidEntry(candles, 0, out tradeType, out decimal bandwitdh))
                {
                    // ignore signals for shorts when not allowed
                    if (tradeType == TradeType.Short && !_settings.AllowShorts)
                    {
                        return(null);
                    }

                    // got buy/sell signal.. write to console
                    int beepFrequency = symbol.Trends[1].Trend > 0 ? 1000 : 500;
                    Console.Beep(beepFrequency, 200);

                    return(new Signal()
                    {
                        Symbol = symbol.Symbol.MarketSymbol,
                        Trade = tradeType.ToString(),
                        Date = $"{candles[0].Timestamp.AddHours(2):dd-MM-yyyy HH:mm}",
                        TimeFrame = $"{minutes} min",
                        HyperTraderURI = GetHyperTradeURI(symbol.Symbol, minutes),
                        Volume = symbol.Ticker.Volume,
                        FourHourTrend = String.Format("{00:P2}", symbol.Trends[0].Trend),
                        OneHourTrend = String.Format("{00:P2}", symbol.Trends[1].Trend),
                        FourHourTrendObject = symbol.Trends[0],
                        OneHourTrendObject = symbol.Trends[1],
                        BBBandwidth = String.Format("{0:0.0#}", bandwitdh)
                    });
                }