2018-11-06 01:25:52 +08:00
|
|
|
|
# coding:utf-8
|
|
|
|
|
#
|
|
|
|
|
# The MIT License (MIT)
|
|
|
|
|
#
|
2019-02-24 19:36:47 +08:00
|
|
|
|
# Copyright (c) 2010-2019 fasiondog/hikyuu
|
2018-11-06 01:25:52 +08:00
|
|
|
|
#
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
|
#
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
|
#
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
# SOFTWARE.
|
2018-10-21 01:56:30 +08:00
|
|
|
|
|
2018-11-06 01:25:52 +08:00
|
|
|
|
class MARKET:
|
|
|
|
|
SH = 'SH'
|
|
|
|
|
SZ = 'SZ'
|
2018-10-21 01:56:30 +08:00
|
|
|
|
|
2018-11-06 01:25:52 +08:00
|
|
|
|
class MARKETID:
|
|
|
|
|
SH = 1
|
|
|
|
|
SZ = 2
|
|
|
|
|
|
|
|
|
|
class STOCKTYPE:
|
2018-11-25 16:46:07 +08:00
|
|
|
|
BLOCK = 0 #板块
|
2018-11-06 01:25:52 +08:00
|
|
|
|
A = 1 #A股
|
|
|
|
|
INDEX = 2 #指数
|
|
|
|
|
B = 3 #B股
|
|
|
|
|
FUND = 4 #基金(非ETF)
|
|
|
|
|
ETF = 5 #ETF
|
|
|
|
|
ND = 6 #国债
|
|
|
|
|
BOND = 7 #其他债券
|
|
|
|
|
GEM = 8 #创业板
|
|
|
|
|
BTC = 9 #数字币
|
2018-10-21 01:56:30 +08:00
|
|
|
|
|
2018-11-04 11:23:07 +08:00
|
|
|
|
def get_stktype_list(quotations=None):
|
2018-11-06 01:25:52 +08:00
|
|
|
|
"""
|
|
|
|
|
根据行情类别获取股票类别元组
|
|
|
|
|
|
|
|
|
|
:param quotations: 'stock'(股票) | 'fund'(基金) | 'bond'(债券)
|
|
|
|
|
:rtype: tuple
|
|
|
|
|
:return: 股票类别元组
|
|
|
|
|
"""
|
2018-11-04 11:23:07 +08:00
|
|
|
|
if not quotations:
|
2018-10-21 01:56:30 +08:00
|
|
|
|
return (1, 2, 3, 4, 5, 6, 7, 8, 9)
|
|
|
|
|
|
2018-11-04 11:23:07 +08:00
|
|
|
|
result = []
|
|
|
|
|
for quotation in quotations:
|
|
|
|
|
new_quotation = quotation.lower()
|
|
|
|
|
if new_quotation == 'stock':
|
2018-11-06 01:25:52 +08:00
|
|
|
|
result += [STOCKTYPE.A, STOCKTYPE.INDEX, STOCKTYPE.B, STOCKTYPE.GEM]
|
2018-11-04 11:23:07 +08:00
|
|
|
|
elif new_quotation == 'fund':
|
2018-11-06 01:25:52 +08:00
|
|
|
|
result += [STOCKTYPE.FUND, STOCKTYPE.ETF]
|
2018-11-04 11:23:07 +08:00
|
|
|
|
elif new_quotation == 'bond':
|
2018-11-06 01:25:52 +08:00
|
|
|
|
result += [STOCKTYPE.ND, STOCKTYPE.BOND]
|
2018-11-04 11:23:07 +08:00
|
|
|
|
else:
|
|
|
|
|
print('Unknow quotation: {}'.format(quotation))
|
|
|
|
|
|
|
|
|
|
return tuple(result)
|