[go: up one dir, main page]

CN112532731B - Automatic optimization method and device for multiple market data sources - Google Patents

Automatic optimization method and device for multiple market data sources Download PDF

Info

Publication number
CN112532731B
CN112532731B CN202011390942.7A CN202011390942A CN112532731B CN 112532731 B CN112532731 B CN 112532731B CN 202011390942 A CN202011390942 A CN 202011390942A CN 112532731 B CN112532731 B CN 112532731B
Authority
CN
China
Prior art keywords
data source
quotation
market
switching
source link
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011390942.7A
Other languages
Chinese (zh)
Other versions
CN112532731A (en
Inventor
杨杰
周华
胡军擎
江俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Information2 Software Inc
Original Assignee
Shanghai Information2 Software Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Information2 Software Inc filed Critical Shanghai Information2 Software Inc
Priority to CN202011390942.7A priority Critical patent/CN112532731B/en
Publication of CN112532731A publication Critical patent/CN112532731A/en
Application granted granted Critical
Publication of CN112532731B publication Critical patent/CN112532731B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The invention discloses a method and a device for automatically selecting the priority of a plurality of channels of market data sources, wherein the method comprises the following steps: s1, selecting and connecting a plurality of paths of superior market quotation data sources, and initially determining a primary data source; s2, acquiring switching marks of each superior data source link, determining an optimal data source link, and updating the switching marks of the main link and the optimal link; s3, acquiring a switching time point mark for the optimal link in the state to be switched, and receiving the current and subsequent data packets to a queue to be switched; s4, when detecting that the switching mark of the main link is in a to-be-switched state, comparing the received market information packet with the data packet marked by the switching time point, and when the comparison result is consistent, transferring the data of the to-be-switched queue to a sending queue, replacing the optimal link with the main link, and updating the corresponding link switching mark; and S5, storing the quotation packets received from the switched main link into a sending queue, and sending the quotation packets to a lower node or an application system.

Description

Automatic optimization method and device for multiple market data sources
Technical Field
The invention relates to the technical field of computer data transmission and analysis, in particular to a method and a device for automatically selecting the optimal position of a plurality of market data sources.
Background
With the rapid development of information technology, the information construction requirements of various industries are gradually improved, and the requirements on the real-time performance and the performance of the data analysis and transmission field are higher and higher.
Taking the quotation data as an example, along with the quotation speeding up of each exchange, the quotation of the original file is gradually switched to a streaming quotation mode, the quotation data is not forwarded to be used, the time consumption of reading and writing the disk of the quotation is reduced, the transmission and use efficiency is greatly improved, and the quotation use of companies such as stock funds and the like and terminal users becomes more real-time and efficient.
In the prior art, for a plurality of market gateway data sources, each stock and fund company usually designates a main use, and switches to a standby use when a main source network or service is abnormal, so that the market network management data sources cannot be automatically preferred. However, with the popularization and promotion of the popularity-based data, the securities and fund companies pay more and more attention to the speed increase of quotations, and different quotation gateway data sources have different speeds due to the difference of transmission lines or hardware conditions, and the difference often has dynamic difference due to resource utilization rate or other reasons.
Therefore, in order to meet the urgent need of market speed improvement, it is necessary to provide a technical means for automatically selecting a plurality of market data sources, so that each dealer or application system provider can preferentially select the market data sources to provide the best market service for the client.
Disclosure of Invention
In order to overcome the defects in the prior art, the invention aims to provide a method and a device for automatically selecting the optimal quotation data sources, which accurately compare data issued by the multiple quotation data sources, calculate and count the optimal quotation data sources in real time, automatically switch to the optimal data sources, ensure that the data are not lost and are transparent and non-sensitive to downstream application.
In order to achieve the above object, the present invention provides an automatic optimization method for multiple market data sources, comprising the following steps:
the method comprises the following steps that S1, multiple paths of superior quotation data sources are selected and connected, quotation data of the superior quotation data sources are respectively received by multiple links, and a main quotation data source is initially determined from the quotation data sources;
s2, acquiring a switching mark corresponding to each superior market data source link, determining an optimal market data source link according to the state of the switching mark corresponding to each link and market time of market acquired from each link, and updating the switching marks of the primary market data source link and the optimal market data source link;
s3, acquiring a first data packet currently received by the optimal market data source link in a state to be switched, storing a cache as a switch time point mark, and receiving the current and subsequent data packets to a queue to be switched in sequence;
step S4, detecting a switching mark of a main quotation data source link, comparing a quotation data packet received by the main quotation data source link with the data packet marked by the switching time point in the step S3 when the switching mark is detected to be in a to-be-switched state, transferring the data of the to-be-switched queue to a sending queue when the comparison result is consistent, replacing the optimal quotation data source link with the main quotation data source link, and updating the switching mark of the corresponding link;
and S5, storing the quotation data packets received from the switched main quotation data source into a sending queue, so that the data of the sending queue is sent to a lower-level client node or an application system.
Preferably, each upper-level market data source link is provided with a respective switching flag, the states of the switching flags include a normal state, a state to be switched, and a switching state, and the switching flag corresponding to each upper-level market data source link is initially set to the normal state.
Preferably, step S2 further comprises:
step S200, after the switching marks corresponding to the superior market data source links are obtained, judging the states of the switching marks corresponding to the links, and if the states of the switching marks are not all in the common state, directly entering step S3;
step S201, if all the states of the switching marks are common states, acquiring market quotation time corresponding to each market quotation data source link, comparing the market quotation time corresponding to each market quotation data source link, and determining the market quotation data source link corresponding to the latest market quotation time as an optimal market quotation data source link;
step S202, judging whether the optimal quotation data source link is consistent with the current main quotation data source link, if so, not needing processing, otherwise, modifying the switching marks on the current main quotation data source link and the optimal quotation data source link to be switched.
Preferably, in step S201, the packet header is analyzed for the data packet received by each link, the current market quotation time is obtained, the current market quotation time is saved as a basis for preferential comparison, the current market quotation data packet received by the non-active market quotation data source link is discarded, the market quotation time corresponding to each superior market quotation data source link is compared, and the latest market quotation time is determined, so that the superior market quotation data source link corresponding to the latest market quotation time is obtained as the optimal market quotation data source link.
Preferably, in step S3, if the length of the queue to be switched currently exceeds the maximum limit, the switching flag of the optimal market data source link is set to be in a normal state, and the data of the queue to be switched is emptied, and the step S2 is returned.
Preferably, in step S4, if the data packet received by the current active market data source link is consistent with the data packet marked by the switching time point in step S3, the switching mark of the current active market data source link and the optimal market data source link in the state to be switched is modified into the switching state, and the placement of the market data packet received by the current active market data source link into the sending queue is stopped, and simultaneously the data of the queue to be switched is transferred to the sending queue, the current active market data source is set as the ordinary market data source, the data source corresponding to the optimal market data source link is set as the active market data source, the switching of the data sources is completed, and after the switching is completed, the switching mark of each data source link is set back to the ordinary state.
Preferably, if the data packet received by the current active market data source link is not consistent with the data packet marked by the switching time point in step S3, the next data packet of the current active market data source link is continuously detected, and the next data packet is compared with the data packet marked by the switching time point in step S3.
In order to achieve the above object, the present invention further provides a device for automatically selecting multiple sources of market data, comprising:
the receiving module is used for selecting and connecting a plurality of paths of quotation data sources, receiving the quotation data of each path of quotation data source by using a plurality of data links, and initially determining a main quotation data source;
the preferred comparison module is used for acquiring a switching mark corresponding to each superior market data source link, determining an optimal market data source link according to the state of the switching mark corresponding to each link and market time of market acquired from each link, and updating the switching marks of the primary market data source link and the optimal market data source link;
the optimal quotation data source link processing module is used for acquiring a first data packet currently received by the optimal quotation data source link in a to-be-switched state, storing a cache as a switching time point mark, and sequentially receiving the current and subsequent data packets to a to-be-switched queue;
the switching processing module is used for detecting a switching mark of the main quotation data source link, comparing a quotation data packet received by the main quotation data source link with a data packet marked by a switching time point of the optimal quotation data source link processing module when the switching mark is detected to be in a to-be-switched state, transferring the data of the to-be-switched queue to a sending queue when the comparison result is consistent, replacing the optimal quotation data source link with the main quotation data source link, and updating the switching mark of the corresponding link;
and the sending module is used for sending the data of the sending queue to the lower-level client node or the application system.
Preferably, the preferential comparison module is specifically configured to:
after the switching marks corresponding to the superior quotation data source links are obtained, judging the states of the switching marks corresponding to the links, and if the states of the switching marks are not all ordinary states, directly entering the optimal quotation data source link processing module;
if all the states of the switching marks are common states, acquiring market time corresponding to each market data source link, comparing the market time corresponding to each market data source link, and determining the market data source link corresponding to the latest market time as the optimal market data source link;
and judging whether the optimal quotation data source link is consistent with the current main quotation data source link or not, if so, not needing processing, and otherwise, modifying the switching marks on the current main quotation data source link and the optimal quotation data source link to be in a to-be-switched state.
Preferably, if the length of the queue to be switched currently exceeds the maximum limit, the optimal market data source link processing module sets the switching flag of the optimal market data source link to be in a normal state, empties the data of the queue to be switched, and returns the data to the preference comparing module.
Compared with the prior art, the invention has the following advantages:
1. the invention supports the simultaneous access of multiple data sources; 2. the main market line normally provides market forwarding service, the preference comparison module performs parallel detection, and the detection service dynamically runs in real time; 3. when market time comparison is carried out according to the market data packet, data statistics is accurate; 4. the invention only analyzes the header information of the market data packet, and the analyzing speed is high; 5. the switching action of the invention does not need to stop or restart the service, and is transparent and unaware to downstream application; 6. after the optimal line is switched, the data is complete without packet loss, and the continuity and reliability of the data are ensured.
Drawings
FIG. 1 is a flow chart illustrating the steps of a method for automatic multi-channel market data source selection according to the present invention;
FIG. 2 is a system architecture diagram of an apparatus for automatic multi-channel market data source optimization according to the present invention;
FIG. 3 is a schematic diagram of a system hierarchy in which embodiments of the present invention are implemented;
fig. 4 is a detailed flowchart of processing a non-active market data source link according to an embodiment of the present invention;
fig. 5 is a detailed flowchart of the processing of the active market data source link according to the embodiment of the present invention;
FIG. 6 is a flowchart illustrating the preferred comparison module according to an embodiment of the present invention.
Detailed Description
Other advantages and capabilities of the present invention will be readily apparent to those skilled in the art from the present disclosure by describing the embodiments of the present invention with specific embodiments thereof in conjunction with the accompanying drawings. The invention is capable of other and different embodiments and its several details are capable of modification in various other respects, all without departing from the spirit and scope of the present invention.
FIG. 1 is a flow chart of the steps of a method for automatic multi-channel market data source optimization according to the present invention. As shown in fig. 1, the method for automatically selecting a plurality of market data sources of the present invention comprises:
s1, selecting and connecting a plurality of paths of quotation data sources to respectively receive the quotation data of each path of superior quotation data source by using a plurality of links, and initially determining a primary quotation data source from the received quotation data. That is to say, each market data source in the invention corresponds to a market data source link, and each market data source receives the market data through the corresponding market data source link.
In the invention, a plurality of superior market data sources are selected firstly, connection is initiated to establish connection with each superior market data source, market data is received, and a connection channel is established for each superior market data source, namely a plurality of corresponding connection channels are established for a plurality of market data sources. In the embodiment of the invention, the TCP protocol is used for connecting the upper-level market data sources.
In step S1, a primary market data source needs to be initially determined from the multiple market data sources, and the corresponding connection channel is a primary market data source link, so as to initially forward data received from the primary market data source channel to a lower level. In the specific embodiment of the present invention, the first channel of quotation data source can be set as the active quotation data source by default, and the data received by the active quotation data source channel is forwarded to the next level for use by default.
And S2, acquiring a switching mark corresponding to each superior market data source link, determining an optimal market data source link according to the state of the switching mark corresponding to each superior market data source link and market time of market acquired from each superior market data source link, and updating the switching marks of the primary market data source link and the optimal market data source link.
In the invention, each upper-level market data source link is provided with a respective switching mark, and the states of the switching marks comprise a common state, a state to be switched and a switching state.
Specifically, step S2 further includes:
step S200, after the switching marks corresponding to the superior quotation data source links are obtained, judging the states of the switching marks corresponding to the superior quotation data source links, if the states of the switching marks are not all in common states, indicating that the data source link of a certain superior quotation data source is in a to-be-switched state or a switching state at the moment, namely, an optimal quotation data source channel is determined, indicating that the period is in a to-be-switched or switching stage, and directly entering step S3;
step S201, if all the states of the switching marks are common states, acquiring market time corresponding to each market data source link, comparing the market time corresponding to each acquired market data source link, and determining that the market data source link corresponding to the latest market time is the optimal market data source channel. Specifically, if the states of the switching flags are all normal states, parsing a header of a received data packet for the market data received by each superior market data source, obtaining current market time of the market data, storing the market time as a preferred comparison basis, discarding the market data packet currently received by the non-primary market data source link (since the data packet received by the primary market data source link is not discarded and needs to be stored in a sending queue to be sent to a subordinate application), comparing the market time corresponding to each superior market data source link, and determining the latest market time, thereby obtaining the superior market data source link corresponding to the latest market time as an optimal market data source channel.
Step S202, judging whether the optimal quotation data source channel is consistent with the current main quotation data source channel, if so, needing no processing, otherwise, modifying the switching mark on the main quotation data source link and the optimal quotation data source link to be in a to-be-switched state.
And S3, acquiring the currently received first data packet of the optimal market data source link in the state to be switched, storing the cache as a switching time point mark, and sequentially receiving the currently received data packet and the subsequent data packets to a queue to be switched. Preferably, if the length of the queue to be switched currently exceeds the limit, the switching flag of the optimal market data source link is set to be in a normal state, the data of the queue to be switched is emptied, and the step S2 is returned.
That is, the optimal quotation data source link is determined through step S2, the switching flag thereof is in a to-be-switched state, for the optimal quotation data source link in the to-be-switched state, the first data packet received from the quotation data source link when the optimal quotation data source link enters the state is acquired, the time point data serving as the switching flag is stored, the current data packet and the subsequent data packets are stored in the to-be-switched queue as the cache before the formal switching, if the length of the current switching queue exceeds the limit, the current switching queue is full, the switching point is not matched, the current seamless switching cannot be performed, the switching flag corresponding to the optimal quotation data source link needs to be set back to the normal state, the data in the to-be-switched queue is emptied, and the step S2 is returned to continuously re-determine the optimal quotation data source link, that is, the current switching is overtime-cancelled, and the next switching is waited.
And S4, detecting a switching mark of the main market quotation source link, comparing the market quotation data packet received by the main market quotation source link with the data packet marked by the switching time point in the step S3 when the switching mark is in a to-be-switched state, and judging whether to transfer the data of the to-be-switched queue to a sending queue and replace the main market quotation data source according to a comparison result.
Specifically, when the main quotation source link receives quotations, the switching mark is detected, if the main quotation source link is not in a to-be-switched state, namely in a common state, the switching mark is returned to the step S2, namely, the head of a quotation data packet is analyzed to obtain market time of the quotation, the market time is added into a to-be-compared cache, the received data packet is added into a sending queue, if the main quotation source link is in the to-be-switched state, whether the currently received data packet is consistent with the data packet marked by the switching time point in the step S3 is judged by comparison, if the currently received data packet is consistent with the data packet marked by the switching time point, the switching point of consistency switching is found, the switching mark of the main quotation source link and the optimal quotation data source link in the to-be-switched state is changed into the switching state, the data packet received by the current main quotation source link is stopped being placed into the sending queue, the data to-be-switched in the sending queue in the step S3 is transferred, the current quotation data source is set as the optimal data source, the data source corresponding to the marked main quotation data source link is set as the main quotation data source, the switching mark in the common state after switching is completed; and if the data packets are inconsistent, continuously detecting the next data packet, namely continuously judging whether the next data packet received by the active market source link is consistent with the data packet marked by the switching time point in the step S3.
And S5, storing the quotation data packets received from the switched main quotation data source into a sending queue, so that the data of the sending queue is sent to a lower-level client node or an application system. That is, after the data source of the optimal market data source link is set as the primary market data source, the optimal market data source link is used as the primary market data source, the market data packets received from the optimal market data source link are stored in the sending queue, and the sending module sends the data in the sending queue to the lower-level client node or the application system. After step S5 is completed, the process returns to step S2 to continue monitoring.
Fig. 2 is a system architecture diagram of an apparatus for automatic multi-channel market data source optimization according to the present invention. As shown in fig. 2, the present invention provides a device for automatically selecting multiple sources of market data, which comprises:
the receiving module 201 is configured to select and connect multiple channels of market data sources, receive market data of each channel of market data source by using multiple data links, and initially determine a primary market data source. In the invention, each market data source corresponds to a data source link, and market data of each market data source is received through the corresponding data source link.
In the invention, a plurality of superior market data sources are selected first, the receiving module 201 initiates connection to establish connection with each superior data source, receives market data, and creates a connection channel for each superior market data source, that is, a plurality of corresponding connection channels are created for a plurality of market data sources. In an embodiment of the present invention, the receiving module 201 uses a TCP protocol to connect to each upper-level market data source.
The receiving module 201 will initially determine a primary market data source from the multiple market data sources, and the corresponding connection channel is the primary market data source channel, so as to initially forward the data received from the primary market data source channel to a lower level. In the specific embodiment of the present invention, the first channel of quotation data source may be set as a primary quotation data source by default, and the data received from the primary quotation data source channel is forwarded to a lower level for use by default, that is, a data packet received from the primary quotation data source channel is added to a sending queue, and is forwarded to a lower level client or application through the sending module 205.
The preference comparing module 202 is configured to obtain a switching flag corresponding to each superior data source link, determine an optimal market data source link according to a state of the switching flag corresponding to each superior market data source link and market time of market obtained from each superior market data source link, and update the switching flags of the active market data source link and the optimal market data source link.
In the invention, each upper-level market data source link is provided with a respective switching mark, and the states of the switching marks comprise a common state, a state to be switched and a switching state.
The preference comparing module 202 is specifically configured to:
after the switching marks corresponding to the upper-level quotation data source links are obtained, the states of the switching marks corresponding to the upper-level quotation data source links are judged, if the states of the switching marks are not all in the common state, the data source link of a certain upper-level quotation data source is in a to-be-switched state or a switching state at the moment, namely, the optimal quotation data source channel is determined, and the optimal quotation data source link processing module 203 is directly entered when the data source link of the certain upper-level quotation data source is in the to-be-switched or switching stage;
and if the states of all the switching marks are common states, acquiring the market time corresponding to each market data source link, comparing the market times corresponding to the market data source links, and determining that the market data source link corresponding to the latest market time is the optimal market data source channel. Specifically, if the state of the switch flag of each superior quotation data source link is all the normal state, analyzing a header of a received data packet aiming at the quotation data received by each superior quotation data source, acquiring the current quotation market time, saving the current quotation market time as a preferred comparison basis, discarding the quotation data packet currently received by the non-primary quotation data source link, comparing the quotation market times corresponding to the superior quotation data source links, determining the latest quotation market time, and thus obtaining the superior quotation data source link corresponding to the latest quotation market time as the optimal quotation data source channel.
Judging whether the optimal quotation data source channel is consistent with the current main quotation data source channel, if so, indicating that the current main quotation data source is the optimal quotation data source, and needing no processing, otherwise, modifying the switching marks on the main quotation data source link and the optimal quotation data source link to be switched.
The optimal quotation data source link processing module 203 is configured to obtain a first currently received data packet for the optimal quotation data source link in the to-be-switched state, store a cache as a switch time point marker, and sequentially receive current and subsequent data packets to a to-be-switched queue. Preferably, if the length of the queue to be switched currently exceeds the limit, the optimal market data source link processing module 203 sets the switching flag of the optimal market data source link to be in a normal state, empties the data of the queue to be switched, and returns to the preference comparing module 202.
That is, the optimal quotation data source link is determined by the preference comparison module 202, the switching flag is in a to-be-switched state, for the optimal quotation data source link in the to-be-switched state, the first data packet received from the quotation data source link when the optimal quotation data source link enters the state is acquired, the time point data serving as the switching flag is stored, the current data packet and the subsequent data packets are stored in the to-be-switched queue to serve as a cache before formal switching, if the length of the current switching queue exceeds the limit, the current switching queue is full, the switching point is not matched, seamless switching cannot be performed currently, the switching flag corresponding to the optimal quotation data source link needs to be set back to the normal state, the data of the to-be-switched queue is emptied, and the preference comparison module 202 is returned to continue to determine the optimal quotation data source link again by preference, that is the switching is cancelled overtime at this time, and the next switching is waited.
The switching processing module 204 is configured to detect a switching flag of the active market source link, compare the market data packet received by the active market source link with the data packet marked by the switching time point stored in the optimal market data source link processing module 203 when the switching flag is in a to-be-switched state, and determine whether to transfer the data of the queue to be switched to the sending queue and replace the active market data source according to a comparison result.
Specifically, the switching processing module 204 detects a switching flag for the primary quotation source link, if the primary quotation source link is in a to-be-switched state, compares and judges whether a currently received data packet is consistent with a data packet marked by a switching time point in the optimal quotation data source link processing module 203, if the currently received data packet is consistent with the data packet marked by the switching time point in the optimal quotation data source link processing module 203, indicates that a switching point of consistent switching is found, modifies the switching flag between the primary quotation source link and the optimal quotation data source link in the to-be-switched state into a switching state, stops placing the data packet received by the current primary quotation source link into a sending queue, transfers the data packet in the to-be-switched queue of the optimal quotation data source link processing module 203 to the sending queue, sets the current primary quotation data source as a common quotation data source, sets a data source corresponding to the marked optimal quotation source link as a quotation data source, thereby completing switching of the data source, and stores the quotation data packet received by the subsequent switched quotation data source link into the sending queue, and after the switching flag of each data source link is set back to the common state; if not, the next packet continues to be detected.
A sending module 205, configured to send data of the sending queue to a lower-level client node or an application system. When the data source of the optimal market data source link is set as the primary market data source, the data source is used as the primary market data source, the market data packets received from the primary market data source are stored in the sending queue, and the sending module sends the data of the sending queue to the lower-level client node or the application system.
Examples
Fig. 3 is a schematic diagram of a hierarchical structure of a system applied in the embodiment of the present invention, in the diagram, the uppermost part is an upper-level market data source or an upper-level application, the lower part is the present invention, a plurality of upper-level market data sources are allowed, and a plurality of corresponding connection channels are provided in the present invention. And after the non-primary market data source receives the market data packet, the data packet is immediately discarded after the market time is obtained by analyzing the data packet, and only when the priority comparison module notifies switching, the data collection is started to prepare for switching.
Fig. 4 is a specific flowchart of processing a non-active market data source link according to an embodiment of the present invention. In this embodiment, a specific process of processing the non-active market data source link is as follows:
firstly, initiating connection and establishing connection with a superior market data source, and receiving market data. The plurality of market data sources create a corresponding plurality of connection channels.
Then, judging the switching mark state of the current link (in the invention, each market data source link is provided with respective switching mark), if the switching mark state of the current link is in a common state, analyzing a packet header of a received data packet to obtain the market time of the current market, saving the market time as a preferred comparison basis, and discarding the currently received data packet; if the switching mark state of the current link is a state to be switched (namely marked as an optimal data source channel), acquiring a first data packet when the current link enters the state, storing time point data serving as a switching mark, simultaneously storing the current data packet and a subsequent data packet into a queue to be switched as a cache before formal switching, if the switching queue is full at the moment, indicating that the switching point is not matched, and seamless switching cannot be performed currently, setting the switching mark back to a common state, emptying the data of the queue to be switched, simultaneously informing a preference comparison module to continue working, canceling the switching overtime, and waiting for next switching.
And if the switching mark state of the current link is the switching state, moving the data of the queue to be switched to a sending queue, setting the current data source as the main market data source, and simultaneously changing the switching mark to be in the common state. And directly adding the subsequently received data into the sending queue to complete the switching.
Fig. 5 is a specific flowchart of the processing of the active market data source link according to the embodiment of the present invention. In this embodiment, the process is as follows:
firstly, a quotation data packet is received from a main quotation data source, whether the current switching mark is in a state to be switched or not is judged, if the current switching mark is in a common state, a head of the quotation data packet is analyzed to obtain market time, the market time is added into a cache to be compared, meanwhile, the data packet is added into a sending queue, and a sending module is waited to send data to a lower-level client or an application system. Decoding protocols are generally classified into FIX (Financial Information Exchange Protocol), FAST (FIX attached For Streaming oriented Information Exchange Protocol), STEP (Security Trade Exchange Protocol), binary (Protocol in Binary format), and the like, according to the types of the source of the market gateway.
If the switching mark is in a state to be switched, judging whether the currently received market data packet is consistent with the data packet of the optimal market data source link marked as the switching time point, if not, indicating that the switching point is not found, continuously forwarding the current data packet, and waiting for the detection of the next data packet; if the consistency is detected, stopping placing the data packet received by the current main quotation source link into the sending queue, modifying the switching mark of the main quotation source link and the optimal quotation data source link in the to-be-switched state into the switching state, starting switching, setting the current main quotation data source as the ordinary data source link, simultaneously transferring the data of the to-be-switched queue of the optimal quotation data source link to the sending queue, setting the optimal quotation data source as the main quotation data source, completing switching, and after the switching is completed, setting the switching mark of each data source link back to the ordinary state.
FIG. 6 is a flowchart illustrating the preferred comparison module according to an embodiment of the present invention. In this embodiment, the process of the preferential comparison module is as follows:
firstly, acquiring a switching mark corresponding to each market data source link, and if the current switching marks are not in a common state, indicating that the time interval is in a stage to be switched or switched, wherein the current preference comparison module does not need to execute and waits for the next detection work.
If all the current switching marks are in a common state, acquiring the market time of the quotation corresponding to each quotation data source link, comparing and judging the market channel corresponding to the latest market time of the quotation to be optimal, if the optimal market channel is not consistent with the current main market channel, modifying the switching marks on the main market data source link and the optimal market data source link to be switched to be in a to-be-switched state, and if not, not needing to process.
In summary, the method and the device for automatically selecting the multiple quotation data sources of the invention obtain the market time of the quotation by analyzing the data packets after the quotation data packets are received from different quotation data sources, compare the market time of the quotation by using the preference comparison module, mark the optimal data channel and find a switching point to complete the switching when detecting that the data sources need to be switched, thereby ensuring the good continuity and integrity of the quotation data and providing the optimal quotation data for the downstream. The invention can provide more intelligent and reliable market lines for users, particularly for the operation department of securities companies, and provide reliable guarantee for speeding and optimizing the market of the users, thereby achieving the purpose of optimizing the market of the users.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Modifications and variations can be made to the above-described embodiments by those skilled in the art without departing from the spirit and scope of the present invention. Therefore, the scope of the invention should be determined from the following claims.

Claims (5)

1. A method for automatically selecting the priority of a plurality of market data sources comprises the following steps:
s1, selecting and connecting a plurality of paths of superior market data sources, respectively receiving market data of each path of superior market data source by using a plurality of links, and initially determining a primary market data source from the market data;
s2, acquiring a switching mark corresponding to each superior market data source link, determining an optimal market data source link according to the state of the switching mark corresponding to each link and market time of market acquired from each link, and updating the switching marks of the primary market data source link and the optimal market data source link; setting respective switching marks on each upper-level quotation data source link, wherein the states of the switching marks comprise a common state, a state to be switched and a switching state, and the switching marks corresponding to each upper-level quotation data source link are initially set to be the common state; step S2 further includes:
step S200, after the switching marks corresponding to the superior market data source links are obtained, judging the states of the switching marks corresponding to the links, and if the states of the switching marks are not all in the common state, directly entering step S3;
step S201, if all the states of the switching marks are common states, acquiring market quotation time corresponding to each market quotation data source link, comparing the market quotation time corresponding to each market quotation data source link, and determining the market quotation data source link corresponding to the latest market quotation time as an optimal market quotation data source link; analyzing a packet header of a data packet received by each link, acquiring current market quotation time, storing the current market quotation time as a preferred comparison basis, discarding the currently received market quotation data packet for a non-primary market data source link, comparing the market quotation time corresponding to each superior market quotation data source link, and determining the latest market quotation time, so as to acquire the superior market quotation data source link corresponding to the latest market quotation time as the optimal market data source link;
step S202, judging whether the optimal quotation data source link is consistent with the current main quotation data source link, if so, needing no processing, otherwise, modifying the switching mark on the current main quotation data source link and the optimal quotation data source link into a state to be switched;
s3, acquiring a first data packet currently received by the optimal market data source link in the state to be switched, storing a cache as a switching time point mark, and sequentially receiving the current and subsequent data packets received by the optimal market data source link to be switched to a queue to be switched;
step S4, detecting a switching mark of a main quotation data source link, comparing a quotation data packet received by the main quotation data source link with the data packet marked by the switching time point in the step S3 when the switching mark is detected to be in a to-be-switched state, transferring the data of the to-be-switched queue to a sending queue when the comparison result is consistent, replacing the optimal quotation data source link with the main quotation data source link, and updating the switching mark of the corresponding link; in step S4, if the data packet received by the current primary quotation data source link is consistent with the data packet marked by the switching time point in step S3, the switching mark of the current primary quotation source link and the optimal quotation data source link in the state to be switched is modified into the switching state, the quotation data packet received by the current primary quotation source link is stopped to be placed in a sending queue, meanwhile, the data of the queue to be switched is transferred to the sending queue, the current primary quotation data source is set as a common quotation data source, the data source corresponding to the optimal quotation data source link is set as a primary quotation data source, the switching of the data sources is completed, and after the switching is completed, the switching marks of the quotation data source links are all set back to the common state;
and S5, storing the quotation data packets received from the switched main quotation data source link into a sending queue, so as to send the data of the sending queue to a lower-level client node or an application system.
2. The method of claim 1, wherein the method comprises: in step S3, if the length of the queue to be switched currently exceeds the maximum limit, the switching flag of the optimal market data source link is set to be in a normal state, and the data of the queue to be switched is emptied, and the step S2 is returned.
3. The method of claim 2, wherein the method comprises: if the data packet received by the current active market data source link is not consistent with the data packet marked by the switching time point in the step S3, the next data packet of the current active market data source link is continuously detected, and the next data packet is compared and judged with the data packet marked by the switching time point in the step S3.
4. An apparatus for automated multi-channel market data source optimization, comprising:
the receiving module is used for selecting and connecting a plurality of paths of quotation data sources, receiving the quotation data of each path of quotation data source by using a plurality of data links, and initially determining a main quotation data source;
the preferred comparison module is used for acquiring a switching mark corresponding to each superior market data source link, determining an optimal market data source link according to the state of the switching mark corresponding to each link and market time of market acquired from each link, and updating the switching marks of the primary market data source link and the optimal market data source link; setting respective switching marks on each upper-level quotation data source link, wherein the states of the switching marks comprise a common state, a state to be switched and a switching state, and the switching marks corresponding to each upper-level quotation data source link are initially set to be the common state; after the switching marks corresponding to the superior quotation data source links are obtained, judging the states of the switching marks corresponding to the links, and if the states of the switching marks are not all ordinary states, directly entering an optimal quotation data source link processing module for processing; if all the states of the switching marks are common states, acquiring market time corresponding to each market data source link, comparing the market time corresponding to each market data source link, and determining the market data source link corresponding to the latest market time as the optimal market data source link; analyzing a packet header of a data packet received by each link, acquiring current market quotation time, storing the current market quotation time as a preferred comparison basis, discarding the currently received market quotation data packet for a non-primary market data source link, comparing the market quotation time corresponding to each superior market quotation data source link, and determining the latest market quotation time, so as to acquire the superior market quotation data source link corresponding to the latest market quotation time as the optimal market data source link; judging whether the optimal quotation data source link is consistent with the current main quotation data source link, if so, not needing processing, otherwise, modifying the switching marks on the current main quotation data source link and the optimal quotation data source link to be in a to-be-switched state;
the optimal quotation data source link processing module is used for acquiring a first data packet currently received by the optimal quotation data source link in a to-be-switched state, storing a cache as a switching time point mark, and sequentially receiving the current and subsequent data packets to a to-be-switched queue;
the switching processing module is used for detecting a switching mark of a main quotation data source link, comparing a quotation data packet received by the main quotation data source link with a data packet marked by a switching time point of the optimal quotation data source link processing module when the switching mark is detected to be in a to-be-switched state, transferring the data of a queue to be switched to a sending queue when the comparison result is consistent, replacing the optimal quotation data source link with the main quotation data source link, and updating the switching mark of the corresponding link; if the data packet received by the current main quotation data source link is consistent with the data packet marked by the switching time point in the optimal quotation data source link processing module, modifying the switching mark of the current main quotation source link and the optimal quotation data source link in the to-be-switched state into the switching state, stopping putting the quotation data packet received by the current main quotation source link into a sending queue, simultaneously transferring the data of the to-be-switched queue to the sending queue, setting the current main quotation data source as a common quotation data source, setting the data source corresponding to the optimal quotation data source link as the main quotation data source, completing the switching of the data sources, and after the switching is completed, setting the switching mark of each quotation data source link back to the common state;
and the sending module is used for sending the data of the sending queue to the lower-level client node or the application system.
5. The apparatus according to claim 4, wherein the means for automatically selecting the sources of the plurality of market data comprises: if the length of the queue to be switched currently exceeds the maximum limit, the optimal market data source link processing module sets the switching mark of the optimal market data source link to be in a common state, empties the data of the queue to be switched, and returns the data to the preference comparison module.
CN202011390942.7A 2020-12-02 2020-12-02 Automatic optimization method and device for multiple market data sources Active CN112532731B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011390942.7A CN112532731B (en) 2020-12-02 2020-12-02 Automatic optimization method and device for multiple market data sources

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011390942.7A CN112532731B (en) 2020-12-02 2020-12-02 Automatic optimization method and device for multiple market data sources

Publications (2)

Publication Number Publication Date
CN112532731A CN112532731A (en) 2021-03-19
CN112532731B true CN112532731B (en) 2023-04-07

Family

ID=74996570

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011390942.7A Active CN112532731B (en) 2020-12-02 2020-12-02 Automatic optimization method and device for multiple market data sources

Country Status (1)

Country Link
CN (1) CN112532731B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113190481B (en) * 2021-07-02 2021-10-29 深圳华云信息系统有限公司 Data transmission method and device, electronic equipment and computer readable storage medium
CN113613097B (en) * 2021-07-23 2024-08-30 四川腾盾科技有限公司 Unmanned aerial vehicle multilink telemetry data optimization method and storage medium
CN114615327B (en) * 2022-02-25 2024-07-26 上海金仕达软件科技股份有限公司 Quotation data optimization method, device, system and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104168057A (en) * 2013-05-20 2014-11-26 中兴通讯股份有限公司 Main/standby link switching method, device and system
CN108040007A (en) * 2017-12-01 2018-05-15 广州供电局有限公司 A kind of alternate routing link-quality monitoring method and system
CN108769417A (en) * 2018-06-01 2018-11-06 深圳市富途网络科技有限公司 A kind of smart machine client operational mode automatic switching method
CN109560993A (en) * 2018-12-20 2019-04-02 航天信息股份有限公司 The method of communication link abnormality detection, device, electronic equipment and network
CN111274050A (en) * 2020-01-19 2020-06-12 深圳华锐金融技术股份有限公司 Service data forwarding method and device, computer equipment and storage medium
CN111953785A (en) * 2020-08-14 2020-11-17 中国工商银行股份有限公司 Data transmission method, system and server

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3988039B2 (en) * 2002-07-24 2007-10-10 日本電気株式会社 Link switching method and link interface
CN102647460A (en) * 2012-03-30 2012-08-22 华为技术有限公司 A kind of service data downloading method and mobile terminal
CN110190974A (en) * 2019-05-31 2019-08-30 深圳市思迪信息技术股份有限公司 Present quotation data distributing method and device
CN111260227B (en) * 2020-01-19 2024-03-26 深圳华锐分布式技术股份有限公司 Service data source processing method, device, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104168057A (en) * 2013-05-20 2014-11-26 中兴通讯股份有限公司 Main/standby link switching method, device and system
CN108040007A (en) * 2017-12-01 2018-05-15 广州供电局有限公司 A kind of alternate routing link-quality monitoring method and system
CN108769417A (en) * 2018-06-01 2018-11-06 深圳市富途网络科技有限公司 A kind of smart machine client operational mode automatic switching method
CN109560993A (en) * 2018-12-20 2019-04-02 航天信息股份有限公司 The method of communication link abnormality detection, device, electronic equipment and network
CN111274050A (en) * 2020-01-19 2020-06-12 深圳华锐金融技术股份有限公司 Service data forwarding method and device, computer equipment and storage medium
CN111953785A (en) * 2020-08-14 2020-11-17 中国工商银行股份有限公司 Data transmission method, system and server

Also Published As

Publication number Publication date
CN112532731A (en) 2021-03-19

Similar Documents

Publication Publication Date Title
CN112532731B (en) Automatic optimization method and device for multiple market data sources
US20220407791A1 (en) Network performance detection method and apparatus, and network device
US8897308B2 (en) Node, a monitoring management method used for a node, and a transfer system, an input circuit and an output circuit
CN111800354B (en) Message processing method and device, message processing equipment and storage medium
CN112422438A (en) A method and device for processing multicast messages
US7020717B1 (en) System and method for resynchronizing interprocess communications connection between consumer and publisher applications by using a shared state memory among message topic server and message routers
CN111726293A (en) A message transmission method and device
CN114938334B (en) Network management method, device, equipment and computer readable storage medium
US20240022507A1 (en) Information flow recognition method, network chip, and network device
CN112787886B (en) Processing method, device driver, readable storage medium and computer for real-time system network device auto-negotiation
CN118885189A (en) Grayscale release method, device, computer equipment and storage medium
CN115348153B (en) Control method, device, equipment and storage medium of forwarding equipment
CN114629825A (en) Path detection method, device and node of computing power sensing network
CN114095383B (en) Network flow sampling method and system and electronic equipment
WO2023231723A1 (en) Streaming media data processing method and system
CN116390272A (en) Method, device and electronic equipment for realizing UPF control by using 5G core network PFCP-GW
CN116545932A (en) Network card message transmission method, device, computer equipment and storage medium
JP5287373B2 (en) Communication device and communication processing method
CN111884835B (en) Method and device for managing messages in civil aviation system
CN110798242B (en) Circuit, multichannel device and multichannel short message sending method
CN111654434B (en) Flow switching method and device and forwarding equipment
JP4669442B2 (en) Packet processing system, packet processing method, and program
CN114040007B (en) Method and device for data transmission between multiple nodes
CN117880227B (en) Chip routing system, method and related device
CN119892770B (en) Message transmission method, device, electronic equipment, medium and product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant