A method and system for repairing K-line in real time

By storing third-party K-line data in real time and providing a K-line repair interface, Mongodb and Beego libraries are used to realize real-time repair of K-lines, solving the problem of K-line calculation errors or missing problems caused by abnormal real-time market conditions, and realizing rapid batch K-line repairs. , restored the normality of market transactions.

CN114329242BActive Publication Date: 2025-01-17FEIMA FINANCIAL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111555114.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-17
Publication Date
2025-01-17
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

In the stock market, real-time market abnormalities lead to errors or missing K-line calculations, affecting market trading, and the K-line cannot be repaired by itself, making it difficult to repair manually.

Method used

By storing third-party K-line data in real time and providing a K-line repair interface, Mongodb and Beego libraries are used to realize real-time repair of K-lines, and repair services are provided through Kafka message middleware and HTTP services.

Benefits of technology

It realizes fast batch real-time repair of the K-line of the entire market code, restoring the K-line to normal, avoiding the difficulty of manual repair and the impact of market transactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114329242B_ABST
    Figure CN114329242B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for real-time repair of K-line, and relates to the technical field of market data processing. The method comprises the following steps: S1, real-time storage of third-party K-line data, and provision of a K-line repair interface; S2, calling the K-line repair interface, and sending a GET request, where the GET request is an HTTP request method; S3, a K-line repair service system starts and completes the repair of the K-line, thereby realizing rapid batch real-time repair of the K-line of the entire market code, and restoring the K-line to normal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of market data processing, and in particular to a method and system for repairing a K-line in real time. Background Art

[0002] In the stock market, K-line is a graph that shows the price trend of the stock market and futures market. K-line is generally calculated from real-time market data. If the real-time market data is normal, the calculated K-line is also normal. However, in some cases, when the real-time market is abnormal, such as the data provider sends wrong data, the data provider service is abnormal, the local market decoding is abnormal, etc., it will cause K-line calculation errors or K-line missing; and the K-lines of thousands of codes in the entire stock market are abnormal, which seriously affects market transactions. K-line cannot repair itself, and manual repair is difficult. At this time, third-party K-line data must be used to complete K-line data repair. Summary of the invention

[0003] In order to overcome the deficiencies of the prior art, the present invention provides a method and system for repairing K-lines in real time to solve the above-mentioned technical problems.

[0004] The technical method adopted by the present invention to solve its technical problem is: a method for repairing K-line in real time, and its improvement lies in: comprising the following steps: S1, real-time storage of third-party K-line data, and providing a K-line repair interface; S2, calling the K-line repair interface, sending a GET request, and the GET request is an HTTP request method; S3, the K-line repair service system starts and completes the repair of the K-line.

[0005] In the above method, step S1 comprises the following steps:

[0006] S11. Through the synchronization program, the third-party K-line data is synchronized in real time to Mongodb in a specific data format. Mongodb is an open source non-relational database.

[0007] S12. The fundamental data service system calls the Beego library to start the HTTP service and provide query services for all stock codes in the market. Beego is an open source HTTP framework based on Golang.

[0008] S13. The K-line reading and writing service system calls the Kafka client library, connects to Kafka, consumes the market data in Kafka, produces K-lines, and calls the Beego library to start the HTTP service to provide K-line query and modification services. Kafka is a high-throughput distributed publish-subscribe messaging system.

[0009] S14. The K-line repair service system calls the Beego library, starts the HTTP service, and provides the K-line repair interface.

[0010] In the above method, in step 13, the market data in Kafka is obtained through the following steps:

[0011] The market decoding service system receives the original market data from the exchange in real time through the network;

[0012] Decode the original market data into a custom market data format;

[0013] Convert the customized market data format into Pb data format and send it to Kafka.

[0014] In the above method, in step S2, the parameters of the GET request include market type, start date and end date.

[0015] In the above method, step S3 comprises the following steps:

[0016] S31. After receiving the GET request, the K-line repair service system parses out parameters, which include market type, start date and end date;

[0017] S32, the K-line repair service system calls the Mongodb client library, connects to Mongodb, and queries the third-party real-time K-line data;

