hikyuu2/hikyuu/data/common.py
2019-02-24 19:36:47 +08:00

68 lines
2.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding:utf-8
#
# The MIT License (MIT)
#
# Copyright (c) 2010-2019 fasiondog/hikyuu
#
# 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.
class MARKET:
SH = 'SH'
SZ = 'SZ'
class MARKETID:
SH = 1
SZ = 2
class STOCKTYPE:
BLOCK = 0 #
A = 1 #A股
INDEX = 2 #
B = 3 #B股
FUND = 4 #ETF
ETF = 5 #ETF
ND = 6 #
BOND = 7 #
GEM = 8 #
BTC = 9 #
def get_stktype_list(quotations=None):
"""
:param quotations: 'stock' | 'fund' | 'bond'
:rtype: tuple
:return:
"""
if not quotations:
return (1, 2, 3, 4, 5, 6, 7, 8, 9)
result = []
for quotation in quotations:
new_quotation = quotation.lower()
if new_quotation == 'stock':
result += [STOCKTYPE.A, STOCKTYPE.INDEX, STOCKTYPE.B, STOCKTYPE.GEM]
elif new_quotation == 'fund':
result += [STOCKTYPE.FUND, STOCKTYPE.ETF]
elif new_quotation == 'bond':
result += [STOCKTYPE.ND, STOCKTYPE.BOND]
else:
print('Unknow quotation: {}'.format(quotation))
return tuple(result)