Beispiel #1
0
        public override async Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Worker started at: {DateTime.Now}");
            if (_exchangePluginService.PluginExchanges != null && _exchangePluginService.PluginExchanges.Any())
            {
                AbstractExchangePlugin[] plugins = _exchangePluginService.PluginExchanges.ToArray();
                _exchangePluginService.PluginExchanges.Clear();
                for (int index = plugins.Length - 1; index >= 0; index--)
                {
                    AbstractExchangePlugin abstractExchangePlugin = plugins[index];
                    abstractExchangePlugin.NotifyAccountInfo                += _exchangeService.DelegateNotifyAccountInfo;
                    abstractExchangePlugin.NotifyCurrentPrices              += _exchangeService.DelegateNotifyCurrentPrices;
                    abstractExchangePlugin.NotifyMainCurrency               += _exchangeService.DelegateNotifyMainCurrency;
                    abstractExchangePlugin.NotifyAssetInformation           += _exchangeService.DelegateNotifyAssetInformation;
                    abstractExchangePlugin.NotifyFills                      += _exchangeService.DelegateNotifyFills;
                    abstractExchangePlugin.NotifyOrders                     += _exchangeService.DelegateNotifyOrders;
                    abstractExchangePlugin.NotifyFillStatistics             += _exchangeService.DelegateNotifyFillStatistics;
                    abstractExchangePlugin.DelegateNotifySubscriptionStatus += _exchangeService.DelegateNotifySubscriptionStatus;
                    abstractExchangePlugin.ProcessLogBroadcast              += ProcessLogBroadcast;
                    bool result = await abstractExchangePlugin.InitAsync(_exchangeSettings);

                    if (!result)
                    {
                        continue;
                    }
                    _logger.LogInformation($"Plugin {abstractExchangePlugin.ApplicationName} loaded.");
                    plugins = plugins.Where(plugin => plugin.ApplicationName != abstractExchangePlugin.ApplicationName).ToArray();
                    _exchangePluginService.PluginExchanges.Add(abstractExchangePlugin);
                }
            }
            _logger.LogInformation($"Plugin Loading completed.");
            await base.StartAsync(cancellationToken);
        }
Beispiel #2
0
 public override void Dispose()
 {
     _logger.LogInformation($"Worker disposed at: {DateTime.Now}");
     if (_exchangePluginService.PluginExchanges != null && _exchangePluginService.PluginExchanges.Any())
     {
         for (int i = _exchangePluginService.PluginExchanges.Count - 1; i >= 0; i--)
         {
             AbstractExchangePlugin abstractExchangePlugin = _exchangePluginService.PluginExchanges[i];
             abstractExchangePlugin.Dispose();
         }
     }
     base.Dispose();
 }
Beispiel #3
0
 public override Task StopAsync(CancellationToken cancellationToken)
 {
     _logger.LogInformation($"Worker stopped at: {DateTime.Now}");
     if (_exchangePluginService.PluginExchanges == null || !_exchangePluginService.PluginExchanges.Any())
     {
         return(base.StopAsync(cancellationToken));
     }
     for (int i = _exchangePluginService.PluginExchanges.Count - 1; i >= 0; i--)
     {
         AbstractExchangePlugin abstractExchangePlugin = _exchangePluginService.PluginExchanges[i];
         abstractExchangePlugin.CloseFeed().GetAwaiter();
     }
     return(base.StopAsync(cancellationToken));
 }
Beispiel #4
0
        public override async Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Worker started at: {DateTime.Now}");
            if (_exchangePluginService.PluginExchanges != null && _exchangePluginService.PluginExchanges.Any())
            {
                for (int i = _exchangePluginService.PluginExchanges.Count - 1; i >= 0; i--)
                {
                    AbstractExchangePlugin abstractExchangePlugin = _exchangePluginService.PluginExchanges[i];
                    abstractExchangePlugin.NotifyAccountInfo   += _exchangeService.DelegateNotifyAccountInfo;
                    abstractExchangePlugin.NotifyCurrentPrices += _exchangeService.DelegateNotifyCurrentPrices;
                    await abstractExchangePlugin.InitAsync(_exchangeSettings.TestMode);

                    abstractExchangePlugin.InitIndicatorsAsync();
                    _logger.LogInformation($"Plugin {abstractExchangePlugin.ApplicationName} loaded.");
                }
            }
            await base.StartAsync(cancellationToken);
        }