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

商品期货API文档(旧文档)

Author: 雨幕(youquant), Created: 2021-10-20 19:26:38, Updated: 2024-06-20 16:13:22

发执行函数会按照倒序依次执行,以上例子会依次使用Log函数打印1 ~ 5。支持不同的线程执行函数共享变量,例如上例中的this.d变量,可以在threadTestFuncB函数中赋值,在threadTestFuncA函数中使用。支持传入函数字符串,例如上例中的"function threadTestFuncC(c) {Log(c)}",可以让线程执行函数调用通过这种方法“导入”的外部函数、库。

对于导入外部库来说,一个具体的使用例子如下:

function ml(input) {
    const net = new brain.NeuralNetwork();
    net.train([
        { input: [0, 0], output: [0] },
        { input: [0, 1], output: [1] },
        { input: [1, 0], output: [1] },
        { input: [1, 1], output: [0] },
    ]);
    return net.run(input);
}

function main() {
    Log(__threadJoin(__Thread([ml, [1, 0]], [HttpQuery("https://unpkg.com/brain.js")])))
}

__threadPeekMessage


在编写程序时需要注意线程死锁问题。以下例子为创建的并发线程的执行函数```testFunc```和主线程的```main```函数通信,线程执行函数```testFunc```会先执行完成。

```js
function testFunc() {
    for(var i = 0 ; i < 5 ; i++) {                // 0 ~ 5 ,向主线程发送5次之后该线程函数执行完成,main函数中__threadPeekMessage函数把所有数据取完,不会再阻塞,立即返回空值
        __threadPostMessage(0, i)                 // 发送数据到主线程
        var msg = __threadPeekMessage(0, -1)      // 监听来自主线程的数据
        Log("from main msg:", msg)
        Sleep(500)
    }
    Log("testFunc执行完毕")
}

function main() {
    var testThread = __Thread(testFunc)           // 创建线程,Id为1 
    
    for (var i = 0 ; i < 10 ; i++) {
        __threadPostMessage(1, i)                 // 发送数据到Id为1的线程,即本例中执行testFunc函数的线程
        var msg = __threadPeekMessage(1, -1)      // 监听Id为1的线程发送来的数据,即本例中执行testFunc函数的线程发送来的数据
        Log("from testFunc msg:", msg)
        Sleep(500)
    }
}

__threadPostMessage


当一个线程的执行函数中调用```__threadPostMessage```函数发出信号、数据时,也会产生消息事件。可以用```EventLoop()```函数收到消息通知。

```js
function testFunc() {
    for(var i = 0 ; i < 10 ; i++) {
        Log("post msg, i:", i)
        __threadPostMessage(0, {msg: "testFunc", i: i})
        Sleep(100)
    }
}

function main() {
    var testThread = __Thread(testFunc)
    
    for (var i = 0 ; i < 10 ; i++) {
        var e = EventLoop()
        Log("e:", e)
        // e: {"Seq":1,"Event":"thread","Index":1,"Nano":1677745512064773600,"Deleted":0,"Symbol":"","Ticker":{"Info":null,"High":0,"Low":0,"Sell":0,"Buy":0,"Last":0,"Volume":0,"OpenInterest":0,"Time":0}}
        if (e.Event == "thread") {
            var msg = __threadPeekMessage(testThread, -1)
            Log("msg:", msg, "#FF0000")
        }
        Sleep(500)
    }
    
    var retThreadJoin = __threadJoin(testThread)
    Log("retThreadJoin:", retThreadJoin)
}

__threadJoin


返回值结构例如:

