Algorithm transaction-oriented high-frequency factor real-time calculation method

By pre-allocating memory and using thread binding, independent memory space is allocated for high-frequency factor calculation, which solves the performance bottleneck problem of high-frequency factor calculation in existing technologies, and achieves efficient factor calculation and improves the performance of algorithmic trading.

CN122089461APending Publication Date: 2026-05-26JIANGSU SECURITIES

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANGSU SECURITIES
Filing Date
2025-12-19
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing technologies have performance bottlenecks in real-time calculation of high-frequency factors, especially in complex computing scenarios where development and operation efficiency is low and it is difficult to meet high-performance requirements.

Method used

By employing pre-allocated memory, binding stocks to computation threads, lock-free programming, and in-place computation, efficient factor calculation is achieved by allocating independent memory space for factors and market data for each stock, and creating computation threads based on the mapping relationship between stock codes and computation threads.

Benefits of technology

It improves computing performance, reduces the impact of multi-threaded contention, enhances data access efficiency, is suitable for high-frequency factor calculation scenarios, and strengthens the market perception sensitivity and order completion probability of algorithmic trading.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122089461A_ABST
    Figure CN122089461A_ABST
Patent Text Reader

Abstract

The invention discloses an algorithm transaction-oriented high-frequency factor real-time calculation method, which comprises the following steps of: acquiring real-time market data, loading factors from a preset dynamic library according to the real-time market data, and obtaining each stock and a corresponding factor thereof; according to the historical market data, the real-time market data, each stock and the corresponding factor, allocating an independent memory space for the stock market data of each stock and the corresponding factor of each stock; creating a thread according to a pre-configured calculation thread number, performing modulus operation on the total calculation thread number according to the number of each stock of the stock code to obtain a corresponding calculation thread program number, and obtaining a binding relationship between the stock code and the calculation thread. According to the method, by adopting the high-performance design of binding the pre-allocated memory, the stock and the calculation thread, the calculation performance is greatly improved, the sensitivity of the algorithm to market perception is enhanced, and the order transaction probability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a real-time calculation method for high-frequency factors for algorithmic trading, belonging to the field of algorithmic trading technology. Background Technology

[0002] The exchange's Level 2 real-time market data stream drives a batch of high-frequency factors to be calculated in real time. All factor calculation results for a single tick of each stock are sent to the downstream model service at once for real-time inference. This is suitable for scenarios where factor calculations for different stocks are independent of each other.

[0003] There are two main solutions for calculating high-frequency factors in existing technologies. One is to directly reuse the Python code implemented in the research phase and use third-party packages such as pandas to process real-time data, avoiding the conversion from research to live trading. This is suitable for scenarios with lower performance requirements. The other is based on open-source stream computing frameworks, such as Flink and Spark Streaming, to process and calculate factor data. These stream computing frameworks generally support SQL and window functions and have built-in common aggregation operators. They are relatively efficient in both development and computation for processing simple indicators and factors, and are suitable for big data stream computing scenarios with high performance requirements and relatively simple factor calculation logic.

[0004] One issue is that the real-time calculation scheme for high-frequency factors based on Python is limited by the language itself and is not suitable for high-performance computing scenarios.

[0005] On the other hand, solutions based on open-source stream computing frameworks can achieve millisecond-level computational performance, but they struggle to implement complex factors. Take Flink as an example. Flink supports SQL and window functions, and common operators used in high-frequency factor calculations are already built into Flink. Therefore, implementing simple factors with Flink is very efficient, and the runtime performance meets requirements. However, for complex computation scenarios requiring nested window functions, Flink needs to break it down into multiple window computation streams and complete the entire computation through parallelism, concatenation, and merging. This implementation becomes extremely complex, severely impacting development and runtime efficiency for a large number of complex factor calculations. If logical judgments and boundary handling are added, implementing such solutions using stream computing frameworks like Flink becomes even more difficult, or even impossible. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide a real-time calculation method for high-frequency factors for algorithmic trading.

[0007] To achieve the above objectives, the present invention is implemented using the following technical solution:

[0008] A real-time calculation method for high-frequency factors for algorithmic trading, comprising:

[0009] Load the stock codes and number each stock in the stock codes;

[0010] Load factors from a pre-defined dynamic library, obtain factor instance objects, obtain the factor's calculation function and dependent factor list based on the factor instance objects, and retrieve and load the dependent factors from the dependent factor list.

