The resource loading... loading...

Trading Terminal

The FMZ Quant Trading Platform provides a modular and customizable “Trade” page. You can freely add various data modules and trading function modules, and even develop their own code modules (trading terminal plugins). With its highly flexible and free usage, it also greatly facilitates users of manual trading and semi-programmatic trading. Various modules on the “Trade” page can be dragged and zoomed, the settings of the trading pairs and exchanges bound by the modules can be modified, and multiple modules of the same type can be added.

The FMZ Quant Trading Platform improved the functionality of the trading terminal, better facilitated manual trading, and introduced the trading plug-in function of the trading terminal.

Principle of Plugin

The principle is the same as the debugging tool: send a piece of code to the docker of the “Trade” terminal page to execute, and support the return of charts and tables (the debugging tool also supports upgradation). The function is the same as debugging tool, it can only be executed for 3 minutes, without charging. It can realize some simple small functions, complex strategies still need to run in live trading.

Plugin Writing

To create a trading terminal plugin, you can set the strategy type to: Trading plugin on the New Strategy page. Trading plugin supports JavaScript, Python, C++, and MyLanguage.

Usage of Plugin

The plugin can execute the code for a period of time, and it can perform some simple operations, such as iceberg orders, pending orders, order cancellation and order calculation. Same as the debugging tool, it uses return to return the results, and it can also directly return the charts and tables. Here are a few examples, and other functions can be explored by yourself.

  • Return to the depth snapshot

    // Return to the depth snapshot
    function main() {
        var tbl = { 
            type: 'table', 
            title: 'snapshot of the order depth @ ' + _D(), 
            cols: ['#', 'Amount', 'Ask', 'Bid', 'Amount'], 
            rows: []
        }
        var d = exchange.GetDepth()
        for (var i = 0; i < Math.min(Math.min(d.Asks.length, d.Bids.length), 15); i++) {
            tbl.rows.push([i, d.Asks[i].Amount, d.Asks[i].Price+'#ff0000', d.Bids[i].Price+'#0000ff', d.Bids[i].Amount])
        }
        return tbl
    }
    
    def main():
        tbl = {
            "type": "table",
            "title": "snapshot of the order depth @ " + _D(),
            "cols": ["#", "Amount", "Ask", "Bid", "Amount"],
            "rows": []
        }
        d = exchange.GetDepth()
        for i in range(min(min(len(d["Asks"]), len(d["Bids"])), 15)):
            tbl["rows"].append([i, d["Asks"][i]["Amount"], str(d["Asks"][i]["Price"]) + "#FF0000", str(d["Bids"][i]["Price"]) + "#0000FF", d["Bids"][i]["Amount"]])
        return tbl
    
    void main() {
        json tbl = R"({
            "type": "table",
            "title": "abc",
            "cols": ["#", "Amount", "Ask", "Bid", "Amount"],
            "rows": []   
        })"_json;
        
        tbl["title"] = "snapshot of the order depth @" + _D(); 
        auto d = exchange.GetDepth();
        for(int i = 0; i < 5; i++) {
            tbl["rows"].push_back({format("%d", i), format("%f", d.Asks[i].Amount), format("%f #FF0000", d.Asks[i].Price), format("%f #0000FF", d.Bids[i].Price), format("%f", d.Bids[i].Amount)});
        }
        
        LogStatus("`" + tbl.dump() + "`");
        // C++ does not support "return json" to display the table, and you can create the live trading to display the table of the status bar
    }
    
  • Draw cross-period spreads

    // Draw cross-period spreads
    var chart = { 
        __isStock: true,    
        title : { text : 'spread analysis chart'},                     
        xAxis: { type: 'datetime'},                 
        yAxis : {                                        
            title: {text: 'spread'},                   
            opposite: false                   
        },
        series : [                    
            {name : "diff", data : []}
        ]
    }  
    
    function main() {
        exchange.SetContractType('quarter')
        var recordsA = exchange.GetRecords(PERIOD_M5)
        exchange.SetContractType('this_week')
        var recordsB = exchange.GetRecords(PERIOD_M5)
        
        for(var i = 0; i < Math.min(recordsA.length, recordsB.length); i++){
            var diff = recordsA[recordsA.length - Math.min(recordsA.length, recordsB.length) + i].Close - recordsB[recordsB.length - Math.min(recordsA.length, recordsB.length) + i].Close
            chart.series[0].data.push([recordsA[recordsA.length - Math.min(recordsA.length, recordsB.length) + i].Time, diff])
        }
        return chart
    }
    
    chart = {
        "__isStock": True,
        "title": {"text": "spread analysis chart"},
        "xAxis": {"type": "datetime"},
        "yAxis": {
            "title": {"text": "spread"}, 
            "opposite": False
        }, 
        "series": [
            {"name": "diff", "data": []}
        ]
    }  
    
    def main():
        exchange.SetContractType("quarter")
        recordsA = exchange.GetRecords(PERIOD_M5)
        exchange.SetContractType("this_week")
        recordsB = exchange.GetRecords(PERIOD_M5)  
    
        for i in range(min(len(recordsA), len(recordsB))):
            diff = recordsA[len(recordsA) - min(len(recordsA), len(recordsB)) + i].Close - recordsB[len(recordsB) - min(len(recordsA), len(recordsB)) + i].Close
            chart["series"][0]["data"].append([recordsA[len(recordsA) - min(len(recordsA), len(recordsB)) + i]["Time"], diff])
        return chart
    
    // C++ does not support "return json" structure drawing
    

There are other examples in the “More Strategies”, such as buy / sell in small quantities.

How to Use

  • Add the plugin module of trading terminal Open the module add menu on the “Trade” terminal page, the trading terminal plugins in the strategy library of the current FMZ account will be displayed in the list automatically, find the plugin to be added and click “Add”.
  • Run the plugin Click “Execute”, and the trading terminal plugin will start running. The plugin will not display the log, but it can return display table.
  • Time of running the plugin The maximum running time of the plugin is 3 minutes; and it will stop running automatically after exceeding 3 minutes.
Extended API Interface Data Exploration