{ “id”:1, // 线程Id “terminated”:false, // 线程是否被强制结束 “elapsed”:2504742813, // 线程的运行时间(纳秒) “ret”: 123 // 线程函数的返回值 }


#### \_\_threadTerminate

```__threadTerminate```函数用于强制结束线程,释放创建线程使用的硬件资源(无法再使用__threadJoin等待结束)。参数```threadId```为```__Thread()```函数返回的Id。返回值:布尔值,表示执行结果。

```js
function testFunc() {
    for(var i = 0 ; i < 10 ; i++) {
        Log("i:", i)
        Sleep(500)
    }
}

function main() {
    var testThread = __Thread(testFunc)
    
    var retThreadTerminate = null 
    for (var i = 0 ; i < 10 ; i++) {
        Log("main i:", i)
        if (i == 5) {
            retThreadTerminate = __threadTerminate(testThread)
        }
        Sleep(500)
    }
    
    Log("retThreadTerminate:", retThreadTerminate)
}

__threadGetData


```threadId```是0表示主线程(即```main```函数所在的线程),可以使用```__threadId()```函数获取当前线程的Id,设置参数```threadId```为当前线程Id,用于在线程执行函数中读取当前线程储存的变量。也可以读取指定Id的线程环境中的变量。

```js
function main() {
    var t1 = __Thread(function() {
        Sleep(2000)
        var id = __threadId()                                                   // 获取当前线程的Id
        Log("id:", id, ", in testThread1 print:", __threadGetData(id, "msg"))   // 读取当前线程中的键名为msg对应的键值,即"testThread2"
        Log("id:", 2, ", in testThread1 print:", __threadGetData(2, "msg"))     // 读取线程Id为2的线程中的键名为msg对应的键值,即99
    })

    var t2 = __Thread(function(t) {
        __threadSetData(t, "msg", "testThread2")                                // 向Id为t1(Id为1)的线程设置键值对,键名msg,键值为字符串"testThread2"
        __threadSetData(__threadId(), "msg", 99)                                // 在当前线程(Id为2)设置键值对,键名msg,键值为数值99
        __threadSetData(0, "msg", 100)                                          // 在主线程设置键值对,键名msg,键值为数值100
    }, t1)
    
    __threadJoin(t1)   // 可以查看__threadJoin(threadId, timeout)函数,用于等待线程执行结束
    Log("in main, get msg:", __threadGetData(0, "msg"))
}

__threadSetData


```threadId```是0表示主线程(即```main```函数所在的线程),可以使用```__threadId()```函数获取当前线程的Id。```value```不指定表示删除```key```。支持线程之间相互访问共享变量,数据在线程没有被执行```__threadJoin```函数(等待退出成功)并且没有被执行```__threadTerminate```函数(强制终止线程)的情况下有效。参数```value```的值必须是可序列化的变量。

```js
function testFunc() {
    var id = __threadId()                  // 获取当前线程Id
    __threadSetData(id, "testFunc", 100)   // 储存在当前线程环境
    __threadSetData(0, "testFunc", 99)     // 储存在主线程环境
    Log("testFunc执行完毕")
}

function main() {
    // threadId为1 ,创建的threadId为1的线程会先执行完,只要线程资源没有被回收,线程本地储存的变量就有效
    var testThread = __Thread(testFunc)
    
    Sleep(1000)

    // 输出 in main, get testFunc: 100
    Log("in main, get testFunc:", __threadGetData(testThread, "testFunc"))

    // 输出 in main, get testFunc: 99
    Log("in main, get testFunc:", __threadGetData(0, "testFunc"))

    // 删除Id为testThread的线程环境中的testFunc键值对
    __threadSetData(testThread, "testFunc")

    // 删除之后,再次读取,__threadGetData函数返回undefined
    Log("in main, get testFunc:", __threadGetData(testThread, "testFunc"))
}

__threadId


```js
function testFunc() {
    Log("in testFunc, __threadId():", __threadId())
}

function main() {
    __Thread(testFunc)

    // 如果主线程执行完成,创建的子线程会停止执行,所以这里Sleep(1000),等待1秒
    Sleep(1000)
    Log("in main, __threadId():", __threadId())
}

支持wasm编码

JavaScript语言的策略中,可以载入wasm文件的hex编码,并且实例化,执行其中的代码。相较于执行JavaScript代码具有一定速度优势。

wasm.parseModule


例如可以将以下c++函数代码编译为wasm代码,再转换为hex字符串,用作```wasm.parseModule(data)```函数的```data```参数。

```cpp
// 斐波纳契数字的递归算法
int fib(int f) {
    if (f < 2) return f;
    return fib(f - 1) + fib(f - 2);   
}

wasm.buildInstance


```opt```参数设置例子:

{ stack_size: 65*1024*1024, }


#### callFunction

```callFunction(funcName, param1, ...)```,该函数是wasm模型实例的一个方法,用于执行wasm模型实例中的函数。```funcName```参数为需要执行的函数名,```param1```参数为执行函数(由参数```funcName```指定)时传入的参数。



# **指标函数**
**调用指标函数时需要加上```TA.```或者```talib.```前缀**

```talib```库、```TA```库指标函数调用例子:
```js
function main(){
    // 鉴于测试代码,不使用商品期货策略一般架构,这里仅仅判断exchange.IO("status")函数,判断连接期货公司前置机成功后立即执行测试代码。股票证券无需使用exchange.IO("status")判断连接状态
    while(true) {
        if (exchange.IO("status")) {
            exchange.SetContractType("rb888")
            var records = exchange.GetRecords()
            // K线需要有足够长度才可以计算指标数据
            if (records && records.length > 100) {
                break
            }
        }
        Sleep(1000)
    }

    var r = exchange.GetRecords()
    var macd = TA.MACD(r)
    var atr = TA.ATR(r, 14)

    // 打印出最后一组指标值
    Log(macd[0][r.length-1], macd[1][r.length-1], macd[2][r.length-1])
    Log(atr[atr.length-1])

    // 打印所有指标数据,在优宽量化交易平台上,JavaScript语言的策略已经集成了talib库
    Log(talib.MACD(r))
    Log(talib.MACD(r, 12, 26, 9))
    Log(talib.OBV(r))

    // talib库的指标函数也可以传入数值数组,依次传入即可。如: OBV(Records[Close], Records[Volume]),需要Close,Volume两个数组参数
    Log(talib.OBV([1,2,3], [7.1, 6.2, 3, 3]))

    // 也可以直接传入包含Close,Volume属性的records数组
    Log(talib.OBV(r))
    Log(TA.Highest(r, 30, 'High'))
    Log(TA.Highest([1,2,3,4], 0))
}
# Python需要单独安装talib库
import talib
def main():
    while True:
        if exchange.IO("status"):
            exchange.SetContractType("rb888")
            records = exchange.GetRecords()
            # records 为 None、空数组[] 判断均为假
            if records and len(records) > 100:
                break
        Sleep(1000)

    r = exchange.GetRecords()
    macd = TA.MACD(r)
    atr = TA.ATR(r, 14)
    Log(macd[0][-1], macd[1][-1], macd[2][-1])
    Log(atr[-1])

    # 针对Python,系统扩展了GetRecords返回的数组的属性,增加了Open,High,Low,Close,Volume方便talib库函数调用
    Log(talib.MACD(r.Close))
    Log(talib.MACD(r.Close, 12, 26, 9))
    Log(talib.OBV(r.Close, r.Volume))

    Log(TA.Highest(r, 30, "High"))
    Log(TA.Highest([1, 2, 3, 4], 0))
void main() {
    while (true) {
        if (exchange.IO("status") != 0) {
            exchange.SetContractType("rb888");
            auto records = exchange.GetRecords();
            if (records.Valid && records.size() > 100) {
                break;
            }
        }
        Sleep(1000);
    }

    auto r = exchange.GetRecords();
    auto macd = TA.MACD(r);
    auto atr = TA.ATR(r, 14);
    Log(macd[0][macd[0].size() - 1], macd[1][macd[1].size() - 1], macd[2][macd[2].size() - 1]);
    Log(atr[atr.size() - 1]);

    Log(talib.MACD(r));
    Log(talib.MACD(r, 12, 26, 9));
    Log(talib.OBV(r));

    Log(TA.Highest(r.Close(), 30));
}

以下参数中的数据均为exchange.GetRecords(Period)函数获取的数据。 注意records的长度,当数据长度不足指标函数的参数计算要求时将返回无效值。

TA-常用指标库

优宽量化的TA指标库,优化了常用指标算法。支持JavaScriptPythonC++语言的策略调用,开源TA库代码。 以下测试例子除特殊例子以外,均不考虑K线长度是否足够,默认为K线数据有足够的线柱数量。设计策略中,计算指标时需要考虑K线长度是否满足指标参数。

MACD,指数平滑异同平均线


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

    // 可以填入不同k线周期,比如PERIOD_M1,PERIOD_M30,PERIOD_H1......
    var records = exchange.GetRecords(PERIOD_M15)
    var macd = TA.MACD(records, 12, 26, 9)
    // 观看日志可得知返回三个数组,分别对应DIF,DEA,MACD
    Log("DIF:", macd[0], "DEA:", macd[1], "MACD:", macd[2])
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    r = exchange.GetRecords(PERIOD_M15)
    macd = TA.MACD(r, 12, 26, 9)
    Log("DIF:", macd[0], "DEA:", macd[1], "MACD:", macd[2])
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto r = exchange.GetRecords(PERIOD_M15);
    auto macd = TA.MACD(r, 12, 26, 9);
    Log("DIF:", macd[0], "DEA:", macd[1], "MACD:", macd[2]);
}

