Self-adaptive price difference transaction system and method based on FPGA
Technical Field
The invention relates to the field of financial transactions, in particular to a self-adaptive price difference transaction system and method based on an FPGA (field programmable gate array).
Background
With the rapid development of financial markets, requirements for trading systems and methods such as programmed trading and quantitative trading are also higher and higher. Price difference trading is obtained by capturing small changes of market prices, traditional trading systems are all realized in a pure software mode, and data analysis, management and control are all completed by a CPU. In the face of a very volatile market, trading opportunities tend to be vanishing somewhat. Conventional approaches take a long time to deal with such high concurrency, large bandwidth problems, resulting in a time delay of up to several hundred microseconds between the triggering of a transaction signal and the completion of the transaction.
The price difference refers to the difference between the incoming price and the outgoing price. Because the difference is very small, when a signal comes temporarily, a preset trading strategy needs to be executed at the first time, the real-time performance of order execution is required to be in a microsecond or even a nanosecond level, meanwhile, as the fused products become rich day by day, more and more data need to be monitored, the traditional price difference trading requires a trader to send an order (buy or sell a certain financial product) to the market at a certain price, and the price difference is set, after the order sent by the trader is in a deal, an order state monitoring system immediately generates a price difference trading signal and informs an order management system to send the order in the opposite market direction according to the preset price difference (namely, the order is sent immediately after the order is bought in the deal, and the order is sent immediately after the order is sold in the deal).
Disclosure of Invention
According to the defects of the prior art, the invention aims to provide the self-adaptive price difference trading system and method based on the FPGA to realize high-speed processing and real-time monitoring of financial market quotation data, real-time capture of trading signals and efficient execution of trading strategies, realize the performance requirements of price difference trading on high concurrency and low delay and provide technical support for the execution of the trading strategies. And tracking the latest price in real time through an order management system to obtain the optimal transaction price, and compared with the traditional fixed price difference, realizing the maximization of the profit of the transaction.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
the invention discloses an adaptive price difference trading system based on an FPGA (field programmable gate array). the system adopts an FPGA integrated circuit and comprises a price difference trading module, an order processing module, a network connection module, a market information acquisition module and a price calculation module;
the price difference trading module (1) is used for receiving an order instruction sent by a client;
the order processing module (2) is used for receiving and processing the order information in the price difference trading module and the order information in the network connection module;
the network connection module (3) is used for receiving the processed order command, adding the specified data, sending the order command to the exchange, receiving a response message returned by the exchange, removing the specified data and transmitting the removed specified data to the order processing module;
the market acquiring module (4) is used for reading market information of the same product in the acquired transaction order;
and the price calculating module (5) is used for comparing and calculating the price of the order form according to the read product market information and the price difference or percentage set when the client places the order, outputting the newly calculated price and other information and finishing sending the order form command.
In the above technical solution, the order instruction received by the price difference transaction module (1) is transmitted through the PCIE bus.
In the above technical solution, the order processing module (2) is divided into the following sub-modules:
(2a) receiving a client order, storing order information in a BLOCK RAM of the FPGA, and sending a counter order after receiving transaction information;
(2b) finishing the functions of packaging, order data management and storage, and transmitting the packaged FIX protocol data to a network connection module;
(2c) and receiving order information determined by the network connection module, and completing FIX message analysis.
In the above technical solution, the data added and removed by the network connection module (3) is header data of TCP/IP.
In the above technical solution, the interface for the network connection module (3) to send data to the exchange and receive data from the exchange is a PHY physical layer interface.
In the technical scheme, the market information is read from the DDR/QDR by the market information acquisition module (4).
The invention also discloses a self-adaptive price difference trading method based on the FPGA, which comprises the following steps:
step one, a client sends an order sending instruction to a price difference trading module in the FPGA, the price difference trading module transmits the order sending instruction to an order processing module, and order information is stored in the FPGA;
step two, after the order data are processed by the order processing module, the order data are transmitted to the network connection module, and the network connection module adds the specified data and then transmits the data to the exchange;
step three, after receiving the order, the exchange returns a response message;
fourthly, after the network connection module in the FPGA receives the returned order information, the specified data is removed, the order information is transmitted to the order processing module for analysis, and if the return transaction information of the transaction exchange is received, the market information acquisition module in the FPGA reads market information of the same product;
and step five, a price calculation module in the FPGA carries out comparison calculation according to the read product market information and the price difference or percentage set when the client places an order, calculates the price of the order for the backhoe, outputs the newly calculated price and other information and completes the sending of the order command for the backhoe.
In the above technical solution, in the first step, the received order sending instruction is transmitted through a PCIE bus, and the order processing module in the FPGA stores the order information in a BLOCK RAM of the FPGA, and is configured to send the backhand order after receiving the transaction information.
In the above technical solution, in the second step, the order processing module completes the functions of packaging, order data management and storage, and transmits the packaged FIX protocol data to the network connection module, and the network connection module adds and removes header data in which the specified data is TCP/IP, and the interface transmitted to the exchange is a PHY physical layer interface.
In the above technical solution, in the fourth step, the market information obtaining module reads market information from the DDR/QDR.
The invention relates to a self-adaptive price difference transaction system and method based on FPGA, which has the following beneficial effects: by utilizing the high parallel computing capability of the FPGA, the market quotation change of a large number of financial products can be monitored simultaneously, when a trading opportunity comes, orders can be rapidly sent to the market, a deal with other participants in priority can be obtained, and the efficient execution of trading strategies is ensured. The method of self-adaptive calculation of the counter-handed single quotation is adopted, the instantaneous change of market quotation is captured in time, the optimal closing quotation is realized, and the transaction profit is effectively improved.
Drawings
FIG. 1 is a block diagram of an adaptive price difference trading system based on FPGA according to the present invention;
FIG. 2 is a flow chart of an adaptive price difference trading method based on FPGA according to the present invention;
FIG. 3 is a diagram of adaptive price difference transaction quotation data based on FPGA according to the present invention
FIG. 4 is a diagram of adaptive price difference transaction contra-manual transaction data based on FPGA according to the present invention
Detailed Description
The invention is described in further detail below with reference to the attached drawing
The invention discloses an adaptive price difference trading system based on an FPGA (field programmable gate array). the system adopts an FPGA integrated circuit and comprises a price difference trading module, an order processing module, a network connection module, a market information acquisition module and a price calculation module, as shown in figure 1;
the price difference trading module (1) is used for receiving an order instruction sent by a client;
and the order instructions received by the price difference transaction module are transmitted through the PCIE bus.
The order processing module (2) is used for receiving and processing the order information in the price difference trading module and the order information in the network connection module;
the order processing module is divided into the following sub-modules:
(2a) receiving a client order, storing order information in a BLOCK RAM of the FPGA, and sending a counter order after receiving transaction information;
(2b) finishing the functions of packaging, order data management and storage, and transmitting the packaged FIX protocol data to a network connection module;
(2c) and receiving order information determined by the network connection module, and completing FIX message analysis.
The network connection module (3) is used for receiving the processed order command, adding the specified data, sending the order command to the exchange, receiving a response message returned by the exchange, removing the specified data and transmitting the removed specified data to the order processing module;
the data added and removed by the network module is TCP/IP packet header data. The interface for the network connection module to send data to the exchange and receive the exchange data is a PHY physical layer interface.
The market acquiring module (4) is used for reading market information of the same product in the acquired transaction order;
the market information acquisition module reads market information from the DDR/QDR.
And the price calculating module (5) is used for comparing and calculating the price of the order form according to the read product market information and the price difference or percentage set when the client places the order, outputting the newly calculated price and other information and finishing sending the order form command.
The price difference trading method comprises the steps that price difference trading is achieved through the strong parallel processing capacity of the FPGA, when deal information of orders is received, the return orders can be sent to a trading post at the same time, and meanwhile, a market situation acquisition module and a price calculation module dynamically determine the price of the return orders in combination with current market situation according to the price difference or price difference ratio set when a customer places the orders.
The invention also discloses a self-adaptive price difference trading method based on the FPGA, which is characterized by comprising the following steps: the method comprises the following steps:
step one, a client sends an order sending instruction to a price difference trading module in the FPGA, the price difference trading module transmits the order sending instruction to an order processing module, and order information is stored in the FPGA;
the received order sending instruction is transmitted through the PCIE bus, and the order processing module in the FPGA stores order information in a BLOCK RAM of the FPGA and is used for sending the counter-hand order after receiving the transaction information.
Step two, after the order data are processed by the order processing module, the order data are transmitted to the network connection module, and the network connection module adds the specified data and then transmits the data to the exchange;
the order processing module completes the functions of packaging, order data management and storage, and transmits packaged FIX protocol data to the network connection module, the network connection module adds and removes packet header data with specified data being TCP/IP, and an interface transmitted to the exchange is a PHY physical layer interface.
Step three, after receiving the order, the exchange returns a response message;
fourthly, after the network connection module in the FPGA receives the returned order information, the specified data is removed, the order information is transmitted to the order processing module for analysis, and if the return transaction information of the transaction exchange is received, the market information acquisition module in the FPGA reads market information of the same product;
the market information acquisition module reads market information from the DDR/QDR.
And step five, a price calculation module in the FPGA carries out comparison calculation according to the read product market information and the price difference or percentage set when the client places an order, calculates the price of the order for the backhoe, outputs the newly calculated price and other information and completes the sending of the order command for the backhoe.
Specifically, as shown in fig. 2, a data packet such as a market quotation and an order sent by a transaction is received through a high-speed network card, and the FPGA analyzes the data packet according to a protocol to obtain market quotation data and an order state at present.
Selecting financial products, selecting the financial products, setting price difference according to the price fluctuation condition of the products, then sending an entrance order (buying or selling) at a reasonable price, sending a corresponding instruction to the exchange by the order management system, starting to continuously monitor the order state if the order is accepted by the exchange, and informing the order management system once the order is found to have a deal.
Depending on the direction of entry (buy or sell), in the opposite direction, orders are placed at a predetermined price difference. The latest quote is obtained by scanning the market quotation, and if the current market quote is better than the preset price of the anti-hand list, the quote of the anti-hand list is automatically adjusted.
The market data shown in fig. 3 shows the price of the current partial order and the size (quantity) of the order, the trader places a buy order at the price of 9.99, the order management system places the order to the exchange and monitors the status of the order in real time. Once the order is committed, a counterhand is immediately placed, since the entry is a buy order (make many), the counterhand order must be a sell order (level), the size of the counterhand depends on the size of the buy order that has been committed, the order quote is calculated from the buy price plus a specified spread, in this case the buy price is 9.99, if the set spread is 3, the price quote for the counterhand order is 10.02, if the counterhand order is committed, the trade is paid 0.03 (regardless of trade commission, etc.). If the admission is a sell (make a null), the trader sells at a price of 10.01 with a price difference of 5, and the corresponding buy order is placed at a price of 9.96 to level immediately after the 10.01 sell order has been filled.
As shown in fig. 3, when the user completes the order at the 9.99 price, the user plans to make a return order at 10.02 according to the set price difference 3, but the market quotation is as shown in fig. 4, the optimal price of the order should be 10.03 which is 0.01 higher than the preset 10.02, and the price of the order can be adjusted in time to obtain a better price of the return order as long as the return order is not completely completed through real-time scanning of the market quotation data. For more purchases, the price quoted for the counter-hand order is not lower than the preset price (purchase price + price difference), and the higher the price quoted, the higher the profit obtained; and for selling to make a null, the price of the contrahand order is not higher than the preset price (selling price-price difference), and the lower the price, the higher the profit. The profit can be effectively enlarged and the risk can be reduced through the self-adaptive quotation.
The parts not described in the specification are prior art or common general knowledge. The present embodiments are to be considered as illustrative and not restrictive, and all changes coming within the meaning and equivalency range of the appended claims are intended to be embraced therein.