Disclosure of Invention
Based on the problems, the invention provides a transaction consignment account book and span map display system and a method; the interaction smoothness can be improved, the resources of the server side are saved, and the system efficiency is improved.
In a first aspect, the present application shows a transaction proxy ledger and span map display system, the system comprising:
the system comprises a feedback module, a rendering module, an analysis module and an aggregation service;
the feedback module includes: the system comprises a span diagram component, a transaction commission account book component, a feedback module DOM structure and a UI display component; the span diagram component and the transaction commission account book component are used for carrying out data interaction with a user; the DOM structure is used for receiving DOM update; the UI display component is used for displaying view data; the feedback module executes a task queue by adopting a javascript asynchronous flow; the feedback module is used for drawing and calculating the overall layout of the page;
the rendering module includes: a reaction frame; the reaction framework is used for receiving a layout loading request of the feedback module and updating the DOM to the feedback module; receiving unidirectional data streams synchronized by the analysis module; the rendering module is used for drawing a transaction commission account book and a span diagram;
the parsing module includes: a Redux state machine and a Redux/Redux-saga framework; the framework is accessed with Web workbench asynchronous calculation; the reduce state machine is used for receiving the view visible region parameters and the data parameters transmitted by the feedback module; subscribing full 2 data to the aggregation service, receiving push data of the aggregation service in real time, throttling and caching the data pushed by the aggregation service by the Redux/Redux-saga framework, calculating by a Web Worker, carrying out quantity and accumulation quantity aggregation calculation according to the transaction commission account book aggregation precision selected by a user, and updating a calculation result to a Redux state machine;
the aggregation service includes: socket.io server; the socket.io server is used for communicating with the analysis module; full/delta calibration and price screening of full Level2 data was performed.
In a second aspect, the present application shows a transaction proxy account book and span map display method, for a browser-side to exchange-side overall process, the method including:
s101: a user enters a terminal of a transaction target from a browser end and requests to view transaction commission account book and span map data; the transaction target terminal comprises: the system comprises a feedback module, a rendering module, an analysis module and an aggregation service;
s102: the feedback module receives a customer viewing request, acquires target information, merging precision and view information, transmits the target information, merging precision and view information into the analysis module for processing, and simultaneously transmits the customer viewing request to the analysis module;
s103: the analysis module receives a user viewing request and subscribes full Level2 business plate data to the aggregation service; the transaction commission account book and span map data are constructed based on full Level2 business board data;
s104: the aggregation service subscribes full Level2 business plate data to an application programming interface of the exchange end;
s105: the exchange terminal receives the subscription information of the aggregation service, pushes the full Level2 business plate data to the aggregation service in real time through an application programming interface of the exchange terminal, performs calibration/aggregation processing in the aggregation service, and puts the data into a memory;
s106: when calibration/aggregation processing is carried out in the aggregation service, after the internal memory is put into the aggregation service, the aggregation service pushes real-time full-quantity Level2 business disc data to an analysis module; the analysis module receives the full Level2 business board data and processes the data to obtain transaction commission account book and span map data; the processing process comprises the following steps: calling Web workbench asynchronous calculation precision merging and span accumulating according to full Level2 business plate data;
s107: after processing, the analysis module updates a single data stream to the rendering module through the reduce frame;
s108: the rendering module synchronously updates the visible transaction commission account book and span map data to the feedback module;
s109: and the feedback module displays the real-time transaction commission account book and span map data to the user through the UI component interface.
In a third aspect, the present application shows a transaction proxy account book and span map display method, which is used for a browser, and is characterized in that the method includes:
s201: the user enters a transaction target terminal from a browser end to check transaction commission account book and span map data, and the transaction target terminal comprises: the system comprises a feedback module, a rendering module, an analyzing module and an aggregation module;
s202: the feedback module receives a client viewing request and sends a layout loading request to the rendering module;
s203: the rendering module updates the DOM to the feedback module,
s204: after updating, the feedback module acquires the view visible region parameter and the data parameter, and synchronizes the view visible region parameter and the data parameter to the analysis module, wherein the analysis module comprises: the system comprises a Redux state machine and a Redux-saga framework, wherein Web workbench asynchronous calculation is connected into the framework;
s205: the Redux state machine of the analysis module synchronizes view visible region parameters and data parameters; the analysis module subscribes full Level2 data to the aggregation service and receives push data of the aggregation service in real time;
s206: when the analysis module receives push data of the aggregation service in real time, the analysis module throttles and caches the data pushed by the aggregation service, and calculates the data through a Web Worker, and the Web Worker calculates the aggregation of the quantity and the accumulation according to the aggregation precision of the transaction commission account book selected by the user; updating the calculation result to a Redux state machine of the analysis module;
s207: after updating to the reduce state machine, the analysis module updates transaction commission account book data and span map data by a unidirectional data flow rendering module;
s208: after the rendering module is updated, the rendering module updates the DOM to the feedback module;
s209: after updating to the feedback module, the feedback module interacts with a user; and displaying the real-time transaction commission account and span map data to the user through the UI component interface.
The beneficial effects of this application are:
splitting the full span diagram of the exchange and the Level2 data calculation, saving the page resources of the browser, and providing real-time quotation data for users with higher interaction smoothness; the aggregation service efficiently schedules and processes the matching engine application program interface data and the user subscription data tasks as required, so that the resources of a server are saved; the feedback module monitors the state of the user behavior, adjusts system parameters in real time, and enables system resources to only serve the part of data concerned by the user, so that the system efficiency is improved; the transaction commission account book and the span map are packaged, so that multi-project multiplexing can be realized, and development cost is saved; the virtual list and the price window mechanism enable the interactive effect displayed to the user to be all data lists, and the actual user browser only processes the part needing to be browsed and performs data calculation according to the need. Optimizing an area map random edge sampling algorithm, eliminating redundant data points and accelerating drawing of a span map; and the calculation of the Web workbench parallel to the main flow is utilized, the front-end calculation capability is expanded, and the page performance overhead is greatly saved as a whole.
Detailed Description
For the convenience of understanding of those skilled in the art, the technical terms related to the technical solution shown in the present application will be explained first.
DOM (Document Object Model ), is a standard programming interface that handles extensible markup language. The method is an application program interface which is irrelevant to a platform and a language, can dynamically access programs and scripts, update the content and the structure of the programs and the scripts, can further process documents, and can add the processed results to a current page.
A UI component (User Interface Module, user interface component) for user interface interactions.
javascript is a lightweight, interpreted or just-in-time programming language with functional prioritization.
The act framework is a Web development framework and is mainly used for constructing a UI, and various parameters such as declaration codes can be transmitted in the act framework to help render the UI; static HTML DOM elements; dynamic variables, and even interactable application components, may also be passed.
Redux is an application data flow framework for application state management.
Web workbench is a multi-threaded solution that can run some computationally intensive code without freezing the user interface.
Referring to FIG. 1, FIG. 1 illustrates a transaction proxy ledger and span map display system, the system comprising:
the system comprises a feedback module, a rendering module, an analysis module and an aggregation service;
the feedback module includes: the system comprises a span diagram component, a transaction commission account book component, a feedback module DOM structure and a UI display component; the span diagram component and the transaction commission account book component are used for carrying out data interaction with a user; the DOM structure is used for receiving DOM update; the UI display component is used for displaying view data; the feedback module executes a task queue by adopting a javascript asynchronous flow; the feedback module is used for drawing and calculating the overall layout of the page;
the rendering module includes: a reaction frame; the reaction framework is used for receiving a layout loading request of the feedback module and updating the DOM to the feedback module; receiving unidirectional data streams synchronized by the analysis module; the rendering module is used for drawing a transaction commission account book and a span diagram;
the parsing module includes: a Redux state machine and a Redux/Redux-saga framework; the framework is accessed with Web workbench asynchronous calculation; the reduce state machine is used for receiving the view visible region parameters and the data parameters transmitted by the feedback module; subscribing full 2 data to the aggregation service, receiving push data of the aggregation service in real time, throttling and caching the data pushed by the aggregation service by the Redux/Redux-saga framework, calculating by a Web Worker, carrying out quantity and accumulation quantity aggregation calculation according to the transaction commission account book aggregation precision selected by a user, and updating a calculation result to a Redux state machine;
the aggregation service includes: socket.io server; the socket.io server is used for communicating with the analysis module; full/delta calibration and price screening of full Level2 data was performed.
Referring to fig. 2, fig. 2 shows a transaction proxy account book and span map display method for an overall process from a browser end to a exchange end, where the method includes:
s101: a user enters a terminal of a transaction target from a browser end and requests to view transaction commission account book and span map data; the transaction target terminal comprises: the system comprises a feedback module, a rendering module, an analysis module and an aggregation service;
s102: the feedback module receives a customer viewing request, acquires target information, merging precision and view information, transmits the target information, merging precision and view information into the analysis module for processing, and simultaneously transmits the customer viewing request to the analysis module;
s103: the analysis module receives a user viewing request and subscribes full Level2 business plate data to the aggregation service; the transaction commission account book and span map data are constructed based on full Level2 business board data;
s104: the aggregation service subscribes full Level2 business plate data to an application programming interface of the exchange end; in one possible embodiment: the method for subscribing the full Level2 business plate data by the aggregation service from the application programming interface of the exchange end comprises the following steps: the aggregation service includes: sub-services; the sub-service serves as a subscription service; the analysis module subscribes price window data parameters from the sub-service; the sub-service dynamically subscribes full 2 buying and selling disc data to an application programming interface of the exchange end according to a corresponding price window according to the subscribed parameter range; when the full-Level 2 business turn-around data is obtained, the sub-service pushes the full-Level 2 business turn-around data to the analysis module; the aggregated service further includes: a subscription task management algorithm, wherein the subscription task management algorithm adopts a modified LRU algorithm;
s105: the exchange terminal receives the subscription information of the aggregation service, pushes the full Level2 business plate data to the aggregation service in real time through an application programming interface of the exchange terminal, performs calibration/aggregation processing in the aggregation service, and puts the data into a memory;
s106: when calibration/aggregation processing is carried out in the aggregation service, after the internal memory is put into the aggregation service, the aggregation service pushes real-time full-quantity Level2 business disc data to an analysis module; the analysis module receives the full Level2 business board data and processes the data to obtain transaction commission account book and span map data; the processing process comprises the following steps: calling Web workbench asynchronous calculation precision merging and span accumulating according to full Level2 business plate data;
s107: after processing, the analysis module updates a single data stream to the rendering module through the reduce frame;
s108: the rendering module synchronously updates the visible transaction commission account book and span map data to the feedback module;
s109: and the feedback module displays the real-time transaction commission account book and span map data to the user through the UI component interface.
Referring to fig. 3, fig. 3 shows a transaction proxy account book and span map display method, which is used for a browser, and the method includes:
s201: the user enters a transaction target terminal from a browser end to check transaction commission account book and span map data, and the transaction target terminal comprises: the system comprises a feedback module, a rendering module, an analyzing module and an aggregation module;
s202: the feedback module receives a client viewing request and sends a layout loading request to the rendering module;
s203: the rendering module updates the DOM to the feedback module,
s204: after updating, the feedback module acquires the view visible region parameter and the data parameter, and synchronizes the view visible region parameter and the data parameter to the analysis module, wherein the analysis module comprises: the system comprises a Redux state machine and a Redux-saga framework, wherein Web workbench asynchronous calculation is connected into the framework;
s205: the Redux state machine of the analysis module synchronizes view visible region parameters and data parameters; the analysis module subscribes full Level2 data to the aggregation service and receives push data of the aggregation service in real time;
s206: when the analysis module receives push data of the aggregation service in real time, the analysis module throttles and caches the data pushed by the aggregation service, and calculates the data through a Web Worker, and the Web Worker calculates the aggregation of the quantity and the accumulation according to the aggregation precision of the transaction commission account book selected by the user; updating the calculation result to a Redux state machine of the analysis module;
s207: after updating to the reduce state machine, the analysis module updates transaction commission account book data and span map data by a unidirectional data flow rendering module;
s208: after the rendering module is updated, the rendering module updates the DOM to the feedback module;
s209: after updating to the feedback module, the feedback module interacts with a user; and displaying the real-time transaction commission account and span map data to the user through the UI component interface.
In a feasible embodiment, the transaction commission account book and span map display method is used for a browser end; the method further comprises the steps of:
s301: when the feedback module interacts with the user, the user scrolls to change the visible area, and at the moment, the feedback module checks whether the data filling meets the DOM layout, and if so, the current DOM layout is displayed; if not, executing batch complement;
the batch filling method comprises the following steps: the feedback module acquires the view visible region parameters and the data parameters and synchronizes the view visible region parameters and the data parameters to the analysis module; the parsing module includes: the Redux state machine, a Redux-saga framework, and a Web workbench asynchronous calculation is connected into the framework;
s302: the Redux state machine of the analysis module synchronizes view visible region parameters and data parameters; the analysis module supplements full Level2 data to the aggregation service according to the conditions and receives push data of the aggregation service in real time;
s303: the analysis module performs throttling caching on data pushed by the aggregation service, calculates through a Web workbench, performs quantity and accumulation quantity aggregation calculation according to the transaction commission account book aggregation precision selected by a user, and updates a calculation result to a reduce state machine;
in a viable embodiment, the view refresh is 60fps (frames/second), then the reasonable throttle time is 16ms (milliseconds); the throttling algorithm is as follows: the data frame received in the throttling time is replaced by the last data frame in the throttling time
The throttle caching method of the analysis module comprises the following steps:
replacing the data frame received in the 16ms throttling time with the last data in the throttling time;
asynchronous calculation is carried out on the replaced data by adopting a Web worker;
the Web worker performs aggregation calculation of quantity and accumulation according to the data aggregation precision;
and updating the result after the aggregation calculation to a Redux state machine.
S304: after updating to the reduce state machine, the analysis module updates transaction commission account book data and span map data by a unidirectional data flow rendering module;
s305: after the rendering module is updated, the rendering module updates the DOM to the feedback module;
s306: after updating to the feedback module, the feedback module interacts with a user; and displaying the real-time transaction commission account and span map data to the user through the UI component interface. Each UI layout change triggers the feedback module to recalculate.
Referring to fig. 4, fig. 4 shows a flow chart of the feedback module acquiring view visible region parameters and data parameters;
the method for acquiring the view visible region parameters and the data parameters by the feedback module comprises the following steps:
the constructor monitors DOM changes of the drawing area;
filling a target drawing area in a drawing area DOM, wherein the drawing area DOM changes, and a user view shows the change of the area;
local updating is realized according to the change of the user view display area; the local update content includes: the lowest bid interval and the highest bid interval.
The feedback module calculates the acquired visual visible region parameters and the data parameters by adopting a price window mechanism; the maximum data range that needs to be prepared; the computation is used for screening out the data set stored in the browser end from the aggregation service.
The method for realizing local updating according to the change of the user view display area comprises the following steps:
drawing a zone DOM acquisition (scrollTop, scrollHeight), wherein the scrollTop refers to the height of the content in the element beyond the upper boundary part of the element, and is used for setting the vertical offset of the scroll bar in the element; the scrollHeight refers to the complete height of the returned element, and is the total height of the element content; drawing a DOM change of a region to enable a getBundingClientRact function to acquire a showHeight (display region height), and obtaining an enlarged data set through self-increasing adjustment of n price windows; where initial n=2, where n is a multiple of the change in the viewable area with user interaction/scrolling view; meanwhile, the DOM of the drawing area changes to change the DOM of the order, and the DOM of the order sets the height of each element through rowHeight;
the feedback module calculates the change of the display area according to the acquired content to realize local update;
updating a data area distributed near the visible area according to a part of order sales trays displayed in the visible area of a browser end user; obtaining local update content. And the local updating content maintains a transaction commission account book in the browser.
In a feasible embodiment, the analysis module uses the scene to include precision aggregation and merging the scenes of the same price orders; when the analysis module is in the scene, the feedback module can not fill all the target drawing areas according to the price interval corresponding to a certain layout; when the feedback module updates the visual visible area parameters and the data parameters, triggering the internal drawing check of the feedback module;
if no unfilled region exists, updating through checking;
if the unfilled region exists, the feedback module calculates the filling range, enlarges the height parameter of the display region, and obtains an enlarged data set by self-increasing the adjustment price window of n; where initial n=2, which is a multiple of the change in the viewable area of the view with user interaction/scrolling.
In the process that the analysis module updates transaction commission account book data and span map data by the unidirectional data flow direction rendering module, a specific position updated by the analysis module to the rendering module is a reaction component of the rendering module, and the reaction component is used for calculating DOM update; synchronizing DOM update to a feedback module;
after updating transaction commission account book data and span map data by the analysis module through a unidirectional data stream to the rendering module; the method for updating the DOM to the feedback module by the rendering module comprises the following steps:
the rendering module draws a transaction commission account book and a span diagram; and the rendering module draws a transaction commission account book by adopting a virtual list algorithm and draws a span graph by adopting a DOM Canvas.
The virtual list algorithm is a dynamically rendered DOM structure which is established by the algorithm and is different from a universal standard DOM list in the control of element quantity, and the virtual list algorithm calculates a data set corresponding to a visible area of a current list relative to the full list data through the estimation of the full list data, the visible range of the current list, the user interaction state of a feedback module and the scrolling height of a user and the external height of the list; meanwhile, the DOM frames are combined, so that high-frequency data stream update is solved, and frame output is performed by using the display refresh frequency, so that a small part of views are quickly rendered, and a good fps index is achieved.
The principle of the virtual list algorithm is as follows:
the lower tables are estimated by constructing the Filtermask mask region, so that N lower tables are managed by one Filtermask,
applying the principle of the virtual list algorithm to the scene shown in the application;
the method for drawing the transaction commission account book comprises the following steps:
the rendering module draws two order forms of the buying disc and the selling disc simultaneously, and only obtains display items and cache items;
meanwhile, the hidden area data is only calculated to be high and reset to the height of the list, so that the height of the scroll bar is expanded, and the position of the scroll bar is positioned; the actual display effect is consistent with all data rendering;
the method for drawing the span graph comprises the following steps:
the rendering module draws a transaction commission account book and a span diagram;
the method for drawing the transaction commission account book comprises the following steps:
the rendering module draws two order forms of the buying disc and the selling disc simultaneously, and only obtains display items and cache items; meanwhile, the hidden area data is only calculated to be high and reset to the height of the list, so that the height of the scroll bar is expanded, and the position of the scroll bar is positioned; its actual display effect is consistent with the full data rendering.
The span graph drawing optimization algorithm principle is as follows:
the span graph is a two-dimensional area graph with the price as an X axis and the quantity as a Y axis; when the data volume is too dense, a large number of data points are corresponding to each pixel point in the two-dimensional area map, and the large number of data points have no meaning for users, so that the data points are combined; the merging adopts a simplified edge sampling algorithm to merge and extract data points, so that the number of drawn data points is reduced, and Canvas drawing efficiency is improved.
Since the span map is an area map, it is necessary to process a data point matrix of [ [ x1, y1], [ x2, y2], … ] ], which is a two-dimensional array.
The method for drawing the span graph comprises the following steps:
drawing the regional pixel length N according to the data point array length M and the area diagram X axis; if M is greater than N, randomly taking 3N data and forming an array K by scrambling the data; if M < = N; the subsequent steps are omitted;
adding the starting point [ x1,0] and the ending point [ xn,0] of the area diagram into K;
traversing each data element of K, calculating the distance Dis between the point and all other points, and recording the distance and index0, index1 of the two points to a new array R, wherein the elements of the new array R are Dis, index0, index 1;
the new array R is ordered in positive sequence according to Dis, if the two indexes have undeleted points, the undeleted points are recorded into a deleted array RM; the above procedure is looped until len (RM) =2n is found, and deletion can be ended;
traversing K, deleting points of index in RM, and sorting according to price to obtain simplified area map data.
Referring to fig. 5, fig. 5 is an aggregated service workflow diagram;
in a feasible embodiment, the aggregation service is deployed separately; the method for subscribing the full Level2 business plate data by the aggregation service from the application programming interface of the exchange end comprises the following steps:
the aggregation service includes: sub-services; the sub-service serves as a subscription service; the analysis module subscribes price window data parameters from the sub-service; the sub-service dynamically subscribes full 2 buying and selling disc data to an application programming interface of the exchange end according to a corresponding price window according to the subscribed parameter range;
when the full-Level 2 business turn-around data is obtained, the sub-service pushes the full-Level 2 business turn-around data to the analysis module.
Referring to fig. 6, fig. 6 is a schematic diagram of an aggregated service subscription task management algorithm.
The aggregated service further includes: and subscribing the task management algorithm, wherein the subscribing task management algorithm adopts a modified LRU algorithm.
The LRU algorithm is used for task management, and real-time on-demand scheduling on-demand calculation is realized.
The present application has been described in detail in connection with specific embodiments and exemplary examples, but such description is not to be construed as limiting the present application. Those skilled in the art will appreciate that various equivalent substitutions, modifications and improvements may be made to the technical solution of the present application and its embodiments without departing from the spirit and scope of the present application, which falls within the scope of the present application, and the scope of the present application is to be determined by the appended claims.