Exemplo n.º 1
0
        public async Task <TradingContext> Build(ExchangeCode exchangeCode, string symbol)
        {
            ITradingStrategy      strategy = null;
            IEnumerable <ICandle> candles  = null;

            return(await WithConnection(async (connection, transaction) =>
            {
                Strategy strategyInfo = await _strategyManager.Get(exchangeCode, symbol, connection);

                if (!strategyInfo.IsEnabled)
                {
                    return null;
                }

                Type type = Type.GetType(strategyInfo.TypeName, true, true);

                strategy = (ITradingStrategy)Activator.CreateInstance(type);

                // TODO: Add Strategy preset support
                //strategy.Preset = strategyInfo.Preset;

                candles = await _candlesManager.GetLastCandles(exchangeCode, symbol, strategy.OptimalTimeframe.Code, strategy.MinNumberOfCandles, connection, transaction);

                TradingContext context = new TradingContext(exchangeCode, symbol, strategy, candles);
                return context;
            }));
        }
Exemplo n.º 2
0
 public Task <IEnumerable <Candle> > GetLast(int exchangeCode, string symbol, int interval, int number)
 {
     return(WithConnection((connection, transaction) =>
     {
         return _candleManager.GetLastCandles(exchangeCode, symbol, interval, number, connection, transaction);
     }));
 }