{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ade96712",
   "metadata": {},
   "source": [
    "# Simple moving average - media mobile semplice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c7b11328",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "plt.style.use(\"seaborn-v0_8\")\n",
    "#plt.style.use(\"seaborn\")\n",
    "import yfinance as yf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a5e40188",
   "metadata": {},
   "outputs": [],
   "source": [
    "sp500 = yf.download(\"^GSPC\", start=\"2014-10-01\", end=\"2024-10-01\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "caead5dc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "30b46def",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac027f32",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f55581bd",
   "metadata": {},
   "source": [
    "$$\\text{SMA}_{\\text{oggi}} = \\frac{\\text{PREZZO}_\\text{ieri}}{N} + ... + \\frac{\\text{PREZZO}_\\text{N giorni prima}}{N} $$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e806c2f1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49f22e53",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0f53acf5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "229da33d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8488b22c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b0c9d153",
   "metadata": {},
   "source": [
    "# Exponential moving average - media mobile esponenziale"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2514a644",
   "metadata": {},
   "source": [
    "$$\\text{SMA}_{\\text{oggi}} = \\frac{\\text{PREZZO}_\\text{ieri}}{N} + ... + \\frac{\\text{PREZZO}_\\text{N giorni prima}}{N} $$\n",
    "$$\\text{EMA}_{\\text{oggi}} = \\text{PREZZO}_{\\text{ieri}} \\cdot \\frac{2}{\\text{span}+1} + \\text{EMA}_{\\text{ieri}} \\cdot \\frac{\\text{span}-1}{\\text{span}+1}$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f65d0d7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cd343a5e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7406e3c5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8897cc7b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
