MCPcopy Create free account
hub / github.com/QuantFans/quantdigger / Contract

Class Contract

quantdigger/kernel/datastruct.py:254–283  ·  view source on GitHub ↗

合约。 :ivar exch_type: 市场类型。 :vartype exch_type: str :ivar code: 合约代码 :vartype code: str

Source from the content-addressed store, hash-verified

252
253
254class Contract(object):
255 """ 合约。
256
257 :ivar exch_type: 市场类型。
258 :vartype exch_type: str
259
260 :ivar code: 合约代码
261 :vartype code: str
262 """
263 def __init__(self, str_contract):
264 info = str_contract.split('.')
265 if len(info) == 2:
266 code = info[0]
267 exchange = info[1]
268 else:
269 ## @todo 合约到市场的映射。
270 assert False
271 self.exch_type = exchange # 用'stock'表示中国股市
272 self.code = code
273
274 def __str__(self):
275 """"""
276 return "%s.%s" % (self.code, self.exch_type)
277
278 def __hash__(self):
279 if hasattr(self, '_hash'):
280 return self._hash
281 else:
282 self._hash = hash(self.__str__())
283 return self._hash
284
285
286class Period(object):

Callers 4

pcontractFunction · 0.90
stockFunction · 0.90
buyMethod · 0.90
sellMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected