private void ProcessData(string folder, IQFeedRequest input, StreamReader streamReader)
        {
            var index             = 0;
            var accumulationIndex = 0;

            var data = new List <string>();

            var line = streamReader.ReadLine();

            if (!CheckContent(line))
            {
                return;
            }
            data.Add(line);
            //  _logger.Info("1");
            try
            {
                var streamWriter = GetWriterToFile(folder, input.CurrentSymbol);


                while (!streamReader.EndOfStream)
                {
                    line = streamReader.ReadLine();

                    if (!CheckEndMessage(line))
                    {
                        data.Add(line);
                        index++;

                        if (index == 100000)
                        {
                            accumulationIndex = accumulationIndex + index;
                            _saver.SaveData(input, ref streamWriter, data);

                            _logger.Info(string.Format("{0} entries of data processed", index));
                            data.Clear();
                            index = 0;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                _saver.SaveData(input, ref streamWriter, data);
                data.Clear();
                streamWriter.Close();
                // _logger.Info("2");
            }
            catch (UnauthorizedAccessException ex)
            {
            }
        }
Example #2
0
 /// <summary>
 /// Add new book in list
 /// </summary>
 /// <param name="newBook">New book</param>
 public void AddBook(Book newBook)
 {
     logger.Debug("Adding a new book");
     if (newBook == null)
     {
         throw new ArgumentNullException(nameof(newBook));
     }
     if (bookList.Contains(newBook))
     {
         logger.Info("The book is already there");
         throw new Exception("The book is already there");
     }
     bookList.Add(newBook);
 }
Example #3
0
        public async void Run()
        {
            Props props = Props.FromProducer(() => new ActorManager(_logger));

            _actorManager = _actorSystem.Root.SpawnNamed(props, "ActorManager");

            Task <int> task  = BTCAddressLoader.LoadAddressesAsync(_logger);
            int        count = await task;

            _logger.Info($"Successfully loaded {count} addresses");

            _actorSystem.Root.Send(_actorManager, new SpawnWorker(20));
            //_actorSystem.Root.Send(_actorManager, new ShowStatistics(TimeSpan.FromSeconds(10)));

            _ = Task.Run(() =>
            {
                while (true)
                {
                    Task.Delay(5200).Wait();
                    _actorSystem.Root.Send(_actorManager, new RequestWorkerCount());
                    _actorSystem.Root.Send(_actorManager, new ShowStatistics(TimeSpan.FromSeconds(10)));
                    _actorSystem.Root.Send(_actorManager, new ShowTotalKeysTried());
                }
            });
        }
        public static async Task <int> LoadAddressesAsync(IMyLogger logger)
        {
            Progress <int> progress = new Progress <int>(count =>
            {
                logger.Info($"Loaded {count} addresses");
            });
            await Task.Run(() => LoadAddresses(progress));

            return(AddressBook.Count);
        }
Example #5
0
        public GroundStation()
        {
            Config.ReloadConfig();

            IMyLogger myLogger = new MyLogger();

            _logger = myLogger.For <GroundStation>();

            _actorSystem = new ActorSystem();

            _logger.Info("Started");
        }
Example #6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Get an access token for the given context and resourceId. An attempt is first made to acquire
        /// the token silently. If that fails, then we try to acquire the token by prompting the user.
        /// </summary>
        ///
        /// <remarks>   Sebastian Schütze, 07/04/2018. </remarks>
        ///
        /// <param name="graphToken">   the token string for the graph client for authentification. </param>
        ///
        /// <returns>   returns a the graph client instance. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public GraphServiceClient GetAuthenticatedClient(string graphToken)
        {
            if (GraphClient != null)
            {
                return(GraphClient);
            }

            // Create Microsoft Graph client.
            try
            {
                _graphClient = new GraphServiceClient(
                    "https://graph.microsoft.com/v1.0",
                    new DelegateAuthenticationProvider(
                        async(requestMessage) =>
                {
                    requestMessage.Headers.Authorization =
                        new AuthenticationHeaderValue("bearer", graphToken);
                }));
                return(GraphClient);
            }

            catch (Exception ex)
            {
                _log.Info("Could not create a graph client: " + ex.Message);
            }

            return(GraphClient);
        }
Example #7
0
        public Task ReceiveAsync(IContext context)
        {
            // _logger.Info($"got msg {context.Message}");
            switch (context.Message)
            {
            case Started _:
                _logger.Info("!!!!!!!!!!!!!");
                break;

            case SpawnWorker msg:
                for (int i = 0; i < msg.Amount; i++)
                {
                    CreateWorkers(context);
                }
                break;

            case RequestWorkerCount _:
                _logger.Info($"Total workers: {GetWorkerCount()}");
                break;

            case ShowStatistics msg:
                foreach (PID pid in _allWorkers)
                {
                    // _scheduler.ScheduleTellRepeatedly(TimeSpan.FromSeconds(5), msg.Duration, pid,
                    //     new RequestNumKeysTried(), out _cts);
                    context.Send(pid, new RequestNumKeysTried());
                }
                break;

            case ResponseNumKeysTried msg:
                _totalKeysTried += msg.Num;
                break;

            case ShowTotalKeysTried _:
                _logger.Info($"Total number of keys tried: {_totalKeysTried}");
                break;
            }
            return(Task.CompletedTask);
        }
Example #8
0
        private void StartCrack(IContext context)
        {
            Key           privateKey    = new Key(); // generate a random private key
            BitcoinSecret bitcoinSecret = privateKey.GetWif(Network.Main);
            string        address       = bitcoinSecret.GetAddress(ScriptPubKeyType.Legacy).ToString();

            if (BTCAddressLoader.AddressBook.Contains(address))
            {
                //bingo!
                Config.AddKey(bitcoinSecret.ToString(), address);
                _logger.Info("Found a key!!!");
            }
            else
            {
                //keep working
                context.Send(context.Self !, new StartCracking());
            }

            NumKeysTried++;
        }
Example #9
0
 public IActionResult Test([FromQuery] string signature, [FromQuery] string timestamp, [FromQuery] string nonce, [FromQuery] string echostr)
 {
     _logger.Info(echostr, signature, timestamp, nonce);
     return(Ok("good"));
 }
 public ActionResult Index()
 {
     _logger.Info("Hi!");
     return(View());
 }
        public string CreateQuery(IRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var dlr = IQFeedConfiguration.Delimiter;
            var trm = IQFeedConfiguration.Terminater;

            var query = string.Empty;

            switch (request.TimeFrame)
            {
            case "Tick Days":
                //HTD,[Symbol],[Days],[MaxDatapoints],[BeginFilterTime],[EndFilterTime],[DataDirection],[RequestID],[DatapointsPerSend]<CR><LF>
                //Retrieves ticks for the previous [Days] days for the specified [Symbol].
                //[Symbol] - Required - Max Length 30 characters.
                //[Days] - Required - The number of calendar days ("1" equals current day) of tick history to be retrieved
                //[MaxDatapoints] - Optional - the maximum number of data points to be retrieved.
                //[BeginFilterTime] - Optional - Format HHmmSS - Allows you to specify the earliest time of day (EST) for which to receive data.
                //[EndFilterTime] - Optional - Format HHmmSS - Allows you to specify the latest time of day (EST) for which to receive data.
                //[DataDirection] - Optional - '0' (default) for "newest to oldest" or '1' for "oldest to newest".
                //[RequestID] - Optional - Will be sent back at the start of each line of data returned for this request.
                //[DatapointsPerSend] - Optional - Specifies the number of data points that IQConnect.exe will queue before attempting to send across the socket to your app.
                query =
                    IQFeedConfiguration.TickDaysHeader + dlr +
                    request.CurrentSymbol + dlr +
                    request.Days + dlr +
                    request.MaxDatapoints + dlr +
                    request.BeginFilterTime + dlr +
                    request.EndFilterTime + dlr + request.DataDirection + dlr +
                    request.DatapointsPerSend + trm;

                _logger.Info(query);
                break;

            case "Tick Interval":
                //HTT,[Symbol],[BeginDate BeginTime],[EndDate EndTime],[MaxDatapoints],[BeginFilterTime],[EndFilterTime],[DataDirection],[RequestID],[DatapointsPerSend]<CR><LF>
                //Retrieves tick data between [BeginDate BeginTime] and [EndDate EndTime] for the specified [Symbol].
                //[Symbol] - Required - Max Length 30 characters.
                //[BeginDate BeginTime] - Required if [EndDate EndTime] not specified - Format CCYYMMDD HHmmSS - Earliest date/time to receive data for.
                //[EndDate EndTime] - Required if [BeginDate BeginTime] not specified - Format CCYYMMDD HHmmSS - Most recent date/time to receive data for.
                //[MaxDatapoints] - Optional - the maximum number of data points to be retrieved.
                //[BeginFilterTime] - Optional - Format HHmmSS - Allows you to specify the earliest time of day (EST) for which to receive data.
                //[EndFilterTime] - Optional - Format HHmmSS - Allows you to specify the latest time of day (EST) for which to receive data.
                //[DataDirection] - Optional - '0' (default) for "newest to oldest" or '1' for "oldest to newest".
                //[RequestID] - Optional - Will be sent back at the start of each line of data returned for this request.
                //[DatapointsPerSend] - Optional - Specifies the number of data points that IQConnect.exe will queue before attempting to send across the socket to your app.
                query =
                    IQFeedConfiguration.TickIntervalHeader + dlr +
                    request.CurrentSymbol + dlr +
                    request.BeginDateTime + dlr +
                    request.EndDateTime + dlr +
                    request.MaxDatapoints + dlr +
                    request.BeginFilterTime + dlr +
                    request.EndFilterTime + dlr +
                    request.DataDirection + dlr +
                    request.DatapointsPerSend + trm;

                _logger.Info(query);
                break;

            case "Intraday Days":
                //HID,[Symbol],[Interval],[Days],[MaxDatapoints],[BeginFilterTime],[EndFilterTime],[DataDirection],[RequestID],[DatapointsPerSend]<CR><LF>
                //Retrieves [Days] days of interval data for the specified [Symbol].
                //[Symbol] - Required - Max Length 30 characters.
                //[Interval] - Required - The interval in seconds.
                //[Days] - Required - The number of calendar days ("1" equals current day) of tick history to be retrieved
                //[MaxDatapoints] - Optional - the maximum number of data points to be retrieved.
                //[BeginFilterTime] - Optional - Format HHmmSS - Allows you to specify the earliest time of day (EST) for which to receive data.
                //[EndFilterTime] - Optional - Format HHmmSS - Allows you to specify the latest time of day (EST) for which to receive data.
                //[DataDirection] - Optional - '0' (default) for "newest to oldest" or '1' for "oldest to newest".
                //[RequestID] - Optional - Will be sent back at the start of each line of data returned for this request.
                //[DatapointsPerSend] - Optional - Specifies the number of data points that IQConnect.exe will queue before attempting to send across the socket to your app.
                query =
                    IQFeedConfiguration.IntradayDaysHeader + dlr +
                    request.CurrentSymbol + dlr +
                    request.Interval + dlr +
                    request.Days + dlr +
                    request.DatapointsPerSend + dlr +
                    request.BeginFilterTime + dlr +
                    request.EndFilterTime + dlr +
                    request.DataDirection + dlr +
                    request.DatapointsPerSend + trm;

                _logger.Info(query);
                break;

            case "Intraday Interval":
                //HIT,[Symbol],[Interval],[BeginDate BeginTime],[EndDate EndTime],[MaxDatapoints],[BeginFilterTime],[EndFilterTime],[DataDirection],[RequestID],[DatapointsPerSend]<CR><LF>
                //Retrieves interval data between [BeginDate BeginTime] and [EndDate EndTime] for the specified [Symbol].
                //[Symbol] - Required - Max Length 30 characters.
                //[Interval] - Required - The interval in seconds.
                //[BeginDate BeginTime] - Required if [EndDate EndTime] not specified - Format CCYYMMDD HHmmSS - Earliest date/time to receive data for.
                //[EndDate EndTime] - Required if [BeginDate BeginTime] not specified - Format CCYYMMDD HHmmSS - Most recent date/time to receive data for.
                //[MaxDatapoints] - Optional - the maximum number of data points to be retrieved.
                //[BeginFilterTime] - Optional - Format HHmmSS - Allows you to specify the earliest time of day (EST) for which to receive data.
                //[EndFilterTime] - Optional - Format HHmmSS - Allows you to specify the latest time of day (EST) for which to receive data.
                //[DataDirection] - Optional - '0' (default) for "newest to oldest" or '1' for "oldest to newest".
                //[RequestID] - Optional - Will be sent back at the start of each line of data returned for this request.
                //[DatapointsPerSend] - Optional - Specifies the number of data points that IQConnect.exe will queue before attempting to send across the socket to your app.
                query =
                    IQFeedConfiguration.IntradayIntervalHeader + dlr +
                    request.CurrentSymbol + dlr +
                    request.Interval + dlr +
                    request.BeginDateTime + dlr +
                    request.EndDateTime + dlr +
                    request.MaxDatapoints + dlr +
                    request.BeginFilterTime +
                    dlr + request.EndFilterTime + dlr +
                    request.DataDirection + dlr +
                    request.DatapointsPerSend + trm;

                _logger.Info(query);
                break;

            case "Daily Days":
                //HDX,[Symbol],[MaxDatapoints],[DataDirection],[RequestID],[DatapointsPerSend]<CR><LF>
                //Retrieves up to [MaxDatapoints] number of End-Of-Day Data for the specified [Symbol].
                //[Symbol] - Required - Max Length 30 characters.
                //[MaxDatapoints] - Required - The maximum number of data points to be retrieved.
                //[DataDirection] - Optional - '0' (default) for "newest to oldest" or '1' for "oldest to newest".
                //[RequestID] - Optional - Will be sent back at the start of each line of data returned for this request.
                //[DatapointsPerSend] - Optional - Specifies the number of data points that IQConnect.exe will queue before attempting to send across the socket to your app.
                query =
                    IQFeedConfiguration.DailyDaysHeader + dlr +
                    request.CurrentSymbol + dlr +
                    request.DatapointsPerSend + dlr +
                    request.DataDirection + dlr +
                    request.DatapointsPerSend + trm;

                _logger.Info(query);
                break;

            case "Daily Interval":
                //HDT,[Symbol],[BeginDate],[EndDate],[MaxDatapoints],[DataDirection],[RequestID],[DatapointsPerSend]<CR><LF>
                //Retrieves Daily data between [BeginDate] and [EndDate] for the specified [Symbol].
                //[Symbol] - Required - Max Length 30 characters.
                //[BeginDate] - Required if [EndDate] not specified - Format CCYYMMDD - Earliest date to receive data for.
                //[EndDate] - Required if [BeginDate] not specified - Format CCYYMMDD - Most recent date to receive data for.
                //[MaxDatapoints] - Optional - the maximum number of data points to be retrieved.
                //[DataDirection] - Optional - '0' (default) for "newest to oldest" or '1' for "oldest to newest".
                //[RequestID] - Optional - Will be sent back at the start of each line of data returned for this request.
                //[DatapointsPerSend] - Optional - Specifies the number of data points that IQConnect.exe will queue before attempting to send across the socket to your app.
                query =
                    IQFeedConfiguration.DailyIntervalHeader + dlr +
                    request.CurrentSymbol + dlr +
                    request.BeginDateTime + dlr +
                    request.EndDateTime + dlr +
                    request.MaxDatapoints + dlr +
                    request.DataDirection + dlr +
                    request.DatapointsPerSend + trm;

                _logger.Info(query);
                break;

            case "Weekly Days":
                //HWX,[Symbol],[MaxDatapoints],[DataDirection],[RequestID],[DatapointsPerSend]<CR><LF>
                //Retrieves up to [MaxDatapoints] data points of composite weekly data points for the specified [Symbol].
                //[Symbol] - Required - Max Length 30 characters.
                //[MaxDatapoints] - Required - The maximum number of data points to be retrieved.
                //[DataDirection] - Optional - '0' (default) for "newest to oldest" or '1' for "oldest to newest".
                //[RequestID] - Optional - Will be sent back at the start of each line of data returned for this request.
                //[DatapointsPerSend] - Optional - Specifies the number of data points that IQConnect.exe will queue before attempting to send across the socket to your app.
                query =
                    IQFeedConfiguration.WeeklyDaysHeader + dlr +
                    request.CurrentSymbol + dlr +
                    request.MaxDatapoints + dlr +
                    request.DataDirection + dlr +
                    request.DatapointsPerSend + trm;

                _logger.Info(query);
                break;

            case "Monthly Days":
                //HMX,[Symbol],[MaxDatapoints],[DataDirection],[RequestID],[DatapointsPerSend]<CR><LF>
                //Retrieves up to [MaxDatapoints] data points of composite monthly data points for the specified [Symbol].
                //[Symbol] - Required - Max Length 30 characters.
                //[MaxDatapoints] - Required - The maximum number of data points to be retrieved.
                //[DataDirection] - Optional - '0' (default) for "newest to oldest" or '1' for "oldest to newest".
                //[RequestID] - Optional - Will be sent back at the start of each line of data returned for this request.
                //[DatapointsPerSend] - Optional - Specifies the number of data points that IQConnect.exe will queue before attempting to send across the socket to your app.
                query =
                    IQFeedConfiguration.MonthlyDaysHeader + dlr +
                    request.CurrentSymbol + dlr +
                    request.MaxDatapoints + dlr +
                    request.DataDirection + dlr +
                    request.DatapointsPerSend + trm;

                _logger.Info(query);
                break;

            default:
                _logger.Error("Request error");
                break;
            }

            return(query);
        }