Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

翻译中文 #150

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bxbot-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<artifactId>bxbot-app</artifactId>
<packaging>jar</packaging>
<name>BX-bot App</name>
<!-- 构建可分发的BX-bot应用程序-->
<description>Builds the distributable BX-bot app</description>
<url>http://github.com/gazbert/bxbot</url>
<parent>
Expand Down
5 changes: 3 additions & 2 deletions bxbot-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<artifactId>bxbot-core</artifactId>
<packaging>jar</packaging>
<name>BX-bot Core</name>
<!-- 机器人的核心-它包括主要的交易引擎-->
<description>The core of the bot - it includes the main Trading Engine</description>
<url>http://github.com/gazbert/bxbot</url>
<parent>
Expand Down Expand Up @@ -50,7 +51,7 @@
</dependency>

<!--
3rd party dependencies
3rd party dependencies 第三方依赖关系
-->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -90,7 +91,7 @@
</dependency>

<!--
Testing dependencies
Testing dependencies 测试依赖关系
-->
<dependency>
<groupId>org.powermock</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.HashMap;
import java.util.Map;

/**
/** Exchange API认证配置。
* Exchange API Authentication config.
*
* @author gazbert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.logging.log4j.Logger;

/**
*Util类,用于构建Exchange API配置。
* Util class for building the Exchange API config.
*
* @author gazbert
Expand All @@ -43,9 +44,10 @@ private ExchangeApiConfigBuilder() {
}

/**
* 构建Exchange API配置。
* Builds Exchange API config.
*
* @param exchangeConfig the raw Exchange config.
* @param exchangeConfig the raw Exchange config. 原始Exchange配置。
* @return the API Exchange config.
*/
public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) {
Expand All @@ -65,8 +67,7 @@ public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) {
} else {
LOG.info(
() ->
"No (optional) NetworkConfiguration NonFatalErrorCodes have been set for "
+ "Exchange Adapter: "
"No (optional) NetworkConfiguration NonFatalErrorCodes have been set for Exchange Adapter: “没有(可选)NetworkConfiguration NonFatalErrorCodes 已为 Exchange 适配器设置:”"
+ exchangeConfig.getAdapter());
}

Expand All @@ -76,18 +77,17 @@ public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) {
} else {
LOG.info(
() ->
"No (optional) NetworkConfiguration NonFatalErrorMessages have been set for "
+ "Exchange Adapter: "
"No (optional) NetworkConfiguration NonFatalErrorMessages have been set for Exchange Adapter: “没有(可选)NetworkConfiguration NonFatalErrorMessages 已为 Exchange 适配器设置:”"
+ exchangeConfig.getAdapter());
}

exchangeApiConfig.setNetworkConfig(exchangeApiNetworkConfig);
LOG.info(() -> "NetworkConfiguration has been set: " + exchangeApiNetworkConfig);
LOG.info(() -> "NetworkConfiguration has been set: NetworkConfiguration 已设置: " + exchangeApiNetworkConfig);

} else {
LOG.info(
() ->
"No (optional) NetworkConfiguration has been set for Exchange Adapter: "
"No (optional) NetworkConfiguration has been set for Exchange Adapter: “没有(可选)为 Exchange 适配器设置网络配置:”"
+ exchangeConfig.getAdapter());
}

Expand All @@ -98,13 +98,13 @@ public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) {
exchangeApiAuthenticationConfig.setItems(authenticationConfig);
exchangeApiConfig.setAuthenticationConfig(exchangeApiAuthenticationConfig);

// We don't log the creds!
LOG.info(() -> "AuthenticationConfiguration has been set successfully.");
// We don't log the creds! 我们不记录信用!
LOG.info(() -> "AuthenticationConfiguration has been set successfully.AuthenticationConfiguration 已成功设置。");

} else {
LOG.info(
() ->
"No (optional) AuthenticationConfiguration has been set for Exchange Adapter: "
"No (optional) AuthenticationConfiguration has been set for Exchange Adapter: “没有(可选)为 Exchange 适配器设置 AuthenticationConfiguration:”"
+ exchangeConfig.getAdapter());
}

