Code Monkey home page Code Monkey logo

stock-data-emailer's Introduction

About

This repository contains a bot designed to extract data from a stock portfolio listed in Excel using the pandas_datareader library. It fetches data from the last n days, where n is the input value of the function. From this data, it calculates today's value and the minimum, average, and maximum values of the adjusted closing prices for the last n days.

Additionally, the bot extracts quotes for the dollar, euro, and cryptocurrencies using an API.

Finally, it includes a function to send all this information via email.

Installation:

To set up the project, follow these steps:

  1. Initialize a virtual environment within the project folder:

    Linux or Mac:

    python3 -m venv .env
    source env/bin/activate

    Windows:

    py -m venv .env
    .\env\Scripts\activate
  2. Install dependencies:

    pip install -r requirements.txt

Configuration:

This repository contains several Python scripts:

  • cotacoes.py: This script is an independent program with two functions:

    • carteira(n_days): This function takes the number of retroactive days as a parameter and defaults to today's date as the end date. For each stock in the portfolio, the function returns today's calculated adjustment, as well as the minimum, average, and maximum values for the last n days.
    • moeda(): This function takes no parameters and returns the values of quotes for the dollar, euro, and cryptocurrency at the moment the program is executed.
  • cotacoesHTML.py: Similar to cotacoes.py, but with HTML adjustments to format the email sending.

  • robotmail.py: This script contains the send_mail(message1, message2) function, which takes two parameters representing the carteira and moeda functions. It sends the results to the specified email address.

Before using the email functionality, ensure you modify the following fields in the code:

  • sender_email: Your email address.
  • receiver_email: The recipient's email address.
  • password: Your email password. If using Gmail, you may need to generate an app password.

Failure to provide accurate credentials, especially for Gmail accounts, may result in email sending failures due to Google's security settings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.