1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-11 06:46:56 +08:00

support parallel HF trading

This commit is contained in:
Young
2021-07-03 08:46:09 +00:00
parent a401f1eafe
commit ef7fe8aa75
3 changed files with 55 additions and 13 deletions

View File

@@ -242,6 +242,7 @@ class Exchange:
raise ValueError("trade_account and position can only choose one")
trade_price = self.get_deal_price(order.stock_id, order.start_time, order.end_time)
# NOTE: order will be changed in this function
trade_val, trade_cost = self._calc_trade_info_by_order(
order, trade_account.current if trade_account else position
)
@@ -256,16 +257,6 @@ class Exchange:
return trade_val, trade_cost, trade_price
def create_order(self, code, amount, start_time, end_time, direction) -> Order:
return Order(
stock_id=code,
amount=amount,
start_time=start_time,
end_time=end_time,
direction=direction,
factor=self.get_factor(code, start_time, end_time),
)
def get_quote_info(self, stock_id, start_time, end_time):
return resam_ts_data(self.quote[stock_id], start_time, end_time, method="last").iloc[0]
@@ -471,6 +462,8 @@ class Exchange:
"""
Calculation of trade info
**NOTE**: Order will be changed in this function
:param order:
:param position: Position
:return: trade_val, trade_cost