资源加载中... loading...

exchange.GetTrades

获取当前设置的交易对、合约代码对应的{@struct/Trade Trade}结构数组,即市场的成交数据。 商品期货通过算法根据行情数据(Tick数据)推算出市场成交记录。

exchange.GetTrades()函数请求数据成功时返回{@struct/Trade Trade}结构数组,请求数据失败时返回空值。

{@struct/Trade Trade}数组、空值

exchange.GetTrades() exchange.GetTrades(symbol)

参数symbol用于指定请求的{@struct/Trade Trade}数组数据对应的合约代码。不传该参数时默认请求当前设置的合约代码的最近成交记录数据。

symbol false string

function main() {
    // 鉴于测试代码,不使用商品期货策略一般架构,这里仅仅判断exchange.IO("status")函数,判断连接期货公司前置机成功后立即执行测试代码。股票证券无需使用exchange.IO("status")判断连接状态
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    Log(exchange.SetContractType("rb888"))

    var trades = exchange.GetTrades()
    Log(trades)
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    Log(exchange.SetContractType("rb888"))
    
    trades = exchange.GetTrades()
    Log(trades)
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    Log(exchange.SetContractType("rb888"));
    
    auto trades = exchange.GetTrades();
    Log(trades);
}

测试exchange.GetTrades()函数:

根据Tick数据推算成交记录的策略例子:

{@fun/Market/exchange.GetTicker exchange.GetTicker}, {@fun/Market/exchange.GetDepth exchange.GetDepth}, {@fun/Market/exchange.GetRecords exchange.GetRecords}

exchange.GetDepth exchange.GetRecords