Skip to content

Instantly share code, notes, and snippets.

View alexrios22's full-sized avatar
🎯
Focusing

Alexander Rios alexrios22

🎯
Focusing
View GitHub Profile
@alexrios22
alexrios22 / list.md
Created October 10, 2021 00:40 — forked from ih2502mk/list.md
Quantopian Lectures Saved
@alexrios22
alexrios22 / basic_examples.py
Created August 28, 2021 01:57 — forked from fefi95/basic_examples.py
Pattern Matching in Python
from typing import List
def http_error(status: int) -> str:
match status:
case 400:
return "Bad request"
case 404:
return "Not found"
case 418:
@alexrios22
alexrios22 / docker-compose-wordpress.yaml
Created August 20, 2021 21:13 — forked from pablokbs/docker-compose-wordpress.yaml
Docker-compose para wordpress con mysql
## docker-compose para correr wordpress con una base de datos en mysql
## by PeladoNerd https://youtu.be/eoFxMaeB9H4
version: '3.1'
services:
wordpress:
image: wordpress:php7.1-apache
ports:
@alexrios22
alexrios22 / Update_Amibroker_EOD_Tiingo.py
Created August 3, 2021 14:41 — forked from sanzpro/Update_Amibroker_EOD_Tiingo.py
Update Amibroker EOD Historical data from Tiingo.com
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 02 17:02:32 2017
@author: Vangelis@logical-invest.com
This script will pull the symbols from your specified Amibroker database and download historical EOD dividend adjusted data from Tiingo.com and will store them
in a folder (Destop/Data/TiingoEOD) as csv files, one for each stock (APPLE.csv SPY.csv, etc)
It will then attempt to open Amibroker and import the csv files.
You need:
1. To add your own Token number you will get when you register at Tiingo.com (line 51)
2. Specify the Amibroker database you want updated (line 99)
@alexrios22
alexrios22 / autofit_outliertreatment.py
Created August 3, 2021 01:06 — forked from wolframalpha/autofit_outliertreatment.py
Function to remove or cap outliers in columns of a `pandas.DataFrame`
def treatoutliers(self, df=None, columns=None, factor=1.5, method='IQR', treament='cap'):
"""
Removes the rows from self.df whose value does not lies in the specified standard deviation
:param columns:
:param in_stddev:
:return:
"""
# if not columns:
# columns = self.mandatory_cols_ + self.optional_cols_ + [self.target_col]
if not columns:
@alexrios22
alexrios22 / Trend.ibpynb
Created November 22, 2020 22:03
Trend.ibpynb
window = 253
# detrend tome series by MA
ratesM = data['Adj Close'].rolling(window).mean().dropna()
ratesD = data['Adj Close'].reindex(ratesM.index).sub(ratesM)
fig, axs = plt.subplots(2, figsize=(16, 8), sharex=True)
data['Adj Close'].plot(ax=axs[0], title="Trend")
ratesM.plot(ax=axs[0])
ratesD.plot(ax=axs[1], c="g", title="Residuals");
@alexrios22
alexrios22 / SeasonalDecompose2019NovDec.ibpynb
Created November 22, 2020 22:02
SeasonalDecompose2019NovDec.ibpynb
seasonal["2019-11":"2019-12"].plot(label='Seasonality', color="blue", figsize=(20,8));
@alexrios22
alexrios22 / SeasonalDecompose2019.ibpynb
Created November 22, 2020 22:01
SeasonalDecompose2019.ibpynb
seasonal["2019"].plot(label='Seasonality', color="blue", figsize=(20,8));
@alexrios22
alexrios22 / SeasonalDecompose.ibpynb
Created November 22, 2020 22:00
SeasonalDecompose.ibpynb
import statsmodels.api as sm
decomposition = sm.tsa.seasonal_decompose(data['Adj Close'], model="additive", period = 253)
trend = decomposition.trend
seasonal = decomposition.seasonal
residual = decomposition.resid
fig, axs = plt.subplots(4, figsize=(14, 10), sharex=True)
data['Adj Close'].plot(title='Original', color="blue", ax=axs[0])
trend.plot(title='Trend', color="red", ax=axs[1])
@alexrios22
alexrios22 / SeasonalDecomposeMoth.ibpynb
Created November 22, 2020 21:59
SeasonalDecomposeMoth.ibpynb
Monthly_Returns = ratesD.groupby([ratesD.index.year.rename('year'),
ratesD.index.month.rename('month')]
).median().to_frame("Returns")
Monthly_Returns.boxplot(by='month', figsize=(16, 8));