Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mich committed Nov 16, 2018
2 parents a404285 + a339168 commit 157b066
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 3 additions & 5 deletions rqalpha/mod/rqalpha_mod_sys_simulation/slippage.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,14 @@ def get_trade_price(self, order, price):
temp_price = price + price * self.rate * (1 if side == SIDE.BUY else -1)
try:
temp_bar = Environment.get_instance().bar_dict[order.order_book_id]
except KeyError:
pass
else:
limit_up, limit_down = temp_bar.limit_up, temp_bar.limit_down

if is_valid_price(limit_up):
temp_price = min(temp_price, limit_up)

if is_valid_price(limit_down):
temp_price = max(temp_price, limit_down)
except KeyError:
# tick中没有涨跌停价
pass
return temp_price


Expand Down
4 changes: 3 additions & 1 deletion rqalpha/model/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ def get_limit_price(self):
def round_price(self, tick_size):
if tick_size:
with decimal_rounding_floor():
self.limit_price = float((Decimal(self.limit_price) / Decimal(tick_size)).to_integral() * Decimal(tick_size))
limit_price_decimal = round(Decimal(self.limit_price), 4)
tick_size_decimal = round(Decimal(tick_size), 4)
self.limit_price = float((limit_price_decimal / tick_size_decimal).to_integral() * tick_size_decimal)
else:
user_system_log.warn('Invalid tick size: {}'.format(tick_size))

0 comments on commit 157b066

Please sign in to comment.