Screening methods and apparatus, storage media and electronic equipment
By constructing a full asset matrix and using the SIMD instruction set for parallel computation, the problem of excessively long condition screening time in traditional bond backtesting is solved, achieving efficient screening for bond backtesting and improving the iteration speed of strategy development.
Patent Information
- Application Number
- CN202611306866.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-26
- Publication Date
- 2026-11-17
AI Technical Summary
Traditional bond portfolio backtesting systems suffer from low overall efficiency when processing large-scale data due to the time-consuming condition screening steps, which severely slows down the iteration cycle of strategy development and optimization.
A full asset matrix is constructed, and asset indicators are encoded as multi-digit integers. Parallel computation is performed using bitwise AND operations and the SIMD instruction set to achieve efficient matching between the screening condition vector and the asset matrix.
It significantly improves the computational efficiency of bond backtesting, reducing the time from hours to seconds or even milliseconds, making full use of the parallel computing capabilities of modern CPUs and reducing the waste of computing resources.
Smart Images

Figure CN123118262A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of financial engineering, and more specifically, to a screening method and apparatus, a storage medium, and an electronic device. Background Technology
[0002] In quantitative investment research on bonds, strategy backtesting is a core step in verifying the effectiveness of a strategy. Traditional bond portfolio backtesting systems typically employ a serial and iterative processing flow. Specifically, when a strategy needs to select bonds that meet specific criteria from a large pool of bonds, a traditional bond portfolio backtesting system iterates through each bond and then compares and judges each selection criterion (e.g., bond type, remaining maturity, credit rating, coupon rate range, etc.) one by one.
[0003] This traditional method based on loop iteration suffers from time consumption and low efficiency when dealing with large-scale data and complex strategies. A typical bond backtesting scenario may involve data from the past 5-10 years, with a bond pool size reaching tens or even hundreds of thousands of bonds. When the strategy includes multiple screening criteria, its time complexity is O(N). M), where N is the number of bonds and M is the number of conditions. This means that a complete backtest often takes several hours or even longer, severely slowing down the iteration cycle of strategy development and optimization.
[0004] There is currently no effective solution to the problem of low overall efficiency in bond backtesting caused by the excessive time spent on condition screening steps.
[0005] Therefore, it is necessary to improve the relevant technology to overcome the aforementioned defects. Summary of the Invention
[0006] This application provides a screening method and apparatus, a storage medium and an electronic device to at least solve the problem of low overall efficiency in bond backtesting caused by the excessive time spent on the condition screening step during bond backtesting in related technologies.
[0007] According to one aspect of the embodiments of this application, a screening method is provided, comprising: constructing a full asset matrix corresponding to multiple assets, wherein each row of the full asset matrix is used to indicate each asset, and each column of the full asset matrix is used to indicate each asset indicator corresponding to each asset; performing a bitwise AND operation on a screening condition vector and the full asset matrix, wherein each element of the screening condition vector is used to indicate a mask of each asset indicator in the full asset matrix, and the length of the screening condition vector is consistent with the number of columns in the full asset matrix; reducing and judging the results of multiple bitwise AND operations corresponding to each asset to determine whether each asset meets each screening condition, and screening the multiple assets according to whether each asset meets each screening condition.
[0008] In an exemplary embodiment, constructing a full asset matrix corresponding to multiple assets includes: mapping multiple asset indicators corresponding to each asset to different bits in a multi-bit integer based on a preset encoding rule to generate an encoded value for each asset indicator; combining the encoded values of the multiple asset indicators corresponding to each asset into a feature vector corresponding to each asset; and constructing the full asset matrix based on the feature vectors corresponding to the multiple assets.
[0009] In an exemplary embodiment, before performing a bitwise AND operation on the filter condition vector and the full asset matrix, the method further includes: upon receiving at least one filter condition sent by the target object, converting each filter condition into a multi-bit integer mask based on a preset mapping rule; and combining the multi-bit integer masks corresponding to the at least one filter condition into the filter condition vector.
[0010] In an exemplary embodiment, converting each filtering condition into a multi-bit integer mask based on a preset mapping rule includes: determining the condition type of each filtering condition; if the condition type is determined to be a limited condition, converting each filtering condition into a multi-bit integer mask corresponding to the limited value of each filtering condition; if the condition type is a wildcard condition, converting each filtering condition into a multi-bit integer mask with the target bit as the bit.
[0011] In an exemplary embodiment, performing a bitwise AND operation on the filtering condition vector and the full asset matrix includes: performing an element-wise bitwise AND operation on each column of matrix elements corresponding to each asset in the full asset matrix according to a target formula to generate multiple bitwise AND operation results corresponding to each asset, wherein the target formula is: Result[i][j]=Assets[i][j]&Mask[j], Assets[i][j] is the bitwise AND operation result of the i-th asset on the j-th asset indicator, Assets[i][j] is the matrix element in the j-th column corresponding to the i-th asset in the full asset matrix, and Mask[j] is the j-th element in the filtering condition vector.
[0012] In an exemplary embodiment, filtering the plurality of assets based on whether each asset meets each filtering condition includes: retaining the first asset if the first asset among the plurality of assets meets all the filtering conditions corresponding to the first asset; and removing the second asset if the second asset among the plurality of assets does not meet any of the filtering conditions corresponding to the second asset.
[0013] According to another aspect of the embodiments of this application, a filtering device is also provided, comprising: a construction module, configured to construct a full asset matrix corresponding to multiple assets, wherein each row element of the full asset matrix is used to indicate each asset, and each column element of the full asset matrix is used to indicate each asset indicator corresponding to each asset; an execution module, configured to perform a bitwise AND operation on a filtering condition vector and the full asset matrix, wherein each element of the filtering condition vector is used to indicate a mask of each asset indicator in the full asset matrix, and the length of the filtering condition vector is consistent with the number of columns in the full asset matrix; and a filtering module, configured to reduce and judge the results of multiple bitwise AND operations corresponding to each asset to determine whether each asset meets each filtering condition, and to filter the multiple assets based on whether each asset meets each filtering condition.
[0014] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the above-described filtering method at runtime.
[0015] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the screening method described above through the computer program.
[0016] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of the methods described in various embodiments of this application.
[0017] This application constructs a full asset matrix corresponding to multiple assets. Each row of the full asset matrix indicates each asset, and each column indicates each asset indicator. A bitwise AND operation is performed on the filtering condition vector and the full asset matrix. Each element in the filtering condition vector indicates a mask for each asset indicator in the full asset matrix. The result of the bitwise AND operation for each asset is reduced to determine whether each asset meets each filtering condition. Multiple assets are then filtered based on whether each asset meets each filtering condition. This application solves the problem of low overall efficiency in bond backtesting caused by the excessive time spent on the condition filtering step in related technologies, thereby reducing the time consumed by the condition filtering step. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a hardware structure block diagram of a computer device for a screening method according to an embodiment of this application;
[0021] Figure 2 This is a flowchart of a screening method according to an embodiment of this application;
[0022] Figure 3 This is a structural block diagram of a screening device according to an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] The methods and embodiments provided in this application can be executed on a computer device or a similar computing device. Taking running on a computer device as an example, Figure 1 This is a hardware structure block diagram of a computer device for a screening method according to an embodiment of this application. For example... Figure 1 As shown, a computer device may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a central processing unit (CPU) or a programmable gate array (FPGA)) and a memory 104 for storing data are also shown. The computer device may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer device described above. For example, the computer device may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0026] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the screening method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0027] The computer device uses a wireless network provided by a communications provider. In one example, transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0028] This embodiment provides a screening method. Figure 2 This is a flowchart of a screening method according to an embodiment of this application, such as... Figure 2 As shown, the method includes:
[0029] Step S202: Construct a full asset matrix corresponding to multiple assets, wherein each row of the full asset matrix is used to indicate each asset, and each column of the full asset matrix is used to indicate each asset indicator corresponding to each asset.
[0030] The full asset matrix is an N-row × M-column matrix, where N is the total number of assets and M is the total number of screening criteria (i.e., the total number of asset indicator pairs).
[0031] Step S204: Perform a bitwise AND operation on the filtering condition vector and the full asset matrix;
[0032] Step S206: Perform a reduction judgment on the multiple operation results corresponding to each asset to determine whether each asset meets each screening condition, and screen the multiple assets according to whether each asset meets each screening condition.
[0033] Through the above steps, a full asset matrix corresponding to multiple assets is constructed. Each row element in the full asset matrix indicates each asset, and each column element indicates each asset indicator. A bitwise AND operation is performed on the filtering condition vector and the full asset matrix. Each element in the filtering condition vector indicates a mask for each asset indicator in the full asset matrix. The result of the bitwise AND operation for each asset is reduced to determine whether each asset meets each filtering condition. Based on whether each asset meets each filtering condition, multiple assets are filtered. This application solves the problem of low overall efficiency in bond backtesting caused by the excessive time consumption of the condition filtering step in related technologies, thereby reducing the time consumption of the condition filtering step.
[0034] Optionally, constructing a full asset matrix corresponding to multiple assets includes: mapping multiple asset indicators corresponding to each asset to different bits in a multi-bit integer based on a preset encoding rule to generate an encoded value for each asset indicator; combining the encoded values of the multiple asset indicators corresponding to each asset into a feature vector corresponding to each asset; and constructing the full asset matrix based on the feature vectors corresponding to multiple assets.
[0035] The aforementioned asset indicators refer to non-numerical or discrete asset indicators. Examples include: bond types, credit ratings, and listed exchanges.
[0036] Understandably, the technical solution for constructing a full asset matrix is as follows: based on preset encoding rules, various non-numerical or discrete asset indicators are mapped to specific bits in a multi-bit integer (e.g., a 64-bit integer int64). Each specific asset indicator value occupies a specific byte or bit segment in the multi-bit integer. For example, suppose a 64-bit integer is used to store the two indicators of "type" and "issuer rating" of bonds: the lower 8 bits (bits 0-7) are used to represent "bond type": 0x01 (binary 00000001) represents "government bonds"; 0x02 (binary 00000010) represents "financial bonds"; and 0x04 (binary 00000100) represents "corporate bonds". The next 8 bits (bits 8-15): used to represent the "subject rating", 0x0100 (binary ... 00000001 00000000) represents "AAA"; 0x0200 (binary ... 00000010 00000000) represents "AA+"; 0x0400 (binary ... 00000100 00000000) represents "AA".
[0037] For a single asset, the coded values of all key asset metrics for that asset are combined. A bitwise OR operation can be used to combine the coded values of different asset metrics into a single integer, forming the asset's feature vector. If multiple screening criteria are included (e.g., type, rating, maturity, yield range, etc.), each dimension corresponds to an independent 64-bit integer, and these multiple dimensions together constitute a multi-dimensional feature vector for an asset.
[0038] Iterate through the entire asset pool (e.g., containing 100,000 bonds) and generate the aforementioned feature vector for each bond. Stack the feature vectors of all assets row-wise to form an N-row × M-column two-dimensional matrix (where N is the total number of assets and M is the number of dimensions for the filtering criteria). This two-dimensional matrix (i.e., the entire asset matrix) is stored as a binary file (such as an int64 array) in contiguous memory.
[0039] In other words, this embodiment maps non-numerical enumeration-type asset indicators (such as bond type, listed exchange, issuer rating, etc.) to different bits in a 64-bit integer (int64) according to a preset encoding rule. Each filtering condition corresponds to an independent 64-bit integer. For each asset, the encoded values of all its enumeration-type indicators are combined (e.g., through a bitwise OR operation) to form a unique integer vector representing all characteristics of that asset. Finally, the vectors of all assets will constitute an N-row × M-column two-dimensional integer matrix (int64 matrix), where N is the total number of assets and M is the total number of filtering conditions. This matrix can be persistently stored for fast loading.
[0040] Optionally, before performing a bitwise AND operation on the filter condition vector and the full asset matrix, the method further includes:
[0041] Step 1: Upon receiving at least one filtering condition from the target object, convert each filtering condition into a multi-bit integer mask based on a preset mapping rule; specifically: determine the condition type of each filtering condition; if the condition type is determined to be a limited condition, convert each filtering condition into a multi-bit integer mask corresponding to the limited value of each filtering condition; if the condition type is a wildcard condition, convert each filtering condition into a multi-bit integer mask with the target bit as the bit.
[0042] Step 2: Combine the multi-bit integer masks corresponding to the at least one filtering condition into the filtering condition vector.
[0043] Understandably, the technical solution for constructing the filtering condition vector is as follows:
[0044] Converting filter criteria into multi-bit integer masks: When the condition type is a restricted condition, determine the specific value of the enumeration value corresponding to the restricted condition in the preset encoding table. Directly convert the enumeration value corresponding to the restricted condition into a multi-bit integer mask. Restricted conditions refer to filter criteria with explicit, unique value requirements for asset attributes. For example, the issuer rating must be AAA, and the bond type must be financial bond. When the condition type is a wildcard condition, determine the encoding set of all possible enumeration values covered by the wildcard condition. Perform a bitwise OR operation on these possible value encodings to generate a mask where all relevant bits are 1. Wildcard conditions refer to filter criteria that do not have specific restrictions on asset attributes, i.e., allow the attribute to have any valid value. For example, "no restrictions on bond type" or "no restrictions on listed exchange".
[0045] Combined into a filtering condition vector: The multi-bit integer mask is arranged according to a predefined dimensional order, such as category dimension, rating dimension, term dimension, etc., and combined into a fixed-length integer array of length M, which is the filtering condition vector.
[0046] In other words, this application receives filtering conditions from business logic or strategy models. The system converts these textual or numerical filtering conditions into an integer array (condition vector) of length M, following the exact same rules as the asset encoding module. Each element in the array is an int64 mask representing the bit pattern that the filtering condition "expects" to match.
[0047] Optionally, a bitwise AND operation is performed on the filtering condition vector and the full asset matrix, including: performing an element-wise bitwise AND operation on each column of matrix elements corresponding to each asset in the full asset matrix according to the target formula, so as to generate multiple bitwise AND operation results corresponding to each asset, wherein the target formula is: Result[i][j]=Assets[i][j]&Mask[j], Assets[i][j] is the bitwise AND operation result of the i-th asset on the j-th asset indicator, Assets[i][j] is the matrix element of the j-th column corresponding to the i-th asset in the full asset matrix, and Mask[j] is the j-th element in the filtering condition vector.
[0048] Understandably, the technical solution for generating multiple bitwise AND operation results is as follows:
[0049] Construct the asset matrix and condition vector: For example: Asset 1 (Government Bond, AAA): Its asset matrix row vector is [0x01, 0x0100]; Asset 2 (Financial Bond, AA+): Its asset matrix row vector is [0x02, 0x0200].
[0050] Condition vector: Mask[0] (type): expects "government bond", that is, match 0x01. Since only government bond is required, other bits are 0, so Mask[0]=0x01; Mask[1] (rating): expects "AAA", that is, match 0x0100, so Mask[1]=0x0100. Condition vector Mask=[0x01, 0x0100].
[0051] Perform a bitwise AND operation: For Asset 1 (row 1, i=1): Calculate in column 1: Assets[1][0]&Mask[0]=0x01&0x01=0x01. The result is non-zero, indicating a type match; Calculate in column 2: Assets[1][1]&Mask[1]=0x0100&0x0100=0x0100. The result is non-zero, indicating a rating match. Bitwise AND operation result: Result[1]=[0x01, 0x0100].
[0052] For Asset 2 (row 2, i=2): Column 1 calculation: Assets[2][0]&Mask[0]=0x02&0x01. Binary operation: …0010&…0001=…0000=0x00. The result is 0, indicating a type mismatch. Column 2 calculation: Assets[2][1]&Mask[1]=0x0200&0x0100. Binary operation: …01000000&…0001000000=0x00. The result is 0, indicating a rating mismatch. Bitwise AND operation result: Result[2]=[0x00, 0x00].
[0053] In other words, this embodiment loads an N×M asset matrix and a 1×M condition vector from locally loaded data into memory. The engine utilizes the Single Instruction, Multiple Data (SIMD) instruction set (e.g., AVX-512) of the Central Processing Unit (CPU) to perform parallel bitwise AND operations on the same column of multiple rows of data at once. That is, each row of the asset matrix is ANDed element-wise with the condition vector.
[0054] Optionally, the plurality of assets may be filtered based on whether each asset meets each filtering condition, including: retaining the first asset if the first asset among the plurality of assets meets all the filtering conditions corresponding to the first asset; and removing the second asset if the second asset among the plurality of assets does not meet any of the filtering conditions corresponding to the second asset.
[0055] Understandably, technical solutions for screening multiple assets include:
[0056] Perform the following logical judgment for each asset:
[0057] Retention Criteria (Exact Match): For a given row in the full asset matrix (representing an asset), perform an element-wise bitwise AND operation between that row and the filtering criteria vector. If every element of the result is non-zero, it proves that the asset meets the preset criteria in all filtered dimensions. In this case, the asset is determined to meet all filtering criteria and is retained in the result set.
[0058] Removal criteria (any mismatch): If any element in the result vector is zero in the bitwise AND operation above, it means that the asset failed the test in at least one filtering dimension (i.e., the bits in that dimension do not correspond or conflict). In this case, the asset is immediately determined to be ineligible for filtering and is removed from the result set.
[0059] In other words, this embodiment performs a reduction judgment on the M & operation results of each row. If all M results in the row are not 0, it means that all conditions of the asset are successfully matched; if any result in the row is 0, it means that at least one condition of the asset is not met, and it is discarded.
[0060] Return the original asset IDs corresponding to all successfully matched asset rows to the strategy backtesting system or business front end to complete the rapid screening of vouchers.
[0061] Obviously, the embodiments described above are merely some embodiments of the present invention, and not all embodiments. To better understand the above method, the following description, in conjunction with embodiments, illustrates the process, but is not intended to limit the technical solutions of the embodiments of the present invention. Specifically:
[0062] In addition to the problems described in the background section, the existing technology also suffers from the following issues: Waste of computing resources: Traditional loop comparisons cannot fully utilize the parallel computing capabilities of modern CPUs. The CPU can only process the comparison of one data element at a time, leaving most computing units idle, resulting in a huge waste of computing resources; Difficulty in meeting high-frequency or real-time requirements: In scenarios requiring rapid response to market changes or real-time stock screening during trading hours, hourly processing speeds are completely unacceptable.
[0063] To address the aforementioned issues, this application proposes an optional embodiment of a rapid asset screening method and system based on bit-level encoding and vectorized operations. This solves the problem of low overall efficiency in bond backtesting due to the excessively time-consuming condition screening steps. By encoding and converting asset attributes and screening conditions, and utilizing the CPU's SIMD (Single Instruction, Multiple Data) vectorized instruction set for parallel computation, the screening efficiency is improved by several orders of magnitude, thereby reducing backtesting time from hours to seconds or even milliseconds.
[0064] The scenario is as follows: Assume there are 5 years of historical bond data, totaling 100,000 bonds. Bonds need to be screened based on three criteria: "bond type," "issuer rating," and "remaining maturity."
[0065] Step S301: Asset indicator coding and matrix construction (offline preprocessing):
[0066] (1) Define encoding rules:
[0067] Condition A (Bond Type): Encoded using the first byte (8 bits) of int64. For example, 0x01 represents "Government Bond", 0x02 represents "Financial Bond", and 0x04 represents "Corporate Bond".
[0068] Condition B (Subject Rating): Encoded using the second byte (8 bits) of int64. For example, 0x0100 represents "AAA", 0x0200 represents "AA+", and 0x0400 represents "AA".
[0069] Condition C (Remaining Term): Encoded using the third byte (8 bits) of int64. For example, 0x010000 represents "1-3 years", 0x020000 represents "3-5 years", and 0x040000 represents "more than 5 years".
[0070] (2) Generate asset vectors: Iterate through 100,000 bonds and generate corresponding integer vectors [attr_A, attr_B, attr_C] based on their actual attributes. For example, a "government bond" (0x01), with a credit rating of "AAA" (0x0100) and a remaining maturity of "3-5 years" (0x020000), has a vector of [0x01, 0x0100, 0x020000]. Another "corporate bond" (0x04), with a credit rating of "AA" (0x0400) and a remaining maturity of "more than 5 years" (0x040000), has a vector of [0x04, 0x0400, 0x040000].
[0071] (3) Construct the asset matrix (i.e. the full asset matrix): Combine the vectors of all 100,000 bonds into a 100,000 x 3 int64 matrix and persist it to a local disk file (such as a binary file).
[0072] Step S302, Filter criteria transformation (online real-time):
[0073] (1) The strategy backend proposes a screening requirement: to screen bonds with "AAA credit rating" and "remaining maturity of 3-5 years". It should be noted that there are no requirements for "bond type" here.
[0074] (2) Generate a condition vector (i.e., a selection condition vector): According to the rules, convert it into a condition vector of length 3 [mask_A, mask_B, mask_C]. mask_A: Since there is no restriction on the type, this condition should be in "wildcard" mode (i.e., wildcard class condition). In the encoding system, wildcard means that all possible type bits should be 1. Therefore, mask_A = 0x01|0x02|0x04 = 0x07 (binary 00000111). mask_B: Requires "AAA", corresponding to 0x0100. mask_C: Requires "3-5 years", corresponding to 0x020000. The final condition vector is [0x07, 0x0100, 0x020000].
[0075] Step S303, Vectorized parallel ticket screening (online real-time):
[0076] (1) Loading data: When the strategy backtesting system starts, it loads a 100,000×3 asset matrix from the local file into memory. At the same time, it receives the condition vector [0x07, 0x0100, 0x020000].
[0077] (2) Perform vectorized computation: The engine uses the SIMD instruction set to perform the following operations in parallel on each row of the asset matrix:
[0078] result_A=attr_A&mask_A; result_B=attr_B&mask_B; result_C=attr_C&mask_C.
[0079] Parallel implementation details: Modern CPUs can load 8, 16, or even 32 attr_A values at once and perform a bitwise AND operation with mask_A in a single instruction, greatly improving throughput.
[0080] (3) Result filtering:
[0081] Checking the first bond (government bond): 0x01&0x07=0x01 (non-zero), 0x0100&0x0100=0x0100 (non-zero), 0x020000&0x020000=0x020000 (non-zero). All three results are non-zero, so the match is successful.
[0082] Checking the second bond (corporate bond): 0x04&0x07=0x04 (non-zero), 0x0400&0x0100=0x0 (zero), the result is 0, the match failed, and it is directly eliminated.
[0083] (4) Return results: The engine returns a list of the original IDs of all successfully matched bond banks to the strategy system.
[0084] Through the above steps, what would have originally required 100,000 The operation of three loop comparisons was transformed into batch bitwise operations on contiguous blocks of data in memory, resulting in an exponential improvement in computational efficiency.
[0085] In summary, according to the optional embodiments of this application, the following can be achieved: A "homogeneous encoding" conversion mechanism for data and conditions: The optional embodiments of this application propose a method to uniformly encode asset enumeration indicators and screening conditions into 64-bit integer bits. This "homogeneous encoding" cleverly transforms complex logical judgment problems into efficient integer bitwise operations, laying a data foundation for subsequent vectorized parallel computing. Matrix-based asset feature modeling: By organizing the encoded vectors of all assets into a two-dimensional matrix, the optional embodiments of this application propose a highly regular, memory-contiguous data structure. This structure perfectly adapts to the cache prefetching mechanism of modern CPUs and the data access mode of SIMD instruction sets, minimizing CPU cache misses and improving data throughput. Transforming serial comparison into parallel bitwise operations: The optional embodiments of this application no longer compare assets and conditions one by one, but utilize the vectorization characteristics of the CPU to encapsulate the screening action of M conditions into a parallel "bitwise AND" operation of an N×M matrix and a 1×M vector. This reduces the original time complexity of O(N*M) to O(N*M). The problem of M) is significantly parallelized at the hardware level, with computation time only slightly exceeding the constant time of O(N). Significant performance improvement: Under the same hardware conditions, the optional embodiments of this application achieve a nearly 2000-fold increase in bond screening speed compared to traditional iterative comparison methods. This allows a full bond backtest that originally took several hours to complete in minutes or even seconds, providing a feasible technical solution for application scenarios with extremely high timeliness requirements, such as high-frequency strategy development and real-time risk monitoring.
[0086] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.
[0087] Figure 3 This is a structural block diagram of a screening device according to an embodiment of this application, the device comprising:
[0088] Construction module 32 is used to construct a full asset matrix corresponding to multiple assets, wherein each row of the full asset matrix is used to indicate each asset, and each column of the full asset matrix is used to indicate each asset indicator corresponding to each asset.
[0089] Execution module 34 is used to perform a bitwise AND operation on the filter condition vector and the full asset matrix, wherein each element in the filter condition vector is used to indicate the mask of each asset indicator in the full asset matrix, and the length of the filter condition vector is the same as the number of columns in the full asset matrix;
[0090] The filtering module 36 is used to perform reduction judgment on the multiple bitwise AND operation results corresponding to each asset to determine whether each asset meets each filtering condition, and to filter the multiple assets based on whether each asset meets each filtering condition.
[0091] Using the aforementioned apparatus, a full asset matrix corresponding to multiple assets is constructed. Each row of the full asset matrix indicates each asset, and each column of the full asset matrix indicates each asset indicator corresponding to each asset. A bitwise AND operation is performed on the filtering condition vector and the full asset matrix. Each element in the filtering condition vector indicates a mask for each asset indicator in the full asset matrix. The result of the bitwise AND operation corresponding to each asset is reduced to determine whether each asset meets each filtering condition. Based on whether each asset meets each filtering condition, multiple assets are filtered. This application solves the problem of low overall efficiency in bond backtesting caused by the excessive time consumption of the condition filtering step in related technologies, thereby reducing the time consumption of the condition filtering step.
[0092] In an exemplary embodiment, the construction module 32 is used to map multiple asset indicators corresponding to each asset to different bits in a multi-bit integer based on a preset encoding rule to generate an encoded value for each asset indicator; combine the encoded values of the multiple asset indicators corresponding to each asset to form a feature vector corresponding to each asset; and construct the full asset matrix based on the feature vectors corresponding to the multiple assets.
[0093] In an exemplary embodiment, the execution module 34 is configured to, upon receiving at least one filtering condition sent by the target object, convert each filtering condition into a multi-bit integer mask based on a preset mapping rule; and combine the multi-bit integer masks corresponding to the at least one filtering condition into the filtering condition vector.
[0094] In an exemplary embodiment, the execution module 34 is configured to determine the condition type of each filtering condition; if the condition type is determined to be a limited condition, convert each filtering condition into a multi-bit integer mask corresponding to the limited value of each filtering condition; if the condition type is a wildcard condition, convert each filtering condition into a multi-bit integer mask with the target bit as the bit.
[0095] In an exemplary embodiment, the execution module 34 is configured to perform an element-wise bitwise AND operation on each column of matrix elements corresponding to each asset in the full asset matrix according to the target formula, so as to generate multiple bitwise AND operation results corresponding to each asset, wherein the target formula is: Result[i][j]=Assets[i][j]&Mask[j], Assets[i][j] is the bitwise AND operation result of the i-th asset on the j-th asset indicator, Assets[i][j] is the matrix element of the j-th column corresponding to the i-th asset in the full asset matrix, and Mask[j] is the j-th element in the filtering condition vector.
[0096] In an exemplary embodiment, the filtering module 36 is configured to retain the first asset if the first asset among the plurality of assets meets all the filtering conditions corresponding to the first asset; and to remove the second asset if the second asset among the plurality of assets does not meet any of the filtering conditions corresponding to the second asset.
[0097] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when run.
[0098] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0099] S1, construct a full asset matrix corresponding to multiple assets, wherein each row of the full asset matrix is used to indicate each asset, and each column of the full asset matrix is used to indicate each asset indicator corresponding to each asset.
[0100] S2, Perform a bitwise AND operation on the filter condition vector and the full asset matrix, wherein each element in the filter condition vector is used to indicate a mask for each asset indicator in the full asset matrix, and the length of the filter condition vector is the same as the number of columns in the full asset matrix;
[0101] S3, perform reduction judgment on the multiple bitwise AND operation results corresponding to each asset to determine whether each asset meets each screening condition, and screen the multiple assets according to whether each asset meets each screening condition.
[0102] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0103] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0104] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0105] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0106] S1, construct a full asset matrix corresponding to multiple assets, wherein each row of the full asset matrix is used to indicate each asset, and each column of the full asset matrix is used to indicate each asset indicator corresponding to each asset.
[0107] S2, Perform a bitwise AND operation on the filter condition vector and the full asset matrix, wherein each element in the filter condition vector is used to indicate a mask for each asset indicator in the full asset matrix, and the length of the filter condition vector is the same as the number of columns in the full asset matrix;
[0108] S3, perform reduction judgment on the multiple bitwise AND operation results corresponding to each asset to determine whether each asset meets each screening condition, and screen the multiple assets according to whether each asset meets each screening condition.
[0109] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0110] Embodiments of this application also provide a computer program product, including a non-volatile computer-readable storage medium storing the computer program product, wherein the computer program, when executed by a processor, implements the steps of the methods described in various embodiments of this application.
[0111] Optionally, in this embodiment, the computer program described above can be configured to perform the following steps when executed by the processor:
[0112] S1, construct a full asset matrix corresponding to multiple assets, wherein each row of the full asset matrix is used to indicate each asset, and each column of the full asset matrix is used to indicate each asset indicator corresponding to each asset.
[0113] S2, Perform a bitwise AND operation on the filter condition vector and the full asset matrix, wherein each element in the filter condition vector is used to indicate a mask for each asset indicator in the full asset matrix, and the length of the filter condition vector is the same as the number of columns in the full asset matrix;
[0114] S3, perform reduction judgment on the multiple bitwise AND operation results corresponding to each asset to determine whether each asset meets each screening condition, and screen the multiple assets according to whether each asset meets each screening condition.
[0115] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0116] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0117] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A screening method, characterized in that, include: Construct a full asset matrix corresponding to multiple assets, wherein each row of the full asset matrix is used to indicate each asset, and each column of the full asset matrix is used to indicate each asset indicator corresponding to each asset. Perform a bitwise AND operation on the filter condition vector and the full asset matrix, wherein each element in the filter condition vector is used to indicate a mask for each asset indicator in the full asset matrix, and the length of the filter condition vector is the same as the number of columns in the full asset matrix; The results of multiple bitwise AND operations corresponding to each asset are reduced and judged to determine whether each asset meets each screening condition, and the multiple assets are screened according to whether each asset meets each screening condition.
2. The screening method according to claim 1, characterized in that, Construct a full asset matrix corresponding to multiple assets, including: Based on a preset encoding rule, multiple asset indicators corresponding to each asset are mapped to different bits in a multi-bit integer to generate the encoded value of each asset indicator. The encoded values of multiple asset indicators corresponding to each asset are combined into a feature vector corresponding to each asset. The full asset matrix is constructed based on the feature vectors corresponding to multiple assets.
3. The screening method according to claim 1, characterized in that, Before performing a bitwise AND operation on the filtering condition vector and the full asset matrix, the method further includes: Upon receiving at least one filtering condition from the target object, each filtering condition is converted into a multi-bit integer mask based on a preset mapping rule; The multi-bit integer masks corresponding to the at least one filtering condition are combined into the filtering condition vector.
4. The screening method according to claim 3, characterized in that, Each filtering condition is converted into a multi-bit integer mask based on preset mapping rules, including: Determine the condition type for each of the filtering conditions; If the condition type is determined to be a restricted condition, each filtering condition is converted into a multi-bit integer mask corresponding to the restricted value according to the restricted value of each filtering condition; When the condition type is a wildcard condition, each filtering condition is converted into a multi-bit integer mask with the target bit as the number of bits.
5. The screening method according to claim 1, characterized in that, Perform a bitwise AND operation on the filter condition vector and the full asset matrix, including: According to the target formula, perform an element-wise bitwise AND operation on each column of matrix elements corresponding to each asset in the full asset matrix to generate multiple bitwise AND operation results for each asset. The target formula is: Result[i][j]=Assets[i][j]&Mask[j], where Assets[i][j] is the bitwise AND operation result of the i-th asset on the j-th asset indicator, Assets[i][j] is the matrix element in the j-th column corresponding to the i-th asset in the full asset matrix, and Mask[j] is the j-th element in the filtering condition vector.
6. The screening method according to claim 1, characterized in that, The multiple assets are filtered based on whether each asset meets each filtering criterion, including: If the first asset among the plurality of assets meets all the screening criteria corresponding to the first asset, the first asset is retained; If the second asset among the multiple assets does not meet any of the screening criteria corresponding to the second asset, the second asset is removed.
7. A screening device, characterized in that, include: The construction module is used to construct a full asset matrix corresponding to multiple assets, wherein each row of the full asset matrix is used to indicate each asset, and each column of the full asset matrix is used to indicate each asset indicator corresponding to each asset. An execution module is used to perform a bitwise AND operation on the filter condition vector and the full asset matrix, wherein each element in the filter condition vector is used to indicate a mask for each asset indicator in the full asset matrix, and the length of the filter condition vector is the same as the number of columns in the full asset matrix; The filtering module is used to perform reduction judgment on multiple bitwise AND operation results corresponding to each asset to determine whether each asset meets each filtering condition, and to filter the multiple assets based on whether each asset meets each filtering condition.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method according to any one of claims 1-6.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1-6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.
