This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date, datetime, timedelta | |
from dateutil.relativedelta import relativedelta | |
def build_formatted_range(interval: str, range_start: date | datetime = None, range_end: date | datetime = None, | |
period: str = None): | |
new_start = range_start | |
new_end = range_end | |
if range_end is None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
db: | |
image: mysql:5.7 | |
volumes: | |
- ./wp-data:/var/lib/mysql | |
restart: always | |
environment: | |
MYSQL_ROOT_PASSWORD: MyR00tMySQLPa$$w0rD | |
MYSQL_DATABASE: MyWordPressDatabaseName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
core: | |
i18n: | |
language: 'es' | |
logging: | |
version: 1 | |
formatters: | |
standard: | |
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s" | |
error: | |
format: "%(asctime)s - %(name)s - %(levelname)s <PID %(process)d:%(processName)s>\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from sqlalchemy import (Table, Column, Integer, Enum, Float, String, Date, Boolean, ForeignKey) | |
from sqlalchemy.orm import registry, relationship | |
from bot.domain import model | |
""" | |
Imperative mapping with dataclasses (models are dataclasses) | |
https://docs.sqlalchemy.org/en/14/orm/mapping_styles.html#imperative-mapping-with-dataclasses-and-attrs | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from os import environ as env | |
from typing import get_type_hints, Union | |
from dotenv import load_dotenv | |
env = os.getenv('ENVIRONMENT') | |
dotenv_path = f'.env.{env}' if env is not None else '.env' | |
load_dotenv(dotenv_path=dotenv_path) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
x-airflow-common: &airflow-common | |
# In order to add custom dependencies or upgrade provider packages you can use your extended image. | |
# Comment the image line, place your Dockerfile in the directory where you placed the docker-compose.yaml | |
# and uncomment the "build" line below, Then run `docker-compose build` to build the images. | |
image: trading-airflow #${AIRFLOW_IMAGE_NAME:-apache/airflow} | |
# build: . | |
environment: &airflow-common-env | |
AIRFLOW__CORE__EXECUTOR: LocalExecutor | |
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pathlib import Path | |
from sqlalchemy import create_engine | |
import pandas as pd | |
from trading_data_pipeline.config import AppConfig | |
config = AppConfig(os.environ) | |
connection_url = config.get_postgres_uri() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT s.symbol, s.sector, first(close, date) AS first_close, last(close, date) AS last_close, | |
MIN(date) AS first_date, | |
MAX(date) AS last_date, | |
100 * (last(close, date) - first(close, date)) / first(close, date) AS return_change | |
FROM | |
daily_bars db, stocks s | |
WHERE | |
db.date >= now() - interval '1 year' AND db.symbol = s.symbol | |
GROUP BY | |
s.symbol |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import backtrader as bt | |
from trading_backtesting.stop_trailer import StopTrailer | |
class GoldenCrossStrategy(bt.Strategy): | |
SHORT, NONE, LONG = -1, 0, 1 | |
params = dict( | |
fast_length=50, |
OlderNewer