1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187 | # -*- coding: utf-8 -*-
import airflow
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from eod_pd import *
# -------------------------------------------------------------------------------
# dag
# these args will get passed on to each operator
# you can override them on a per-task basis during operator initialization
default_args = {
'owner': 'TongYu',
'catchup': False,
'start_date': airflow.utils.dates.days_ago(1),
}
dag = DAG(
'eod_pd_dag',
catchup=False,
default_args=default_args,
schedule_interval='30 7-11 * * 1-5',
dagrun_timeout=timedelta(minutes=15),
description='close_task pd dag')
# -------------------------------------------------------------------------------
basic_position_operator = PythonOperator(
task_id='basic_position_task',
python_callable=basic_position_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
basic_cash_flow_operator = PythonOperator(
task_id='basic_cash_flow_task',
python_callable=basic_cash_flow_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
basic_cash_flow_today_operator = PythonOperator(
task_id='basic_cash_flow_today_task',
python_callable=basic_cash_flow_today_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
basic_risks_default_close_operator = PythonOperator(
task_id='basic_risks_default_close_task',
python_callable=basic_risks_default_close_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
# basic_risks_risk_close_operator = PythonOperator(
# task_id='basic_risks_risk_close_task',
# python_callable=basic_risks_risk_close_pd_run,
# execution_timeout=timedelta(minutes=5),
# dag=dag)
basic_underlyer_position_default_close_operator = PythonOperator(
task_id='basic_underlyer_position_default_close_task',
python_callable=basic_underlyer_position_default_close_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
# basic_underlyer_position_risk_close_operator = PythonOperator(
# task_id='basic_underlyer_position_risk_close_task',
# python_callable=basic_underlyer_position_risk_close_pd_run,
# execution_timeout=timedelta(minutes=5),
# dag=dag)
basic_reference_data_operator = PythonOperator(
task_id='basic_reference_data_task',
python_callable=basic_reference_data_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
eod_position_default_close_operator = PythonOperator(
task_id='eod_position_default_close_task',
python_callable=eod_position_default_close_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
# eod_position_risk_close_operator = PythonOperator(
# task_id='eod_position_risk_close_task',
# python_callable=eod_position_risk_close_pd_run,
# execution_timeout=timedelta(minutes=5),
# dag=dag)
eod_risk_default_close_operator = PythonOperator(
task_id='eod_risk_default_close_task',
python_callable=eod_risk_default_close_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
# eod_risk_risk_close_operator = PythonOperator(
# task_id='eod_risk_risk_close_task',
# python_callable=eod_risk_risk_close_pd_run,
# execution_timeout=timedelta(minutes=5),
# dag=dag)
eod_daily_pnl_default_close_operator = PythonOperator(
task_id='eod_daily_pnl_default_close_task',
python_callable=eod_daily_pnl_default_close_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
# eod_daily_pnl_risk_close_operator = PythonOperator(
# task_id='eod_daily_pnl_risk_close_task',
# python_callable=eod_daily_pnl_risk_close_pd_run,
# execution_timeout=timedelta(minutes=5),
# dag=dag)
eod_hst_pnl_default_close_operator = PythonOperator(
task_id='eod_hst_pnl_default_close_task',
python_callable=eod_hst_pnl_default_close_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
# eod_hst_pnl_risk_close_operator = PythonOperator(
# task_id='eod_hst_pnl_risk_close_task',
# python_callable=eod_hst_pnl_risk_close_pd_run,
# execution_timeout=timedelta(minutes=5),
# dag=dag)
financial_otc_trade_default_close_operator = PythonOperator(
task_id='financial_otc_trade_default_close_task',
python_callable=financial_otc_trade_default_close_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
# financial_otc_trade_risk_close_operator = PythonOperator(
# task_id='financial_otc_trade_risk_close_task',
# python_callable=financial_otc_trade_risk_close_pd_run,
# execution_timeout=timedelta(minutes=5),
# dag=dag)
financial_otc_fund_detail_operator = PythonOperator(
task_id='financial_otc_fund_detail_task',
python_callable=financial_otc_fund_detail_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
finanical_otc_client_fund_operator = PythonOperator(
task_id='finanical_otc_client_fund_task',
python_callable=finanical_otc_client_fund_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
eod_shift_model_valuation_date_operator = PythonOperator(
task_id='eod_shift_model_valuation_date_task',
python_callable=eod_shift_model_valuation_date,
execution_timeout=timedelta(minutes=5),
dag=dag)
# -----------------------------------------------------------------------------------
# Operator Dependency Relationship
# default close tasks
basic_risks_default_close_operator.set_upstream(basic_position_operator)
eod_position_default_close_operator.set_upstream(basic_risks_default_close_operator)
eod_position_default_close_operator.set_upstream(basic_cash_flow_operator)
eod_position_default_close_operator.set_upstream(basic_reference_data_operator)
eod_risk_default_close_operator.set_upstream(eod_position_default_close_operator)
eod_risk_default_close_operator.set_upstream(basic_underlyer_position_default_close_operator)
eod_hst_pnl_default_close_operator.set_upstream(eod_position_default_close_operator)
eod_hst_pnl_default_close_operator.set_upstream(basic_underlyer_position_default_close_operator)
eod_hst_pnl_default_close_operator.set_upstream(basic_cash_flow_operator)
eod_daily_pnl_default_close_operator.set_upstream(eod_hst_pnl_default_close_operator)
eod_daily_pnl_default_close_operator.set_upstream(basic_cash_flow_today_operator)
financial_otc_trade_default_close_operator.set_upstream(basic_risks_default_close_operator)
financial_otc_trade_default_close_operator.set_upstream(basic_cash_flow_operator)
financial_otc_trade_default_close_operator.set_upstream(basic_reference_data_operator)
# risk close tasks
# basic_risks_risk_close_operator.set_upstream(basic_position_operator)
# eod_position_risk_close_operator.set_upstream(basic_risks_risk_close_operator)
# eod_position_risk_close_operator.set_upstream(basic_cash_flow_operator)
# eod_risk_risk_close_operator.set_upstream(eod_position_risk_close_operator)
# eod_risk_risk_close_operator.set_upstream(basic_underlyer_position_risk_close_operator)
# eod_hst_pnl_risk_close_operator.set_upstream(eod_position_risk_close_operator)
# eod_hst_pnl_risk_close_operator.set_upstream(basic_underlyer_position_risk_close_operator)
# eod_hst_pnl_risk_close_operator.set_upstream(basic_cash_flow_operator)
# eod_daily_pnl_risk_close_operator.set_upstream(eod_hst_pnl_risk_close_operator)
# eod_daily_pnl_risk_close_operator.set_upstream(basic_cash_flow_today_operator)
# financial_otc_trade_risk_close_operator.set_upstream(basic_risks_risk_close_operator)
# financial_otc_trade_risk_close_operator.set_upstream(basic_cash_flow_operator)
# financial_otc_trade_risk_close_operator.set_upstream(basic_reference_data_operator)
finanical_otc_client_fund_operator.set_upstream(basic_reference_data_operator)
|