Exemplo n.º 1
0
        public override Task StartAsync(CancellationToken cancellationToken)
        {
            Task task = base.StartAsync(cancellationToken);

            return(task.ContinueWith(t => {
                Manager = new StrategiesManager();

                TaSimpleStrategy strategy = new TaSimpleStrategy();
                strategy.TickerInfo = new Crypto.Core.Common.TickerNameInfo()
                {
                    BaseCurrency = "USDT", MarketCurrency = "BTC", Exchange = CryptoMarketClient.ExchangeType.Poloniex
                };
                strategy.DemoMode = true;
                strategy.MaxAllowedDeposit = 1000;

                Manager.Strategies.Add(strategy);
                if (!Manager.Initialize(new RealtimeStrategyDataProvider()))
                {
                    LogManager.Default.Log(LogType.Error, Manager, "strategies manager did not initialized.", "");
                    _logger.LogError("strategies manager did not initialized.");
                    return;
                }
                LogManager.Default.Log(LogType.Success, Manager, "start strategies manager.", "");
                if (!Manager.RunSingleThread())
                {
                    LogManager.Default.Log(LogType.Error, Manager, "strategies manager did not start.", "");
                    _logger.LogError("strategies manager did not start.");
                    return;
                }
                LogManager.Default.Log(LogType.Success, Manager, "strategies manager started.", "");
                _logger.LogInformation("strategies manager successuflly started.");
            }));
        }
Exemplo n.º 2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);

            while (!stoppingToken.IsCancellationRequested)
            {
                if (Manager != null && !Manager.Running)
                {
                    _logger.LogInformation("Start Strategies Maanger at {time}", DateTimeOffset.Now);
                    if (!Manager.Start())
                    {
                        _logger.LogError("Strategies Manager did not start");
                        await Task.FromCanceled(stoppingToken);
                    }
                    else
                    {
                        _logger.LogInformation("Strategies Maanger started at {time}", DateTimeOffset.Now);
                    }
                }
                lock (Manager.Strategies[0]) {
                    TaSimpleStrategy s = (TaSimpleStrategy)Manager.Strategies[0];
                    _logger.LogInformation(DateTime.Now.ToLongTimeString() + " deposit = " + s.MaxActualDeposit + " earned = " + s.Earned);
                }
                await Task.CompletedTask;// Task.Delay(1000, stoppingToken);
            }
        }
Exemplo n.º 3
0
 public string Get()
 {
     lock (Startup.Manager) {
         TaSimpleStrategy s = (TaSimpleStrategy)Startup.Manager.Strategies[0];
         if (s.Ticker.OrderBook.Bids.Count == 0)
         {
             return("");
         }
         return(DateTime.Now.ToLongTimeString() + " deposit = " + s.MaxActualDeposit + " earned = " + s.Earned + " latest price = " + s.Ticker.OrderBook.Bids[0].Value.ToString("########"));
     }
 }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            LogManager.Default.Log(LogType.Success, null, "starting.", "");
            Debug.WriteLine("starting...");

            StrategiesManager manager = new StrategiesManager();

            TaSimpleStrategy strategy = new TaSimpleStrategy();

            strategy.TickerInfo = new Crypto.Core.Common.TickerNameInfo()
            {
                BaseCurrency = "USDT", MarketCurrency = "BTC", Exchange = CryptoMarketClient.ExchangeType.Poloniex
            };
            strategy.DemoMode          = true;
            strategy.MaxAllowedDeposit = 1000;

            manager.Strategies.Add(strategy);
            if (!manager.Initialize(new RealtimeStrategyDataProvider()))
            {
                LogManager.Default.Log(LogType.Error, manager, "strategies manager did not initialized.", "");
                Debug.WriteLine("strategies manager did not initialized.");
                return;
            }
            LogManager.Default.Log(LogType.Success, manager, "start strategies manager.", "");
            if (!manager.Start())
            {
                LogManager.Default.Log(LogType.Error, manager, "strategies manager did not start.", "");
                Debug.WriteLine("strategies manager did not start.");
                return;
            }
            LogManager.Default.Log(LogType.Success, manager, "strategies manager started.", "");
            Console.WriteLine("strategies manager successuflly started.");
            while (true)
            {
                lock (manager) {
                    if (!manager.Running)
                    {
                        break;
                    }
                }
                lock (strategy) {
                    Debug.WriteLine(DateTime.Now.ToLongTimeString() + " deposit = " + strategy.MaxActualDeposit + " earned = " + strategy.Earned);
                }
            }
            LogManager.Default.Log(LogType.Success, manager, "strategies manager stopped.", "");
            Console.WriteLine("strategies manager successuflly stopped.");
        }
Exemplo n.º 5
0
        public void StartStrategiesManager()
        {
            LogManager.Default.Log(LogType.Success, null, "starting.", "");
            Console.WriteLine("starting...");

            StrategiesManager manager = new StrategiesManager();

            if (!PoloniexExchange.Default.Connect())
            {
                LogManager.Default.Log(LogType.Error, null, "Poloniex exchange not connected.", "");
                Console.WriteLine("Poloniex exchange not connected.");
                return;
            }

            TaSimpleStrategy strategy = new TaSimpleStrategy();

            strategy.StrategyInfo.Tickers.Add(new TickerInputInfo()
            {
                Exchange     = ExchangeType.Poloniex,
                TickerName   = "USDT_BTC",
                UseOrderBook = true,
            });
            strategy.Enabled           = true;
            strategy.DemoMode          = true;
            strategy.MaxAllowedDeposit = 1000;

            manager.Strategies.Add(strategy);
            if (!manager.Initialize(new RealtimeStrategyDataProvider()))
            {
                LogManager.Default.Log(LogType.Error, manager, "strategies manager did not initialized.", "");
                Console.WriteLine("strategies manager did not initialized.");
                return;
            }
            LogManager.Default.Log(LogType.Success, manager, "start strategies manager.", "");
            if (!manager.Start())
            {
                LogManager.Default.Log(LogType.Error, manager, "strategies manager did not start.", "");
                Console.WriteLine("strategies manager did not start.");
                return;
            }
            LogManager.Default.Log(LogType.Success, manager, "strategies manager started.", "");
            Console.WriteLine("strategies manager successuflly started.");

            Manager = manager;
        }