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

update exchange

This commit is contained in:
wangwenxi.handsome
2021-08-15 12:45:29 +00:00
committed by you-n-g
parent 2da6a8c770
commit f67b99a30e
4 changed files with 150 additions and 13 deletions

View File

@@ -21,7 +21,7 @@ from ..config import C, REG_CN
from ..utils.resam import resam_ts_data, ts_data_last
from ..log import get_module_logger
from .order import Order, OrderDir, OrderHelper
from .high_performance_ds import PandasQuote
from .high_performance_ds import PandasQuote, NumpyQuote
class Exchange:
@@ -39,7 +39,7 @@ class Exchange:
close_cost=0.0025,
min_cost=5,
extra_quote=None,
quote_cls=PandasQuote,
quote_cls=NumpyQuote,
**kwargs,
):
"""__init__
@@ -725,9 +725,9 @@ class Exchange:
"""
max_trade_amount = 0
if cash >= self.min_cost:
# critical_amount means the stock transaction amount when the service fee is equal to min_cost.
critical_amount = self.min_cost / self.open_cost + self.min_cost
if cash >= critical_amount:
# critical_price means the stock transaction price when the service fee is equal to min_cost.
critical_price = self.min_cost / self.open_cost + self.min_cost
if cash >= critical_price:
# the service fee is equal to open_cost * trade_amount
max_trade_amount = cash / (1 + self.open_cost) / trade_price
else: