diff --git a/vnpy/trader/constant.py b/vnpy/trader/constant.py index 2d5b1f5..c443157 100644 --- a/vnpy/trader/constant.py +++ b/vnpy/trader/constant.py @@ -9,9 +9,9 @@ class Direction(Enum): """ Direction of order/trade/position. """ - LONG = "多" - SHORT = "空" - NET = "净" + LONG = "Long" + SHORT = "Short" + NET = "Net" class Offset(Enum): @@ -19,47 +19,47 @@ class Offset(Enum): Offset of order/trade. """ NONE = "" - OPEN = "开" - CLOSE = "平" - CLOSETODAY = "平今" - CLOSEYESTERDAY = "平昨" + OPEN = "Open" + CLOSE = "Close" + CLOSETODAY = "CloseToday" + CLOSEYESTERDAY = "CloseYesterday" class Status(Enum): """ Order status. """ - SUBMITTING = "提交中" - NOTTRADED = "未成交" - PARTTRADED = "部分成交" - ALLTRADED = "全部成交" - CANCELLED = "已撤销" - REJECTED = "拒单" + SUBMITTING = "Submitting" + NOTTRADED = "Not Traded" + PARTTRADED = "Part Traded" + ALLTRADED = "All Traded" + CANCELLED = "Cancelled" + REJECTED = "Rejected" class Product(Enum): """ Product class. """ - EQUITY = "股票" - FUTURES = "期货" - OPTION = "期权" - INDEX = "指数" - FOREX = "外汇" - SPOT = "现货" + EQUITY = "Equity" + FUTURES = "Futures" + OPTION = "Option" + INDEX = "Index" + FOREX = "Forex" + SPOT = "Spot" ETF = "ETF" - BOND = "债券" - WARRANT = "权证" - SPREAD = "价差" - FUND = "基金" + BOND = "Bond" + WARRANT = "Warrant" + SPREAD = "Spread" + FUND = "Fund" class OrderType(Enum): """ Order type. """ - LIMIT = "限价" - MARKET = "市价" + LIMIT = "LIMIT" + MARKET = "MARKET" STOP = "STOP" FAK = "FAK" FOK = "FOK" @@ -70,8 +70,8 @@ class OptionType(Enum): """ Option type. """ - CALL = "看涨期权" - PUT = "看跌期权" + CALL = "Call" + PUT = "PUT" class Exchange(Enum): diff --git a/vnpy/trader/database.py b/vnpy/trader/database.py index b384093..3c7842a 100644 --- a/vnpy/trader/database.py +++ b/vnpy/trader/database.py @@ -151,7 +151,7 @@ def get_database() -> BaseDatabase: try: module: ModuleType = import_module(module_name) except ModuleNotFoundError: - print(f"找不到数据库驱动{module_name},使用默认的SQLite数据库") + print(f"Database adaptor missing {module_name}, use the default SQLite adaptor.") module: ModuleType = import_module("vnpy_sqlite") # Create database object from module diff --git a/vnpy/trader/datafeed.py b/vnpy/trader/datafeed.py index 0f840e1..cf46732 100644 --- a/vnpy/trader/datafeed.py +++ b/vnpy/trader/datafeed.py @@ -22,13 +22,13 @@ def query_bar_history(self, req: HistoryRequest, output: Callable = print) -> Op """ Query history bar data. """ - output("查询K线数据失败:没有正确配置数据服务") + output("Failed to query bar history, please check datafeed config.") def query_tick_history(self, req: HistoryRequest, output: Callable = print) -> Optional[List[TickData]]: """ Query history tick data. """ - output("查询Tick数据失败:没有正确配置数据服务") + output("Failed to query tick history, please check datafeed config.") datafeed: BaseDatafeed = None @@ -47,7 +47,7 @@ def get_datafeed() -> BaseDatafeed: if not datafeed_name: datafeed = BaseDatafeed() - print("没有配置要使用的数据服务,请修改全局配置中的datafeed相关内容") + print("Missing datafeed config, please update datafeed setting in global settings.") else: module_name: str = f"vnpy_{datafeed_name}" @@ -61,6 +61,6 @@ def get_datafeed() -> BaseDatafeed: except ModuleNotFoundError: datafeed = BaseDatafeed() - print(f"无法加载数据服务模块,请运行 pip install {module_name} 尝试安装") + print(f"Faild to import datafeed module, run [pip install {module_name}] to install.") return datafeed diff --git a/vnpy/trader/engine.py b/vnpy/trader/engine.py index 6a956a1..0b92da3 100644 --- a/vnpy/trader/engine.py +++ b/vnpy/trader/engine.py @@ -124,7 +124,7 @@ def get_gateway(self, gateway_name: str) -> BaseGateway: """ gateway: BaseGateway = self.gateways.get(gateway_name, None) if not gateway: - self.write_log(f"找不到底层接口:{gateway_name}") + self.write_log(f"Gateway missing: {gateway_name}") return gateway def get_engine(self, engine_name: str) -> "BaseEngine": @@ -133,7 +133,7 @@ def get_engine(self, engine_name: str) -> "BaseEngine": """ engine: BaseEngine = self.engines.get(engine_name, None) if not engine: - self.write_log(f"找不到引擎:{engine_name}") + self.write_log(f"Engine missing: {engine_name}") return engine def get_default_setting(self, gateway_name: str) -> Optional[Dict[str, Any]]: diff --git a/vnpy/trader/optimize.py b/vnpy/trader/optimize.py index 3592bc2..e3450f2 100644 --- a/vnpy/trader/optimize.py +++ b/vnpy/trader/optimize.py @@ -41,13 +41,13 @@ def add_parameter( """""" if end is None and step is None: self.params[name] = [start] - return True, "固定参数添加成功" + return True, "Fixed parameter added." if start >= end: - return False, "参数优化起始点必须小于终止点" + return False, "Start value must be lower than end value." if step <= 0: - return False, "参数优化步进必须大于0" + return False, "Step must be higher than 0." value: float = start value_list: List[float] = [] @@ -58,7 +58,7 @@ def add_parameter( self.params[name] = value_list - return True, f"范围参数添加成功,数量{len(value_list)}" + return True, f"Range parameter added, total count {len(value_list)}." def set_target(self, target_name: str) -> None: """""" @@ -84,11 +84,11 @@ def check_optimization_setting( ) -> bool: """""" if not optimization_setting.generate_settings(): - output("优化参数组合为空,请检查") + output("The optimization space is empty, please check the setting.") return False if not optimization_setting.target_name: - output("优化目标未设置,请检查") + output("The optimization target is not set, please check the setting.") return False return True @@ -104,8 +104,8 @@ def run_bf_optimization( """Run brutal force optimization""" settings: List[Dict] = optimization_setting.generate_settings() - output("开始执行穷举算法优化") - output(f"参数优化空间:{len(settings)}") + output("Brute-force optimization started.") + output(f"Total space conut: {len(settings)}") start: int = perf_counter() @@ -122,7 +122,7 @@ def run_bf_optimization( end: int = perf_counter() cost: int = int((end - start)) - output(f"穷举算法优化完成,耗时{cost}秒") + output(f"Brute-force optimization finished, time cost: {cost}s.") return results @@ -181,20 +181,20 @@ def mutate_individual(individual: list, indpb: float) -> tuple: lambda_: int = pop_size # number of children to produce at each generation mu: int = int(pop_size * 0.8) # number of individuals to select for the next generation - cxpb: float = 0.95 # probability that an offspring is produced by crossover - mutpb: float = 1 - cxpb # probability that an offspring is produced by mutation - ngen: int = ngen_size # number of generation + cxpb: float = 0.95 # probability that an offspring is produced by crossover + mutpb: float = 1 - cxpb # probability that an offspring is produced by mutation + ngen: int = ngen_size # number of generation pop: list = toolbox.population(pop_size) # Run ga optimization - output("开始执行遗传算法优化") - output(f"参数优化空间:{total_size}") - output(f"每代族群总数:{pop_size}") - output(f"优良筛选个数:{mu}") - output(f"迭代次数:{ngen}") - output(f"交叉概率:{cxpb:.0%}") - output(f"突变概率:{mutpb:.0%}") + output("Genetic-algorithm optimization started.") + output(f"Total space: {total_size}") + output(f"Population size: {pop_size}") + output(f"Selection size: {mu}") + output(f"Generation limit: {ngen}") + output(f"Crossover probability: {cxpb:.0%}") + output(f"Mutation probability: {mutpb:.0%}") start: int = perf_counter() @@ -212,7 +212,7 @@ def mutate_individual(individual: list, indpb: float) -> tuple: end: int = perf_counter() cost: int = int((end - start)) - output(f"遗传算法优化完成,耗时{cost}秒") + output(f"Genetic-algorithm optimization finished, time cost: {cost}s.") results: list = list(cache.values()) results.sort(reverse=True, key=key_func) diff --git a/vnpy/trader/setting.py b/vnpy/trader/setting.py index 27111ac..29eacee 100644 --- a/vnpy/trader/setting.py +++ b/vnpy/trader/setting.py @@ -10,7 +10,7 @@ SETTINGS: Dict[str, Any] = { - "font.family": "微软雅黑", + "font.family": "Arial", "font.size": 12, "log.active": True,