Skip to content

Instantly share code, notes, and snippets.

View fsndzomga's full-sized avatar

Franck Stéphane Ndzomga fsndzomga

View GitHub Profile
# Use Ubuntu 20.04 LTS as a base image
FROM ubuntu:20.04
# Prevent apt from asking questions when installing packages
ARG DEBIAN_FRONTEND=noninteractive
# Set the working directory in the container
WORKDIR /app
# Install PostgreSQL, Python, Tesseract-OCR, and other necessary packages in one RUN command
# Step 1: Set the base image
FROM node:14
# Step 2: Set working directory
WORKDIR /usr/src/app
# Step 3: Copy package.json files
COPY package*.json ./
# Step 4: Install dependencies
import yfinance as yf
import pandas as pd
# Define tickers by sector
sectors = {
'Technology': ['AAPL', 'MSFT', 'GOOGL'],
'Healthcare': ['JNJ', 'PFE', 'MRK'],
'Consumer Discretionary': ['AMZN', 'TSLA', 'MCD']
}
import yfinance as yf
import matplotlib.pyplot as plt
import pandas as pd
# Fetch historical data for AAPL
data = yf.download('AAPL', start='2023-01-01', end='2024-01-01')
# Calculate RSI
def RSI(data, window=14):
delta = data['Adj Close'].diff(1)
import yfinance as yf
import numpy as np
import pandas as pd
# Fetch historical data for AAPL and MSFT
tickers = ['AAPL', 'MSFT']
data = yf.download(tickers, start='2022-01-01', end='2023-01-01')['Adj Close']
# Calculate daily returns
daily_returns = data.pct_change().dropna()
import yfinance as yf
import pandas as pd
import numpy as np
# Define the tickers of the stocks in the portfolio
tickers = ['AAPL', 'MSFT', 'AMZN']
# Fetch historical data for these stocks
data = yf.download(tickers, start='2023-01-01', end='2024-01-01')['Adj Close']
import yfinance as yf
import pandas as pd
import matplotlib.pyplot as plt
# Define the ticker symbols for the stock and the benchmark index
stock_symbol = 'AAPL'
benchmark_symbol = '^GSPC'
# Fetch historical data for the past year
stock_data = yf.download(stock_symbol, start='2023-01-01', end='2024-01-01')
import yfinance as yfinance
import pandas as data_frame
import numpy as numerical
def retrieve_stock_data(symbol, begin_date, finish_date):
"""
Obtain historical stock data from Yahoo Finance.
"""
historical_data = yfinance.download(symbol, start=begin_date, end=finish_date)
return historical_data
import yfinance as yf
import pandas as pd
import numpy as np
def fetch_stock_data(ticker, start_date, end_date):
"""
Fetch historical stock data from Yahoo Finance.
"""
stock_data = yf.download(ticker, start=start_date, end=end_date)
return stock_data
!pip install edsl
# Need to set an OPENAI_API_KEY as environnement variable
from google.colab import userdata
import os
os.environ['OPENAI_API_KEY'] = userdata.get('OPENAI_API_KEY')
from edsl.questions import QuestionMultipleChoice