Open statistical method for foreign exchange transaction, electronic equipment and medium
By aggregating and grouping foreign exchange transaction data by settlement date and currency pair, and using sparse indexes and Bloom filters to quickly locate target data blocks, the problems of low storage efficiency and slow statistical speed in massive foreign exchange transactions are solved, achieving efficient storage and fast exposure statistics.
Patent Information
- Application Number
- CN202610093289.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-23
- Publication Date
- 2026-02-27
AI Technical Summary
In the case of massive foreign exchange transaction data, the existing technology has a low rate of risk exposure statistics and low storage efficiency, and cannot quickly locate the storage location related to the statistical request, resulting in excessive consumption of computing resources.
By aggregating and grouping transaction data by settlement date and currency pair, and utilizing sparse indexes and Bloom filters to quickly locate target data blocks, efficient storage and rapid exposure statistics are achieved.
It improves the storage efficiency of transaction data and the rate of exposure statistics, reduces the consumption of computing resources, is suitable for massive foreign exchange transactions in cross-border payment scenarios, and achieves high real-time risk exposure statistics.
Smart Images

Figure CN121582002A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cross-border payment technology, and in particular to a method, electronic device, and medium for statistical analysis of foreign exchange transaction exposure. Background Technology
[0002] Cross-border payment scenarios involve a massive amount of foreign exchange transactions, which essentially involve the exchange of different currency pairs to complete cross-border fund settlements. Because foreign exchange transactions have long settlement cycles and the transaction exchange rate naturally differs from the market exchange rate, this difference generates daily gains and losses as exchange rate fluctuations occur. Therefore, it is necessary to calculate the risk exposure of foreign exchange transactions based on the difference between the two exchange rates in order to assess the potential losses that cross-border enterprises may face in scenarios involving massive transactions and multiple currency pairs.
[0003] Exposure statistics rely on transaction data such as exchange rates, trading volume, and settlement dates. Currently, completing exposure statistics requires multiple sifting through servers storing large amounts of transaction data to obtain the target transaction data, and then calculating the profit and loss value according to the profit and loss formula.
[0004] However, this method suffers from a low rate of risk exposure statistics when dealing with massive amounts of foreign exchange transaction data. Summary of the Invention
[0005] This invention aims to address, to a certain extent, one of the technical problems in related technologies. To this end, this invention provides a method for calculating the exposure of foreign exchange transactions, an electronic device for performing the method, and a computer-readable medium, which has the advantages and characteristics of high efficiency in storing transaction data, fast exposure calculation speed, and accurate exposure calculation results.
[0006] To achieve the above objectives, as a first aspect of the present invention, a method for calculating the exposure of foreign exchange transactions is provided, wherein the method includes: Retrieve multiple transaction data entries to be stored; Multiple sets of transaction data to be stored are aggregated according to the settlement date to obtain multiple sets of aggregated transaction data; wherein, the settlement dates of the aggregated transaction data in different sets are different, and the settlement dates of the aggregated transaction data in the same set are the same; Multiple first target data blocks are determined based on the settlement date of multiple sets of aggregated transaction data. The first target data blocks store transaction data with the same settlement date as the aggregated transaction data. Select a second target data block from multiple first target data blocks that contains the same currency pair as the aggregated transaction data; The aggregated transaction data is stored in the second target data block; In response to an exposure statistics request, determine the delivery date and currency pair corresponding to the exposure statistics request; Exposure statistics are performed based on the determined settlement date, currency pair, and the transaction data in the data block that stores the transaction data corresponding to the determined settlement date and currency pair.
[0007] Optionally, the aggregation of multiple sets of transaction data to be stored according to the settlement date to obtain multiple sets of aggregated transaction data includes: The transaction data to be stored is preprocessed to obtain processed transaction data, wherein the processed transaction data includes a settlement date field, a currency pair field, and a transaction date field arranged in sequence. The processed data is grouped according to the delivery date field to obtain multiple aggregated transaction data sets.
[0008] Optionally, the step of grouping the processed transaction data according to the delivery date field to obtain multiple groups of aggregated transaction data includes: Extract the delivery date field from multiple processed transaction data; Perform full string matching on multiple extracted delivery date fields, and group multiple processed transaction data with identical delivery date field strings into the same group to obtain multiple aggregated transaction data; Multiple extracted settlement date fields are hashed to obtain multiple settlement date hash values. Multiple processed transaction data with the same settlement date hash value are grouped together to obtain multiple aggregated transaction data.
[0009] Optionally, the first target data block further includes a bit array; the bit array carries a mapping relationship between the positions of the currency pair hash values in the bit array; The step of selecting a second target data block from multiple first target data blocks that contains the same currency pair as the aggregated transaction data includes: Extract the currency pair field from the aggregated transaction data; Multiple hash functions are used to perform hash operations on the extracted currency pair field to obtain multiple currency pair hash values; Based on the mapping relationship between the obtained hash values of multiple currency pairs and the bit arrays of each first target data block, the positions of the obtained hash values of multiple currency pairs in the bit arrays of each first target data block are determined. Verify the position of the hash values of multiple currency pairs in the bit array of each first target data block; The first target data block that passes the verification is used as the second target data block containing the currency pair and multiple aggregated transaction data.
[0010] Optionally, the first target data block stores multiple currency pairs; the position information of the bit array carries information about the type of currency pair. The verification of the positions of the hash values of multiple currency pairs in the bit arrays of each first target data block includes: If multiple currency pair hash values are found to have the same currency pair type information carried at the position of the bit array in the first target data block, the data content stored at the position of the bit array is verified. If the data stored at the position of the bit array is preset data, the first target data block passes the verification.
[0011] Optionally, the step of performing exposure statistics based on the determined settlement date, currency pair, and transaction data in the data block storing the transaction data corresponding to the determined settlement date and currency pair includes: Using the determined delivery date as a sparse index, multiple first target data blocks are determined in the target data block that stores multiple sets of aggregated transaction data; A second target data block is extracted from multiple first target data blocks using a Bloom filter and a determined currency pair; wherein the Bloom filter corresponds one-to-one with the data block; and the second target data block stores the transaction data corresponding to the determined currency pair. The profit and loss value is determined based on the transaction data and profit and loss statistics stored in the second target data block.
[0012] Optionally, the step of filtering the second target data block from multiple first target data blocks using a Bloom filter and the determined currency pairs includes: Perform a hash operation on the determined currency pairs to obtain the currency pair hash values; If the obtained currency pair hash value is included in the multiple currency pair hash values stored in the Bloom filter corresponding to the first target data block, the first target data block is used as the second target data block.
[0013] Optionally, the transaction data stored in the second target data block may also include the transaction date, market exchange rate, transaction exchange rate, and transaction volume; The step of determining the profit and loss value based on the transaction data and profit and loss statistics stored in the second target data block includes: Determine the daily exchange rate difference between the market exchange rate and the transaction exchange rate for each day during the trading day and settlement day; The daily exchange rate difference and the corresponding trading volume are multiplied to obtain multiple daily sub-profits and losses. The profit and loss value is obtained by summing the multiple daily sub-profits and losses.
[0014] As a second aspect of the present invention, an electronic device is provided, comprising: One or more processors; A memory having stored one or more computer programs that, when executed by one or more processors, cause the one or more processors to implement the foreign exchange transaction exposure statistics method provided according to the first aspect of the invention.
[0015] Furthermore, as a third aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the foreign exchange transaction exposure statistics method provided in the first aspect of the present invention.
[0016] This invention aggregates massive amounts of transaction data to be stored according to their settlement dates. After aggregation, transaction data with the same settlement date are grouped together, resulting in multiple groups of aggregated transaction data. During storage, a first target data block is determined by using the settlement date to identify multiple consecutive address ranges of stored transaction data with the same settlement date. Within the first target data block, a second target data block is selected from the multiple first target data blocks based on currency pairs, and the aggregated data is stored in the corresponding second target data block. This hierarchical, ordered, and directional storage method, which aggregates and groups data before selecting storage carriers, avoids the problems of scattered, messy, and irregular storage of massive amounts of transaction data by aggregating the data from the source. The method of locating target storage data blocks by settlement date and currency pairs eliminates the need to traverse the global storage address to quickly locate the storage location and store the data, achieving efficient storage even for massive amounts of data and improving storage efficiency. According to the aforementioned data storage method, upon receiving an exposure statistics request, the delivery date and currency pair for this exposure statistics are determined by parsing the request. The determined delivery date and currency pair are then used as inputs to the sparse index and Bloom filter, respectively. Following an aggregation-grouping-layered storage method, the target data block is quickly located. Exposure statistics are then completed based on the transaction data stored in the target data block, improving the statistics speed and reducing computational resource consumption during the statistics process. The exposure statistics method provided by this invention features high transaction data storage efficiency, fast exposure statistics speed, and accurate exposure statistics results. It is particularly suitable for high-volume foreign exchange transactions, multiple currency pairs, and high real-time risk exposure statistics tasks in cross-border payment scenarios.
[0017] These features and advantages of the present invention will be disclosed in detail in the following specific embodiments and accompanying drawings. The preferred embodiments or means of the present invention will be shown in detail in conjunction with the accompanying drawings, but are not intended to limit the technical solutions of the present invention. In addition, each of these features, elements and components appearing in the following text and drawings is a plurality of, and different symbols or numbers are used for convenience of representation, but all represent parts with the same or similar construction or function. Attached Figure Description
[0018] The present invention will be further described below with reference to the accompanying drawings: Figure 1 A flowchart illustrating a method for statistical analysis of exposure in foreign exchange transactions provided by this invention; Figure 2 A flowchart illustrating one embodiment of step S120 of the openness statistics method provided by the present invention; Figure 3 A flowchart illustrating one embodiment of step S122 of the openness statistics method provided by the present invention; Figure 4 A flowchart illustrating one embodiment of step S140 of the openness statistics method provided by the present invention; Figure 5 A flowchart illustrating one embodiment of step S144 of the openness statistics method provided by the present invention; Figure 6 A flowchart illustrating one embodiment of step S170 of the openness statistics method provided by the present invention; Figure 7 A flowchart illustrating one embodiment of step S172 of the openness statistics method provided by the present invention; Figure 8 A flowchart of one embodiment of step S173 of the openness statistics method provided by the present invention; Figure 9 A module diagram of an electronic device provided by the present invention; Figure 10 This invention provides a schematic diagram of a computer-readable medium.
[0019] Explanation of reference numerals in the attached figures Among them, 101 is the processor; 102 is the memory; 103 is the I / O interface; and 104 is the bus. Detailed Implementation
[0020] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described are intended to explain the present invention and should not be construed as limiting the invention.
[0021] The terms "an embodiment," "example," or "trademark" used in this specification refer to a particular feature, structure, or characteristic described in connection with the embodiment itself that may be included in at least one embodiment disclosed in this invention. The phrase "in an embodiment" appearing in various places throughout the specification does not necessarily refer to the same embodiment.
[0022] During exposure statistics, the target transaction data needs to be filtered multiple times from servers storing massive amounts of transaction data. However, the large amount of out-of-order and irregularly stored transaction data makes it impossible to quickly locate the storage location and data related to the current exposure statistics request during statistics. It can only rely on global traversal to complete the filtering, which is extremely time-consuming. Even if the data is stored according to a certain fixed rule, since the storage rules generally have the problem of strong binding between the filtering conditions and the storage index, if a secondary filtering condition is added, the storage index must be reconstructed. When there are a large number of duplicate prefixes in the index, it will cause the index storage to occupy too much memory space, reduce query efficiency, and ultimately seriously reduce the overall speed of exposure statistics.
[0023] In view of this, and in order to solve the above problems, as a first aspect of the present invention, a method for calculating the exposure of foreign exchange transactions is provided, such as... Figure 1 As shown, the exposure statistics method includes: In step S110, multiple transaction data to be stored are acquired; In step S120, multiple sets of transaction data to be stored are aggregated according to the settlement date to obtain multiple sets of aggregated transaction data; wherein, the settlement dates of the aggregated transaction data in different sets are different, and the settlement dates of the aggregated transaction data in the same set are the same; In step S130, multiple first target data blocks are determined based on the settlement dates of multiple sets of aggregated transaction data. The first target data blocks store transaction data with the same settlement date as the aggregated transaction data. In step S140, a second target data block containing the same currency pair as the aggregated transaction data is selected from multiple first target data blocks; In step S150, the aggregated transaction data is stored in the second target data block; In step S160, in response to the exposure statistics request, the delivery date and currency pair corresponding to the exposure statistics request are determined; In step S170, exposure statistics are performed based on the determined settlement date, currency pair, and the transaction data in the data block that stores the transaction data corresponding to the determined settlement date and currency pair.
[0024] This invention aggregates massive amounts of transaction data to be stored according to their settlement dates. After aggregation, transaction data with the same settlement date are grouped together, resulting in multiple groups of aggregated transaction data. During storage, a first target data block is determined by using the settlement date to identify multiple consecutive address ranges of stored transaction data with the same settlement date. Within the first target data block, a second target data block is selected from the multiple first target data blocks based on currency pairs, and the aggregated data is stored in the corresponding second target data block. This hierarchical, ordered, and directional storage method, which aggregates and groups data before selecting storage carriers, avoids the problems of scattered, messy, and irregular storage of massive amounts of transaction data by aggregating the data from the source. The method of locating target storage data blocks by settlement date and currency pairs eliminates the need to traverse the global storage address to quickly locate the storage location and store the data, achieving efficient storage even for massive amounts of data and improving storage efficiency. According to the aforementioned data storage method, upon receiving an exposure statistics request, the delivery date and currency pair for this exposure statistics are determined by parsing the request. The determined delivery date and currency pair are then used as inputs to the sparse index and Bloom filter, respectively. This different processing method for the inputs of the sparse index and Bloom filter decouples them. The target data block is then quickly located using an aggregation-grouping hierarchical storage method. Exposure statistics are completed based on the transaction data stored in the target data block, improving the statistical speed and reducing computational resource consumption during the statistical process. The exposure statistics method provided by this invention features high transaction data storage efficiency, fast exposure statistics speed, and accurate exposure statistics results. It is particularly suitable for high-volume foreign exchange transactions, multiple currency pairs, and high real-time risk exposure statistics tasks in cross-border payment scenarios.
[0025] To address the issues of scattered, irregular storage of massive amounts of data and low storage efficiency, this invention performs aggregation operations on multiple transaction data sets to be stored before storage. Specifically, it addresses the core and essential business need for risk exposure statistics in cross-border payment scenarios. For example, consider a transaction to be stored where Company A initiates a cross-border payment transaction with Company B in Vietnam on September 1, 2025, for a transaction amount of 10,000 RMB. Both parties agree to settle directly using the CNY / VND (RMB to Vietnamese Dong) currency pair. The cost exchange rate on the transaction date is 3728.50, and settlement is completed on September 3, 2025. The market exchange rates from the transaction date to the settlement date are 3727.50, 3730.50, and 3732.60, respectively. For example, another transaction data to be stored includes the transaction date September 2, 2025, the currency pair CNY / VND, the settlement date September 3, 2025, the trading volume / transaction amount of 20,000 RMB, the cost exchange rate of 3728.40, and the market exchange rates (based on the market exchange rates from the transaction date to the settlement date) of 3730.50 and 3732.60 respectively. As an optional implementation of step S120, such as... Figure 2 As shown, the aggregation of multiple sets of transaction data to be stored according to the settlement date yields multiple sets of aggregated transaction data, including: In step S121, the transaction data to be stored is preprocessed to obtain processed transaction data, wherein the processed transaction data includes a settlement date field, a currency pair field, and a transaction date field arranged in sequence. In step S122, the processed data is grouped according to the delivery date field to obtain multiple groups of aggregated transaction data.
[0026] Taking the two transaction data to be stored above as examples, after aggregation in steps S121 and S122, since the settlement dates of the two transaction data are the same, they are classified into the same group of aggregated transaction data. For example, this group of aggregated data is: [Settlement Date: September 3, 2025; Currency Pair: CNY / VND, Transaction Date: September 1, 2025, Transaction Amount: 10,000 RMB, Cost Exchange Rate: 3728.50, Market Exchange Rate: 3727.50, 3730.50, 3732.60; Currency Pair: CNY / VND, Transaction Date: September 2, 2025, Transaction Amount: 20,000 RMB, Cost Exchange Rate: 3728.40, Market Exchange Rate: 3730]. [.50, 3732.60]; It should be noted here that the aggregation operation does not change the value of the transaction data, but only completes the data classification in advance before storage and exposure statistics, so that the originally scattered and disordered transaction data are formed into groups of data with certain correlations, and finally obtain multiple groups of aggregated data that correspond one-to-one with the delivery date; In addition to solving the problem of scattered and disordered data, this aggregation operation can directly match the corresponding storage dimension after aggregation. Compared with the traditional method of determining the data storage location of a single data in the global storage, aggregation simplifies the complexity of data management, reduces the time consumption of storage location, realizes efficient batch storage and retrieval of data, and further improves the exposure statistics rate.
[0027] The preprocessed transaction data obtained before aggregation consists of basic transaction attributes and quantitative transaction data. The basic transaction attributes are, in order, the settlement date field, the currency pair field, and the transaction date field; the quantitative transaction data includes data such as trading volume and exchange rate corresponding to the settlement date field, currency pair field, and transaction date field. The following describes a specific implementation of aggregation using an LMS tree structure and a two-level merge operation: First, based on the transaction's basic attributes, multiple processed transaction data with consistent basic attributes are identified through string matching (matching the strings of the transaction's basic attributes) or field hash value comparison (comparing the hash values corresponding to the fields of the transaction's basic attributes). Transactions with consistent basic attributes are grouped into one category, and the quantitative data within the same category is merged to reduce data redundancy. After the first merge, the merged data (pre-aggregated tree) is sent to a database defined by the LMS tree data structure (where, due to the large volume of transaction data, an additional central server can be used to store the database). Since the first merge operation is completed in real time, the number of pre-aggregated trees in the database increases over time, and the database capacity grows. When a preset capacity threshold is reached, the database is written to disk (disk write-in complete). A separate thread is used to merge the multiple pre-aggregated trees in the disk-written database according to their settlement dates, completing the second merge. Here, we will explain the two mergers in more detail. The first merger is a data merger, which can integrate multiple transaction data with completely identical basic transaction attributes into a single data record. The subsequent merger based on the settlement date is a data organization method. It only gathers transaction data with the same settlement date into the same hierarchical structure, and does not merge the data content. This is because the business perspective of settlement date-related data is time-sensitive. If the transaction data of the same settlement date is examined from the perspective of the current day and the next day, the relevant data with the transaction date of the next day will be added from the perspective of the next day. Therefore, it is only necessary to collect the data, not merge the data. In addition, after the second merger, the corresponding transaction data can be retrieved directly by the settlement date when completing the exposure statistics calculation, reducing the retrieval time of the corresponding transaction data in the exposure statistics.
[0028] Considering the dynamic nature of the statistical benchmark time for exposure statistics, multiple different statistical benchmark dates exist within the time interval from the transaction date to the settlement date of a cross-border foreign exchange transaction. When the transaction date is used as the statistical benchmark date, the transaction data to be statistically analyzed only includes all transaction data generated on that transaction day; when the day after the transaction date is used as the statistical benchmark date, the transaction data to be statistically analyzed includes all transaction data from that transaction day to the day after; when the settlement date is used as the statistical benchmark date, the transaction data to be statistically analyzed needs to cover all transaction data from the settlement date to the transaction date (inclusive). Therefore, the aggregation operation in data storage of this invention is actually to classify and group multiple transaction data according to the settlement date, reorganize them, and ensure that data with the same settlement date is included in the aggregated transaction data. This facilitates the storage and retrieval of all transaction data required for exposure statistics under different benchmark statistical dates, further improving the exposure statistics speed.
[0029] Specifically, two different grouping methods can be used in the aggregation process. As one implementation of step S122, such as... Figure 3 As shown, the processed transaction data is grouped according to the delivery date field to obtain multiple groups of aggregated transaction data, including: In step S122a, the delivery date field of multiple processed transaction data is extracted; In step S122b, a full string match is performed on multiple extracted delivery date fields. Multiple processed transaction data with identical strings in the delivery date field are grouped into the same group to obtain multiple aggregated transaction data. In step S122c, a hash operation is performed on the multiple extracted delivery date fields to obtain multiple delivery date hash values. Multiple processed transaction data with the same delivery date hash value are grouped together to obtain multiple groups of aggregated transaction data.
[0030] The two grouping methods mentioned above, based on matching the delivery date string and matching the delivery date field hash value, can be chosen according to actual computing resources.
[0031] In actual storage, multiple sets of aggregated data include multiple different settlement dates. The relationship between the aggregated data and the first target data block is explained below. Since the settlement date is only one element of a transaction data set, the transaction data also includes other elements such as currency pairs and trading days. Therefore, a set of aggregated transaction data obtained according to the settlement date will correspond to multiple first target data blocks. These multiple first target data blocks serve as the actual storage medium, and their address ranges are contiguous. For example, the aggregated transaction data corresponding to the settlement dates of September 3, 2025, is stored in a linked list within multiple first target data blocks starting at address PP+0 and ending at address PP+2 (the first first target data block starts at address PP+0, and the second starts at address PP+1). Similarly, the aggregated transaction data corresponding to another set of settlement dates of September 4, 2025, is also stored in a linked list within multiple first target data blocks with contiguous address ranges, where the first first target data block starts at address PP+2.
[0032] Continuing with the example of aggregated transaction data with a settlement date of September 3, 2025, the multiple first target data blocks corresponding to the settlement date constitute a storage range with relatively large granularity (large range). To narrow the data filtering range during exposure statistics and avoid cross-address reads, the storage space of this data needs to be further reduced to speed up exposure statistics. The first target data block also includes a bit array; the bit array carries the mapping relationship between the position of the currency pair hash value in the bit array; as an optional implementation of step S140, such as... Figure 4 As shown, the step of filtering out the second target data block containing the same currency pair as the aggregated transaction data from multiple first target data blocks includes: In step S141, the currency pair field of the aggregated transaction data is extracted; In step S142, multiple hash functions are used to perform hash operations on the extracted currency pair fields to obtain multiple currency pair hash values; In step S143, the positions of the obtained multiple currency pair hash values in the bit arrays of each first target data block are determined according to the mapping relationship between the obtained multiple currency pair hash values and the bit arrays of each first target data block. In step S144, the positions of the hash values of multiple currency pairs in the bit array of each first target data block are verified; In step S145, the first target data block that passes the verification is used as the second target data block containing the same currency pair as the currency pair and multiple aggregated transaction data.
[0033] The aforementioned bit array refers to an array that stores data in binary form. The mapping relationship between the positions of the currency pair hash values in the bit array is as follows: Taking a total bit array length M of 256, a hash algorithm of CRC32, and an input currency pair of CNY / VND as an example, the currency pair CNY / VND is hashed using the CRC32 hash algorithm, resulting in a currency pair hash value (decimal) of H = 2620697197. Then, a bitwise AND operation is performed on the currency pair hash value and the array length to map it to the index of the bit array position (Pos = H & (M-1) = 221), setting the 221st bit of the bit array from its initial 0 to 1. Each first target data block corresponds to a bit array, and according to the above mapping rule, this bit array contains multiple data points with a value of 1. Considering the risk of hash collisions, multiple different hash algorithms are used in actual calculations, resulting in each currency pair mapping to multiple positions in the bit array. Since the first target data block stores transaction data for multiple currency pairs, its corresponding bit array will contain a large number of data points with a value of 1. After performing the same operation on the currency pairs of the aggregated data, it is necessary to verify whether the position where the data is 1 is mapped from the same currency pair to avoid mismatches of currency pairs caused by hash collisions. The first target data block stores multiple currency pairs; the position information of the bit array carries the type information of the currency pair; as an optional implementation of step S144, such as Figure 5 As shown, the verification of the position of the hash values of multiple currency pairs in the bit array of each first target data block includes: In step S144a, if it is detected that the currency pair type information carried by the positions of multiple currency pair hash values in the bit array of the first target data block is consistent, the data content stored at the positions of the bit array is verified. In step S144b, if the data stored at the position of the bit array is preset data, the first target data block passes the verification. The preset data is 1.
[0034] Using the verified first target data block as the second target data block in the aggregated transaction data allows for the selection of a smaller (fineer-grained) second target data block from multiple first target data blocks of varying sizes. Within this smaller-grained address space, the aggregated data is stored, significantly reducing addressing and lookup times, thus achieving efficient storage of massive amounts of forex transaction data. Furthermore, the settlement date and currency pair of the second target data block are identical to those of the aggregated transaction data. This storage method is well-suited to the business logic of forex exposure statistics, improving the data query speed during subsequent exposure statistics.
[0035] It's important to note that the input parameters differ between the two specific steps: determining multiple first target data blocks and selecting second target data blocks from them. One step uses the settlement date, while the other uses a currency pair. This decoupling of input parameters offers greater flexibility (e.g., adding filtering conditions to the second step). Furthermore, without decoupling (e.g., using the same input parameters for both steps), determining the second target data block requires both the settlement date and the currency pair. This method results in unnecessary duplicate data, wasting memory space, which becomes even more pronounced in storing massive amounts of transaction data, severely impacting storage performance. Therefore, another benefit of decoupling is saving memory space and significantly improving the storage performance / efficiency of massive amounts of forex transaction data.
[0036] After storing massive amounts of transaction data into the target data block according to the method of this invention, upon receiving an exposure statistics request, the exposure statistics request is first parsed to obtain the delivery date and currency pair corresponding to the exposure statistics request. In the process of performing exposure statistics, as an optional implementation of step S170, such as... Figure 6 As shown, the step of performing exposure statistics based on the determined settlement date, currency pair, and the transaction data in the data block storing the transaction data corresponding to the determined settlement date and currency pair includes: In step S171, the determined delivery date is used as a sparse index to determine multiple first target data blocks in the target data block that stores multiple sets of aggregated transaction data; In step S172, a second target data block is filtered out from multiple first target data blocks using a Bloom filter and the determined currency pair; wherein, the Bloom filter corresponds one-to-one with the data block; the second target data block stores the transaction data corresponding to the determined currency pair; In step S173, the profit and loss value is determined based on the transaction data and profit and loss statistics stored in the second target data block.
[0037] During the exposure statistics process, a combination of sparse indexes and Bloom filters can be used to quickly find the transaction data corresponding to the statistics request. Specifically, the settlement date in the statistics request serves as the input to the sparse index, and the currency pair in the statistics request serves as the input to the Bloom filter. As an optional implementation of step S172, such as... Figure 7 As shown, the step of filtering out a second target data block from multiple first target data blocks using a Bloom filter and the determined currency pairs includes: In step S172a, a hash operation is performed on the determined currency pair to obtain the currency pair hash value; In step S172b, if the obtained currency pair hash value is included in the multiple currency pair hash values stored in the Bloom filter corresponding to the first target data block, the first target data block is used as the second target data block.
[0038] The transaction data stored in the second target data block also includes the transaction date, market exchange rate, transaction exchange rate, and transaction volume; as an optional implementation of step S173, such as Figure 8 As shown, determining the profit and loss value based on the transaction data and profit and loss statistics stored in the second target data block includes: In step S173a, the daily exchange rate difference between the market exchange rate and the transaction exchange rate corresponding to each day during the trading day and the settlement day is determined; In step S173b, the daily exchange rate difference and the corresponding trading volume are multiplied to obtain multiple daily sub-profits and losses; In step S173c, the multiple daily sub-profits and losses are summed to obtain the profit and loss value.
[0039] Specifically, the exposure statistics method of this invention can dynamically calculate the profit and loss value corresponding to each day within the time period from the transaction date to the delivery date. The following formula (1) is an exposure statistics formula: (1) In the above formula, p d To calculate the cumulative profit and loss value on the base date, j is the transaction number, k is the number of transactions to be counted, and d is the transaction day T. d By delivery date T v For any day between these dates (i.e., the statistical baseline date), I() is a conditional function; it outputs 1 if the condition is true and 0 if the condition is false; C j and R j r corresponds to the transaction volume and exchange rate of a single transaction, respectively. d The market exchange rate represents the statistical base date.
[0040] The profit and loss values are given by combining the aggregated data and Formula 1. The aggregated data is as follows: [Delivery Date: September 3, 2025; Currency Pair: CNY / VND, Transaction Date: September 1, 2025, Transaction Amount: 10,000 RMB, Cost Exchange Rate: 3728.50, Market Exchange Rate: 3727.50, 3730.50, 3732.60; Currency Pair: CNY / VND, Transaction Date: September 2, 2025, Transaction Amount: 20,000 RMB, Cost Exchange Rate: 3728.40, Market Exchange Rate: 3730.50, 3732.60].
[0041] The cumulative profit and loss value corresponding to the statistical base date of September 1, 2025 = (3727.50) 3728.50)×10000×1+0= 10000VND; The cumulative profit and loss value corresponding to the statistical base date of September 2, 2025 = (3730.50) 3728.50)×10000×1+(3730.50-3728.40)×20000×1=62000VND; The cumulative profit and loss value corresponding to the statistical base date of September 3, 2025 = (3732.60) 3728.50)×10000×1+(3732.60-3728.40)×20000×1=125000VND.
[0042] It is important to reiterate the exposure statistics method of this invention. Utilizing the storage method of this invention, all information of the transaction data (such as settlement date, currency pair, trading day, exchange rate, etc.) can be quickly retrieved during exposure statistics. Foreign exchange trading risk exposure statistics involve hundreds of currency pairs, each corresponding to a large number of fluctuating market exchange rates. This directly results in a massive scale of storage and computation of transaction data. Furthermore, the statistical dimensions of profit and loss values include indicators such as daily profit and loss, and monthly profit and loss. Given the large volume of transaction data and the numerous dimensions of exposure statistics, the transaction data storage method and exposure statistics method of this invention can quickly locate and find all transaction data corresponding to each profit and loss value to be calculated, reducing data filtering steps and thus achieving rapid, real-time statistics of risk exposure, ensuring the timeliness and accuracy of the statistical results.
[0043] In the exposure statistics method of this invention, by leveraging the aggregation, grouping, and hierarchical storage method of this invention, sparse indexes and Bloom filters can be used to quickly locate the second target data block corresponding to the exposure statistics request. All transaction data of the second target data block is loaded into memory, and the daily profit and loss value can be obtained according to Formula 1. Based on the profit and loss value, the risk exposure can be determined, and the potential losses that cross-border enterprises may face in scenarios involving massive transactions and multiple currency pairs can be assessed. Compared to the traditional process of filtering target data from massive, discretely stored transaction data, this method significantly reduces the time spent on the filtering process and still enables real-time risk exposure statistics for massive transaction data.
[0044] As a second aspect of the present invention, an electronic device is provided, such as... Figure 9 As shown, it includes: One or more processors 101; The memory 102 stores one or more computer programs that, when executed by the one or more processors 101, cause the one or more processors 101 to implement the foreign exchange transaction exposure statistics method provided according to the first aspect of the present invention.
[0045] The tool may also include one or more I / O interfaces 103 connected between the processor 101 and the memory 102, configured to enable information interaction between the processor 101 and the memory 102.
[0046] The processor 101 is a device with data processing capabilities, including but not limited to a central processing unit 101 (CPU); the first memory 102 is a device with data storage capabilities, including but not limited to random access memory 102 (RAM, more specifically SDRAM, DDR, etc.), read-only memory 102 (ROM), electrically erasable programmable read-only memory 102 (EEPROM), and flash memory (FLASH); the I / O interface 103 (read-write interface) is connected between the processor 101 and the memory 102, enabling information interaction between the processor 101 and the memory 102, including but not limited to a data bus 104 (Bus).
[0047] In some embodiments, the processor 101, memory 102, and I / O interface 103 are interconnected via bus 104, and thus connected to other components of the computing device.
[0048] Furthermore, as a third aspect of the present invention, a computer-readable medium is also provided having a computer program stored thereon, such as... Figure 10 As shown, when the computer program is executed by the processor, it implements the foreign exchange transaction exposure statistics method provided in the first aspect of the present invention.
[0049] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. Accordingly, the computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can implement the methods of any of the above embodiments. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0050] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Those skilled in the art should understand that the present invention includes, but is not limited to, the contents described in the accompanying drawings and the specific embodiments above. Any modifications that do not depart from the functional and structural principles of the present invention will be included within the scope of the claims.
Claims
1. A method for statistically analyzing exposure in foreign exchange transactions, characterized in that, The method for statistical analysis of exposure includes: Retrieve multiple transaction data entries to be stored; Multiple sets of transaction data to be stored are aggregated according to the settlement date to obtain multiple sets of aggregated transaction data; wherein, the settlement dates of the aggregated transaction data in different sets are different, and the settlement dates of the aggregated transaction data in the same set are the same; Multiple first target data blocks are determined based on the settlement date of multiple sets of aggregated transaction data. The first target data blocks store transaction data with the same settlement date as the aggregated transaction data. Select a second target data block from multiple first target data blocks that contains the same currency pair as the aggregated transaction data; The aggregated transaction data is stored in the second target data block; In response to an exposure statistics request, determine the delivery date and currency pair corresponding to the exposure statistics request; Exposure statistics are performed based on the determined settlement date, currency pair, and the transaction data in the data block that stores the transaction data corresponding to the determined settlement date and currency pair.
2. The method for statistical analysis of openness according to claim 1, characterized in that, The aggregation of multiple sets of transaction data to be stored according to the settlement date yields multiple sets of aggregated transaction data, including: The transaction data to be stored is preprocessed to obtain processed transaction data, wherein the processed transaction data includes a settlement date field, a currency pair field, and a transaction date field arranged in sequence. The processed data is grouped according to the delivery date field to obtain multiple aggregated transaction data sets.
3. The method for statistical analysis of openness according to claim 2, characterized in that, The processed transaction data is grouped according to the delivery date field to obtain multiple groups of aggregated transaction data, including: Extract the delivery date field from multiple processed transaction data; Perform full string matching on multiple extracted delivery date fields, and group multiple processed transaction data with identical delivery date field strings into the same group to obtain multiple aggregated transaction data; Multiple extracted settlement date fields are hashed to obtain multiple settlement date hash values. Multiple processed transaction data with the same settlement date hash value are grouped together to obtain multiple aggregated transaction data.
4. The method for statistical analysis of openness according to claim 1, characterized in that, The first target data block also includes a bit array; the bit array carries a mapping relationship between the positions of the currency pair hash values in the bit array; The step of selecting a second target data block from multiple first target data blocks that contains the same currency pair as the aggregated transaction data includes: Extract the currency pair field from the aggregated transaction data; Multiple hash functions are used to perform hash operations on the extracted currency pair field to obtain multiple currency pair hash values; Based on the mapping relationship between the obtained hash values of multiple currency pairs and the bit arrays of each first target data block, the positions of the obtained hash values of multiple currency pairs in the bit arrays of each first target data block are determined. Verify the position of the hash values of multiple currency pairs in the bit array of each first target data block; The first target data block that passes the verification is used as the second target data block containing the currency pair and multiple aggregated transaction data.
5. The method for statistical analysis of openness according to claim 4, characterized in that, The first target data block stores multiple currency pairs; the position information of the bit array carries information about the types of currency pairs. The verification of the positions of the hash values of multiple currency pairs in the bit arrays of each first target data block includes: If multiple currency pair hash values are found to have the same currency pair type information carried at the position of the bit array in the first target data block, the data content stored at the position of the bit array is verified. If the data stored at the position of the bit array is preset data, the first target data block passes the verification.
6. The method for statistical analysis of openness according to claim 1, characterized in that, The step of performing exposure statistics based on the determined settlement date, currency pair, and transaction data in the data block storing the transaction data corresponding to the determined settlement date and currency pair includes: Using the determined delivery date as a sparse index, multiple first target data blocks are determined in the target data block that stores multiple sets of aggregated transaction data; A second target data block is extracted from multiple first target data blocks using a Bloom filter and a determined currency pair; wherein the Bloom filter corresponds one-to-one with the data block; and the second target data block stores the transaction data corresponding to the determined currency pair. The profit and loss value is determined based on the transaction data and profit and loss statistics stored in the second target data block.
7. The method for statistical analysis of openness according to claim 6, characterized in that, The step of filtering out a second target data block from multiple first target data blocks using a Bloom filter and the identified currency pairs includes: Perform a hash operation on the determined currency pairs to obtain the currency pair hash values; If the obtained currency pair hash value is included in the multiple currency pair hash values stored in the Bloom filter corresponding to the first target data block, the first target data block is used as the second target data block.
8. The method for statistical analysis of openness according to claim 6, characterized in that, The second target data block stores transaction data including transaction date, market exchange rate, transaction exchange rate, and transaction volume; The step of determining the profit and loss value based on the transaction data and profit and loss statistics stored in the second target data block includes: Determine the daily exchange rate difference between the market exchange rate and the transaction exchange rate for each day during the trading day and settlement day; The daily exchange rate difference and the corresponding trading volume are multiplied to obtain multiple daily sub-profits and losses. The profit and loss value is obtained by summing the multiple daily sub-profits and losses.
9. An electronic device, characterized in that, include: One or more processors; A memory having stored one or more computer programs that, when executed by one or more processors, cause the one or more processors to implement the exposure statistics method according to any one of claims 1 to 8.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the exposure statistics method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Transaction recording method, transaction query method, electronic equipment and storage medium
CN112783971A
Data aggregation method and device for foreign exchange transaction
CN116563026A
Risk transaction identification method and device based on block chain
CN118134485A
Data searching method and device, computer equipment and readable storage medium
CN118503269A
Foreign exchange transaction open statistical method, electronic equipment and computer readable medium
CN120508583A