"""单日轮动执行所需的单表核验。""" from app.core import strategy_book as books from app.db import session as db def buy_ban(code): with books.scope(books.ORIGINAL): rows = db.fetch_all( "SELECT cmd_type FROM pms_command WHERE ts_code=:code AND cmd_class='param' " "AND status='EFFECTIVE' AND cmd_type IN ('FREEZE_STOCK','UNFREEZE_STOCK'," "'BLACKLIST_ADD','BLACKLIST_REMOVE') ORDER BY id DESC", {'code': code}) types = [row['cmd_type'] for row in rows] frozen = next((t for t in types if t in ('FREEZE_STOCK', 'UNFREEZE_STOCK')), '') black = next((t for t in types if t in ('BLACKLIST_ADD', 'BLACKLIST_REMOVE')), '') return frozen == 'FREEZE_STOCK' or black == 'BLACKLIST_ADD' def release_parent(parent): return db.execute( "UPDATE pms_instruction SET status='PROPOSED',updated_at=:at " "WHERE instruction_id=:iid AND origin_id=:plan AND status='WAIT_REVIEW' AND exec_qty=0", {'at': parent['at'], 'iid': parent['id'], 'plan': 'P_'+parent['id']})