[0011] Based on the stock code, factors, stock trading hours, and market data update frequency, allocate independent memory space for the factors and market data of each stock;

[0012] A calculation thread is created based on the pre-configured number of calculation threads. The corresponding calculation thread program number is obtained by taking the modulo of the total number of calculation threads based on the stock code number, and the mapping relationship between the stock code and the calculation thread is obtained.

[0013] Based on the currently updated real-time market data, the calculation function for each factor is passed to perform factor calculations, and the factor calculation results are output.

[0014] Furthermore, the allocation of independent memory space for factors and market data for each stock based on stock code, factors, stock trading hours, and market data update frequency includes:

[0015] Based on different computing scenarios, stock market data and factors are processed. Combining row-based and column-based storage modes, independent memory space is allocated for the stock market data of each stock and the factor calculation results of each factor of each stock.

[0016] Furthermore, the data processing of stock market data and factors according to different calculation scenarios includes:

[0017] The stock market data and factor data are processed using methods such as cross-sectional calculation, window calculation, and time window calculation to obtain factor calculation results;

[0018] Furthermore, the process involves creating computation threads based on a pre-configured number of computation threads, obtaining the corresponding computation thread number by taking the modulo of the total number of computation threads with the stock code for each stock, and establishing the mapping relationship between stock codes and computation threads. This also includes:

[0019] Cache the mapping relationship between stock codes and computing threads.

[0020] Furthermore, the process of creating computing threads based on a pre-configured number of computing threads, obtaining the corresponding computing thread program number by taking the modulo of the total number of computing threads based on the stock code number of each stock, and obtaining the mapping relationship between stock codes and computing threads, further includes:

[0021] Subscribe to stock market data based on a pre-defined range of stocks to be calculated and a pre-defined market data source. Based on the stock market data subscription, obtain and push real-time market data for each stock in the range of stocks to be calculated from the market data source.

[0022] Furthermore, in addition to subscribing to stock market data based on a pre-defined range of stocks to be calculated and a pre-defined market data source, and obtaining and pushing real-time market data for each stock in the range of stocks to be calculated from the market data source according to the stock market data subscription, the process also includes:

[0023] The received real-time market data is stored in the corresponding pre-allocated memory.

[0024] Furthermore, while storing the received real-time market data into the corresponding pre-allocated memory, a market update signal is written to the corresponding computing thread queue according to the mapping relationship between stock codes and computing threads. The signal contains the memory address of the real-time market data.

[0025] Furthermore, the step of inputting the currently updated real-time market data into the calculation function of each factor for factor calculation and outputting the factor calculation results includes: continuously monitoring the calculation thread queue, and after detecting a market update, retrieving the memory address of the real-time market data, inputting it into the calculation function of each factor in turn for calculation, and temporarily caching the calculation results in a result array.

[0026] Furthermore, the result array is implemented using local variables of the Thread class.

[0027] Furthermore, after temporarily caching the calculation results in a result array, it also includes: pushing the factor calculation results directly downstream in the form of a binary structure.

[0028] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:

[0029] This invention provides a real-time calculation method for high-frequency factors for algorithmic trading. By allocating independent memory space for factors and market data of each stock based on stock codes, factors, and pre-obtained stock market data, it can avoid the impact of multi-threaded competition on data access performance.

[0030] The present invention also creates computing threads based on a pre-configured number of computing threads, obtains the corresponding computing thread program number by taking the modulo of the total number of computing threads based on the number of each stock in the stock code, and obtains the mapping relationship between stock codes and computing threads. By determining the computing thread by taking the modulo of the number, it can be ensured that the number of stocks processed by each computing thread is basically the same, thereby further improving computing performance. Attached Figure Description

[0031] Figure 1 This is a functional module and data flow diagram of a high-frequency factor real-time calculation method for algorithmic trading provided in an embodiment of the present invention;

[0032] Figure 2 This is a schematic diagram of the time mapping of a high-frequency factor real-time calculation method for algorithmic trading provided in an embodiment of the present invention;

[0033] Figure 3 This is a schematic diagram illustrating the calculation effect of the factor calculation engine in a high-frequency factor real-time calculation method for algorithmic trading provided in an embodiment of the present invention. Detailed Implementation

[0034] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.

[0035] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are used only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.

