Skip to content

Commit

Permalink
[Mod] translation core language to English
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy committed Dec 20, 2023
1 parent 49124e9 commit 4f9eba7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 55 deletions.
54 changes: 27 additions & 27 deletions vnpy/trader/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,57 @@ class Direction(Enum):
"""
Direction of order/trade/position.
"""
LONG = ""
SHORT = ""
NET = ""
LONG = "Long"
SHORT = "Short"
NET = "Net"


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"
Expand All @@ -70,8 +70,8 @@ class OptionType(Enum):
"""
Option type.
"""
CALL = "看涨期权"
PUT = "看跌期权"
CALL = "Call"
PUT = "PUT"


class Exchange(Enum):
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions vnpy/trader/datafeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"

Expand All @@ -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
4 changes: 2 additions & 2 deletions vnpy/trader/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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]]:
Expand Down
40 changes: 20 additions & 20 deletions vnpy/trader/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand All @@ -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:
""""""
Expand All @@ -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
Expand All @@ -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()

Expand All @@ -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

Expand Down Expand Up @@ -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()

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vnpy/trader/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


SETTINGS: Dict[str, Any] = {
"font.family": "微软雅黑",
"font.family": "Arial",
"font.size": 12,

"log.active": True,
Expand Down

0 comments on commit 4f9eba7

Please sign in to comment.