Skip to content

Commit 17c1099

Browse files
committed
Define daily options chain ingestion airflow DAG
1 parent 269dc32 commit 17c1099

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

airflow/dags/.DS_Store

6 KB
Binary file not shown.

airflow/dags/_bootstrap.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os
2+
import sys
3+
4+
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))
5+
6+
if APP_ROOT not in sys.path:
7+
sys.path.append(APP_ROOT)
8+
9+
print('sys.path:'); print(sys.path);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# FILE: `StockTrader/airflow/dags/ingest_options_chain_dag.py`
3+
#
4+
5+
import sys
6+
from pathlib import Path
7+
sys.path.append(str(Path(__file__).parents[2]))
8+
9+
from airflow import DAG
10+
from airflow.operators.python import PythonOperator
11+
from datetime import datetime, timedelta
12+
from scripts.ingest_options_chain import ingest_options_chain
13+
14+
default_args = {
15+
"owner": "airflow",
16+
"depends_on_past": False,
17+
# "start_date": datetime.today(),
18+
"start_date": datetime(2025,3,17),
19+
"retries": 1,
20+
"retry_delay": timedelta(minutes=2)
21+
}
22+
23+
# cron: minute hour day_of_month month day_of_week
24+
25+
dag = DAG(
26+
"ingest_options_chain",
27+
default_args = default_args,
28+
schedule_interval = "35 14 * * 1-5",
29+
catchup = False
30+
)
31+
32+
DOW30_DIVIDENDS = ['AXP', 'AMGN', 'AAPL', 'BA', 'CAT', 'CSCO', 'CVX', 'GS', 'HD', 'HON', 'IBM', 'JNJ', 'KO', 'JPM', 'MCD', 'MMM', 'MRK', 'MSFT', 'NKE', 'PG', 'TRV', 'UNH', 'CRM', 'VZ', 'V', 'WMT', 'DIS', 'DOW']
33+
34+
tasks = []
35+
for s in DOW30_DIVIDENDS:
36+
task = PythonOperator(
37+
task_id=f"ingest_options_chain_{s}",
38+
python_callable=ingest_options_chain,
39+
op_kwargs={"symbol":s},
40+
dag=dag
41+
)
42+
tasks.append(task)

airflow/dags/test_dag.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# FILE: `StockTrader/airflow/dags/test_dag.py`
3+
#
4+
5+
6+
import sys
7+
from pathlib import Path
8+
sys.path.append(str(Path(__file__).parents[2]))
9+
10+
from airflow import DAG
11+
from airflow.operators.dummy_operator import DummyOperator
12+
from datetime import datetime
13+
14+
from scripts.ingest_options_chain import ingest_options_chain
15+
16+
default_args = {"owner":"airflow", "start_date":datetime(2025,3,17), "retries":1}
17+
with DAG("test_dag", default_args=default_args, schedule_interval="@daily", catchup=False) as dag:
18+
start = DummyOperator(task_id="start")
19+
20+
start

0 commit comments

Comments
 (0)