[0018] S33, the K-line repair service system calls the HTTP interface of the fundamental data service system to query all stock codes in the market;

[0019] S34, the K-line repair service system sequentially traverses all the stock codes, queries the third-party real-time K-line data, and the K-line reading and writing service system writes the third-party real-time K-line data to the K-line file;

[0020] S35. Repair is completed, and the K-line repair service system returns the HTTP result.

[0021] In the above method, step S34 comprises the following steps:

[0022] S341. The K-line repair service system traverses all the stock codes, uses the stock code, start date and end date as query conditions, and queries the third-party real-time K-line data from Mongodb;

[0023] S342, the K-line repair service system calls the K-line modification interface of the K-line reading and writing service system, and sends the third-party real-time K-line data to the K-line reading and writing service system through the K-line modification interface in a POST request;

[0024] S343. After receiving the POST request data, the K-line reading and writing service system writes each real-time K-line data into the K-line file according to the stock code, start date and end date in the POST request data.

[0025] The present invention also provides a system for real-time repair of K-line, including a fundamental data service system, a K-line reading and writing service system and a K-line repair service system.

[0026] The fundamental data service system is used to call the Beego library, start the HTTP service, and provide query services for all stock codes in the market;

[0027] The K-line repair service system is used to call the Beego library, start the HTTP service, and provide the K-line repair interface; after receiving the GET request for repairing the K-line, parse out the parameters, which include the market type, start date, and end date; call the Mongodb client library, connect to Mongodb, and query the third-party real-time K-line data; call the HTTP interface of the fundamental data service system to query all stock codes in the market; traverse all the stock codes, use the stock code, start date, and end date as query conditions, and query the third-party real-time K-line data from Mongodb; call the K-line modification interface of the K-line read-write service system, and send the third-party real-time K-line data to the K-line read-write service system through the K-line modification interface in a POST request; and return the HTTP result after the K-line repair is completed;

[0028] The K-line reading and writing service system is used to call the Kafka client library, connect to Kafka, consume the market data in Kafka, produce K-lines, and call the Beego library at the same time, start the HTTP service, and provide K-line query and modification services; after receiving the POST request data, each real-time K-line data is written to the K-line file according to the stock code, start date and end date in the POST request data.

[0029] The above system also includes a market decoding service system, which is used to receive the original market data of the exchange in real time through the network, decode the original market data into a custom market data format, and convert the custom market data format into a Pb data format and send it to Kafka.

[0030] The beneficial effects of the present invention are: third-party K-lines are stored in real time through Mongodb, and a K-line repair interface is provided through HTTP service, so that the K-lines of the entire market code can be repaired in real time in batches quickly, so that the K-lines return to normal. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Attached Figure 1 The present invention is a flowchart of a method for repairing K-line in real time. DETAILED DESCRIPTION

[0032] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0033] The following will clearly and completely describe the concept, specific structure and technical effects of the present invention in combination with the embodiments and drawings, so as to fully understand the purpose, characteristics and effects of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, other embodiments obtained by technicians in this field without creative work are all within the scope of protection of the present invention. In addition, all the connection / connection relationships involved in the patent do not refer to the direct connection of components, but refer to the formation of a better connection structure by adding or reducing connection accessories according to the specific implementation situation. The various technical features in the invention can be combined interchangeably without conflicting with each other.

[0034] Reference Figure 1 As shown, a method for real-time repairing of K-line of the present invention comprises the following steps:

[0035] S1. Real-time storage of third-party K-line data and provision of K-line repair interface;

[0036] Specifically, the steps include:

[0037] S11. Using a synchronization program written in Python, the third-party K-line data is synchronized to Mongodb in real time in a specific data format. Mongodb is an open source non-relational database. In the present invention, it is used to store the third-party K-line data in real time and provide a K-line data source for the K-line repair service system.

[0038] S12. The fundamental data service system calls the Beego library to start the HTTP service and provide query services for all stock codes in the market. Beego is an open source HTTP framework based on Golang.

