Skip to content

💵 - PyInvestAnalyser is an application that allows you to monitor and analyze stock dividends, BDRs and real estate funds.

License

Notifications You must be signed in to change notification settings

ElisonLima/PyInvestAnalyser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyInvestAnalyser

Star LinkedIn wakatime Test

Python Docker Pytest Selenium

PyInvestAnalyser is a Python project that uses web scraping to obtain data on financial assets. With the help of Selenium, Docker, and Pyenv libraries, you can analyze relevant information about different assets in an automated manner.

Prerequisites

Before you start, 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. Access the project directory:

    $ cd PyInvestAnalyser
    
  3. Create and Install project dependencies:

    $ pip install pipenv
    $ pipenv install
    
  4. activate a virtual environment with Pyenv:

    $ pipenv shell
    
  5. Make sure 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 is an example of how to import the ExtractInfoFromStock class to obtain information about the B3SA3 stock:

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 execute a multi-threaded script to obtain information about multiple assets at the same time:

In this case, the script will obtain information about the stocks B3SA3, BBDC3, BBSE3, and BMGB4 and save the results in 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())

Contributing

If you want 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

About

💵 - PyInvestAnalyser is an application that allows you to monitor and analyze stock dividends, BDRs and real estate funds.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.3%
  • Dockerfile 0.7%