Expand All @@ -113,11 +113,11 @@ public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) {
final OtherConfigImpl exchangeApiOtherConfig = new OtherConfigImpl();
exchangeApiOtherConfig.setItems(otherConfig);
exchangeApiConfig.setOtherConfig(exchangeApiOtherConfig);
LOG.info(() -> "Other Exchange Adapter config has been set: " + exchangeApiOtherConfig);
LOG.info(() -> "Other Exchange Adapter config has been set: 其他 Exchange 适配器配置已设置:" + exchangeApiOtherConfig);
} else {
LOG.info(
() ->
"No Other config has been set for Exchange Adapter: " + exchangeConfig.getAdapter());
"No Other config has been set for Exchange Adapter:没有为 Exchange 适配器设置其他配置: " + exchangeConfig.getAdapter());
}

return exchangeApiConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

/**
* Exchange API Exchange config.
* 交换 API 交换配置。
*
* @author gazbert
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

/**
* Exchange API Network config.
* Exchange API 网络配置。
*
* @author gazbert
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

/**
* Exchange API Other config.
* Exchange API 其他配置。
*
* @author gazbert
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

/**
* Holds information for an Exchange market.
* bxbot 应用程序
*
* @author gazbert
*/
Expand All @@ -41,11 +42,19 @@ public final class MarketImpl implements Market {

/**
* Creates a new MarketImpl.
* 创建一个新的 MarketImpl。
*
* @param name the name of the market.
* 市场的名称。
*
* @param id the ID of the the market.
* 市场的 ID。
*
* @param baseCurrency the market base currency.
* 市场基础货币。
*
* @param counterCurrency the market counter currency.
* 市场柜台货币。
*/
public MarketImpl(String name, String id, String baseCurrency, String counterCurrency) {
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.Map;
import java.util.Set;

/**
/**封装(可选)策略配置项
* Encapsulates (optional) Strategy Config Items.
*
* @author gazbert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
/**:加载并初始化要执行的交易策略的Util类。
* Util class that loads and initialises the Trading Strategies to execute.
*
* @author gazbert
Expand All @@ -58,11 +58,18 @@ public void setTradingStrategyFactory(TradingStrategyFactory tradingStrategyFact

/**
* Builds the Trading Strategy execution list.
* 建立交易策略执行列表。
*
* @param strategies the strategies.
* 策略。
*
* @param markets the markets.
* 市场。
*
* @param exchangeAdapter the Exchange Adapter.
* 交换适配器。
* @return the Trading Strategy list.
* @return 交易策略列表。
*/
public List<TradingStrategy> buildStrategies(
List<StrategyConfig> strategies,
Expand All @@ -71,22 +78,22 @@ public List<TradingStrategy> buildStrategies(

final List<TradingStrategy> tradingStrategiesToExecute = new ArrayList<>();

// Register the strategies
// Register the strategies // 注册策略
final Map<String, StrategyConfig> tradingStrategyConfigs = new HashMap<>();
for (final StrategyConfig strategy : strategies) {
tradingStrategyConfigs.put(strategy.getId(), strategy);
LOG.info(() -> "Registered Trading Strategy with Trading Engine: Id=" + strategy.getId());
LOG.info(() -> "Registered Trading Strategy with Trading Engine: Id=使用交易引擎注册的交易策略:Id=" + strategy.getId());
}

// Set logic only as crude mechanism for checking for duplicate Markets.
// Set logic only as crude mechanism for checking for duplicate Markets. 仅将逻辑设置为检查重复市场的粗略机制。
final Set<Market> loadedMarkets = new HashSet<>();

// Load em up and create the Strategies
// Load em up and create the Strategies // 加载它们并创建策略
for (final MarketConfig market : markets) {
final String marketName = market.getName();
if (!market.isEnabled()) {
LOG.info(
() -> marketName + " market is NOT enabled for trading - skipping to next market...");
() -> marketName + " market is NOT enabled for trading - skipping to next market...市场未启用交易 - 跳至下一个市场...\"");
continue;
}

Expand All @@ -95,21 +102,21 @@ public List<TradingStrategy> buildStrategies(
marketName, market.getId(), market.getBaseCurrency(), market.getCounterCurrency());
final boolean wasAdded = loadedMarkets.add(tradingMarket);
if (!wasAdded) {
final String errorMsg = "Found duplicate Market! Market details: " + market;
final String errorMsg = "Found duplicate Market! Market details: 发现重复的市场!市场详情:" + market;
LOG.fatal(() -> errorMsg);
throw new IllegalArgumentException(errorMsg);
} else {
LOG.info(
() ->
"Registered Market with Trading Engine: Id="
"Registered Market with Trading Engine: Id=“带有交易引擎的注册市场:Id=”"
+ market.getId()
+ ", Name="
+ marketName);
}

// Get the strategy to use for this Market
// Get the strategy to use for this Market // 获取用于该市场的策略
final String strategyToUse = market.getTradingStrategyId();
LOG.info(() -> "Market Trading Strategy Id to use: " + strategyToUse);
LOG.info(() -> "Market Trading Strategy Id to use: 要使用的市场交易策略 ID:" + strategyToUse);

if (tradingStrategyConfigs.containsKey(strategyToUse)) {
final StrategyConfig tradingStrategy = tradingStrategyConfigs.get(strategyToUse);
Expand All @@ -120,38 +127,38 @@ public List<TradingStrategy> buildStrategies(
} else {
LOG.info(
() ->
"No (optional) configuration has been set for Trading Strategy: "
"No (optional) configuration has been set for Trading Strategy: 没有为交易策略设置(可选)配置:"
+ strategyToUse);
}
LOG.info(() -> "StrategyConfigImpl (optional): " + tradingStrategyConfig);

/*
* Load the Trading Strategy impl, instantiate it, set its config, and store in the
* Trading Strategy execution list.
/**
* Load the Trading Strategy impl, instantiate it, set its config, and store in the Trading Strategy execution list.
* 加载 Trading Strategy impl,实例化它,设置它的配置,并存储在 Trading Strategy 执行列表中。
*/
final TradingStrategy strategyImpl =
tradingStrategyFactory.createTradingStrategy(tradingStrategy);
strategyImpl.init(exchangeAdapter, tradingMarket, tradingStrategyConfig);

LOG.info(
() ->
"Initialized trading strategy successfully. Name: ["
"Initialized trading strategy successfully. Name: [ 成功初始化交易策略。姓名: ["
+ tradingStrategy.getName()
+ "] Class: "
+ tradingStrategy.getClassName());

tradingStrategiesToExecute.add(strategyImpl);
} else {

// Game over. Config integrity blown - we can't find strat.
// Game over. Config integrity blown - we can't find strat. // 游戏结束。配置完整性被破坏 - 我们找不到策略。
final String errorMsg =
"Failed to find matching Strategy for Market "
"Failed to find matching Strategy for Market “未能找到市场匹配策略”"
+ market
+ " - The Strategy "
+ " - The Strategy “ - 战略”"
+ "["
+ strategyToUse
+ "] cannot be found in the "
+ " Strategy Descriptions map: "
+ "] cannot be found in the 无法在 "
+ " Strategy Descriptions map: 策略说明图:"
+ tradingStrategyConfigs;
LOG.error(() -> errorMsg);
throw new IllegalArgumentException(errorMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
/**用于实例化交易策略类的工厂类。
* Factory class for instantiating a Trading Strategy class.
*
* @author gazbert
Expand All @@ -48,27 +48,28 @@ public void setSpringContext(ApplicationContext springContext) {
this.springContext = springContext;
}

/** Creates the Trading Strategy instance. */
/** Creates the Trading Strategy instance.
* 创建交易策略实例 */
TradingStrategy createTradingStrategy(StrategyConfig tradingStrategy) {
final String tradingStrategyClassname = tradingStrategy.getClassName();
final String tradingStrategyBeanName = tradingStrategy.getBeanName();

TradingStrategy strategyImpl = null;
if (tradingStrategyBeanName != null) {
// if beanName is configured, try get the bean first
// if beanName is configured, try get the bean first // 如果配置了beanName,先尝试获取bean
try {
strategyImpl = (TradingStrategy) springContext.getBean(tradingStrategyBeanName);

} catch (NullPointerException e) {
final String errorMsg =
"Failed to obtain bean [" + tradingStrategyBeanName + "] from spring context";
"Failed to obtain bean [ 获取bean失败[" + tradingStrategyBeanName + "] from spring context ] 来自spring的背景";
LOG.error(() -> errorMsg);
throw new IllegalArgumentException(errorMsg);
}
}

if (strategyImpl == null) {
// if beanName not configured use className
// if beanName not configured use className // 如果没有配置 beanName 使用 className
strategyImpl = ConfigurableComponentFactory.createComponent(tradingStrategyClassname);
}
return strategyImpl;
Expand Down
Loading