-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtt21.py
40 lines (35 loc) · 1.41 KB
/
tt21.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# coding=utf8
__author__ = 'wangjp'
import time
import numpy as np
import pandas as pd
from FactorModule.FactorBase import FactorBase
from DataReaderModule.Constants import ALIAS_FIELDS as t
class Factor(FactorBase):
def __init__(self):
super(Factor,self).__init__()
self.neutral = False
self.factorName = __name__.split('.')[-1]
self.needFields = [t.HIGH, t.LOW, t.CLOSE, t.ADJFCT, t.TRDSTAT] # 设置需要的字段
def factor_definition(self):
"""
收集派发指标
:return:
"""
s = time.time()
needData = self.needData # 计算所需数据
adjLow = needData[t.LOW] * needData[t.ADJFCT]
adjHigh = needData[t.HIGH] * needData[t.ADJFCT]
adjClose = needData[t.CLOSE] * needData[t.ADJFCT]
lowLow=self.calculator.Delay(x=adjLow, num=1)
highHigh=self.calculator.Delay(x=adjHigh, num=1)
#preClose = self.calculator.Delay(x=adjClose, num=1)
#distrib = (adjClose >= lowLow)*(adjClose - self.calculator.cmpMin(preClose, adjLow)) + (adjClose < preClose)*(adjClose - self.calculator.cmpMax(preClose, adjHigh))
factor = highHigh/lowLow
print(111111111111,factor)
print('factor {0} done with {1} seconds'.format(self.factorName, time.time() - s))
return factor
def run_factor(self):
self.run()
fct = Factor()
fct.run_factor()