[0036] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art will understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0037] Example 1: This example introduces a real-time calculation method for high-frequency factors in algorithmic trading, referring to... Figure 1 It comprises five main functional modules: process preprocessing module, market data processing engine, factor calculation engine, market data cache pool, and factor cache pool, all of which are independently developed by this invention. The functions of each module are as follows:

[0038] The process preprocessing module is responsible for loading stock codes and factors during the process initialization phase (before market opening); then, it performs memory pre-allocation, pre-allocating the entire day's market data cache for each stock based on the stock code table and factor object list, and recording the mapping between stock codes and cache addresses; it also pre-allocates the entire day's factor calculation result cache for each factor of each stock, and records the mapping between stock codes, factor objects, and corresponding cache addresses; next, it performs stock thread binding, specifically by creating a group of calculation threads with thread queues, evenly distributing all stocks to each calculation thread, and recording the mapping between stock codes and calculation threads, as well as the thread queue; finally, it subscribes to real-time market data based on the stock code table.

[0039] The market data processing engine is responsible for receiving real-time market data pushed from the market data source, parsing and caching the data, and then writing market update signals to the thread queue of the computing thread corresponding to the stock code. Real-time market data is the real-time status data of stock trading released by the stock exchange, pushed at a fixed frequency (e.g., Level-2 market data is normally a slice every 3 seconds). A slice includes order book data (Level-2 has 10 bid and 5 ask levels, each consisting of price and volume) and fields such as opening price, highest price, lowest price, cumulative trading volume, and cumulative trading value. The market data source receives and parses real-time market data from the exchange and forwards it to downstream subscribers. The market data source pushes real-time market data through multiple threads. When the corresponding thread receives real-time market data, it first parses the stock code, finds the corresponding market data cache address using the stock code, and then incrementally writes data to the market data cache. After the market data is cached, it queries the corresponding computing thread using the stock code and writes a market update signal to the thread queue.

[0040] Factor Calculation Engine: Responsible for processing real-time market data based on factor calculation logic, obtaining factor calculation results, and pushing them downstream. The factor calculation engine consists of a group of calculation threads. The calculation threads continuously consume market update signals from the thread queue, and obtain the market cache address of the stock from the market cache pool based on the stock code in the market update signal. Then, they sequentially call the calculation functions of each factor, passing in the market cache address of the stock, obtaining the calculation result of each factor and caching it in the corresponding factor calculation result cache for the stock and factor. Finally, the factor calculation results are pushed outward.

[0041] Market data cache pool: Responsible for managing stock market data cache, consisting of two parts: one part is a mapping table between stock codes and market data cache addresses, and the other part is the stock market data cache, providing external capabilities for stock market data cache addressing and access.

[0042] Factor Cache Pool: Responsible for managing stock factor cache, consisting of two parts: one part is a mapping table of stock codes, factor objects, and factor calculation result cache addresses, and the other part is the factor calculation result cache, providing external capabilities for stock factor cache addressing and factor calculation result cache access.

[0043] This embodiment includes the following steps:

[0044] S100, Service Initialization: Stock code loading, factor loading, pre-allocation of memory and binding of stock threads. This process is executed before the market opens each day.

[0045] S101. Specifically, load the stock code table from the market data source. Since the stock code table may change daily, it needs to be loaded within a fixed time period before the market opens each day. After loading the stock codes, assign a number to each stock code sequentially so that all stocks can be evenly distributed among the calculation threads when binding stock threads later.

[0046] S102. Factor loading includes: loading factors from a pre-defined dynamic library, obtaining factor instance objects, obtaining the factor's calculation function and dependent factor list based on the factor instance objects, and obtaining and loading the dependent factors in the dependent factor list.

[0047] This embodiment uses a framework-plugin model to manage factor loading.

[0048] The factor computation framework is responsible for the lifecycle management of factors, including factor plugin loading, factor object creation, and factor object list maintenance. During the initialization phase, the framework loads factor plugins based on the factor list configured in the service, calls the factor object creation export interface in the plugins to create factor objects, and then caches the factor object list sequentially. In the S203 factor real-time computation phase, driven by the factor computation engine, the framework sequentially calls the computation interfaces of each factor object in the factor object list to perform factor computation and returns the computation results.

