INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
除权除息 | def QA_fetch_get_stock_xdxr(code, ip=None, port=None):
'除权除息'
ip, port = get_mainmarket_ip(ip, port)
api = TdxHq_API()
market_code = _select_market_code(code)
with api.connect(ip, port):
category = {
'1': '除权除息', '2': '送配股上市', '3': '非流通股上市', '4': '未知股本变动', '5': '股本变化',
... |
股票基本信息 | def QA_fetch_get_stock_info(code, ip=None, port=None):
'股票基本信息'
ip, port = get_mainmarket_ip(ip, port)
api = TdxHq_API()
market_code = _select_market_code(code)
with api.connect(ip, port):
return api.to_df(api.get_finance_info(market_code, code)) |
板块数据 | def QA_fetch_get_stock_block(ip=None, port=None):
'板块数据'
ip, port = get_mainmarket_ip(ip, port)
api = TdxHq_API()
with api.connect(ip, port):
data = pd.concat([api.to_df(api.get_and_parse_block_info("block_gn.dat")).assign(type='gn'),
api.to_df(api.get_and_parse_block_... |
期货代码list | def QA_fetch_get_extensionmarket_list(ip=None, port=None):
'期货代码list'
ip, port = get_extensionmarket_ip(ip, port)
apix = TdxExHq_API()
with apix.connect(ip, port):
num = apix.get_instrument_count()
return pd.concat([apix.to_df(
apix.get_instrument_info((int(num / 500) - i) * ... |
[ summary ] | def QA_fetch_get_future_list(ip=None, port=None):
"""[summary]
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
42 3 商品指数 TI
60 3 主力期货合约 MA
28 3 郑州商品 QZ
... |
全球指数列表 | def QA_fetch_get_globalindex_list(ip=None, port=None):
"""全球指数列表
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
37 11 全球指数(静态) FW
12 5 国际指数 WI
"""
global extension_m... |
[ summary ] | def QA_fetch_get_goods_list(ip=None, port=None):
"""[summary]
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
42 3 商品指数 TI
60 3 主力期货合约 MA
28 3 郑州商品 QZ
... |
[ summary ] | def QA_fetch_get_globalfuture_list(ip=None, port=None):
"""[summary]
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
14 3 伦敦金属 LM
15 3 伦敦石油 IP
16 3 纽约商... |
[ summary ] | def QA_fetch_get_hkstock_list(ip=None, port=None):
"""[summary]
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
# 港股 HKMARKET
27 5 香港指数 FH
31 2 香港主板 KH
48 2... |
[ summary ] | def QA_fetch_get_hkindex_list(ip=None, port=None):
"""[summary]
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
# 港股 HKMARKET
27 5 香港指数 FH
31 2 香港主板 KH
48 2... |
[ summary ] | def QA_fetch_get_hkfund_list(ip=None, port=None):
"""[summary]
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
# 港股 HKMARKET
27 5 香港指数 FH
31 2 香港主板 KH
48 ... |
[ summary ] | def QA_fetch_get_usstock_list(ip=None, port=None):
"""[summary]
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
## 美股 USA STOCK
74 13 美国股票 US
40 11 中国概念股 CH
41 ... |
宏观指标列表 | def QA_fetch_get_macroindex_list(ip=None, port=None):
"""宏观指标列表
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
38 10 宏观指标 HG
"""
global extension_market_list
extension_market_list = QA... |
期权列表 | def QA_fetch_get_option_list(ip=None, port=None):
"""期权列表
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
## 期权 OPTION
1 12 临时期权(主要是50ETF)
4 12 郑州商品期权 OZ
5 ... |
#🛠todo 获取期权合约的上市日期 ? 暂时没有。: return: list Series | def QA_fetch_get_option_contract_time_to_market():
'''
#🛠todo 获取期权合约的上市日期 ? 暂时没有。
:return: list Series
'''
result = QA_fetch_get_option_list('tdx')
# pprint.pprint(result)
# category market code name desc code
'''
fix here :
See the caveats in the documentation: http://panda... |
#🛠todo 获取期权合约的上市日期 ? 暂时没有。: return: list Series | def QA_fetch_get_option_50etf_contract_time_to_market():
'''
#🛠todo 获取期权合约的上市日期 ? 暂时没有。
:return: list Series
'''
result = QA_fetch_get_option_list('tdx')
# pprint.pprint(result)
# category market code name desc code
'''
fix here :
See the caveats in the documenta... |
铜期权 CU 开头 上期证 豆粕 M开头 大商所 白糖 SR开头 郑商所 测试中发现,行情不太稳定 ? 是 通达信 IP 的问题 ? | def QA_fetch_get_commodity_option_CF_contract_time_to_market():
'''
铜期权 CU 开头 上期证
豆粕 M开头 大商所
白糖 SR开头 郑商所
测试中发现,行情不太稳定 ? 是 通达信 IP 的问题 ?
'''
result = QA_fetch_get_option_list('tdx')
# pprint.pprint(result)
# category market code name desc code
# df = pd.DataFra... |
汇率列表 | def QA_fetch_get_exchangerate_list(ip=None, port=None):
"""汇率列表
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
## 汇率 EXCHANGERATE
10 4 基本汇率 FE
11 4 交叉汇率 FX
""... |
期货数据 日线 | def QA_fetch_get_future_day(code, start_date, end_date, frequence='day', ip=None, port=None):
'期货数据 日线'
ip, port = get_extensionmarket_ip(ip, port)
apix = TdxExHq_API()
start_date = str(start_date)[0:10]
today_ = datetime.date.today()
lens = QA_util_get_trade_gap(start_date, today_)
global e... |
期货数据 分钟线 | def QA_fetch_get_future_min(code, start, end, frequence='1min', ip=None, port=None):
'期货数据 分钟线'
ip, port = get_extensionmarket_ip(ip, port)
apix = TdxExHq_API()
type_ = ''
start_date = str(start)[0:10]
today_ = datetime.date.today()
lens = QA_util_get_trade_gap(start_date, today_)
global... |
期货历史成交分笔 | def QA_fetch_get_future_transaction(code, start, end, retry=4, ip=None, port=None):
'期货历史成交分笔'
ip, port = get_extensionmarket_ip(ip, port)
apix = TdxExHq_API()
global extension_market_list
extension_market_list = QA_fetch_get_extensionmarket_list(
) if extension_market_list is None else extensio... |
期货历史成交分笔 | def QA_fetch_get_future_transaction_realtime(code, ip=None, port=None):
'期货历史成交分笔'
ip, port = get_extensionmarket_ip(ip, port)
apix = TdxExHq_API()
global extension_market_list
extension_market_list = QA_fetch_get_extensionmarket_list(
) if extension_market_list is None else extension_market_lis... |
期货实时价格 | def QA_fetch_get_future_realtime(code, ip=None, port=None):
'期货实时价格'
ip, port = get_extensionmarket_ip(ip, port)
apix = TdxExHq_API()
global extension_market_list
extension_market_list = QA_fetch_get_extensionmarket_list(
) if extension_market_list is None else extension_market_list
__data =... |
类似于pd. concat 用于合并一个list里面的多个DataStruct 会自动去重 | def concat(lists):
"""类似于pd.concat 用于合并一个list里面的多个DataStruct,会自动去重
Arguments:
lists {[type]} -- [DataStruct1,DataStruct2,....,DataStructN]
Returns:
[type] -- new DataStruct
"""
return lists[0].new(
pd.concat([lists.data for lists in lists]).drop_duplicates()
) |
一个任意格式转化为DataStruct的方法 Arguments: data { [ type ] } -- [ description ] Keyword Arguments: frequence { [ type ] } -- [ description ] ( default: { FREQUENCE. DAY } ) market_type { [ type ] } -- [ description ] ( default: { MARKET_TYPE. STOCK_CN } ) default_header { list } -- [ description ] ( default: { [] } ) Returns: [... | def datastruct_formater(
data,
frequence=FREQUENCE.DAY,
market_type=MARKET_TYPE.STOCK_CN,
default_header=[]
):
"""一个任意格式转化为DataStruct的方法
Arguments:
data {[type]} -- [description]
Keyword Arguments:
frequence {[type]} -- [description] (default: {FREQU... |
dataframe from tushare | def from_tushare(dataframe, dtype='day'):
"""dataframe from tushare
Arguments:
dataframe {[type]} -- [description]
Returns:
[type] -- [description]
"""
if dtype in ['day']:
return QA_DataStruct_Stock_day(
dataframe.assign(date=pd.to_datetime(dataframe.date)
... |
日线QDS装饰器 | def QDS_StockDayWarpper(func):
"""
日线QDS装饰器
"""
def warpper(*args, **kwargs):
data = func(*args, **kwargs)
if isinstance(data.index, pd.MultiIndex):
return QA_DataStruct_Stock_day(data)
else:
return QA_DataStruct_Stock_day(
data.assign(d... |
分钟线QDS装饰器 | def QDS_StockMinWarpper(func, *args, **kwargs):
"""
分钟线QDS装饰器
"""
def warpper(*args, **kwargs):
data = func(*args, **kwargs)
if isinstance(data.index, pd.MultiIndex):
return QA_DataStruct_Stock_min(data)
else:
return QA_DataStruct_Stock_min(
... |
获取股票的复权因子 Arguments: code { [ type ] } -- [ description ] Keyword Arguments: end { str } -- [ description ] ( default: { } ) Returns: [ type ] -- [ description ] | def QA_fetch_get_stock_adj(code, end=''):
"""获取股票的复权因子
Arguments:
code {[type]} -- [description]
Keyword Arguments:
end {str} -- [description] (default: {''})
Returns:
[type] -- [description]
"""
pro = get_pro()
adj = pro.adj_factor(ts_code=code, trade... |
字符串 20180101 转变成 float 类型时间 类似 time. time () 返回的类型: param date: 字符串str -- 格式必须是 20180101 ,长度8: return: 类型float | def cover_time(date):
"""
字符串 '20180101' 转变成 float 类型时间 类似 time.time() 返回的类型
:param date: 字符串str -- 格式必须是 20180101 ,长度8
:return: 类型float
"""
datestr = str(date)[0:8]
date = time.mktime(time.strptime(datestr, '%Y%m%d'))
return date |
通过data新建一个stock_block | def new(self, data):
"""通过data新建一个stock_block
Arguments:
data {[type]} -- [description]
Returns:
[type] -- [description]
"""
temp = copy(self)
temp.__init__(data)
return temp |
按股票排列的查看blockname的视图 | def view_code(self):
"""按股票排列的查看blockname的视图
Returns:
[type] -- [description]
"""
return self.data.groupby(level=1).apply(
lambda x:
[item for item in x.index.remove_unused_levels().levels[0]]
) |
getcode 获取某一只股票的板块 | def get_code(self, code):
"""getcode 获取某一只股票的板块
Arguments:
code {str} -- 股票代码
Returns:
DataStruct -- [description]
"""
# code= [code] if isinstance(code,str) else
return self.new(self.data.loc[(slice(None), code), :]) |
getblock 获取板块 block_name是list或者是单个str | def get_block(self, block_name):
"""getblock 获取板块, block_name是list或者是单个str
Arguments:
block_name {[type]} -- [description]
Returns:
[type] -- [description]
"""
# block_name = [block_name] if isinstance(
# block_name, str) else block_name
... |
get_both_code 获取几个股票相同的版块 Arguments: code { [ type ] } -- [ description ] Returns: [ type ] -- [ description ] | def get_both_code(self, code):
"""get_both_code 获取几个股票相同的版块
Arguments:
code {[type]} -- [description]
Returns:
[type] -- [description]
"""
return self.new(self.data.loc[(slice(None), code), :]) |
统一的获取期货/ 股票tick的接口 | def QA_get_tick(code, start, end, market):
"""
统一的获取期货/股票tick的接口
"""
res = None
if market == MARKET_TYPE.STOCK_CN:
res = QATdx.QA_fetch_get_stock_transaction(code, start, end)
elif market == MARKET_TYPE.FUTURE_CN:
res = QATdx.QA_fetch_get_future_transaction(code, start, end)
... |
统一的获取期货/ 股票实时行情的接口 | def QA_get_realtime(code, market):
"""
统一的获取期货/股票实时行情的接口
"""
res = None
if market == MARKET_TYPE.STOCK_CN:
res = QATdx.QA_fetch_get_stock_realtime(code)
elif market == MARKET_TYPE.FUTURE_CN:
res = QATdx.QA_fetch_get_future_realtime(code)
return res |
一个统一的获取k线的方法 如果使用mongo 从本地数据库获取 失败则在线获取 | def QA_quotation(code, start, end, frequence, market, source=DATASOURCE.TDX, output=OUTPUT_FORMAT.DATAFRAME):
"""一个统一的获取k线的方法
如果使用mongo,从本地数据库获取,失败则在线获取
Arguments:
code {str/list} -- 期货/股票的代码
start {str} -- 开始日期
end {str} -- 结束日期
frequence {enum} -- 频率 QA.FREQUENCE
m... |
随机生成股票代码: param stockNumber: 生成个数: return: [ 60XXXX 00XXXX 300XXX ] | def QA_util_random_with_zh_stock_code(stockNumber=10):
'''
随机生成股票代码
:param stockNumber: 生成个数
:return: ['60XXXX', '00XXXX', '300XXX']
'''
codeList = []
pt = 0
for i in range(stockNumber):
if pt == 0:
#print("random 60XXXX")
iCode = random.randint(600000, 6... |
生成account随机值 | def QA_util_random_with_topic(topic='Acc', lens=8):
"""
生成account随机值
Acc+4数字id+4位大小写随机
"""
_list = [chr(i) for i in range(65,
91)] + [chr(i) for i in range(97,
123)
... |
支持股票/ 期货的更新仓位 | def update_pos(self, price, amount, towards):
"""支持股票/期货的更新仓位
Arguments:
price {[type]} -- [description]
amount {[type]} -- [description]
towards {[type]} -- [description]
margin: 30080
margin_long: 0
margin_short: 30080
... |
收盘后的结算事件 | def settle(self):
"""收盘后的结算事件
"""
self.volume_long_his += self.volume_long_today
self.volume_long_today = 0
self.volume_long_frozen_today = 0
self.volume_short_his += self.volume_short_today
self.volume_short_today = 0
self.volume_short_frozen_today = 0 |
可平仓数量 | def close_available(self):
"""可平仓数量
Returns:
[type] -- [description]
"""
return {
'volume_long': self.volume_long - self.volume_long_frozen,
'volume_short': self.volume_short - self.volume_short_frozen
} |
委托回报 | def orderAction(self, order:QA_Order):
"""
委托回报
"""
return self.pms[order.code][order.order_id].receive_order(order) |
聚宽实现方式 save current day s stock_min data | def QA_SU_save_stock_min(client=DATABASE, ui_log=None, ui_progress=None):
"""
聚宽实现方式
save current day's stock_min data
"""
# 导入聚宽模块且进行登录
try:
import jqdatasdk
# 请自行将 JQUSERNAME 和 JQUSERPASSWD 修改为自己的账号密码
jqdatasdk.auth("JQUSERNAME", "JQUSERPASSWD")
except:
rais... |
Execute a command on the command - line.: param str list command: The command to run: param bool shell: Whether or not to use the shell. This is optional ; if command is a basestring shell will be set to True otherwise it will be false. You can override this behavior by setting this parameter directly.: param str worki... | def execute(command, shell=None, working_dir=".", echo=False, echo_indent=0):
"""Execute a command on the command-line.
:param str,list command: The command to run
:param bool shell: Whether or not to use the shell. This is optional; if
``command`` is a basestring, shell will be set to True, otherw... |
使用数据库数据计算复权 | def QA_data_calc_marketvalue(data, xdxr):
'使用数据库数据计算复权'
mv = xdxr.query('category!=6').loc[:,
['shares_after',
'liquidity_after']].dropna()
res = pd.concat([data, mv], axis=1)
res = res.assign(
shares=res.shares_afte... |
1. DIF向上突破DEA,买入信号参考。 2. DIF向下跌破DEA,卖出信号参考。 | def MACD_JCSC(dataframe, SHORT=12, LONG=26, M=9):
"""
1.DIF向上突破DEA,买入信号参考。
2.DIF向下跌破DEA,卖出信号参考。
"""
CLOSE = dataframe.close
DIFF = QA.EMA(CLOSE, SHORT) - QA.EMA(CLOSE, LONG)
DEA = QA.EMA(DIFF, M)
MACD = 2*(DIFF-DEA)
CROSS_JC = QA.CROSS(DIFF, DEA)
CROSS_SC = QA.CROSS(DEA, DIFF)
... |
Create the tables needed to store the information. | def _create(self, cache_file):
"""Create the tables needed to store the information."""
conn = sqlite3.connect(cache_file)
cur = conn.cursor()
cur.execute("PRAGMA foreign_keys = ON")
cur.execute('''
CREATE TABLE jobs(
hash TEXT NOT NULL UNIQUE PRIMARY ... |
Retrieves the job with the selected ID.: param str id: The ID of the job: returns: The dictionary of the job if found None otherwise | def get(self, id):
"""Retrieves the job with the selected ID.
:param str id: The ID of the job
:returns: The dictionary of the job if found, None otherwise
"""
self.cur.execute("SELECT * FROM jobs WHERE hash=?", (id,))
item = self.cur.fetchone()
if item:
... |
Update last_run next_run and last_run_result for an existing job.: param dict job: The job dictionary: returns: True | def update(self, job):
"""Update last_run, next_run, and last_run_result for an existing job.
:param dict job: The job dictionary
:returns: True
"""
self.cur.execute('''UPDATE jobs
SET last_run=?,next_run=?,last_run_result=? WHERE hash=?''', (
job["last-ru... |
Adds a new job into the cache.: param dict job: The job dictionary: returns: True | def add_job(self, job):
"""Adds a new job into the cache.
:param dict job: The job dictionary
:returns: True
"""
self.cur.execute("INSERT INTO jobs VALUES(?,?,?,?,?)", (
job["id"], job["description"], job["last-run"], job["next-run"], job["last-run-result"]))
... |
Adds a job run result to the history table.: param dict job: The job dictionary: returns: True | def add_result(self, job):
"""Adds a job run result to the history table.
:param dict job: The job dictionary
:returns: True
"""
self.cur.execute(
"INSERT INTO history VALUES(?,?,?,?)",
(job["id"], job["description"], job["last-run"], job["last-run-result"... |
tick 采样为 分钟数据 1. 仅使用将 tick 采样为 1 分钟数据 2. 仅测试过,与通达信 1 分钟数据达成一致 3. 经测试,可以匹配 QA. QA_fetch_get_stock_transaction 得到的数据,其他类型数据未测试 demo: df = QA. QA_fetch_get_stock_transaction ( package = tdx code = 000001 start = 2018 - 08 - 01 09: 25: 00 end = 2018 - 08 - 03 15: 00: 00 ) df_min = QA_data_tick_resample_1min ( df ) | def QA_data_tick_resample_1min(tick, type_='1min', if_drop=True):
"""
tick 采样为 分钟数据
1. 仅使用将 tick 采样为 1 分钟数据
2. 仅测试过,与通达信 1 分钟数据达成一致
3. 经测试,可以匹配 QA.QA_fetch_get_stock_transaction 得到的数据,其他类型数据未测试
demo:
df = QA.QA_fetch_get_stock_transaction(package='tdx', code='000001',
... |
tick采样成任意级别分钟线 | def QA_data_tick_resample(tick, type_='1min'):
"""tick采样成任意级别分钟线
Arguments:
tick {[type]} -- transaction
Returns:
[type] -- [description]
"""
tick = tick.assign(amount=tick.price * tick.vol)
resx = pd.DataFrame()
_temp = set(tick.index.date)
for item in _temp:
... |
tick采样成任意级别分钟线 | def QA_data_ctptick_resample(tick, type_='1min'):
"""tick采样成任意级别分钟线
Arguments:
tick {[type]} -- transaction
Returns:
[type] -- [description]
"""
resx = pd.DataFrame()
_temp = set(tick.TradingDay)
for item in _temp:
_data = tick.query('TradingDay=="{}"'.format(ite... |
分钟线采样成大周期 | def QA_data_min_resample(min_data, type_='5min'):
"""分钟线采样成大周期
分钟线采样成子级别的分钟线
time+ OHLC==> resample
Arguments:
min {[type]} -- [description]
raw_type {[type]} -- [description]
new_type {[type]} -- [description]
"""
try:
min_data = min_data.reset_index().set_i... |
期货分钟线采样成大周期 | def QA_data_futuremin_resample(min_data, type_='5min'):
"""期货分钟线采样成大周期
分钟线采样成子级别的分钟线
future:
vol ==> trade
amount X
"""
min_data.tradeime = pd.to_datetime(min_data.tradetime)
CONVERSION = {
'code': 'first',
'open': 'first',
'high': 'max',
'low': 'min... |
日线降采样 | def QA_data_day_resample(day_data, type_='w'):
"""日线降采样
Arguments:
day_data {[type]} -- [description]
Keyword Arguments:
type_ {str} -- [description] (default: {'w'})
Returns:
[type] -- [description]
"""
# return day_data_p.assign(open=day_data.open.resample(type_).fir... |
save stock info | def QA_SU_save_stock_info(engine, client=DATABASE):
"""save stock info
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_stock_info(client=client) |
save stock_list | def QA_SU_save_stock_list(engine, client=DATABASE):
"""save stock_list
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_stock_list(client=client) |
save index_list | def QA_SU_save_index_list(engine, client=DATABASE):
"""save index_list
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_index_list(client=client) |
save etf_list | def QA_SU_save_etf_list(engine, client=DATABASE):
"""save etf_list
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_etf_list(client=client) |
save future_list | def QA_SU_save_future_list(engine, client=DATABASE):
"""save future_list
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_future_list(client=client) |
save future_day | def QA_SU_save_future_day(engine, client=DATABASE):
"""save future_day
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_future_day(client=client) |
save future_day_all | def QA_SU_save_future_day_all(engine, client=DATABASE):
"""save future_day_all
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_future_day_all(client=... |
save future_min Arguments: engine { [ type ] } -- [ description ] | def QA_SU_save_future_min(engine, client=DATABASE):
"""save future_min
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_future_min(client=client) |
[ summary ] | def QA_SU_save_future_min_all(engine, client=DATABASE):
"""[summary]
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_future_min_all(client=client) |
save stock_day | def QA_SU_save_stock_day(engine, client=DATABASE, paralleled=False):
"""save stock_day
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine, paralleled=paralleled)
engine.QA... |
: param engine:: param client:: return: | def QA_SU_save_option_commodity_min(engine, client=DATABASE):
'''
:param engine:
:param client:
:return:
'''
engine = select_save_engine(engine)
engine.QA_SU_save_option_commodity_min(client=client) |
: param engine:: param client:: return: | def QA_SU_save_option_commodity_day(engine, client=DATABASE):
'''
:param engine:
:param client:
:return:
'''
engine = select_save_engine(engine)
engine.QA_SU_save_option_commodity_day(client=client) |
save stock_min | def QA_SU_save_stock_min(engine, client=DATABASE):
"""save stock_min
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_stock_min(client=client) |
save index_day | def QA_SU_save_index_day(engine, client=DATABASE):
"""save index_day
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_index_day(client=client) |
save index_min | def QA_SU_save_index_min(engine, client=DATABASE):
"""save index_min
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_index_min(client=client) |
save etf_day | def QA_SU_save_etf_day(engine, client=DATABASE):
"""save etf_day
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_etf_day(client=client) |
save etf_min | def QA_SU_save_etf_min(engine, client=DATABASE):
"""save etf_min
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_etf_min(client=client) |
save stock_xdxr | def QA_SU_save_stock_xdxr(engine, client=DATABASE):
"""save stock_xdxr
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_stock_xdxr(client=client) |
save stock_block | def QA_SU_save_stock_block(engine, client=DATABASE):
"""save stock_block
Arguments:
engine {[type]} -- [description]
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE})
"""
engine = select_save_engine(engine)
engine.QA_SU_save_stock_block(client=client) |
select save_engine tushare ts Tushare 使用 Tushare 免费数据接口, tdx 使用通达信数据接口: param engine: 字符串Str: param paralleled: 是否并行处理;默认为False: return: sts means save_tushare_py or stdx means save_tdx_py | def select_save_engine(engine, paralleled=False):
'''
select save_engine , tushare ts Tushare 使用 Tushare 免费数据接口, tdx 使用通达信数据接口
:param engine: 字符串Str
:param paralleled: 是否并行处理;默认为False
:return: sts means save_tushare_py or stdx means save_tdx_py
'''
if engine in ['tushare', 'ts', 'Tushare']:... |
获取股票日线 | def QA_fetch_stock_day(code, start, end, format='numpy', frequence='day', collections=DATABASE.stock_day):
"""'获取股票日线'
Returns:
[type] -- [description]
感谢@几何大佬的提示
https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/#return-the-specified-fields-and-the-id-field-on... |
获取股票分钟线 | def QA_fetch_stock_min(code, start, end, format='numpy', frequence='1min', collections=DATABASE.stock_min):
'获取股票分钟线'
if frequence in ['1min', '1m']:
frequence = '1min'
elif frequence in ['5min', '5m']:
frequence = '5min'
elif frequence in ['15min', '15m']:
frequence = '15min'
... |
获取股票列表 | def QA_fetch_stock_list(collections=DATABASE.stock_list):
'获取股票列表'
return pd.DataFrame([item for item in collections.find()]).drop('_id', axis=1, inplace=False).set_index('code', drop=False) |
获取ETF列表 | def QA_fetch_etf_list(collections=DATABASE.etf_list):
'获取ETF列表'
return pd.DataFrame([item for item in collections.find()]).drop('_id', axis=1, inplace=False).set_index('code', drop=False) |
获取指数列表 | def QA_fetch_index_list(collections=DATABASE.index_list):
'获取指数列表'
return pd.DataFrame([item for item in collections.find()]).drop('_id', axis=1, inplace=False).set_index('code', drop=False) |
获取股票基本信息 已经退市的股票列表 | def QA_fetch_stock_terminated(collections=DATABASE.stock_terminated):
'获取股票基本信息 , 已经退市的股票列表'
# 🛠todo 转变成 dataframe 类型数据
return pd.DataFrame([item for item in collections.find()]).drop('_id', axis=1, inplace=False).set_index('code', drop=False) |
purpose: tushare 股票列表数据库 | def QA_fetch_stock_basic_info_tushare(collections=DATABASE.stock_info_tushare):
'''
purpose:
tushare 股票列表数据库
code,代码
name,名称
industry,所属行业
area,地区
pe,市盈率
outstanding,流通股本(亿)
totals,总股本(亿)
totalAssets,总资产(万)
liquidAssets,流动资产
... |
获取全市场的某一日的数据 | def QA_fetch_stock_full(date, format='numpy', collections=DATABASE.stock_day):
'获取全市场的某一日的数据'
Date = str(date)[0:10]
if QA_util_date_valid(Date) is True:
__data = []
for item in collections.find({
"date_stamp": QA_util_date_stamp(Date)}, batch_size=10000):
__data... |
获取股票分钟线 | def QA_fetch_index_min(
code,
start, end,
format='numpy',
frequence='1min',
collections=DATABASE.index_min):
'获取股票分钟线'
if frequence in ['1min', '1m']:
frequence = '1min'
elif frequence in ['5min', '5m']:
frequence = '5min'
elif frequence in ['15min... |
获取股票分钟线 | def QA_fetch_future_min(
code,
start, end,
format='numpy',
frequence='1min',
collections=DATABASE.future_min):
'获取股票分钟线'
if frequence in ['1min', '1m']:
frequence = '1min'
elif frequence in ['5min', '5m']:
frequence = '5min'
elif frequence in ['15m... |
获取期货列表 | def QA_fetch_future_list(collections=DATABASE.future_list):
'获取期货列表'
return pd.DataFrame([item for item in collections.find()]).drop('_id', axis=1, inplace=False).set_index('code', drop=False) |
仅供存储的ctp tick使用 | def QA_fetch_ctp_tick(code, start, end, frequence, format='pd', collections=DATABASE.ctp_tick):
"""仅供存储的ctp tick使用
Arguments:
code {[type]} -- [description]
Keyword Arguments:
format {str} -- [description] (default: {'pd'})
collections {[type]} -- [description] (default: {DATABASE.... |
获取股票除权信息/ 数据库 | def QA_fetch_stock_xdxr(code, format='pd', collections=DATABASE.stock_xdxr):
'获取股票除权信息/数据库'
code = QA_util_code_tolist(code)
data = pd.DataFrame([item for item in collections.find(
{'code': {'$in': code}}, batch_size=10000)]).drop(['_id'], axis=1)
data['date'] = pd.to_datetime(data['date'])
... |
获取全部实时5档行情的存储结果 | def QA_fetch_quotations(date=datetime.date.today(), db=DATABASE):
'获取全部实时5档行情的存储结果'
try:
collections = db.get_collection(
'realtime_{}'.format(date))
data = pd.DataFrame([item for item in collections.find(
{}, {"_id": 0}, batch_size=10000)])
return data.assign(dat... |
get the account | def QA_fetch_account(message={}, db=DATABASE):
"""get the account
Arguments:
query_mes {[type]} -- [description]
Keyword Arguments:
collection {[type]} -- [description] (default: {DATABASE})
Returns:
[type] -- [description]
"""
collection = DATABASE.account
return ... |
get the risk message | def QA_fetch_risk(message={}, params={"_id": 0, 'assets': 0, 'timeindex': 0, 'totaltimeindex': 0, 'benchmark_assets': 0, 'month_profit': 0}, db=DATABASE):
"""get the risk message
Arguments:
query_mes {[type]} -- [description]
Keyword Arguments:
collection {[type]} -- [description] (default... |
get the user | def QA_fetch_user(user_cookie, db=DATABASE):
"""
get the user
Arguments:
user_cookie : str the unique cookie_id for a user
Keyword Arguments:
db: database for query
Returns:
list --- [ACCOUNT]
"""
collection = DATABASE.account
return [res for res in collection... |
get the account | def QA_fetch_strategy(message={}, db=DATABASE):
"""get the account
Arguments:
query_mes {[type]} -- [description]
Keyword Arguments:
collection {[type]} -- [description] (default: {DATABASE})
Returns:
[type] -- [description]
"""
collection = DATABASE.strategy
retur... |
获取某一天龙虎榜数据 | def QA_fetch_lhb(date, db=DATABASE):
'获取某一天龙虎榜数据'
try:
collections = db.lhb
return pd.DataFrame([item for item in collections.find(
{'date': date}, {"_id": 0})]).set_index('code', drop=False).sort_index()
except Exception as e:
raise e |
获取专业财务报表 Arguments: code { [ type ] } -- [ description ] report_date { [ type ] } -- [ description ] Keyword Arguments: ltype { str } -- [ description ] ( default: { EN } ) db { [ type ] } -- [ description ] ( default: { DATABASE } ) Raises: e -- [ description ] Returns: pd. DataFrame -- [ description ] | def QA_fetch_financial_report(code, report_date, ltype='EN', db=DATABASE):
"""获取专业财务报表
Arguments:
code {[type]} -- [description]
report_date {[type]} -- [description]
Keyword Arguments:
ltype {str} -- [description] (default: {'EN'})
db {[type]} -- [description] (default: {DAT... |
获取股票日线 | def QA_fetch_stock_divyield(code, start, end=None, format='pd', collections=DATABASE.stock_divyield):
'获取股票日线'
#code= [code] if isinstance(code,str) else code
# code checking
code = QA_util_code_tolist(code)
if QA_util_date_valid(end):
__data = []
cursor = collections.find({
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.