Policy transaction method and system based on block chain, terminal equipment and product
By providing a blockchain-based strategy trading method on the blockchain, decoupling trading strategies and blockchain application details, the problem that DEFI applications need to pay attention to blockchain technology details when trading strategies is solved, and the effect of simplifying application development and reusing trading strategies is achieved.
Patent Information
- Application Number
- CN202411865250.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-05-06
AI Technical Summary
Due to the large differences in blockchain technology architecture, DEFI applications need to pay attention to many blockchain technical details when trading strategies, and application development is more cumbersome.
Provide a blockchain-based strategy trading method, which determines the data to be traded by receiving the current transaction data and specified strategy information of the target blockchain, and generates a target transaction request, sends it to the target blockchain for transactions, decoupling the transaction strategy and blockchain application details.
It realizes the decoupling between transaction strategies and blockchain application details, simplifies application development, and reuses existing transaction strategies without adjusting the technical details of blockchain.
Smart Images

Figure CN119941403A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of blockchain technology, and in particular relates to a blockchain-based strategic trading method, system, terminal device and product. Background Art
[0002] There are various decentralized finance (DEFI) applications on the current blockchain. Due to the large differences in the technical architecture of each blockchain, the interaction methods of DEFI applications on each blockchain are different. At the same time, the working principles of each DEFI application are also different. As a result, DEFI applications need to pay attention to many technical details of the blockchain when conducting strategic transactions, and application development is relatively cumbersome. Summary of the invention
[0003] The embodiments of the present application provide a blockchain-based strategy trading method, system, terminal device and product, which can decouple trading strategies and application details of specific blockchains and simplify application development.
[0004] In a first aspect, an embodiment of the present application provides a blockchain-based strategy trading method, comprising:
[0005] When receiving current transaction data of a current transaction action in the target blockchain, determining the pending transaction data of the target blockchain according to the current transaction data and the first specified policy information;
[0006] Generate a target transaction request for the target blockchain based on the transaction data;
[0007] The target transaction request is sent to the target blockchain, so that the target blockchain performs a transaction based on the target transaction request.
[0008] Optionally, determining the data to be traded of the target blockchain according to the current transaction data and the first specified policy information includes:
[0009] Update the current market information corresponding to the target blockchain based on the current transaction data, where the current market information at least includes the current transaction information and historical transaction information of the transaction object;
[0010] According to the current transaction information, historical transaction information and first specified policy information of the transaction object, the data to be traded of the target blockchain is determined.
[0011] Optionally, the first specified policy information includes a first policy identifier and a first policy configuration parameter, and determines the data to be traded of the target blockchain according to the current transaction information, historical transaction information and the first specified policy information of the transaction object, including:
[0012] The current transaction information, historical transaction information and the first strategy configuration parameters are input into the first transaction strategy code to obtain the data to be traded of the target blockchain, wherein the first transaction strategy code is the code of the transaction strategy corresponding to the first strategy identifier, and the data to be traded includes the number of objects to be traded and slippage data.
[0013] Optionally, a target transaction request of a target blockchain is generated based on the transaction data, including:
[0014] Generate an initial transaction request of the target blockchain based on the transaction data;
[0015] According to the initial transaction request and the second specified policy information, a target transaction request of the target blockchain is determined.
[0016] Optionally, the second specified policy information includes a second policy identifier and a second policy configuration parameter, and determining a target transaction request of a target blockchain according to the initial transaction request and the second specified policy information includes:
[0017] Input the second strategy configuration parameter into the second trading strategy code to obtain the sending parameter of the data to be traded, where the second trading strategy code is the code of the sending trading strategy corresponding to the second strategy identifier;
[0018] The initial transaction request is updated based on the sending parameters to obtain the target transaction request of the target blockchain.
[0019] Optionally, the data to be traded includes the address to be traded, and the target transaction request is sent to the target blockchain, including:
[0020] Use the address to be traded to sign the target transaction request to obtain the signed target transaction request;
[0021] Send the signed target transaction request to the target blockchain.
[0022] Optionally, after sending the target transaction request to the target blockchain, the method further includes:
[0023] Obtain the transaction receipt information returned by the target blockchain for the target transaction request;
[0024] Parse the transaction receipt information to obtain the actual transaction data corresponding to the target transaction request;
[0025] Update the current market information of the target blockchain based on actual transaction data.
[0026] In a second aspect, the embodiment of the present application provides a blockchain-based strategy trading system, including:
[0027] A transaction engine module, configured to determine the pending transaction data of the target blockchain according to the current transaction data and the first specified policy information when receiving the current transaction data of the current transaction action in the target blockchain;
[0028] A market data module, corresponding to the target blockchain, is used to generate a target transaction request for the target blockchain based on the data to be traded;
[0029] The adapter module establishes a communication connection with the target blockchain and is used to send the target transaction request to the target blockchain so that the target blockchain performs transactions based on the target transaction request.
[0030] Optionally, the market data module includes a data acquisition unit and a data management unit.
[0031] A data acquisition unit, used to acquire current transaction data of a current transaction action in a target blockchain;
[0032] The data management unit is used to update the current market information corresponding to the target blockchain based on the current transaction data, and the current market information at least includes the current transaction information and historical transaction information of the transaction object.
[0033] Optionally, the market data module also includes a market driver unit.
[0034] The market driving unit is used to generate an initial transaction request of the target blockchain based on the data to be traded; and determine the target transaction request of the target blockchain according to the initial transaction request and the second specified policy information.
[0035] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any method of the first aspect when executing the computer program.
[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method of any one of the first aspects is implemented.
[0037] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on a strategy trading system, the strategy trading system executes any one of the methods in the first aspect above.
[0038] The embodiment of the present application provides a blockchain-based policy transaction method, system, terminal device and product, the method comprising: upon receiving the current transaction data of the current transaction action in the target blockchain, determining the target blockchain's pending transaction data according to the current transaction data and the first specified policy information; generating a target transaction request for the target blockchain based on the pending transaction data; sending the target transaction request to the target blockchain so that the target blockchain performs transactions based on the target transaction request. Using the above technical solution, upon receiving the current transaction data of the current transaction action in the target blockchain, the target blockchain's pending transaction data can be directly determined according to the current transaction data and the first specified policy information, and the target blockchain performs transactions through interaction with the target blockchain, and the existing transaction strategy can be reused without adjusting the technical details of the blockchain, thereby achieving decoupling between the transaction strategy and the blockchain application details and simplifying application development. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 This is a flowchart of a blockchain-based strategic trading method provided by an embodiment of the present application;
[0041] Figure 2 This is a flowchart of a blockchain-based strategic trading method provided by another embodiment of the present application;
[0042] Figure 3 This is a schematic diagram of the structure of a blockchain-based strategy trading system provided in one embodiment of the present application;
[0043] Figure 4 This is a schematic diagram of the structure of another blockchain-based strategy trading system provided in one embodiment of the present application;
[0044] Figure 5 It is a structural diagram of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0045] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0046] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0047] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0048] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0049] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0050] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0051] It should be noted that the information collection process (such as facial image collection process, transaction data process, etc.) / feature extraction process involved in this application is performed with the user's knowledge and permission, that is, the information collection process / feature extraction process complies with the requirements of laws and regulations and does not constitute an act that harms the public interest.
[0052] Figure 1 This is a flowchart of a blockchain-based strategy trading method provided in one embodiment of the present application. As an example but not a limitation, this method can be applied to a blockchain-based strategy trading system.
[0053] S101. When receiving current transaction data of a current transaction action in a target blockchain, determine the pending transaction data of the target blockchain according to the current transaction data and first specified policy information.
[0054] The target blockchain may be a pre-specified blockchain that needs to be subject to strategic trading. For example, a user may trigger a transaction task creation instruction in the strategic trading system in advance according to actual needs. The transaction task creation instruction may include the identification information of the target blockchain, the market type in which the target blockchain is located, and the specified transaction strategy information, etc., so that after the strategic trading system recognizes that the target blockchain has a transaction action, it may determine whether a transaction request needs to be created in the next step through its own transaction logic, and calculate the specific data to be traded when a transaction request needs to be created. Among them, the specified transaction strategy information may be understood as information related to the transaction specified by the user, and may include the first specified strategy information, which may be used to determine the data to be traded of the target blockchain. The specific content of the first specified strategy information is not limited, such as including a specified transaction strategy, or configuration information related to the transaction strategy, etc.
[0055] The current transaction action may refer to the transaction action currently executed in the target blockchain, and the current transaction data refers to the transaction data corresponding to the current transaction action, such as data related to the traded object; the pending transaction data may be the relevant data of the transaction to be carried out determined by the transaction strategy, which may include the object to be traded, and may also include parameter data related to the transaction.
[0056] Specifically, in this embodiment, when the current transaction data of the current transaction action in the target blockchain is received, the data to be traded of the target blockchain can be determined according to the received current transaction data and the first specified policy information. The specific process of determining the data to be traded is not limited. For example, the data to be traded of the target blockchain can be directly output through the transaction strategy model. The transaction strategy model can be a pre-trained neural network model, or certain calculations can be performed on the current transaction data and the first specified policy information to realize the determination of the data to be traded. The specific calculation process can be configured according to the actual situation, and this embodiment will not be further elaborated on this.
[0057] S102: Generate a target transaction request for the target blockchain based on the data to be traded.
[0058] The target transaction request can be used to request the target blockchain to conduct a transaction.
[0059] In this embodiment, the target transaction request of the target blockchain can be generated directly based on the data to be traded obtained in the above step, or the target transaction request can be improved by combining other data on the basis of the data to be traded.
[0060] In some embodiments, generating a target transaction request of a target blockchain based on the to-be-transacted data includes:
[0061] Generate an initial transaction request of the target blockchain based on the transaction data;
[0062] According to the initial transaction request and the second specified policy information, a target transaction request of the target blockchain is determined.
[0063] Among them, the initial transaction request can be a initially generated transaction request; the second specified policy information can be relevant information of a pre-specified sending transaction strategy. For example, the policy trading system can pre-store multiple sending transaction strategies, and each sending transaction strategy involves packaging information for sending transaction data to the target blockchain, etc. In specific applications, the target transaction request of the target blockchain can be determined based on the initial transaction request and the second specified policy information. For example, the second specified policy information and the initial transaction request can be directly input into the update model to implement the update of the initial transaction request, thereby obtaining the target transaction request of the target blockchain, or it can be determined based on the specific content of the second specified policy information.
[0064] In some embodiments, the second specified policy information includes a second policy identifier and a second policy configuration parameter, and determining a target transaction request of the target blockchain according to the initial transaction request and the second specified policy information includes:
[0065] Input the second strategy configuration parameter into the second trading strategy code to obtain the sending parameter of the data to be traded, where the second trading strategy code is the code of the sending trading strategy corresponding to the second strategy identifier;
[0066] The initial transaction request is updated based on the sending parameters to obtain the target transaction request of the target blockchain.
[0067] In this embodiment, each code for sending a transaction strategy is configured with a corresponding strategy identifier, the second strategy identifier is a pre-specified strategy identifier, which is used to determine the code for the sending transaction strategy to be used, and the second transaction strategy code is the code for the sending transaction strategy corresponding to the second strategy identifier; the second strategy configuration parameter can be understood as a configuration parameter related to the sending transaction strategy, which can include the maximum value settings such as the transaction fee gas fee and the verification tip gas price, as well as the logic of whether the blockchain transaction is finally timed out and unconfirmed. The sending parameter can refer to the parameters related to the sending of the data to be traded determined by the sending transaction strategy, such as the specific values of the transaction fee and the verification tip. On this basis, by determining the sending parameters to update the initial transaction request, the transaction efficiency of the data to be traded can be guaranteed to a certain extent, and the quality of the transaction can be guaranteed.
[0068] S103: Send the target transaction request to the target blockchain, so that the target blockchain performs transactions based on the target transaction request.
[0069] After the target transaction request is generated through the above steps, the target transaction request can be directly sent to the target blockchain through the communication connection between the strategy trading system and the target blockchain, so that the target blockchain can perform actual transactions based on the target transaction request; the sending logic of the target transaction request can also be further enriched. For example, the user can pre-specify multiple available transaction addresses, and the data to be traded determined in step S101 can include one of the addresses to be traded, so as to indicate that the data to be traded can be traded using the address to be traded, so that the target transaction request can be signed using the address to be traded in this example, so as to send the signed target transaction request to the target blockchain.
[0070] The present embodiment provides a blockchain-based policy trading method. When receiving the current transaction data of the current transaction action in the target blockchain, the target blockchain's pending transaction data can be directly determined according to the current transaction data and the first specified policy information, and the target blockchain can be enabled to conduct transactions through interaction with the target blockchain. The existing transaction strategy can be reused without adjusting the technical details of the blockchain, thereby achieving decoupling between the transaction strategy and the blockchain application details and simplifying application development.
[0071] Figure 2This is a flowchart of a blockchain-based strategy trading method provided by another embodiment of the present application. This embodiment further optimizes the determination of the target blockchain's pending transaction data based on the current transaction data and the first specified strategy information as follows: based on the current transaction data, the current market information corresponding to the target blockchain is updated, and the current market information at least includes the current transaction information and historical transaction information of the transaction object; based on the current transaction information, historical transaction information and the first specified strategy information of the transaction object, the pending transaction data of the target blockchain is determined. Figure 2 As shown, the method includes:
[0072] S201. When receiving the current transaction data of the current transaction action in the target blockchain, update the current market information corresponding to the target blockchain based on the current transaction data. The current market information at least includes the current transaction information and historical transaction information of the transaction object.
[0073] S202. Determine the data to be traded in the target blockchain according to the current transaction information, historical transaction information and first specified policy information of the transaction object.
[0074] The current market information can be used to characterize the current state of the target blockchain, and may include the current transaction information and historical transaction information of the transaction object, such as the current quantity of the transaction object in the contract, the current price, the historical transaction quantity and historical price of the transaction object, and other data related to the transaction object; the transaction object is the object that can be used for transaction in the target blockchain.
[0075] In this embodiment, the current market information of the target blockchain can be updated based on the received current transaction data, so that the data to be traded of the target blockchain can be comprehensively determined based on the current transaction information, historical transaction information and the first specified policy information of the transaction object. The specific method of determining the data to be traded can be determined based on the specific content of the first specified policy information.
[0076] In some embodiments, the first specified policy information includes a first policy identifier and a first policy configuration parameter, and the to-be-transacted data of the target blockchain is determined according to the current transaction information, historical transaction information and the first specified policy information of the transaction object, including:
[0077] The current transaction information, historical transaction information and the first strategy configuration parameters are input into the first transaction strategy code to obtain the data to be traded of the target blockchain, wherein the first transaction strategy code is the code of the transaction strategy corresponding to the first strategy identifier, and the data to be traded includes the number of objects to be traded and slippage data.
[0078] It can be understood that the strategy trading system can store multiple trading strategies, and the trading strategies can be used to determine the data to be traded of the blockchain. The code of each trading strategy is configured with a corresponding strategy identifier, so the first specified strategy information can include the first strategy identifier and the first strategy configuration parameter, and the first trading strategy code specified by the user can be determined by the first strategy identifier to determine the data to be traded of the target blockchain; the first strategy configuration parameter can be understood as a configuration parameter related to the first trading strategy code, such as the maximum transaction quantity of the trading object; the data to be traded can include the number of objects to be traded and slippage data, and the objects to be traded are the objects to be traded, such as the objects to be traded can include the objects to be paid and the objects obtained by the transaction, and the number of objects to be traded is the number of objects to be paid and the number of objects obtained by the transaction, and the slippage data can refer to the parameters of the deviation between the specified transaction quantity and the actual transaction quantity when the transaction is carried out. On this basis, by inputting the current transaction information, the historical transaction information and the first strategy configuration parameter into the first trading strategy code, the data to be traded is obtained, which provides a feasible means for determining the data to be traded, and at the same time, there is no need to pay attention to the technical details of the blockchain, which speeds up the efficiency of determining the data to be traded.
[0079] S203: Generate a target transaction request for the target blockchain based on the data to be traded.
[0080] S204: Send the target transaction request to the target blockchain, so that the target blockchain performs transactions based on the target transaction request.
[0081] The present embodiment provides a blockchain-based strategy trading method, which can accurately determine the data to be traded on the target blockchain by updating the current transaction information and historical transaction information of the transaction object corresponding to the target blockchain based on the current transaction data, thereby providing a data basis for improving the accuracy of strategy trading.
[0082] In some embodiments, after sending the target transaction request to the target blockchain, the method further includes:
[0083] Obtain the transaction receipt information returned by the target blockchain for the target transaction request;
[0084] Parse the transaction receipt information to obtain the actual transaction data corresponding to the target transaction request;
[0085] Update the current market information of the target blockchain based on actual transaction data.
[0086] It can be considered that after sending the target transaction request to the target blockchain, the confirmation result of the target blockchain can be waited for. For example, after the target blockchain confirms and executes the transaction request, the actual transaction data corresponding to the target transaction request can be collected through data query, or the transaction receipt information of the target blockchain can be queried. After obtaining the transaction receipt information returned by the target blockchain for the target transaction request, the transaction receipt information can be parsed to obtain the actual transaction data corresponding to the target transaction request, so that the current market information of the target blockchain can be updated based on the actual transaction data obtained. On this basis, the consistency of blockchain data can be guaranteed and the accuracy of strategic transactions can be improved.
[0087] Figure 3 is a schematic diagram of a block chain-based strategy trading system provided by an embodiment of the present application, such as Figure 3 As shown, the strategy trading system includes:
[0088] The transaction engine module 301 is used to determine the pending transaction data of the target blockchain according to the current transaction data and the first specified policy information when receiving the current transaction data of the current transaction action in the target blockchain;
[0089] The market data module 302 corresponds to the target blockchain and is used to generate a target transaction request of the target blockchain based on the data to be traded;
[0090] The adapter module 303 establishes a communication connection with the target blockchain and is used to send the target transaction request to the target blockchain so that the target blockchain performs a transaction based on the target transaction request.
[0091] Among them, the transaction engine module 301 can be considered as the core engine for executing the entire transaction task in the strategy trading system, controlling the start and stop of the transaction task, as well as the maintenance and update of data, etc.; the market data module 302 can be considered as the market module corresponding to the target blockchain in the strategy trading system, which is used to process various types of data in the target blockchain, such as collecting the current transaction data in the target blockchain, and other related operations. The adapter module 303 can be used to access the adapter of the API of various blockchains, such as the adapter module 303 can establish a communication connection with the target blockchain, and the number of adapter modules 303 can be multiple, corresponding to each blockchain.
[0092] The embodiment of the present application provides a blockchain-based policy trading system. When the current transaction data of the current transaction action in the target blockchain is received, the transaction engine module determines the target blockchain's pending transaction data according to the current transaction data and the first specified policy information; the market data module generates a target transaction request for the target blockchain based on the pending transaction data; the adapter module sends the target transaction request to the target blockchain, so that the target blockchain trades based on the target transaction request. Using this policy trading system, when the current transaction data of the current transaction action in the target blockchain is received, the target blockchain's pending transaction data can be directly determined according to the current transaction data and the first specified policy information, and the target blockchain is traded through interaction with the target blockchain. The existing transaction strategy can be reused without adjusting the technical details of the blockchain, realizing the decoupling between the transaction strategy and the blockchain application details, and simplifying the application development.
[0093] In some embodiments, the market data module includes a data acquisition unit and a data management unit.
[0094] A data acquisition unit, used to acquire current transaction data of a current transaction action in a target blockchain;
[0095] The data management unit is used to update the current market information corresponding to the target blockchain based on the current transaction data, and the current market information at least includes the current transaction information and historical transaction information of the transaction object.
[0096] In this embodiment, the market data module 302 may include a data acquisition unit and a data management unit. The data acquisition unit may be used to acquire the current transaction data of the current transaction action in the target blockchain. For example, the data acquisition unit may collect the current transaction data of the current transaction action in the target blockchain by means of data query. The data management unit may be used to update the current market information of the target blockchain based on the current transaction data, so that the transaction engine module 301 may determine the data to be traded of the target blockchain according to the current transaction information, historical transaction information and the first specified policy information of the transaction object.
[0097] In some embodiments, the market data module further includes a market driver unit,
[0098] The market driving unit is used to generate an initial transaction request of the target blockchain based on the data to be traded; and determine the target transaction request of the target blockchain according to the initial transaction request and the second specified policy information.
[0099] In a specific implementation, the strategy trading system may further include a first strategy management module storing at least one trading strategy, and the trading engine module 301 may obtain the first trading strategy code by exchanging information with the first strategy management module, such as the trading engine module 301 may send a first strategy acquisition request containing a first strategy identifier to the first strategy management module, and then the first strategy management module may receive the first strategy acquisition request and return the first trading strategy code corresponding to the first strategy identifier to the trading engine module 301. Subsequently, the trading engine module 301 may input the current trading information, historical trading information and first strategy configuration parameters of the trading object into the first trading strategy code to obtain the number of objects to be traded and slippage data of the target blockchain, and enable the market driving unit to generate a corresponding target trading request based on the number of objects to be traded and the slippage data, so that the generated target trading request may be sent to the target blockchain through the adapter module 303, so that the target blockchain may trade based on the target trading request.
[0100] In a specific embodiment, the strategy trading system may further include a second strategy management module storing at least one sending transaction strategy, and the stored sending transaction strategy may be used to characterize the sending strategy of the transaction. The transaction engine module 301 may obtain the second transaction strategy code by exchanging information with the second strategy management module, such as the transaction engine module 301 may send a second strategy acquisition request containing a second strategy identifier to the second strategy management module, and then the second strategy management module may receive the second strategy acquisition request and return the second transaction strategy code corresponding to the second strategy identifier to the transaction engine module 301. Subsequently, the transaction engine module 301 may input the second strategy configuration parameters into the second transaction strategy code to obtain the sending parameters of the data to be traded, and then the market driving unit may update the initially generated initial transaction request based on the sending parameters to obtain the target transaction request, so that the strategy trading system may call the adapter module 303 to send the target transaction request to the target blockchain.
[0101] Figure 4 is a schematic diagram of the structure of another blockchain-based strategy trading system provided by an embodiment of the present application, such as Figure 4 As shown, the entire strategy trading system can be composed of the following parts:
[0102] Trading engine module TradeEngine: used to execute the entire trading task, control the start and stop of trading tasks, and maintain and update trading records and overall statistical data.
[0103] Adapter module ChainAdaptor: Adapters used to access the APIs of various blockchains (such as Chain Adapter 1 and Chain Adapter 2), and communicate with the corresponding blockchains (such as Blockchain 1 and Blockchain 2) respectively; it is also used to implement transaction signature submission, wait for confirmation, track the sending parameters on the chain, and manage transaction addresses.
[0104] Market data module Market: represents the trading market on the blockchain (such as market data module 1 corresponding to blockchain 1, market data module 2 corresponding to blockchain 2, etc.), including the following three parts:
[0105] a) Market data source MarketDatasource (i.e. data acquisition unit): used to obtain transaction data from the blockchain and uniformly process these data into a data format supported by the data management unit MarketManager. If it is a real-time transaction, it can track related transactions on the blockchain and parse blockchain transactions to obtain market transaction data (such as whether it is a spending transaction, the number of objects to be spent, the number of objects obtained from the transaction, and the transaction address); if it is a backtest, it can directly read historical transaction data (such as files or data in a database).
[0106] b) Market Driver: used to parse blockchain transactions (such as parsing transaction data from blockchain transaction receipts), construct transaction requests to be sent, and calculate the limit quantity based on the set slippage.
[0107] c) Data management unit MarketManager: used to manage and track all data of the same blockchain (such as the number of objects that can be traded, etc.), use the transaction data input by MarketDatasource to update the current state of the market, and calculate the number of second objects that can be traded by spending a specified number of first objects according to the current state of the market (such as used by the trading engine to calculate floating profits and losses, and calculate the corresponding number when executing buy and sell), and append transaction data to the transaction history of the market. At the same time, it will calculate the price of the transaction for the trading strategy to use to determine whether to trade at present. The first object is the object that needs to be consumed, and the second object is the object obtained from the transaction.
[0108] TradeTaskManager: used to manage the status of multiple trading tasks (such as Task 1 and Task 2).
[0109] Send transaction strategy management SendTxStrategyManager (i.e. the second strategy management module): manages multiple strategies for sending blockchain transactions (such as transaction strategy 1 and transaction strategy 2). Each sending transaction strategy is bound to the corresponding blockchain, and the strategy of one blockchain cannot be used for another blockchain.
[0110] Trading strategy management TradeStrategyManager (i.e., the first strategy management module): manages multiple trading strategies for trading (such as trading strategy 1 and trading strategy 2). Trading strategies can be simple stop-profit and stop-loss strategies, or dollar-cost averaging (DCA) strategies, or more complex trading strategies. After creating a new market, the first strategy management module will be called when the status of the trading market on the blockchain is updated to decide whether to trade and the transaction quantity. For example, the historical transaction prices of the market can be used to calculate some transaction basis parameters to assist in decision-making.
[0111] Taking the creation of a transaction task and the simplest spending and selling as an example, the strategy trading method involved in the above strategy trading system is explained.
[0112] The user can trigger a trading task creation instruction in the strategy trading system. The trading task creation instruction may include: the blockchain where the trading task is located, the market type of the blockchain, the list of available trading addresses, task control parameters (such as running time, start time, maximum total loss, etc.), the name of the trading strategy TradeStrategy used (i.e. the first strategy identifier), the trading strategy configuration parameters (i.e. the first strategy configuration parameters), the name of the sending trading strategy SendTxStrategy used (i.e. the second strategy identifier), and the SendTxStrategy configuration parameters (i.e. the second strategy configuration parameters), and then the trading engine can instantiate the task. The trading strategy configuration parameters may include, for example, the total amount of the first object to be spent, the maximum amount of the first object to be spent at a time, and when the current quantitative indicator RSI is too low, the amount of the first object is increased; when the current quantitative indicator RSI is not too high, the amount of the first object is reduced.
[0113] The transaction engine can check whether there is already a data acquisition unit MarketDatasource corresponding to the market type on the blockchain where the transaction task is located. If so, it will be reused; if not, it will be created and wait to receive real-time market transaction data on the blockchain.
[0114] After the data management unit MarketDatasource pushes the Market trade data (i.e., the current transaction data of the current transaction action) to the transaction engine, the transaction engine can pass in the configuration parameters of the transaction strategy TradeStrategy, call the transaction strategy TradeStrategy used by the task, decide whether to trade, and calculate the number of second objects that can be traded based on the number of the first object to be spent and the current state of the market, set the slippage, and select the transaction address to be used (i.e., input the current transaction information, historical transaction information and the first strategy configuration parameters into the first transaction strategy code to obtain the data to be traded of the target blockchain, the data to be traded includes the number of objects to be traded, slippage data, and the address to be traded), thereby returning the number of the first object to be spent, the corresponding number of the second object (i.e., the number of objects to be traded), the slippage parameters (i.e., the slippage data) and the transaction address to be used (i.e., the address to be traded) to the transaction engine.
[0115] The transaction engine can call the corresponding MarketDriver according to the amount of the first object to be spent, the corresponding amount of the second object and the slippage parameter, and construct the blockchain transaction to be sent. For example, the amount of the first object to be spent, the corresponding amount of the second object and the slippage parameter are sent to the market driver unit, and the market driver unit can return the generated blockchain transaction to the transaction engine (i.e., generate an initial transaction request for the target blockchain based on the data to be traded).
[0116] The transaction engine can then pass in the configuration parameters of SendTxStrategy, call the SendTxStrategy used by the task, update the blockchain transaction constructed in the previous step, and set the sending parameters (i.e., input the second strategy configuration parameters into the second transaction strategy code to obtain the sending parameters of the data to be traded; based on the sending parameters, update the initial transaction request to obtain the target transaction request of the target blockchain). The transaction engine can also create a transaction record for the transaction to update the status of the transaction record later.
[0117] The transaction engine can then call the ChainAdaptor of the corresponding chain, use the selected transaction address to sign the constructed transaction, and then send the signed transaction to the blockchain for confirmation. There are two confirmation methods: a) MarketDatasource pushes the actual transaction data of this blockchain transaction; b) ChainAdaptor queries the blockchain transaction receipt, calls MarketDriver to parse the blockchain transaction receipt to obtain the actual transaction data (that is, obtain the transaction receipt information returned by the target blockchain for the target transaction request; parse the transaction receipt information to obtain the actual transaction data corresponding to the transaction request).
[0118] After the blockchain transaction is confirmed, the trading engine can mark the transaction record as completed and update the current market information based on the actual transaction data.
[0119] Furthermore, after MarketDatasource collects new market trade data (i.e., current trading data of the current trading action), it pushes it to the trading engine. The trading engine calculates the current unrealized profit and loss (PNL) and unrealized PNL rate based on the number of tradable objects and the latest current market status, and passes them into the configuration parameters of TradeStrategy; the TradeStrategy used by the calling task decides whether to trade.
[0120] If TradeStrategy determines that the loss has reached the stop loss line, it can calculate the number of corresponding second trading objects based on the number of tradable first objects and the current market status, set the slippage to select the trading address to be used, and return it to the trading engine (that is, input the current trading information, historical trading information and the first strategy configuration parameters into the first trading strategy code to obtain the data to be traded on the target blockchain).
[0121] The trading engine can call the corresponding MarketDriver to construct the blockchain transaction to be sent according to the amount of the first object to be spent, the corresponding amount of the second object and the slippage parameters; pass in the configuration parameters of SendTxStrategy; call the SendTxStrategy used by the task; update the blockchain transaction constructed in the previous step, set the sending parameters, and if it is found that the loss is large, in order to prevent the loss from being magnified, SendTxStrategy can increase the sending parameters.
[0122] The trading engine can create a transaction record for the sale to update the status of the transaction record later; call the ChainAdaptor of the corresponding chain, use the selected transaction address to sign the constructed transaction, and send it to the blockchain for confirmation.
[0123] After the blockchain transaction is confirmed, the transaction record can be marked as completed, and the market data information can be updated based on the actual transaction data to calculate the realized PNL and realized PNL rate.
[0124] From the above description, it can be found that the strategy trading system and method provided in this embodiment no longer focus on the specific technical details of the specific blockchain and DEFI on the blockchain, but put these differences into the corresponding trading engine and market data module and other components for implementation and adaptation, so that the scalability of the overall framework is greatly improved, the decoupling of trading strategies is achieved, and the details of the blockchain are no longer concerned.
[0125] At the same time, the strategy trading system and method provided in this embodiment only needs to implement the minimum logic to connect to the new blockchain, support reuse strategies, and the overall trading engine does not need to be changed; for the operation of multiple trading tasks in the same market, only the same MarketDatasource needs to be instantiated, saving the blockchain's remote procedure call (RPC) resources, lower latency, and high operating efficiency; the implementation of switching MarketDatasource can support backtesting of strategies on historical data. In addition, it also supports flexible adjustment of the sending parameter size of the blockchain transaction to be carried out according to the profit and loss status, which is used to speed up the transaction confirmation speed.
[0126] In summary, the general and efficient strategy trading system and method provided in this embodiment can support rapid access to DEFI applications on any blockchain, decouple the data source and the trading engine, and decouple the trading strategy from the specific DEFI application details. Therefore, when switching between different DEFI applications, existing strategies can be reused without adjusting the strategy code, which greatly reduces the development and maintenance costs, and can also quickly switch to new DEFI applications.
[0127] It should be noted that the information interaction, execution process, etc. between the above-mentioned modules / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0128] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0129] The present application also provides a terminal device, Figure 5 is a schematic diagram of the structure of a terminal device provided by an embodiment of the present application, such as Figure 5As shown, the terminal device includes: at least one processor 401, a memory 402, an input device 403, an output device 404, and a computer program stored in the memory 402 and executable on at least one processor 401. When the processor 401 executes the computer program, the steps in any of the above-mentioned method embodiments are implemented.
[0130] The input device 403 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the terminal device. The output device 404 may include a display device such as a display screen.
[0131] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by the processor 401, the steps in the above-mentioned method embodiments can be implemented.
[0132] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0133] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor 401, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0134] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0135] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0136] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0137] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0138] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A strategy trading method based on blockchain, characterized in that: include: When receiving current transaction data of a current transaction action in a target blockchain, determining the pending transaction data of the target blockchain according to the current transaction data and the first specified policy information; Generate a target transaction request of the target blockchain based on the to-be-transacted data; The target transaction request is sent to the target blockchain, so that the target blockchain performs a transaction based on the target transaction request.
2. The blockchain-based strategic trading method according to claim 1, characterized in that: The determining, according to the current transaction data and the first specified policy information, the to-be-transacted data of the target blockchain includes: Based on the current transaction data, the current market information corresponding to the target blockchain is updated, where the current market information includes at least the current transaction information and historical transaction information of the transaction object; Determine the data to be traded of the target blockchain according to the current transaction information, the historical transaction information and the first specified policy information of the transaction object.
3. The blockchain-based strategic trading method according to claim 2, characterized in that: The first specified policy information includes a first policy identifier and a first policy configuration parameter, and the determining, according to the current transaction information of the transaction object, the historical transaction information and the first specified policy information, the to-be-transacted data of the target blockchain includes: The current transaction information, the historical transaction information and the first strategy configuration parameters are input into the first transaction strategy code to obtain the data to be traded of the target blockchain, wherein the first transaction strategy code is the code of the transaction strategy corresponding to the first strategy identifier, and the data to be traded includes the number of objects to be traded and slippage data.
4. The blockchain-based strategic trading method according to claim 1, characterized in that: The generating a target transaction request of the target blockchain based on the to-be-transacted data includes: Generate an initial transaction request of the target blockchain based on the data to be traded; Determine a target transaction request of the target blockchain according to the initial transaction request and the second specified policy information.
5. The blockchain-based strategic trading method according to claim 4, characterized in that: The second specified policy information includes a second policy identifier and a second policy configuration parameter, and determining the target transaction request of the target blockchain according to the initial transaction request and the second specified policy information includes: Inputting the second strategy configuration parameter into the second trading strategy code to obtain the sending parameter of the data to be traded, wherein the second trading strategy code is a code of the sending trading strategy corresponding to the second strategy identifier; The initial transaction request is updated based on the sending parameters to obtain a target transaction request of the target blockchain.
6. The blockchain-based strategic trading method according to claim 1, characterized in that: The data to be traded includes an address to be traded, and sending the target transaction request to the target blockchain includes: Sign the target transaction request using the address to be traded to obtain a signed target transaction request; The signed target transaction request is sent to the target blockchain.
7. The blockchain-based strategic trading method according to claim 1, characterized in that: After sending the target transaction request to the target blockchain, the method further includes: Obtaining transaction receipt information returned by the target blockchain for the target transaction request; Parsing the transaction receipt information to obtain actual transaction data corresponding to the target transaction request; Update the current market information of the target blockchain based on the actual transaction data.
8. A blockchain-based strategy trading system, characterized in that: include: A transaction engine module, configured to determine, upon receiving current transaction data of a current transaction action in a target blockchain, the pending transaction data of the target blockchain according to the current transaction data and the first specified policy information; A market data module, corresponding to the target blockchain, and configured to generate a target transaction request for the target blockchain based on the data to be traded; The adapter module establishes a communication connection with the target blockchain and is used to send the target transaction request to the target blockchain so that the target blockchain performs a transaction based on the target transaction request.
9. The blockchain-based strategy trading system according to claim 8, characterized in that: The market data module includes a data acquisition unit and a data management unit. The data acquisition unit is used to acquire current transaction data of the current transaction action in the target blockchain; The data management unit is used to update the current market information corresponding to the target blockchain based on the current transaction data, and the current market information at least includes the current transaction information and historical transaction information of the transaction object.
10. The blockchain-based strategy trading system according to claim 9, characterized in that: The market data module also includes a market driving unit. The market driving unit is used to generate an initial transaction request of the target blockchain based on the data to be traded; and determine a target transaction request of the target blockchain according to the initial transaction request and the second specified policy information.
11. A terminal device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the terminal device implements the method according to any one of claims 1 to 7.
12. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, enables the method according to any one of claims 1 to 7 to be performed.