[0049] Each factor is a plugin, existing as a dynamic link library. Factors are developed based on a template, which consists of a series of exported functions, a factor base class, and factor classes. The exported functions include creating factor objects, releasing factor objects, obtaining a list of dependent factors, and factor calculation functions. The factor base class provides the implementation specifications for factor classes, including how to construct a factor object, how to describe factor dependencies, and the calculation function interface. It also provides default implementations for all member functions except the calculation function; the only function that the factor class must implement is the calculation function. Each factor is compiled into an independent dynamic link library plugin, with the factor name included in the library name, and stored centrally in a fixed location for easy framework loading. To improve factor development efficiency and performance, this application provides a set of vectorized operators encapsulated based on the "in-place computation" design concept. In-place computation refers to performing calculations directly at the address where the data resides, avoiding the additional time consumption introduced by data copying. This set of vectorized operators includes calculations of maximum / minimum values, quantiles, variance, standard deviation, correlation coefficients, etc., which factors can directly call for efficient calculations.

[0050] The factor calculation framework iterates through the factor list in the service configuration, finds and loads the corresponding factor dynamic link library according to the factor name, then obtains and calls the function to create factor objects to create factor objects, then obtains and calls the function to obtain the list of dependent factors of the factor to obtain the list of dependent factors, and loads dependent factors in the same way as above. After the dependent factors are loaded, all factor objects created in the process are cached in the factor object list in sequence, thus completing the factor loading process.

[0051] It should be noted that, to avoid duplicate factor calculations, the calculation of the dependent factor should occur before the calculation of the dependent factor. When calculating the dependent factor, only the calculation result of the dependent factor needs to be retrieved. Therefore, the list of factor objects maintained in memory must also be an ordered list sorted according to the order of calculation. This application implements sequential caching of factor objects during factor loading, as illustrated by the following example.

[0052] For example, in one specific embodiment, there are three factors to be loaded, denoted as A, B, and C. A depends on B and C, B depends on C, and C has no dependencies. When loading factor A, if A's dependencies on B and C are detected, B and C will be loaded first. If C is loaded first, and it is found that C has no dependencies, the C factor object will be cached directly. Then, B is loaded, and it is found that B depends on C, but a C object already exists in memory, so the B object will be cached after C. Finally, the A object will be cached after B. If B is loaded first, and it is found that its dependent C is not in the cache, C will be loaded and cached first. Therefore, the final order of factor objects in the cache will always be C, B, A.

[0053] S103. Memory pre-allocation includes memory allocation for market data and factor calculation results. This embodiment supports processing intraday historical data of market data and factor calculation results of arbitrary window length. To ensure data read and write performance, all intraday historical data is cached in memory. At the same time, to avoid multi-threaded contention affecting data access performance, independent memory space is allocated for the market data of each stock and the factor calculation results of each factor for each stock during memory allocation.

[0054] Furthermore, in terms of storage structure design, this embodiment combines both row-based and column-based storage structures to reduce redundant reads during data access and further optimize data access performance, catering to different data calculation scenarios. In high-frequency factor calculation scenarios, window calculation mode is generally used for stock market data fields other than order book fields (such as latest price, cumulative trading volume, etc.) and secondary processing that depends on factor calculation results. For example, the calculation logic of factor A is to calculate the average of the latest prices of the most recent 20 market data slices, which is a typical window calculation scenario. Secondary processing of market order book data generally uses cross-sectional calculation mode. For example, the calculation logic of factor B is to statistically analyze the trend of order book volume changes in the top 5 bid and ask prices, which is a cross-sectional calculation scenario. Therefore, this embodiment uses a row-based storage mode for market order book data, while using a column-based storage mode for other market data fields and factor values.

[0055] Time window calculation is a special type of calculation scenario that requires first mapping the start and end times of the window to the location of the target data in the sequential storage structure before performing the window calculation. Due to its correlation with the trading activity of stocks, stock market data is not evenly distributed over time, making it impossible to directly map the start and end times to the storage structure index based on market frequency. To avoid inefficient traversal lookups, this application improves the performance of time window calculation by adding a time mapping array.

[0056] The time mapping array is established synchronously when caching market data. It also uses pre-allocated memory. Each stock maintains an independent mapping array, where the array index corresponds to consecutive seconds of market data, and the array element is the memory address of the latest market data whose time is less than or equal to the index. Assume that a stock currently receives market data with time MDTime(t) and stores it at address i. The address of the previous market data with time MDTime(t-1) is i-1, and the index of the time mapping array corresponding to MDTime(t-1) is m. At this point, starting from position m+1, seconds(MDTime(t) - MDTime(t-1))-1 consecutive data entries with the value i-1 will be written to the time mapping array, and then a data entry with the value i will be inserted.

