Skip to content

Releases: ericksonlopes/PyInvestAnalyser

v1.0.0-beta

30 Jun 17:39
Compare
Choose a tag to compare
v1.0.0-beta Pre-release
Pre-release

PyInvestAnalyser - Release Summary

PyInvestAnalyser is a Python project that utilizes web scraping to gather data about financial assets. With the help of Selenium, Docker, and Pyenv libraries, you can automate the analysis of different assets and obtain relevant information.

Prerequisites

Before getting started, make sure you have the following prerequisites installed:

  • Python (recommended to use Pyenv for package management)
  • Docker

Installation

Follow the steps below to install the project:

  1. Clone this repository:

    $ git clone https://github.com/ericksonlopes/PyInvestAnalyser.git
    
  2. Navigate to the project directory:

    $ cd PyInvestAnalyser
    
  3. Create and activate a virtual environment with Pyenv:

    $ pip install pipenv
    $ pipenv install
    
  4. Install the project dependencies:

    $ pip install -r requirements.txt
    
  5. Ensure that Docker is running.

  6. Run Docker Compose to start the execution environment:

    $ docker-compose up -d
    

Usage

To use PyInvestAnalyser, follow these steps:

Import the ExtractInfoFromStock class for the respective type of asset you want to analyze (stocks, real estate funds, and DBRs):

Here's an example of how to import the ExtractInfoFromStock class to get information about the stock B3SA3:

from src.services import ExtractInfoFromStock

stock = ExtractInfoFromStock().get_info_active('B3SA3')

print(stock)
# Stock(name='B3SA3', company_nam...

Additionally, providing context to a more complex example, you can run a multithreaded script to retrieve information about multiple assets simultaneously:

In this case, the script will obtain information about the stocks B3SA3, BBDC3, BBSE3, and BMGB4 and save the results to a CSV file.

import concurrent.futures
import csv

from src.models import Stock
from src.services import ExtractInfoFromStock

actives = [
    'B3SA3',
    'BBDC3',
    'BBSE3',
    'BMGB4'
]

result_actives = []

with concurrent.futures.ThreadPoolExecutor() as executor:
    futures = [executor.submit(ExtractInfoFromStock().get_info_active, active) for active in actives]

    for future in concurrent.futures.as_completed(futures):
        try:
            active = future.result()

            if isinstance(active, str):
                active = ExtractInfoFromStock().get_active_keys_indicators(active)

            result_actives.append(active)

        except Exception as e:
            print(f'Error1: {str(e)}')

with open('result_for_actives.csv', 'w', newline='', encoding="utf-8") as file:
    writer = csv.writer(file)
    writer.writerow(Stock().get_meaning_of_fields().values())

    for active in result_actives:
        writer.writerow(active.__dict__.values())

Contribution

If you wish to contribute to the PyInvestAnalyser project, follow the steps below:

  1. Fork the project.

  2. Create a new branch (git checkout -b feature/new-feature).

  3. Make your changes.

  4. Commit your changes (git commit -am 'Add new feature').

  5. Push to the branch (git push origin feature/new-feature).

  6. Open a Pull Request.

Authors

License

This project is licensed under the MIT License.

References