# 第六章 信号交易系统（外汇、股市与区块链）

 1 2 技术分析、舆论分析、新闻分析（含突发新闻与数据新闻）、报告分析， 以及它们的历史数据、机器学习后backtesting的数据。 

 1 2 3 为了保持盈利水平，可能需要扩大正反馈，减弱负反馈，即止盈大、止损小。 控制器设计在输入信号作为反馈的基础上，将历史订单的盈利水平作为主要参考， 即将整个控制器置于输入环节，从而形成完整的闭环系统。 

 1 为了保持高并发，哈希环分发任务，消息队列mq，使用工作流控制任务，数据库使用少字段多KV，新增功能加到KeyVaule列表中，无需增加数据库字段。 

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 交易： 注册 -> 分配MT4虚拟机（容器）-> 交易开始 -> 周期结算 注册 -> 独立MT4客户端 -> 交易开始 -> 周期结算 新闻： 新闻提供GIS与新闻源两种查看方法 免注册 -> 新闻查看、搜索 注册 -> 新闻查看、搜索、推送 算法： 一：专家人工复制 二：指数指标机器学习交易 三：基本分析与舆情分析，并结合（二）进行交易 
graph LR
A[Start] --> B{Error?};
B -->|Yes| C[Hmm...];
C --> D[Debug];
D --> B;
B ---->|No| E[Yay!];

{image} ../images/arch.png :align: center

 1 2 3 4 这是目前的服务器架构图： {image} ../images/forex_infra_1.png :align: center 

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 主站点 https://forex.fusionworks.cn 新闻GIS系统 https://github.com/lofyer/forex-gis-news.git MT4服务端 https://github.com/lofyer/mt4-server.git MT4交易脚本 https://github.com/lofyer/mt4-scripts.git TUI汇率展示 https://github.com/lofyer/forex-rate-board.git OANDA API调用脚本 https://github.com/lofyer/oanda-scripts.git 交易模型 https://github.com/lofyer/quantum-trade-model.git 原始交易模型 https://github.com/lofyer/trade-model-01.git 

## 6.1. 新闻、报告与大盘信息

### 6.1.2. 新闻分类与评级

 1 2 3 4 5 StoryId Class word1 word2 gram1 gram2 ... 1 sports 0 0.2 0.01 0 2 tech 0.5 0.01 0 0.3 3 sports 0 0.1 0.3 0.01 

https://github.com/yassersouri/classify-text

https://github.com/kareemf/news-article-classification

http://www.nltk.org/

scipy

scikit_learn

pybrain

jieba

tensorflow

### 6.1.3. 报告评级

• 国际收支（贸易余额）
• 利率与货币供给政策
• 通胀与通缩
• 资产价格（债券、股票、房地产）
• 商品价格（CRB现货指数）
• 政府预算与财政政策
• 国家信用评级
• 政治与战争
• 自然因素
• 数据公布（消费者物价指数CPI、零售销售、生产者物价指数PPI、工业生产IP、采购经理人指数PMI、就业数据）

### 6.1.5. 大盘历史数据

QCollector Expert for eSignal

MT4客户端数据下载

## 6.4. 交易策略

### 6.4.3. 策略3 - 技术指标自动交易

1. 1分钟观察窗口

index平时交易： index上升时交易：

15分钟交易

1. 5分钟观察，30分钟交易

{image} ../images/strategy3.png :align: center



## 6.7. 客户模拟平台

StockSharp（开源）

my_library/source/forex/

QuantConnect Lean

AkShare股市数据

## 6.8. 交易箴言

FPGA交易机器人

### 交易心理

In the contemporary exchange market exchange rates are defined through decisions of thousands of traders and investors. The psychology of human behavior is considered to be the clue of understanding what happens in financial markets. What are the motivations for trading? How our emotions affect our decicion making process? How to avoid the failure and become a successful trader? Have you ever wondered about these questions? Keep reading to find out the answers.

Avoiding Failure

In stock trading decisive influence on the behavior of the trader is made by common to all feelings such as fear, greed, hope, etc. Weak and self confident, greedy and slow; all these people are doomed to become the victims of the market.

The recognition of your own abilities, positive or negative qualities will help you as a trader to avoid failure. If we also add to this the ability of adequate evaluation of the psychological state and the behavior of the market, the success is guaranteed.