[0057] According to the above rules, before calculating the time window, the time mapping array stores the memory addresses of the market data corresponding to each second up to the current time. During time window creation calculation, the time mapping array is first queried to find the memory addresses of the market data corresponding to the start and end times, and then the calculation is performed directly based on this contiguous target memory segment. (Refer to...) Figure 2 This example demonstrates start and end time positioning based on a time mapping array. The current time in the image is 09:30:09, corresponding to index 9 in the time mapping array and index 2 in the actual data storage array. We need to retrieve market data from the last 5 seconds for processing. Using the time mapping array, we can quickly locate the start time 9:30:04, with an index of 9-5=4, corresponding to index 1 in the data array. Therefore, the market data within the last 5 seconds is the memory data at indices 1-2 in the data array, and this contiguous memory segment can be directly processed.

[0058] S104. Stock thread binding specifically includes the following steps:

[0059] Threads are created based on the configured number of computation threads. Then, the corresponding computation thread number is obtained by taking the modulo of the total number of computation threads with the stock number generated during the stock code loading step. The mapping relationship between stock codes and thread objects is then cached for quick location of computation threads during real-time computation. Since the stock numbers are sequentially incremented, determining the computation thread by taking the modulo of the number ensures that each computation thread processes a roughly consistent number of stocks.

[0060] Each calculation thread has its own independent thread signal queue. When the market data receiving thread receives market data, it writes a data update signal (containing the market data cache address) to the calculation thread's signal queue. The calculation thread continuously consumes the signal queue and triggers calculations.

[0061] By binding the target to the thread in this way, a specific stock will only be calculated in real time in a specific calculation thread. Access to stock market data and factor data is single-write and single-read, which makes it easier to apply lock-free programming technology and reduces the performance loss caused by multi-threaded contention.

[0062] S200 calculates high-frequency factors based on real-time market data and outputs the calculation results.

[0063] S201. Market data subscription includes subscribing to market data based on the range of stocks that the system needs to calculate, and the market data source is a market data source that supports subscription push.

[0064] S202. Real-time market data reception: Receive real-time market data pushed by the market data source, cache it in the pre-allocated memory of the corresponding stock, and at the same time write a market data update signal to the computing thread queue corresponding to the stock. The signal contains the memory address of the stock's market data.

[0065] S203. Real-time factor calculation includes: The calculation thread continuously monitors the thread queue. After detecting a market update, it retrieves the corresponding stock's market data cache address from the market update signal and sequentially passes it to the calculation function of each factor in the factor object list through the factor calculation framework to drive factor calculation and obtain the factor calculation result.

[0066] S204. Factor calculation result push includes directly pushing the factor calculation results downstream in binary structure form. Since the calculation result push speed is very fast (1-2μs), this step is implemented directly in the factor calculation thread.

[0067] Reference Figure 3 According to tests, the calculation of 114 factors for approximately 5,200 stocks in the Shanghai and Shenzhen stock exchanges on a single 144C 3.1GHz physical server took an average of less than 1ms.

[0068] In summary, the high-frequency factor real-time calculation method for algorithmic trading provided by this invention has the following advantages:

[0069] This invention employs high-performance designs such as pre-allocated memory, binding of stocks to computing threads / memory, lock-free programming, and in-site computation, which significantly improves computing performance. This is of positive significance for enhancing the algorithm's sensitivity to market perception, increasing the probability of order completion, and improving algorithm performance.

[0070] This invention balances vectorized computation and random data access in its storage design, has a more open framework, provides stronger support for multi-layer window computation, condition judgment, boundary handling and special computation scenarios, and has fewer restrictions on factor code implementation.

[0071] The factor development of this invention is directly developed using the C++ language, which does not require additional learning costs for C++ developers. At the same time, since the framework isolates the data required for factor calculation in the stock dimension, there is no need to consider complex memory management and multi-threaded access issues during factor development, and the security, development efficiency and performance of the system can be guaranteed.

[0072] Example 2: This example provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in Example 1.

[0073] Example 3: This example provides a computer device, including:

[0074] Memory, used to store computer programs / instructions;

[0075] A processor for executing the computer program / instructions to implement the steps of the method described in Embodiment 1.

[0076] Example 4: This example provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the method described in Example 1.

[0077] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

