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 urllib.request import urlopen | |
from pyspark.sql import SparkSession | |
from pyspark.sql.types import StructType, StructField, StringType | |
from config import AppConfig | |
import findspark | |
from pipeline_utils import rename_cols, snake_case | |
from trading_data_pipeline.load_daily_bars_etl import JDBC_PROPERTIES | |
""" |
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 sqlalchemy as db | |
import pandas as pd | |
def create_upsert_method(meta: db.MetaData): | |
""" | |
Create upsert method that satisfied the pandas's to_sql API. Adapted to 2.0 | |
""" | |
def method(table, conn, keys, data_iter): |
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 json | |
from streamlit_lightweight_charts import renderLightweightCharts | |
import pandas_ta as ta | |
class StockChart: | |
@staticmethod | |
def show_chart(df, symbol): | |
COLOR_BULL = 'rgba(38,166,154,0.9)' # #26a69a |
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 | |
import pandas as pd | |
from dateutil.relativedelta import relativedelta | |
from dateutil.utils import today | |
from app.charts import render_candlestick_chart | |
import streamlit as st | |
import asyncio | |
import plotly.graph_objects as go |
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 abc import abstractmethod | |
import backtrader as bt | |
class BaseStrategy(bt.Strategy): | |
params = dict( | |
verbose=True, | |
longs_enabled=True, | |
shorts_enabled=True | |
) |
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, |
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
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 |
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
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 |
NewerOlder