KDJ,随机指标


```js
function main(){
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    exchange.SetContractType("rb888")

    var records = exchange.GetRecords(PERIOD_M15)
    var kdj = TA.KDJ(records, 9, 3, 3)
    Log("k:", kdj[0], "d:", kdj[1], "j:", kdj[2])
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    r = exchange.GetRecords(PERIOD_M15)
    kdj = TA.KDJ(r, 9, 3, 3)
    Log("k:", kdj[0], "d:", kdj[1], "j:", kdj[2])
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto r = exchange.GetRecords();
    auto kdj = TA.KDJ(r, 9, 3, 3);
    Log("k:", kdj[0], "d:", kdj[1], "j:", kdj[2]);
}

RSI,强弱指标


```js
function main(){
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    exchange.SetContractType("rb888")

    var records = exchange.GetRecords(PERIOD_M30)
    var rsi = TA.RSI(records, 14)
    Log(rsi)
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    r = exchange.GetRecords(PERIOD_M30)
    rsi = TA.RSI(r, 14)
    Log(rsi)
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto r = exchange.GetRecords(PERIOD_M30);
    auto rsi = TA.RSI(r, 14);
    Log(rsi); 
}

ATR,平均真实波幅


```js
function main(){
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    exchange.SetContractType("rb888")

    var records = exchange.GetRecords(PERIOD_M30)
    var atr = TA.ATR(records, 14)
    Log(atr)
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    r = exchange.GetRecords(PERIOD_M30)
    atr = TA.ATR(r, 14)
    Log(atr)
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto r = exchange.GetRecords(PERIOD_M30);
    auto atr = TA.ATR(r, 14);
    Log(atr);
}

OBV,能量潮


```js
function main(){
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    exchange.SetContractType("rb888")

    var records = exchange.GetRecords(PERIOD_M30)
    var obv = TA.OBV(records)
    Log(obv)
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    r = exchange.GetRecords(PERIOD_M30)
    obv = TA.OBV(r)
    Log(obv)
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto r = exchange.GetRecords(PERIOD_M30);
    auto obv = TA.OBV(r);
    Log(obv);
}

MA,移动平均线


```js
function main(){
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    exchange.SetContractType("rb888")

    var records = exchange.GetRecords(PERIOD_M30)
    var ma = TA.MA(records, 14)
    Log(ma)
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    r = exchange.GetRecords(PERIOD_M30)
    ma = TA.MA(r, 14)
    Log(ma)
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto r = exchange.GetRecords(PERIOD_M30);
    auto ma = TA.MA(r, 14);
    Log(ma);
}

EMA,指数平均数指标


```js
function main(){
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    exchange.SetContractType("rb888")

    var records = exchange.GetRecords()
    // 判断K线bar数量是否满足指标计算周期
    if (records && records.length > 9) {
        var ema = TA.EMA(records, 9)          
        Log(ema)
    }
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    r = exchange.GetRecords()
    if r and len(r) > 9:
        ema = TA.EMA(r, 9)
        Log(ema)
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto r = exchange.GetRecords();
    if(r.Valid && r.size() > 9) {
        auto ema = TA.EMA(r, 9);
        Log(ema);
    }
}

BOLL,布林带


```js
function main() {
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    exchange.SetContractType("rb888")

    var records = exchange.GetRecords()
    if(records && records.length > 20) {
        var boll = TA.BOLL(records, 20, 2)
        var upLine = boll[0]
        var midLine = boll[1]
        var downLine = boll[2]
        Log(upLine)
        Log(midLine)
        Log(downLine)
    }
}
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    r = exchange.GetRecords()
    if r and len(r) > 20:
        boll = TA.BOLL(r, 20, 2)
        upLine = boll[0]
        midLine = boll[1]
        downLine = boll[2]
        Log(upLine)
        Log(midLine)
        Log(downLine)
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto r = exchange.GetRecords();
    if(r.Valid && r.size() > 20) {
        auto boll = TA.BOLL(r, 20, 2);
        auto upLine = boll[0];
        auto midLine = boll[1];
        auto downLine = boll[2];
        Log(upLine);
        Log(midLine);
        Log(downLine);
    }
}

Alligator,Alligator Indicator


### CMF,Chaikin Money Flow

```TA.CMF(数据, 周期)```,蔡金货币流量指标,CMF(数据, 周期),默认周期参数为20,返回一个一维数组。

### Highest,周期最高价

```TA.Highest(数据, 周期, 属性)```,返回最近周期内的最大值(不包含当前Bar),如```TA.Highest(records, 30, 'High')```,如果```周期```为0指所有Bar,如```属性```不指定则视数据为普通数组,返回一个价格(数值类型)。

### Lowest,周期最低价

```TA.Lowest(数据, 周期, 属性)```,返回最近周期内的最小值(不包含当前Bar),如```TA.Lowest(records, 30, 'Low')```,如果```周期```为0指所有Bar,如```属性```不指定则视数据为普通数组,返回一个价格(数值类型)。

```C++```策略中```TA.Highest(...)```、```TA.Lowest(...)```的使用需注意,```Highest```、```Lowest```函数各自只有2个参数,并且第一个参数传入的不是```auto r = exchange.GetRecords()```函数返回值。需要调用```r```的方法传入具体属性数据,例如:传入```r.Close()```收盘价数据。```Close```、```High```、```Low```、```Open```、```Volume```如同```r.Close()```调用方式。

```C++```范例:
```c++
void main() {
    // 构造的K线数据,并非接口返回的数据 
    Records r;
    r.Valid = true;
    for (auto i = 0; i < 10; i++) {
        Record ele;
        ele.Time = i * 100000;
        ele.High = i * 10000;
        ele.Low = i * 1000;
        ele.Close = i * 100;
        ele.Open = i * 10;
        ele.Volume = i * 1;
        r.push_back(ele);
    }

    for(int j = 0; j < r.size(); j++){
        Log(r[j]);
    }

    // 注意:第一个参数传入的不是r,需要调用r.Close()
    auto highest = TA.Highest(r.Close(), 8);   
    Log(highest);                     
}

