How to specify different versions of the data to be rented by using the policy for the metadata of the taxi code

Author: The Little Dream, Created: 2021-05-20 09:53:15, Updated: 2023-09-24 19:37:08

img

Application of tactical tax code metadata

Inventors' quantitative trading platforms, small partners who develop may often have the following needs:

When developing a strategy lease, you want to have different capital limits for the strategy, different exchange limits for the strategy lease (exchanges that operate the strategy are restricted), or you want to have exchange account configuration restrictions for the strategy lease (specify that the policy will only operate the pre-agreed accounts, the strategy user will use other accounts when the policy is prompted and will no longer trade).

These obviously cannot be written dead in the code, because if they are written dead in the code. All users will be restricted by these conditions, and it is not possible to control different permissions for different user groups.

Based on the above demand scenario, the inventor of the quantitative trading platform has expanded new features:The policy is to set up the metadata of the rental registry code

You can specify a metadata when you create a registration code.Meta, the data is a string. Note: Meta cannot exceed 190 characters in length when generating the registration code.

  • Use the FMZ registry code metadata to restrict policy

    For example, I'm a strategy builder, and I've developed a strategy for a spot trading pair for BTC_USDT, a strategy that only does more (originally only quotes coins).QuoteCurrencyUSDT is a currency that can be traded on a stock exchange if bought.BaseCurrencyI'm going to lease this strategy, which is called the Bitcoin strategy.test1

    This is a demonstration of a spot strategy. If the strategy is a futures strategy, it is to limit the holdings of the periodic commodity (according to the holdings data returned by GetPosition). When the strategy finds that the holdings exceed the limit, it no longer executes the single-opening logic (other logics need to be executed normally, such as a placement operation).

    So these designs need to be combined with the specifics of the strategy itself, and this example is just a simple illustrative example and may not have any practical use value.

    The source code of the strategy:

    function main() {
        // 策略允许的计价币最大资产数值
        var maxBaseCurrency = null
        
        // 获取创建注册码时的元数据
        var level = GetMeta()
        
        // 检测Meta对应的条件
        if (level == "level1") {
            // -1为不限制
            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()
            
            // 检测资产数值
            var acc = exchange.GetAccount()
            if (maxBaseCurrency != -1 && maxBaseCurrency < acc.Stocks + acc.FrozenStocks) {
                // 停止执行策略交易逻辑
                LogStatus(_D(), "持仓超过注册码的使用限定,不再执行策略交易逻辑!")
                continue
            }
            
            // 其它交易逻辑
            
            // 正常输出状态栏信息
            LogStatus(_D(), "策略正常运行!ticker数据:\n", ticker)
        }
    }
    

    When you create a registration code, you can find the test1 policy in the policy library and click on the one on the right.Operating itemsClick hereThe sale

    img

    Click hereInternally sold

    img

    Click on the button to set the registration code metadata.

    img

    And then you write the information you want to limit.MetaControls, for example, use several of the strategies designed in this case:

    • Level 1: No restrictions on the number of holdings.
    • Level 2: Limit holds to 10 coins.
    • Level 3: Limit holds to one coin.
    • Meta not set: When not set, the default hold limit is 0.5 coins.

    img

    We're going to set up the Meta controller first.level1Let's say that this registry code is created with a test1 policy.level1I'm not going to lie. I've created a registration code:

    购买地址: https://www.fmz.com/m/s/282900
    注册码: 7af0c24404b268812c97b55d073c1867
    

    The policy landlord sends this registration code to the policy tenant.

    For example, this time I used this registration code for my other account (the policy tenant) and got permission to use the policy test1.

    img

  • Strategy used by tenants

    Strategy tenant, create a virtual disk, use test1, add a WexApp exchange object (WexApp is an FMZ platform analog disk), and run the virtual disk.

    img

    You can see that the strategy is working properly.level1The ranking does not limit the number of holdings (number of coins held in a cash account).

  • Modified meta data

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

    In the strategy library, in the sales records.

    img

    You can modify the meta data.

    img

    We changed the metadata from the previous registration code tolevel3In this case, the user will be asked to restart the test on the hard disk.

    img

    As you can see in the diagram above, it triggers.level3The ranking limits holdings to a maximum of one coin.

  • See also:

    Meta data is configured according to different user groups, different pay-level rental strategies, to achieve policy hierarchy control.

    Of course, this is just a list of the most common constraint and control needs. There are a variety of similar needs that can be implemented using this feature.


Related

More