diff --git a/app/services/intraday_rotation.py b/app/services/intraday_rotation.py index c684ad0..dafce99 100644 --- a/app/services/intraday_rotation.py +++ b/app/services/intraday_rotation.py @@ -32,7 +32,9 @@ def read_release(now): with books.scope(books.MICRO): command = pms_repo.get_command(release['command_id']) or {} params = command.get('params') or {} - if command.get('status') != 'EXECUTING' or command.get('issued_by') != 'user' or command.get('cmd_type') != 'ROTATE_MICRO': + if (command.get('status') != 'EXECUTING' or command.get('issued_by') != 'user' + or command.get('cmd_type') != 'ROTATE_MICRO' or command.get('archived_at') + or (command.get('progress') or {}).get('cancel_requested')): return None if any(params.get(k) != release[k] for k in ('authorization','ticket','expires_at','snapshot_version','rule_version')): raise ValueError('盘中指令与授权版本不一致') @@ -59,6 +61,7 @@ def basket_for(now, morning, config): and release['rule_version'] == config['rule_version'] == core.EXECUTION_RULE and basket.get('authorization') in (release['authorization'], (auth.get('revision') or {}).get('replaces')) and release['expires_at'] == auth.get('expires_at') == ticket.get('expires_at') + and release.get('funding_sales') is auth.get('funding_sales') and release['authorization'] == ticket.get('source_auth') and release['ticket'] == ticket.get('id') and ticket.get('no_carry') is True and ticket.get('book') == books.MICRO and release['snapshot_version'] == ticket.get('source_version') == basket.get('snapshot_version') diff --git a/scripts/test_intraday_rotation.py b/scripts/test_intraday_rotation.py index 04e1f3b..86a9d06 100644 --- a/scripts/test_intraday_rotation.py +++ b/scripts/test_intraday_rotation.py @@ -29,7 +29,7 @@ class IntradayEntry(TestCase): self.lines = [dict(code=c, id='PARENT'+c, side='buy',qty=100) for c in self.codes[:44]] self.docs = {entry.release_key(self.day): self.release, 'intraday-basket:155:'+self.day: self.basket, 'auth2':dict(actor='user',account='155模拟', effective_date=self.day,rule_version=core.EXECUTION_RULE, - expires_at=self.release['expires_at'],revision={'replaces':'auth1'}), + expires_at=self.release['expires_at'],funding_sales=True,revision={'replaces':'auth1'}), 'ticket':dict(id='ticket',source_auth='auth2',source_version=self.basket['snapshot_version'], expires_at=self.release['expires_at'], no_carry=True,book='micro30',lines=self.lines), 'state:live':{'rotation':{'phase':'entering_micro','consumed_entry':self.basket['snapshot_version'], @@ -95,6 +95,9 @@ class IntradayEntry(TestCase): self.order['side']='sell' self.parent.update(book_id='original',side='sell') self.assertTrue(eo.prepare_send('child')['marked']) + self.cmd['progress']={'cancel_requested':True} + self.assertFalse(eo.prepare_send('child')['marked']) + self.cmd['progress']={} self.cmd['status']='CANCELLED' self.assertFalse(eo.prepare_send('child')['marked']) self.assertEqual(mark.call_count,1)