# -*- coding: utf-8 -*-
import airflow
from intraday_pd import *
from airflow import DAG
from airflow.operators.python_operator import PythonOperator, ShortCircuitOperator
# -------------------------------------------------------------------------------
# dag
# these args will get passed on to each operator
# you can override them on a per-task basis during operator initialization
# this dag is used for recalc position report, the dag name is not corrected
default_args = {
'owner': 'TongYu',
'catchup': False,
'start_date': airflow.utils.dates.days_ago(1),
}
dag = DAG(
'real_time_valuation_dag',
catchup=False,
default_args=default_args,
schedule_interval=None,
dagrun_timeout=timedelta(minutes=15),
description='real_time_valuation 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_risks_operator = PythonOperator(
task_id='basic_risks_task',
python_callable=basic_risks_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)
real_time_position_operator = PythonOperator(
task_id='real_time_position_task',
python_callable=real_time_position_pd_run,
execution_timeout=timedelta(minutes=5),
dag=dag)
valuation_notification_operator = PythonOperator(
task_id='real_time_valuation_notification_task',
python_callable=intraday_valuation_report_notifier,
execution_timeout=timedelta(minutes=5),
dag=dag)
# -------------------------------------------------------------------------------
# Operator Dependency Relationship
basic_risks_operator.set_upstream(basic_position_operator)
real_time_position_operator.set_upstream(basic_risks_operator)
real_time_position_operator.set_upstream(basic_cash_flow_operator)
real_time_position_operator.set_upstream(basic_reference_data_operator)
real_time_position_operator.set_downstream(valuation_notification_operator)