[0039] S13, the K-line reading and writing service system calls the Kafka client library, connects to Kafka, consumes the market data in Kafka, and produces K-lines. At the same time, another coroutine of the K-line reading and writing service system calls the Beego library, starts the HTTP service, and provides K-line query and modification services. Kafka is a high-throughput distributed publish-subscribe messaging system. In the present invention, it is used as a messaging middleware to store real-time market information.

[0040] The market data in Kafka is obtained in the following way: the market decoding service system receives the original market data from the exchange in real time through the network, then decodes the original market data into a custom market data format, and finally converts it into Pb data format and sends it to Kafka. Pb is protobuf, a Google open source mechanism for realizing automatic data serialization and deserialization;

[0041] S14. The K-line repair service system calls the Beego library, starts the HTTP service, and provides the K-line repair interface.

[0042] S2. The administrator calls the K-line repair interface provided by the K-line repair service system and sends a GET request. The parameters of the GET request include market type, start date and end date. The start date and end date are used to determine the time interval of the K-line to be repaired. The GET request is an HTTP request method.

[0043] S3, the K-line repair service system starts and completes the K-line repair;

[0044] Specifically, the following steps are included:

[0045] S31. After receiving the GET request, the K-line repair service system parses out parameters, which include market type, start date and end date;

[0046] S32, the K-line repair service system calls the Mongodb client library, connects to Mongodb, and queries the third-party real-time K-line data;

[0047] S33, the K-line repair service system calls the HTTP interface of the fundamental data service system to query all stock codes in the market;

[0048] S34, the K-line repair service system sequentially traverses all stock codes described in step S33, queries third-party real-time K-line data, and the K-line reading and writing service system writes the third-party real-time K-line data to the K-line file;

[0049] Specifically, the step S34 includes the following steps:

[0050] S341. The K-line repair service system traverses all the stock codes, uses the stock code, start date and end date as query conditions, and queries the third-party real-time K-line data from Mongodb;

[0051] S342, the K-line repair service system calls the K-line modification interface of the K-line reading and writing service system, and sends the third-party real-time K-line data to the K-line reading and writing service system through the K-line modification interface in a POST request. The POST request is an HTTP request method.

[0052] S343, after receiving the POST request data, the K-line reading and writing service system writes each real-time K-line data into the K-line file according to the stock code, start date and end date in the POST request data;

[0053] S35. The repair is completed, and the K-line repair service system returns the HTTP result, realizing the rapid batch real-time repair of the K-line of the entire market code, so that the K-line returns to normal.

[0054] The present invention also provides a system for real-time repair of K-line, including a fundamental data service system, a K-line reading and writing service system and a K-line repair service system.

[0055] The fundamental data service system is used to call the Beego library, start the HTTP service, and provide query services for all stock codes in the market;

[0056] The K-line repair service system is used to call the Beego library, start the HTTP service, and provide the K-line repair interface; after receiving the GET request for repairing the K-line, parse out the parameters, which include the market type, start date, and end date; call the Mongodb client library, connect to Mongodb, and query the third-party real-time K-line data; call the HTTP interface of the fundamental data service system to query all stock codes in the market; traverse all the stock codes, use the stock code, start date, and end date as query conditions, and query the third-party real-time K-line data from Mongodb; call the K-line modification interface of the K-line read-write service system, and send the third-party real-time K-line data to the K-line read-write service system through the K-line modification interface in a POST request; and return the HTTP result after the K-line repair is completed;

[0057] The K-line reading and writing service system is used to call the Kafka client library, connect to Kafka, consume the market data in Kafka, produce K-lines, and call the Beego library to start the HTTP service to provide K-line query and modification services; after receiving the POST request data, each real-time K-line data is written to the K-line file according to the stock code, start date and end date in the POST request data. At this point, the K-line repair is completed, and the K-line repair service system returns the HTTP result, realizing the fast batch real-time repair of the K-line of the entire market code, so that the K-line returns to normal.

[0058] Furthermore, a real-time K-line repair system of the present invention also includes a market decoding service system, which is used to receive original market data from the exchange in real time through the network, decode the original market data into a custom market data format, and convert the custom market data format into a Pb data format, and send it to Kafka.

[0059] The present invention stores third-party K-lines in real time through Mongodb and provides a K-line repair interface through HTTP service, thereby realizing fast batch real-time repair of K-lines of the entire market code and restoring the K-lines to normal.

