zipline:更改内置因子的输入数据

时间:2019-01-10 01:06:07

标签: zipline back-testing quantopian

我正在尝试在本地环境中使用Zipline API。

我已经成功摄取了自定义的csv数据,并且无需使用Pipeline API即可进行回测。

但是,我迷失了使用Pipeline API时应该如何利用内置因素的原因。

更具体地说,我想在以下示例中更改输入变量。

open class Profile : RealmObject() {

    @PrimaryKey
    var id = ""
    var email = ""
    var firstName = ""
    var lastName = ""
    var dateJoined = 0
    var gender: String? = null
    var birthday: Int? = null // I want to change this to Long?
}

也就是说,我想使用//this prints all sequences that consist of m numbers from 0 to (n - 1), and return the number of them. //for example, if m = 2 and n = 3 then it prints "0 0 / 0 1 / 0 2 / 1 0 / 1 1 / 1 2 / 2 0 / 2 1 / 2 2 / " and return 9. int sequence(int m, int n){ int i[100], j = 0, count = 0; A: if(!(j < m)){ for(int k = 0; k < m; ++k) printf("%d ", i[k]); printf("/ "); ++count; goto C; } i[j] = 0; B: if(i[j] < n){ ++j; goto A; } C: --j; if(j >= 0){ ++i[j]; goto B; } putchar('\n'); return count; } int sequence_substitute(int m, int n){ int i[100], count = 0; for(int j = 0; j < m; ++j) i[j] = 0; for(;;){ int j = m - 1; for(int k = 0; k < m; ++k) printf("%d ", i[k]); printf("/ "); ++count; for(;;){ if(i[j] < n - 1){ ++i[j]; break; }else{ if(j == 0){ putchar('\n'); return count; }else{ i[j] = 0; --j; } } } } } 而不是使用sma_10 = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=10) sma_30 = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=30) 。那有可能吗?如果可以,我应该如何实现呢?

预先感谢

1 个答案:

答案 0 :(得分:0)

这个Quantopian社区问题为问题提供了提示:

https://github.com/quantopian/zipline/issues/911