Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuizi7 committed Sep 24, 2017
2 parents 22e56a1 + 107b5c7 commit 0d519ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion rqalpha/mod/rqalpha_mod_sys_simulation/mod.py
Expand Up @@ -19,7 +19,7 @@
from rqalpha.interface import AbstractMod
from rqalpha.utils.i18n import gettext as _
from rqalpha.utils.exception import patch_user_exc
from rqalpha.const import MATCHING_TYPE
from rqalpha.const import MATCHING_TYPE, RUN_TYPE

from .simulation_broker import SimulationBroker
from .signal_broker import SignalBroker
Expand All @@ -31,6 +31,10 @@ def __init__(self):
pass

def start_up(self, env, mod_config):

if env.config.base.run_type == RUN_TYPE.LIVE_TRADING:
return

mod_config.matching_type = self.parse_matching_type(mod_config.matching_type)
if mod_config.commission_multiplier < 0:
raise patch_user_exc(ValueError(_(u"invalid commission multiplier value: value range is [0, +∞)")))
Expand Down
9 changes: 5 additions & 4 deletions rqalpha/mod/rqalpha_mod_sys_simulation/signal_broker.py
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import numpy as np
from copy import copy

from rqalpha.interface import AbstractBroker
from rqalpha.utils.logger import user_system_log
Expand Down Expand Up @@ -43,11 +44,11 @@ def get_open_orders(self, order_book_id=None):

def submit_order(self, order):
account = self._env.get_account(order.order_book_id)
self._env.event_bus.publish_event(Event(EVENT.ORDER_PENDING_NEW, account=account, order=order))
self._env.event_bus.publish_event(Event(EVENT.ORDER_PENDING_NEW, account=account, order=copy(order)))
if order.is_final():
return
order.active()
self._env.event_bus.publish_event(Event(EVENT.ORDER_CREATION_PASS, account=account, order=order))
self._env.event_bus.publish_event(Event(EVENT.ORDER_CREATION_PASS, account=account, order=copy(order)))
self._match(account, order)

def cancel_order(self, order):
Expand All @@ -73,7 +74,7 @@ def _match(self, account, order):
reason = _(u"Order Cancelled: current bar [{order_book_id}] miss market data.").format(
order_book_id=order_book_id)
order.mark_rejected(reason)
self._env.event_bus.publish_event(Event(EVENT.ORDER_UNSOLICITED_UPDATE, account=account, order=order))
self._env.event_bus.publish_event(Event(EVENT.ORDER_UNSOLICITED_UPDATE, account=account, order=copy(order)))
return

if order.type == ORDER_TYPE.LIMIT:
Expand Down Expand Up @@ -116,4 +117,4 @@ def _match(self, account, order):
trade._tax = self._tax_decider.get_tax(account.type, trade)
order.fill(trade)

self._env.event_bus.publish_event(Event(EVENT.TRADE, account=account, trade=trade, order=order))
self._env.event_bus.publish_event(Event(EVENT.TRADE, account=account, trade=trade, order=copy(order)))

0 comments on commit 0d519ea

Please sign in to comment.