[0078] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0079] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0080] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0081] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure and not to limit its protection scope. Although this disclosure has been described in detail with reference to the above embodiments, those skilled in the art should understand that after reading this disclosure, they can still make various changes, modifications or equivalent substitutions to the specific implementation of the invention, but these changes, modifications or equivalent substitutions are all within the protection scope of the pending claims.

Claims

1. A method for real-time calculation of high-frequency factors for algorithmic trading, characterized in that, include: Load the stock codes and number each stock in the stock codes; Load factors from a pre-defined dynamic library, obtain factor instance objects, obtain the factor's calculation function and dependent factor list based on the factor instance objects, and obtain and load the dependent factors from the dependent factor list. Based on the stock code, factors, and pre-obtained stock market data, allocate independent memory space for the factors and the market data of each stock; A computing thread is created based on the pre-configured number of computing threads. The corresponding computing thread program number is obtained by taking the modulo of the total number of computing threads based on the number of each stock in the stock code, and the mapping relationship between the stock code and the computing thread is obtained. Based on the currently updated real-time market data, the calculation function for each factor is passed to perform factor calculations, and the calculation results are output.

2. The method for real-time calculation of high-frequency factors for algorithmic trading according to claim 1, characterized in that, The process of allocating independent memory space for the factors and the market data of each stock based on the stock code, factors, and pre-obtained stock market data includes: Based on different computing scenarios, stock market data and factors are processed. Combining row-based and column-based storage modes, independent memory space is allocated for the stock market data and corresponding factors of each stock.

3. The method for real-time calculation of high-frequency factors for algorithmic trading according to claim 2, characterized in that, The data processing of stock market data and factors according to different calculation scenarios includes: The cross-sectional calculation method is used to process the market data in stock market data, and the processed market data is stored in a row-by-row storage mode. The system uses a time window to calculate and process all data in stock market data except for order book data, as well as factors. It also uses a column-oriented storage model to store the processed historical market data and real-time market data except for order book data, as well as factors.

4. The method for real-time calculation of high-frequency factors for algorithmic trading according to claim 1, characterized in that, The system creates computation threads based on a pre-configured number of computation threads, obtains the corresponding computation thread number by taking the modulo of the total number of computation threads for each stock code, and establishes the mapping relationship between stock codes and computation threads. This also includes: Cache the mapping relationship between stock codes and computing threads.

5. The method for real-time calculation of high-frequency factors for algorithmic trading according to claim 3, characterized in that, The process of creating computing threads based on a pre-configured number of computing threads, obtaining the corresponding computing thread program number by taking the modulo of the total number of computing threads based on the stock code number of each stock, and obtaining the mapping relationship between stock codes and computing threads, further includes: Subscribe to stock market data based on a pre-defined range of stocks to be calculated and a pre-defined market data source. Based on the stock market data subscription, obtain and push real-time market data for each stock in the range of stocks to be calculated from the market data source.

6. The method for real-time calculation of high-frequency factors for algorithmic trading according to claim 5, characterized in that, The process includes subscribing to stock market data based on a pre-defined range of stocks to be calculated and a pre-defined market data source. Based on the stock market data subscription, real-time market data for each stock within the range to be calculated is obtained from and pushed to the market data source. This also includes: The received real-time market data is stored in the corresponding pre-allocated memory.

7. The method for real-time calculation of high-frequency factors for algorithmic trading according to claim 6, characterized in that, While storing the received real-time market data into the corresponding pre-allocated memory, a market update signal is written to the corresponding computing thread queue according to the mapping relationship between stock codes and computing threads. The signal contains the memory address of the real-time market data.

8. The method for real-time calculation of high-frequency factors for algorithmic trading according to claim 7, characterized in that, The process of obtaining the currently updated real-time market data, passing it into the calculation function of each factor for factor calculation, and outputting the calculation results includes: continuously monitoring the calculation thread queue, detecting market updates, retrieving the memory address of the real-time market data, passing it into the calculation function of each factor in turn for calculation, and temporarily caching the calculation results in a result array.

9. A method for real-time calculation of high-frequency factors for algorithmic trading according to claim 8, characterized in that, The result array is implemented using local variables of the Thread class.

10. A method for real-time calculation of high-frequency factors for algorithmic trading according to claim 9, characterized in that, After temporarily caching the calculation results in a result array, the method also includes: pushing the factor calculation results directly downstream in the form of a binary structure.