Releases: ericksonlopes/PyInvestAnalyser
v1.0.0-beta
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:
-
Clone this repository:
$ git clone https://github.com/ericksonlopes/PyInvestAnalyser.git
-
Navigate to the project directory:
$ cd PyInvestAnalyser
-
Create and activate a virtual environment with Pyenv:
$ pip install pipenv $ pipenv install
-
Install the project dependencies:
$ pip install -r requirements.txt
-
Ensure that Docker is running.
-
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:
-
Fork the project.
-
Create a new branch (
git checkout -b feature/new-feature
). -
Make your changes.
-
Commit your changes (
git commit -am 'Add new feature'
). -
Push to the branch (
git push origin feature/new-feature
). -
Open a Pull Request.
Authors
License
This project is licensed under the MIT License.