[0060] The above is a specific description of the preferred implementation of the present invention, but the invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A method for real-time repair of K-line, characterized by: The steps include: S1. Real-time storage of third-party K-line data and provision of K-line repair interface; The step S1 comprises the following steps: S11. Through the synchronization program, the third-party K-line data is synchronized in real time to Mongodb in a specific data format. Mongodb is an open source non-relational database. S12. The fundamental data service system calls the Beego library to start the HTTP service and provide query services for all stock codes in the market. Beego is an open source HTTP framework based on Golang. S13. The K-line reading and writing service system calls the Kafka client library, connects to Kafka, consumes the market data in Kafka, produces K-lines, and calls the Beego library to start the HTTP service to provide K-line query and modification services. Kafka is a high-throughput distributed publish-subscribe messaging system. S14. The K-line repair service system calls the Beego library, starts the HTTP service, and provides the K-line repair interface; In step 13, the market data in Kafka is obtained through the following steps: The market decoding service system receives the original market data from the exchange in real time through the network; Decode the original market data into a custom market data format; Convert the customized market data format into Pb data format and send it to Kafka; S2. Call the K-line repair interface and send a GET request. The GET request is an HTTP request method. In step S2, the parameters of the GET request include market type, start date and end date; S3, the K-line repair service system starts and completes the K-line repair; The step S3 comprises the following steps: S31. After receiving the GET request, the K-line repair service system parses out parameters, which include market type, start date and end date; S32, the K-line repair service system calls the Mongodb client library, connects to Mongodb, and queries the third-party real-time K-line data; S33, the K-line repair service system calls the HTTP interface of the fundamental data service system to query all stock codes in the market; S34, the K-line repair service system sequentially traverses all the stock codes, queries the third-party real-time K-line data, and the K-line reading and writing service system writes the third-party real-time K-line data to the K-line file; S35. Repair is completed, and the K-line repair service system returns the HTTP result.

2. A method for real-time repair of K-line according to claim 1, characterized in that: The step S34 comprises the following steps: S341. The K-line repair service system traverses all the stock codes, uses the stock code, start date and end date as query conditions, and queries the third-party real-time K-line data from Mongodb; S342, the K-line repair service system calls the K-line modification interface of the K-line reading and writing service system, and sends the third-party real-time K-line data to the K-line reading and writing service system through the K-line modification interface in a POST request; S343. After receiving the POST request data, the K-line reading and writing service system writes each real-time K-line data into the K-line file according to the stock code, start date and end date in the POST request data.

3. A system for real-time repair of K-line, characterized by: Including fundamental data service system, K-line reading and writing service system and K-line repair service system, The fundamental data service system is used to call the Beego library, start the HTTP service, and provide query services for all stock codes in the market; The K-line repair service system is used to call the Beego library, start the HTTP service, and provide the K-line repair interface; After receiving the GET request for repairing the K-line, parse out the parameters, which include the market type, start date and end date; call the Mongodb client library, connect to Mongodb, and query the third-party real-time K-line data; call the HTTP interface of the fundamental data service system to query all stock codes in the market; traverse all the stock codes, use the stock code, start date and end date as query conditions, and query the third-party real-time K-line data from Mongodb; call the K-line modification interface of the K-line reading and writing service system, and send the third-party real-time K-line data to the K-line reading and writing service system through the K-line modification interface in a POST request; and return the HTTP result after the K-line repair is completed; The K-line reading and writing service system is used to call the Kafka client library, connect to Kafka, consume the market data in Kafka, produce K-lines, and call the Beego library to start the HTTP service to provide K-line query and modification services; after receiving the POST request data, write each real-time K-line data into the K-line file according to the stock code, start date and end date in the POST request data; It also includes a market decoding service system, which is used to receive the original market data of the exchange in real time through the network, decode the original market data into a custom market data format, and convert the custom market data format into a Pb data format and send it to Kafka.

Citation Information

Patent Citations

  • Digital asset transaction method and system and computer readable storage medium

    CN110365533A

  • Method for realizing mobile security exchange

    CN1991900A