58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
|
from strategy import trade_strategy
|
|||
|
from task.base_task import base_task
|
|||
|
from task.check_high_volume_func_task import check_high_volume_func_task
|
|||
|
from task.check_limit_up_func_task import check_limit_up_func_task
|
|||
|
from task.check_remain_amount_func_task import check_remain_amount_func_task
|
|||
|
from task.process_pending_buy_task import process_pending_buy_task
|
|||
|
from task.process_pending_sells_task import process_pending_sells_task
|
|||
|
|
|||
|
class trade_afternoon_task(base_task):
|
|||
|
"""
|
|||
|
下午交易任务:
|
|||
|
1. 检查是否有因为涨停破板触发的卖出信号;
|
|||
|
2. 如启用了成交量监控,则检测是否有异常成交量;
|
|||
|
3. 检查账户中是否需要补仓;
|
|||
|
4. 处理待买入和待卖出队列。
|
|||
|
|
|||
|
参数:
|
|||
|
context: 聚宽平台传入的交易上下文对象
|
|||
|
"""
|
|||
|
|
|||
|
def __init__(self, strategy: trade_strategy):
|
|||
|
super().__init__(strategy)
|
|||
|
|
|||
|
|
|||
|
|
|||
|
def begin(self, context):
|
|||
|
self.no_trading_today_signal = self.config['no_trading_today_signal']
|
|||
|
self.HV_control = bool(self.config['HV_control']) # 是否启用成交量监控
|
|||
|
|
|||
|
def run(self, context):
|
|||
|
|
|||
|
if not self.no_trading_today_signal:
|
|||
|
check_limit_up_task = check_limit_up_func_task(self.strategy, sub_task=self.sub_task)
|
|||
|
check_limit_up_task.process(context)
|
|||
|
|
|||
|
if self.HV_control:
|
|||
|
check_high_volume_task = check_high_volume_func_task(self.strategy)
|
|||
|
check_high_volume_task.process(context)
|
|||
|
|
|||
|
# 先处理待卖出股票
|
|||
|
process_pending_sells_task = process_pending_sells_task(self.strategy)
|
|||
|
process_pending_sells_task.process(context)
|
|||
|
|
|||
|
# 再检查是否需要补仓
|
|||
|
check_remain_amount_task = check_remain_amount_func_task(self.strategy, sub_task=self.sub_task)
|
|||
|
check_remain_amount_task.process(context)
|
|||
|
|
|||
|
# 最后处理待买入股票
|
|||
|
sells_task = process_pending_buy_task(self.strategy)
|
|||
|
sells_task.process(context)
|
|||
|
pass
|
|||
|
|
|||
|
def handle(self, context):
|
|||
|
pass
|
|||
|
|
|||
|
def end(self, context):
|
|||
|
pass
|