forked from QuantFans/quantdigger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
50 lines (38 loc) · 1.3 KB
/
Copy path__init__.py
File metadata and controls
50 lines (38 loc) · 1.3 KB
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
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf8 -*-
import datetime
from logbook import Logger
import time
from progressbar import ProgressBar
elogger = Logger('engine')
dlogger = Logger('data')
#def api(method):
#def wrapper(*args, **kwargs):
#rst = method(*args, **kwargs)
#return rst
#return wrapper
def time2int(t):
""" datetime转化为unix毫秒时间。 """
epoch = int(time.mktime(t.timetuple())*1000)
return epoch
def int2time(tf):
return datetime.datetime.fromtimestamp(float(tf)/1000)
#def pcontract(contract, period):
#""" 构建周期合约结构的便捷方式。
#:param str contract: 合约如:'IF000.SHEF'
#:param str Period: 周期如:'10.Minute'
#:return: 周期合约
#:rtype: PContract
#"""
#from quantdigger.datastruct import PContract, Contract, Period
#return PContract(Contract(contract),
#Period(period))
#def stock(code,period='1.Day'):
#""" 构建周期合约结构的便捷方式。
#:param str code: 股票代码。
#:param str period: 回测周期。
#:return: 周期合约。
#:rtype: PContract
#"""
#from quantdigger.datastruct import PContract, Contract, Period
#return PContract(Contract('%s.stock' % code),
#Period(period))