The Motivations

One of the driving forces, making you to take part in the work of speculative financial markets, is the possibility of earning "easy money" or, saying directly, greed. The result of greedy action is the motivation for making deals.

One can distinguish between two kinds of motivations:

• Rational motivation is expressed through cold prudence when taking decisions about making a deal.
• Irrational motivation is expressed through passion of the player; the others are the slaves of their emotions and are practically doomed to lose.
If the trader does not have a working plan formed before making deals, it speaks about the fact that the person is likely to work under the influence of greed but not reason.

Understanding Hope

The following factor motivating the trader to make deals is the hope to get profit. If the hope prevails over the profit calculation, the trader undertakes the risk of overestimating his abilities when analyzing the situation. Hope must be placed in subordinate relations both with calculation and greed. It is the great hope that brings beginners to failure. The trader, living with hope, is doomed to failure. It is a hope that pushes traders towards making one of the most cruel mistakes- shift of the stop-loss orders level.

From outside, trading seems to be an utterly simple matter. But in reality for the majority of people it later on appears to be the most difficult of all the issues.

Accepting Losses

You will not be able to become a successful trader until you are ready both for victories and losses. Both of them are important and inseparable parts of the trading process. On the way of mastering the art of trade very often barriers are met. When the trader focuses on the problems (there can be numerous problems, for instance, lack of means, resources and knowledge), he feels anger, guilt, disappointment and dissatisfaction. But such an emotional state will not let him move forward. If the loss is unacceptable for the trader, he will not be able to close the losing position. When the trader is not ready to face losses, they usually become more.

In trading, there is a tiny minority of winners and overwhelming majority of losers and the latter wish to know the secrets of success of the winners. But is there a difference between them? Yes, there is; the one who makes money week by week, month by month and year by year, trades keeping self-discipline. To the question of the secrets of his stable market triumph, such a winner answers without hesitating, that he was able to reach such heights by learning how to control his emotions and change his decisions to match the market.

Note, self discipline, control of emotions and the ability to reconsider are all psychological moments which are not related to information services, consultation firms, new exchanges, technical or fundamental trade systems (with computer programs or without them).

Do not confuse confidence with extreme self-confidence

Interviews with traders confirm that extreme self-confidence plays an important role in making trading decisions. If the trader receives good profit, he becomes more prone to risk which is followed by negative consequences. This is a tendency of becoming extremely self-confident after success, which mostly happens with the less experienced market participants.

Extreme confidence easily transforms into a dangerous quality, as people who are too much confident in their beliefs will not pay attention to important information which is valuable for their trading decisions. Confidence and negative emotions are directly related to each other in strength. In general, confidence and fear are similar senses by nature; only the one is with a "plus" sign and the other with - "minus" sign. If the person feels more confident, there is a little room left for confusion, alarm and fear.

How does the sense of self confidence develop?

In a natural way, the person gets used to relying on himself in everything that he has to do without any hesitation. With such trust in himself he does not have to fear the market with its seemingly unpredictable and chaotic behavior. The matter here is not with him at all, as the market did not change but the inner world and psychological warehouse of the trader have.

How to become a successful trader?

There are two important terms in relation to a good trader.

• To set a principle of trading exclusively on the basis of self discipline.
• To learn how to remove the negative emotional energy of the last trade experience.

Due to the principle to self discipline, self trust is being formed, which is necessary for successful trading actions.

Almost in the majority of cases each trader starts his way on the primary level without understanding trading psychology and without the principle of self discipline. And it is likely to get psychological trauma (a psychological state which is capable of making people feel fear) of this or that severity. It is necessary to learn how to get rid of worries. When there is little fear as a consequence, you absorb new knowledge about the nature of the market.

Do not forget that each moment is an excellent indicator of your development level. But if you consider each failure (if it did not happen as you have expected or wanted) to be a mistake, you very often deprive yourself of understanding yourself. While people become shy of learning something new about them. Why? Because mistakes mean an emotional pain for them. Avoiding pain instinctively, the person unconsciously refuses to recognize himself, when it is necessary to manage better a similar situation in future.

The bottom line

To reach a success in trading, you need to take the whole responsibility of your decisions and actions on yourself.