附带的第三方库

JavaScript

C++

例子

  • JavaScripthttp://mathjs.org/
    
    function main() {
      Log(math.round(math.e, 3))                // 2.718
      Log(math.atan2(3, -3) / math.pi)          // 0.75
      Log(math.log(10000, 10))                  // 4
      Log(math.sqrt(-4))                        // {"mathjs":"Complex","re":0,"im":2}   
    }
    

http://mikemcl.github.io/decimal.js/

  function main() {
      var x = -1.2
      var a = Decimal.abs(x)
      var b = new Decimal(x).abs()
      Log(a.equals(b))                           // true  

      var y = 2.2
      var sum = Decimal.add(x, y)
      Log(sum.equals(new Decimal(x).plus(y)))    // true    
  }

http://underscorejs.org/

  function main() {
      var sum = _.reduce([1, 2, 3], function(memo, num){return memo + num}, 0)
      Log(sum)
  }
  • [https://nlohmann.github.io/json/](https://nlohmann.github.io/json/)
    ```cpp
    void main() {
      json table = R"({"type": "table", "title": "持仓信息", "cols": ["列1", "列2"], "rows": [["abc", "def"], ["ABC", "support color #ff0000"]]})"_json;
      LogStatus("`" + table.dump() + "`");
      LogStatus("第一行消息\n`" + table.dump() + "`\n第三行消息");
      json arr = R"([])"_json;
      arr.push_back(table);
      arr.push_back(table);
      LogStatus("`" + arr.dump() + "`");
    
    
      table = R"({
          "type" : "table", 
          "title" : "持仓操作", 
          "cols" : ["列1", "列2", "Action"], 
          "rows" : [
              ["abc", "def", {"type": "button", "cmd": "coverAll", "name": "平仓"}]
          ] 
      })"_json;
      LogStatus("`" + table.dump() + "`", "\n`" + R"({"type": "button", "cmd": "coverAll", "name": "平仓"})"_json.dump() + "`");
    }
    

talib库里面的函数指标

以下函数的参数中Records[Close]代表传入的k线数据中的收盘价,Array()代表数组,Array(outInteger)代表返回的是整型数据数组。

```js
function main() {
    while(!exchange.IO("status")) {
        Sleep(1000)
    }
    exchange.SetContractType("rb888")

    var records = exchange.GetRecords()
    var cci = talib.CCI(records, 14)
    Log(cci)
}
import talib
def main():
    while not exchange.IO("status"):
        Sleep(1000)
    exchange.SetContractType("rb888")

    records = exchange.GetRecords()
    # 14这个参数可以缺省
    cci = talib.CCI(records.High, records.Low, records.Close, 14)   
    Log(cci)
void main() {
    while(exchange.IO("status") == 0) {
        Sleep(1000);
    }
    exchange.SetContractType("rb888");

    auto records = exchange.GetRecords();
    auto cci = talib.CCI(records, 14);
    Log(cci);
}
  • Pattern Recognition模式识别:

|指标|描述| |:-|:-| |CDL2CROWS|Two Crows (K线图–两只乌鸦)| ||CDL2CROWS(Records[Open,High,Low,Close]) = Array(outInteger)| |CDL3BLACKCROWS|Three Black Crows (K线图–3只黑乌鸦)| ||CDL3BLACKCROWS(Records[Open,High,Low,Close]) = Array(outInteger)| |CDL3INSIDE|Three Inside Up/Down (K线图:3内上下震荡)| ||CDL3INSIDE(Records[Open,High,Low,Close]) = Array(outInteger)| |CDL3LINESTRIKE|Three-Line Strike (K线图:3线震荡)| ||CDL3LINESTRIKE(Records[Open,High,Low,Close]) = Array(outInteger)| |CDL3OUTSIDE|Three Outside Up/Down (K线图:3外下震荡)| ||CDL3OUTSIDE(Records[Open,High,Low,Close]) = Array(outInteger)| |CDL3STARSINSOUTH|Three Stars In The South (K线图:南方三星)| ||CDL3STARSINSOUTH(Records[Open,High,Low,Close]) = Array(outInteger)| |CDL3WHITESOLDIERS|Three Advancing White Soldiers (K线图:三白兵)| ||CDL3WHITESOLDIERS(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLABANDONEDBABY|Abandoned Baby (K线图:弃婴)| ||CDLABANDONEDBABY(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger)| |CDLADVANCEBLOCK|Advance Block (K线图:推进)| ||CDLADVANCEBLOCK(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLBELTHOLD|Belt-hold (K线图:带住)| ||CDLBELTHOLD(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLBREAKAWAY|Breakaway (K线图:分离)| ||CDLBREAKAWAY(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLCLOSINGMARUBOZU|Closing Marubozu (K线图:收盘光头光脚)| ||CDLCLOSINGMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLCONCEALBABYSWALL|Concealing Baby Swallow (K线图:藏婴吞没形态)| ||CDLCONCEALBABYSWALL(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLCOUNTERATTACK|Counterattack (K线图:反击)| ||CDLCOUNTERATTACK(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLDARKCLOUDCOVER|Dark Cloud Cover (K线图:乌云盖)| ||CDLDARKCLOUDCOVER(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger)| |CDLDOJI|Doji (K线图:十字星 )| ||CDLDOJI(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLDOJISTAR|Doji Star (K线图:十字星)| ||CDLDOJISTAR(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLDRAGONFLYDOJI|Dragonfly Doji (K线图:蜻蜓十字星)| ||CDLDRAGONFLYDOJI(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLENGULFING|Engulfing Pattern (K线图:吞没)| ||CDLENGULFING(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLEVENINGDOJISTAR|Evening Doji Star (K线图:黄昏十字星)| ||CDLEVENINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger)| |CDLEVENINGSTAR|Evening Star (K线图:黄昏之星)| ||CDLEVENINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger)| |CDLGAPSIDESIDEWHITE|Up/Down-gap side-by-side white lines (K线图:上/下间隙并排的白色线条)| ||CDLGAPSIDESIDEWHITE(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLGRAVESTONEDOJI|Gravestone Doji (K线图:墓碑十字线)| ||CDLGRAVESTONEDOJI(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLHAMMER|Hammer (K线图:锤)| ||CDLHAMMER(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLHANGINGMAN|Hanging Man (K线图:吊人)| ||CDLHANGINGMAN(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLHARAMI|Harami Pattern (K线图:阴阳线)| ||CDLHARAMI(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLHARAMICROSS|Harami Cross Pattern (K线图:交叉阴阳线)| ||CDLHARAMICROSS(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLHIGHWAVE|High-Wave Candle (K线图:长脚十字线 )| ||CDLHIGHWAVE(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLHIKKAKE|Hikkake Pattern (K线图:陷阱)| ||CDLHIKKAKE(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLHIKKAKEMOD|Modified Hikkake Pattern (K线图:改良的陷阱)| ||CDLHIKKAKEMOD(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLHOMINGPIGEON|Homing Pigeon (K线图:信鸽)| ||CDLHOMINGPIGEON(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLIDENTICAL3CROWS|Identical Three Crows (K线图:相同的三只乌鸦)| ||CDLIDENTICAL3CROWS(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLINNECK|In-Neck Pattern (K线图:颈纹)| ||CDLINNECK(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLINVERTEDHAMMER|Inverted Hammer (K线图:倒锤)| ||CDLINVERTEDHAMMER(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLKICKING|Kicking (K线图:踢)| ||CDLKICKING(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLKICKINGBYLENGTH|Kicking - bull/bear determined by the longer marubozu (K线图:踢牛/踢熊)| ||CDLKICKINGBYLENGTH(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLLADDERBOTTOM|Ladder Bottom (K线图:梯底)| ||CDLLADDERBOTTOM(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLLONGLEGGEDDOJI|Long Legged Doji (K线图:长腿十字线)| ||CDLLONGLEGGEDDOJI(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLLONGLINE|Long Line Candle (K线图:长线)| ||CDLLONGLINE(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLMARUBOZU|Marubozu (K线图:光头光脚 )| ||CDLMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLMATCHINGLOW|Matching Low (K线图:匹配低)| ||CDLMATCHINGLOW(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLMATHOLD|Mat Hold (K线图:垫住)| ||CDLMATHOLD(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger)| |CDLMORNINGDOJISTAR|Morning Doji Star (K线图:早晨十字星)| ||CDLMORNINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger)| |CDLMORNINGSTAR|Morning Star (K线图:晨星)| ||CDLMORNINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger)| |CDLONNECK|On-Neck Pattern (K线图:颈型)| ||CDLONNECK(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLPIERCING|Piercing Pattern (K线图:穿孔模式)| ||CDLPIERCING(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLRICKSHAWMAN|Rickshaw Man (K线图:车夫)| ||CDLRICKSHAWMAN(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLRISEFALL3METHODS|Rising/Falling Three Methods (K线图:上升/下降三法)| ||CDLRISEFALL3METHODS(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLSEPARATINGLINES|Separating Lines (K线图:分割线)| ||CDLSEPARATINGLINES(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLSHOOTINGSTAR|Shooting Star (K线图:流星)| ||CDLSHOOTINGSTAR(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLSHORTLINE|Short Line Candle (K线图:短线)| ||CDLSHORTLINE(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLSPINNINGTOP|Spinning Top (K线图:陀螺)| ||CDLSPINNINGTOP(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLSTALLEDPATTERN|Stalled Pattern (K线图:停滞模式)| ||CDLSTALLEDPATTERN(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLSTICKSANDWICH|Stick Sandwich (K线图:棍子三明治)| ||CDLSTICKSANDWICH(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLTAKURI|Takuri (Dragonfly Doji with very long lower shadow) (K线图:托里)| ||CDLTAKURI(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLTASUKIGAP|Tasuki Gap (K线图:翼隙)| ||CDLTASUKIGAP(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLTHRUSTING|Thrusting Pattern (K线图:推模式)| ||CDLTHRUSTING(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLTRISTAR|Tristar Pattern (K线图:三星模式)| ||CDLTRISTAR(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLUNIQUE3RIVER|Unique 3 River (K线图:独特的3河)| ||CDLUNIQUE3RIVER(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLUPSIDEGAP2CROWS|Upside Gap Two Crows (K线图:双飞乌鸦)| ||CDLUPSIDEGAP2CROWS(Records[Open,High,Low,Close]) = Array(outInteger)| |CDLXSIDEGAP3METHODS|Upside/Downside Gap Three Methods (K线图:上行/下行缺口三方法)| ||CDLXSIDEGAP3METHODS(Records[Open,High,Low,Close]) = Array(outInteger)|

  • Volume Indicators量指标:

|指标|描述| |:-|:-| |AD|Chaikin A/D Line (线随机指标)| ||AD(Records[High,Low,Close,Volume]) = Array(outReal)| |ADOSC|Chaikin A/D Oscillator (佳庆指标)| ||ADOSC(Records[High,Low,Close,Volume],Fast Period = 3,Slow Period = 10) = Array(outReal)| |OBV|On Balance Volume (能量潮)| ||OBV(Records[Close],Records[Volume]) = Array(outReal)|

  • Math Transform数学变换:

|指标|描述| |:-|:-| |ACOS|Vector Trigonometric ACos (反余弦函数)| ||ACOS(Records[Close]) = Array(outReal)| |ASIN|Vector Trigonometric ASin (反正弦函数)| ||ASIN(Records[Close]) = Array(outReal)| |ATAN|Vector Trigonometric ATan (反正切函数)| ||ATAN(Records[Close]) = Array(outReal)| |CEIL|Vector Ceil (取整函数)| ||CEIL(Records[Close]) = Array(outReal)| |COS|Vector Trigonometric Cos (余弦函数)| ||COS(Records[Close]) = Array(outReal)| |COSH|Vector Trigonometric Cosh (双曲余弦值)| ||COSH(Records[Close]) = Array(outReal)| |EXP|Vector Arithmetic Exp (指数函数)| ||EXP(Records[Close]) = Array(outReal)| |FLOOR|Vector Floor (向下取整)| ||FLOOR(Records[Close]) = Array(outReal)| |LN|Vector Log Natural (自然对数)| ||LN(Records[Close]) = Array(outReal)| |LOG10|Vector Log10 (对数函数)| ||LOG10(Records[Close]) = Array(outReal)| |SIN|Vector Trigonometric Sin (正弦值)| ||SIN(Records[Close]) = Array(outReal)| |SINH|Vector Trigonometric Sinh (双曲正弦函数)| ||SINH(Records[Close]) = Array(outReal)| |SQRT|Vector Square Root (平方根)| ||SQRT(Records[Close]) = Array(outReal)| |TAN|Vector Trigonometric Tan (正切)| ||TAN(Records[Close]) = Array(outReal)| |TANH|Vector Trigonometric Tanh (双曲正切函数)| ||TANH(Records[Close]) = Array(outReal)|

  • Math Operators数学运算符:

|指标|描述| |:-|:-| |MAX|Highest value over a specified period (最大值)| ||MAX(Records[Close],Time Period = 30) = Array(outReal)| |MAXINDEX|Index of highest value over a specified period (最大值索引)| ||MAXINDEX(Records[Close],Time Period = 30) = Array(outInteger)| |MIN|Lowest value over a specified period (最小值)| ||MIN(Records[Close],Time Period = 30) = Array(outReal)| |MININDEX|Index of lowest value over a specified period (最小值索引)| ||MININDEX(Records[Close],Time Period = 30) = Array(outInteger)| |MINMAX|Lowest and highest values over a specified period (最小最大值)| ||MINMAX(Records[Close],Time Period = 30) = [Array(outMin),Array(outMax)]| |MINMAXINDEX|Indexes of lowest and highest values over a specified period (最小最大值索引)| ||MINMAXINDEX(Records[Close],Time Period = 30) = [Array(outMinIdx),Array(outMaxIdx)]| |SUM|Summation (求和)| ||SUM(Records[Close],Time Period = 30) = Array(outReal)|

  • Cycle Indicators循环指标:

|指标|描述| |:-|:-| |HT_DCPERIOD|Hilbert Transform - Dominant Cycle Period (希尔伯特变换, 主周期)| ||HT_DCPERIOD(Records[Close]) = Array(outReal)| |HT_DCPHASE|Hilbert Transform - Dominant Cycle Phase (希尔伯特变换,主阶段)| ||HT_DCPHASE(Records[Close]) = Array(outReal)| |HT_PHASOR|Hilbert Transform - Phasor Components (希尔伯特变换,相成分)| ||HT_PHASOR(Records[Close]) = [Array(outInPhase),Array(outQuadrature)]| |HT_SINE|Hilbert Transform - SineWave (希尔伯特变换,正弦波)| ||HT_SINE(Records[Close]) = [Array(outSine),Array(outLeadSine)]| |HT_TRENDMODE|Hilbert Transform - Trend vs Cycle Mode (希尔伯特变换-趋势与周期模式)| ||HT_TRENDMODE(Records[Close]) = Array(outInteger)|

  • Volatility Indicators波动性指标:

|指标|描述| |:-|:-| |ATR|Average True Range (平均真实波幅)| ||ATR(Records[High,Low,Close],Time Period = 14) = Array(outReal)| |NATR|Normalized Average True Range (归一化平均值范围)| ||NATR(Records[High,Low,Close],Time Period = 14) = Array(outReal)| |TRANGE|True Range (真实范围)| ||TRANGE(Records[High,Low,Close]) = Array(outReal)|

  • Overlap Studies重叠的研究:

|指标|描述| |:-|:-| |BBANDS|Bollinger Bands (布林带)| ||BBANDS(Records[Close],Time Period = 5,Deviations up = 2,Deviations down = 2,MA Type = 0) = [Array(outRealUpperBand),Array(outRealMiddleBand),Array(outRealLowerBand)]| |DEMA|Double Exponential Moving Average (双指数移动平均线)| ||DEMA(Records[Close],Time Period = 30) = Array(outReal)| |EMA|Exponential Moving Average (指数移动平均线)| ||EMA(Records[Close],Time Period = 30) = Array(outReal)| |HT_TRENDLINE|Hilbert Transform - Instantaneous Trendline (希尔伯特变换,瞬时趋势)| ||HT_TRENDLINE(Records[Close]) = Array(outReal)| |KAMA|Kaufman Adaptive Moving Average (适应性移动平均线)| ||KAMA(Records[Close],Time Period = 30) = Array(outReal)| |MA|Moving average (移动平均线)| ||MA(Records[Close],Time Period = 30,MA Type = 0) = Array(outReal)| |MAMA|MESA Adaptive Moving Average (MESA 移动平均线)| ||MAMA(Records[Close],Fast Limit = 0.5,Slow Limit = 0.05) = [Array(outMAMA),Array(outFAMA)]| |MIDPOINT|MidPoint over period (中点)| ||MIDPOINT(Records[Close],Time Period = 14) = Array(outReal)| |MIDPRICE|Midpoint Price over period (中点价格)| ||MIDPRICE(Records[High,Low],Time Period = 14) = Array(outReal)| |SAR|Parabolic SAR (抛物线转向)| ||SAR(Records[High,Low],Acceleration Factor = 0.02,AF Maximum = 0.2) = Array(outReal)| |SAREXT|Parabolic SAR - Extended (增强型抛物线转向)| ||SAREXT(Records[High,Low],Start Value = 0,Offset on Reverse = 0,AF Init Long = 0.02,AF Long = 0.02,AF Max Long = 0.2,AF Init Short = 0.02,AF Short = 0.02,AF Max Short = 0.2) = Array(outReal)| |SMA|Simple Moving Average (简单移动平均)| ||SMA(Records[Close],Time Period = 30) = Array(outReal)| |T3|Triple Exponential Moving Average (T3) (三指数移动平均)| ||T3(Records[Close],Time Period = 5,Volume Factor = 0.7) = Array(outReal)| |TEMA|Triple Exponential Moving Average (三指数移动平均)| ||TEMA(Records[Close],Time Period = 30) = Array(outReal)| |TRIMA|Triangular Moving Average (三指数移动平均)| ||TRIMA(Records[Close],Time Period = 30) = Array(outReal)| |WMA|Weighted Moving Average (加权移动平均)| ||WMA(Records[Close],Time Period = 30) = Array(outReal)|

  • Statistic Functions统计功能:

|指标|描述| |:-|:-| |LINEARREG|Linear Regression (线性回归)| ||LINEARREG(Records[Close],Time Period = 14) = Array(outReal)| |LINEARREG_ANGLE|Linear Regression Angle (线性回归的角度)| ||LINEARREG_ANGLE(Records[Close],Time Period = 14) = Array(outReal)| |LINEARREG_INTERCEPT|Linear Regression Intercept (线性回归截距)| ||LINEARREG_INTERCEPT(Records[Close],Time Period = 14) = Array(outReal)| |LINEARREG_SLOPE|Linear Regression Slope (线性回归斜率)| ||LINEARREG_SLOPE(Records[Close],Time Period = 14) = Array(outReal)| |STDDEV|Standard Deviation (标准偏差)| ||STDDEV(Records[Close],Time Period = 5,Deviations = 1) = Array(outReal)| |TSF|Time Series Forecast (时间序列预测)| ||TSF(Records[Close],Time Period = 14) = Array(outReal)| |VAR|Variance (方差)| ||VAR(Records[Close],Time Period = 5,Deviations = 1) = Array(outReal)|

  • Momentum Indicators动量指标:

|指标|描述| |:-|:-| |ADX|Average Directional Movement Index (平均趋向指数)| ||ADX(Records[High,Low,Close],Time Period = 14) = Array(outReal)| |ADXR|Average Directional Movement Index Rating (评估指数)| ||ADXR(Records[High,Low,Close],Time Period = 14) = Array(outReal)| |APO|Absolute Price Oscillator (绝对价格振荡指数)| ||APO(Records[Close],Fast Period = 12,Slow Period = 26,MA Type = 0) = Array(outReal)| |AROON|Aroon (阿隆指标)| ||AROON(Records[High,Low],Time Period = 14) = [Array(outAroonDown),Array(outAroonUp)]| |AROONOSC|Aroon Oscillator (阿隆震荡线)| ||AROONOSC(Records[High,Low],Time Period = 14) = Array(outReal)| |BOP|Balance Of Power (均势指标)| ||BOP(Records[Open,High,Low,Close]) = Array(outReal)| |CCI|Commodity Channel Index (顺势指标)| ||CCI(Records[High,Low,Close],Time Period = 14) = Array(outReal)| |CMO|Chande Momentum Oscillator (钱德动量摆动指标)| ||CMO(Records[Close],Time Period = 14) = Array(outReal)| |DX|Directional Movement Index (动向指数)| ||DX(Records[High,Low,Close],Time Period = 14) = Array(outReal)| |MACD|Moving Average Convergence/Divergence (指数平滑移动平均线)| ||MACD(Records[Close],Fast Period = 12,Slow Period = 26,Signal Period = 9) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)]| |MACDEXT|MACD with controllable MA type (MA型可控 MACD)| ||MACDEXT(Records[Close],Fast Period = 12,Fast MA = 0,Slow Period = 26,Slow MA = 0,Signal Period = 9,Signal MA = 0) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)]| |MACDFIX|Moving Average Convergence/Divergence Fix 1226 (移动平均收敛/发散修复12/26)| ||MACDFIX(Records[Close],Signal Period = 9) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)]| |MFI|Money Flow Index (货币流量指数)| ||MFI(Records[High,Low,Close,Volume],Time Period = 14) = Array(outReal)| |MINUS_DI|Minus Directional Indicator (负向指标)| ||MINUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal)| |MINUS_DM|Minus Directional Movement (负向运动)| ||MINUS_DM(Records[High,Low],Time Period = 14) = Array(outReal)| |MOM|Momentum (动量)| ||MOM(Records[Close],Time Period = 10) = Array(outReal)| |PLUS_DI|Plus Directional Indicator (更向指示器)| ||PLUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal)| |PLUS_DM|Plus Directional Movement (定向运动)| ||PLUS_DM(Records[High,Low],Time Period = 14) = Array(outReal)| |PPO|Percentage Price Oscillator (价格振荡百分比)| ||PPO(Records[Close],Fast Period = 12,Slow Period = 26,MA Type = 0) = Array(outReal)| |ROC|Rate of change : ((price/prevPrice)-1)*100 (变动率指标)| ||ROC(Records[Close],Time Period = 10) = Array(outReal)| |ROCP|Rate of change Percentage: (price-prevPrice)/prevPrice (价格变化率)| ||ROCP(Records[Close],Time Period = 10) = Array(outReal)| |ROCR|Rate of change ratio: (price/prevPrice) (价格变化率)| ||ROCR(Records[Close],Time Period = 10) = Array(outReal)| |ROCR100|Rate of change ratio 100 scale: (price/prevPrice)*100 (价格变化率)| ||ROCR100(Records[Close],Time Period = 10) = Array(outReal)| |RSI|Relative Strength Index (相对强弱指标)| ||RSI(Records[Close],Time Period = 14) = Array(outReal)| |STOCH|Stochastic (STOCH指标)| ||STOCH(Records[High,Low,Close],Fast-K Period = 5,Slow-K Period = 3,Slow-K MA = 0,Slow-D Period = 3,Slow-D MA = 0) = [Array(outSlowK),Array(outSlowD)]| |STOCHF|Stochastic Fast (快速STOCH指标)| ||STOCHF(Records[High,Low,Close],Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = [Array(outFastK),Array(outFastD)]| |STOCHRSI|Stochastic Relative Strength Index (随机强弱指数)| ||STOCHRSI(Records[Close],Time Period = 14,Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = [Array(outFastK),Array(outFastD)]| |TRIX|1-day Rate-Of-Change (ROC) of a Triple Smooth EMA (三重指数平滑平均线)| ||TRIX(Records[Close],Time Period = 30) = Array(outReal)| |ULTOSC|Ultimate Oscillator (极限振子)| ||ULTOSC(Records[High,Low,Close],First Period = 7,Second Period = 14,Third Period = 28) = Array(outReal)| |WILLR|Williams’ %R (威廉指标)| ||WILLR(Records[High,Low,Close],Time Period = 14) = Array(outReal)|

  • Price Transform价格指标:

|指标|描述| |:-|:-| |AVGPRICE|Average Price (平均价格)| ||AVGPRICE(Records[Open,High,Low,Close]) = Array(outReal)| |MEDPRICE|Median Price (中位数价格)| ||MEDPRICE(Records[High,Low]) = Array(outReal)| |TYPPRICE|Typical Price (典型价格)| ||TYPPRICE(Records[High,Low,Close]) = Array(outReal)| |WCLPRICE|Weighted Close Price (加权收盘价)| ||WCLPRICE(Records[High,Low,Close]) = Array(outReal)|

基本面数据

优宽量化交易平台支持回测、实盘时查询各项基本面数据。基本面数据由优宽量化交易平台数据中心实时提供,优宽量化交易平台数据中心会持续收集、汇总各项基本面数据。

数据调用

使用exchange.GetData(Source)函数获取基本面数据。

回测系统测试数据调用,以BCEEI为例:

/*backtest
start: 2020-02-23 00:00:00
end: 2020-05-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
*/

function main() {
    while(true) {
        var ret = exchange.GetData("BCEEI")
        Log(ret)
        Sleep(1000 * 60 * 60 * 24 * 30)
    }
}
'''backtest
start: 2020-02-23 00:00:00
end: 2020-05-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
'''

def main():
    while True:
        ret = exchange.GetData("BCEEI")
        Log(ret)
        Sleep(1000 * 60 * 60 * 24 * 30)
/*backtest
start: 2020-02-23 00:00:00
end: 2020-05-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
*/

void main() {
    while (true) {
        auto ret = exchange.GetData("BCEEI");
        Log(ret);
        Sleep(1000 * 60 * 60 * 24 * 30);
        break;
    }
}

数据格式

名称 代码 名称 代码 名称 代码 名称 代码 名称 代码
基差 BASIS 企业景气及企业家信心指数 BCEEI 交易结算资金(银证转账) BTSF 存款准备金率 CKZBJ 居民消费价格指数 CPI
外商直接投资数据 FDI 外汇和黄金储备 FEGR 国内生产总值 GDP 全国股票交易统计表 GPJYTJ 股票账户统计详细数据 GPZHSJ
货币供应量 HBGYL 海关进出口增减情况一览表 HGJCK 消费者信心指数 ICS 贷款市场报价利率 LRP 新房价指数 NREPI
旧房价指数 OREPI 采购经理人指数 PMI 工业品出厂价格指数 PPI 全国税收收入 QGSSSR 企业商品价格指数 QYSPJG
社会消费品零售总额 TRSCG 城镇固定资产投资 UIFA 期货标准仓单 WHR 本外币存款 WBCK 外汇贷款数据 WHXD
银行利率调整 YHLL 交易所会员成交量及持仓明细 DTP 交易所会员持仓盈亏 FCPP 财政收入 CZSR 工业增加值增长 GYZJZ
汽柴油价格 OILPRICE 现货价格 SPOTPRICE 新增信贷数据 XZXD

基差 代码BASIS

描述: 基差是某一特定商品于某一特定的时间和地点的现货价格与期货价格之差。它的计算方法是现货价格减去期货价格。若现货价格低于期货价格,基差为负值;现货价格高于期货价格,基差为正值。

格式:

{
    "日期": "2016-01-11",
    "螺纹钢": 29,
    "菜籽粕": 54
}

企业景气及企业家信心指数 代码BCEEI

描述: 企业家信心指数也称”宏观经济景气指数”,是根据企业家对企业外部市场经济环境与宏观政策的认识、看法、判断与预期而编制的指数,用以综合反映企业家对宏观经济环境的感受与信心。

格式: “` { “季度”: “2005第1季度”, “企业家信心指数”: { “指数”: 135.9, “同比”


更多内容

henryp1 怎么不显示目录?

雨幕(youquant) 哪个目录 ?