How to Assign Different Version Data to a Rented Strategy via Strategy Rental Code Metadata

Author: Lydia, Created: 2022-11-09 10:34:37, Updated: 2023-09-20 10:59:17

img

Application of strategy rental code metadata

Partners who work as developers on the FMZ Quant Trading Platform may often have such needs:

When developing a strategy for hire, you may want to have different capital restrictions on the strategy, and different exchange restrictions on the strategy lease (the exchange that restricts the strategy operation), or restrictions on the exchange account configuration when you want to lease the strategy (specify that this strategy can only operate the account agreed in advance, and the strategy user will not do any trading when using other accounts).

These obviously cannot be written in the code, because if they are written in the code, all users would be subject to these conditions, and it would not be possible to make controls for different user groups with different usage rights.

Based on the above demand scenario, the FMZ Quant Trading Platform is extended with a new function: strategy rental registration code metadata settings

When creating a registration code, you can specify a metadata Meta, and the data is a string. Attention: The length of the meta cannot exceed 190 characters when generating the registration code.

· Limit the strategy by using FMZ registration code metadata

For example, if I am a strategy develop hotshot and I have developed a spot trading pair for BTC_USDT, and it goes long only (there is only the pricing currency QuoteCurrency initially, that is, USDT; after buying, there is trading currency BaseCurrency, that is, BTC). I want to rent this strategy, which is named as test1.

It can be seen that the limited design of the strategy needs to be designed according to the specific situation of the strategy. The example is a demonstration of the spot strategy. What if the strategy is a futures strategy? Then it is necessary to limit the futures position information (according to the position data returned by GetPosition). When the strategy finds that the position exceeds the limit, it will not execute the logic of opening the position (other logic needs to be executed normally, such as closing the position).

Therefore, these designs need to be specific to the strategy itself. The example here is just a simple illustration and may not be of practical use.

Strategy source code:

function main() {
    // The maximum asset value of the denominated currency allowed by the strategy
    var maxBaseCurrency = null
    
    //Obtain the metadata when creating the registration code
    var level = GetMeta()
    
    // Detecting the conditions corresponding to Meta
    if (level == "level1") {
        // -1 is not limited
        maxBaseCurrency = -1       
    } else if (level == "level2") {
        maxBaseCurrency = 10     
    } else if (level == "level3") {
        maxBaseCurrency = 1
    } else {
        maxBaseCurrency = 0.5
    }
    
    while(1) {
        Sleep(1000)
        var ticker = exchange.GetTicker()
        
        // Detect asset values
        var acc = exchange.GetAccount()
        if (maxBaseCurrency != -1 && maxBaseCurrency < acc.Stocks + acc.FrozenStocks) {
            // Stop executing strategic trading logic
            LogStatus(_D(), "Positions exceeding the usage limit of the registration code will no longer execute the strategy trading logic!")
            continue
        }
        
        // Other trading logic
        
        // Output the status bar information normally
        LogStatus(_D(), "The strategy is running properly! ticker data:\n", ticker)
    }
}

When creating a registration code, find the strategy test1 in the strategy library, click on the action item on the right, click on “Rent”,

img

and then click on “Internal Sale”.

img

Click on “Little Wrench” to set the registration code metadata.

img

Then write the information to be qualified into the Meta control, such as several strategy usage levels designed in this example:

· level1: No limit to the number of positions. · level2: Limit the maximum number of positions to 10 coins. · level3: Limit the maximum number of positions to 1 coins. · No Meta setting: When there is no Meta setting, the default maximum position limit is 0.5 coins.

img

First, we set level1 for the Meta control, so that the created registration code has the level1 level of the test1 strategy. Registration code created :

Purchase address: https://www.fmz.com/m/s/282900
Registration code: 7af0c24404b268812c97b55d073c1867

The strategy lessor sends the registration code to the strategy renter.

· The usage strategy for strategy renters

Strategy renter create a real bot, use strategy test1, add a WexApp Spot Exchange object (WexApp is a demo of FMZ platform), run it.

· Modify the Meta data

When the strategy registration code has been used, it can also be modified if the strategy developer needs to adjust the Meta data of the issued registration code.

Meta data can be modified in the Strategy Library, Sale Record.

We changed the Meta data of the previous registration code to level3,

img

then the strategy user restarted the test.

· Summary

When leasing strategies are based on different user groups and different payment levels, Meta metadata is configured specifically to achieve hierarchical strategy control.

Of course, the above only lists the most common limitation and control requirements. There are a variety of similar requirements that can be implemented by using this function.


More