Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function: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... | [] |
Please provide a description of the function: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 marke... | [] |
Please provide a description of the function:def QA_fetch_get_exchangerate_list(ip=None, port=None):
global extension_market_list
extension_market_list = QA_fetch_get_extensionmarket_list(
) if extension_market_list is None else extension_market_list
return extension_market_list.query('market==10 ... | [
"汇率列表\n\n Keyword Arguments:\n ip {[type]} -- [description] (default: {None})\n port {[type]} -- [description] (default: {None})\n\n ## 汇率 EXCHANGERATE\n 10 4 基本汇率 FE\n 11 4 交叉汇率 FX\n\n\n "
] |
Please provide a description of the function: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_g... | [] |
Please provide a description of the function: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... | [] |
Please provide a description of the function: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(
) i... | [] |
Please provide a description of the function: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_... | [] |
Please provide a description of the function: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... | [] |
Please provide a description of the function:def concat(lists):
return lists[0].new(
pd.concat([lists.data for lists in lists]).drop_duplicates()
) | [
"类似于pd.concat 用于合并一个list里面的多个DataStruct,会自动去重\n\n\n\n Arguments:\n lists {[type]} -- [DataStruct1,DataStruct2,....,DataStructN]\n\n Returns:\n [type] -- new DataStruct\n "
] |
Please provide a description of the function:def datastruct_formater(
data,
frequence=FREQUENCE.DAY,
market_type=MARKET_TYPE.STOCK_CN,
default_header=[]
):
if isinstance(data, list):
try:
res = pd.DataFrame(data, columns=default_header)
if freque... | [
"一个任意格式转化为DataStruct的方法\n \n Arguments:\n data {[type]} -- [description]\n \n Keyword Arguments:\n frequence {[type]} -- [description] (default: {FREQUENCE.DAY})\n market_type {[type]} -- [description] (default: {MARKET_TYPE.STOCK_CN})\n default_header {list} -- [description]... |
Please provide a description of the function:def from_tushare(dataframe, dtype='day'):
if dtype in ['day']:
return QA_DataStruct_Stock_day(
dataframe.assign(date=pd.to_datetime(dataframe.date)
).set_index(['date',
'code']... | [
"dataframe from tushare\n\n Arguments:\n dataframe {[type]} -- [description]\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def QDS_StockDayWarpper(func):
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(
... | [
"\n 日线QDS装饰器\n "
] |
Please provide a description of the function:def QDS_StockMinWarpper(func, *args, **kwargs):
def warpper(*args, **kwargs):
data = func(*args, **kwargs)
if isinstance(data.index, pd.MultiIndex):
return QA_DataStruct_Stock_min(data)
else:
return QA_DataStruct_Sto... | [
"\n 分钟线QDS装饰器\n "
] |
Please provide a description of the function:def QA_fetch_get_stock_adj(code, end=''):
pro = get_pro()
adj = pro.adj_factor(ts_code=code, trade_date=end)
return adj | [
"获取股票的复权因子\n \n Arguments:\n code {[type]} -- [description]\n \n Keyword Arguments:\n end {str} -- [description] (default: {''})\n \n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def cover_time(date):
datestr = str(date)[0:8]
date = time.mktime(time.strptime(datestr, '%Y%m%d'))
return date | [
"\n 字符串 '20180101' 转变成 float 类型时间 类似 time.time() 返回的类型\n :param date: 字符串str -- 格式必须是 20180101 ,长度8\n :return: 类型float\n "
] |
Please provide a description of the function:def new(self, data):
temp = copy(self)
temp.__init__(data)
return temp | [
"通过data新建一个stock_block\n\n Arguments:\n data {[type]} -- [description]\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def view_code(self):
return self.data.groupby(level=1).apply(
lambda x:
[item for item in x.index.remove_unused_levels().levels[0]]
) | [
"按股票排列的查看blockname的视图\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def get_code(self, code):
# code= [code] if isinstance(code,str) else
return self.new(self.data.loc[(slice(None), code), :]) | [
"getcode 获取某一只股票的板块\n\n Arguments:\n code {str} -- 股票代码\n\n Returns:\n DataStruct -- [description]\n "
] |
Please provide a description of the function:def get_block(self, block_name):
# block_name = [block_name] if isinstance(
# block_name, str) else block_name
# return QA_DataStruct_Stock_block(self.data[self.data.blockname.apply(lambda x: x in block_name)])
return self.new(se... | [
"getblock 获取板块, block_name是list或者是单个str\n\n Arguments:\n block_name {[type]} -- [description]\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def get_both_code(self, code):
return self.new(self.data.loc[(slice(None), code), :]) | [
"get_both_code 获取几个股票相同的版块\n \n Arguments:\n code {[type]} -- [description]\n \n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def QA_get_tick(code, start, end, market):
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, star... | [
"\n 统一的获取期货/股票tick的接口\n "
] |
Please provide a description of the function: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 | [
"\n 统一的获取期货/股票实时行情的接口\n "
] |
Please provide a description of the function:def QA_quotation(code, start, end, frequence, market, source=DATASOURCE.TDX, output=OUTPUT_FORMAT.DATAFRAME):
res = None
if market == MARKET_TYPE.STOCK_CN:
if frequence == FREQUENCE.DAY:
if source == DATASOURCE.MONGO:
try:
... | [
"一个统一的获取k线的方法\n 如果使用mongo,从本地数据库获取,失败则在线获取\n\n Arguments:\n code {str/list} -- 期货/股票的代码\n start {str} -- 开始日期\n end {str} -- 结束日期\n frequence {enum} -- 频率 QA.FREQUENCE\n market {enum} -- 市场 QA.MARKET_TYPE\n source {enum} -- 来源 QA.DATASOURCE\n output {enum} -- 输... |
Please provide a description of the function: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")... | [] |
Please provide a description of the function:def QA_util_random_with_topic(topic='Acc', lens=8):
_list = [chr(i) for i in range(65,
91)] + [chr(i) for i in range(97,
123)
... | [
"\n 生成account随机值\n\n Acc+4数字id+4位大小写随机\n\n "
] |
Please provide a description of the function:def update_pos(self, price, amount, towards):
temp_cost = amount*price * \
self.market_preset.get('unit_table', 1)
# if towards == ORDER_DIRECTION.SELL_CLOSE:
if towards == ORDER_DIRECTION.BUY:
# 股票模式/ 期货买入开仓
... | [
"支持股票/期货的更新仓位\n\n Arguments:\n price {[type]} -- [description]\n amount {[type]} -- [description]\n towards {[type]} -- [description]\n\n margin: 30080\n margin_long: 0\n margin_short: 30080\n open_cost_long: 0\n open_cos... |
Please provide a description of the function: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_sho... | [
"收盘后的结算事件\n "
] |
Please provide a description of the function:def close_available(self):
return {
'volume_long': self.volume_long - self.volume_long_frozen,
'volume_short': self.volume_short - self.volume_short_frozen
} | [
"可平仓数量\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def orderAction(self, order:QA_Order):
return self.pms[order.code][order.order_id].receive_order(order) | [
"\n 委托回报\n "
] |
Please provide a description of the function:def QA_SU_save_stock_min(client=DATABASE, ui_log=None, ui_progress=None):
# 导入聚宽模块且进行登录
try:
import jqdatasdk
# 请自行将 JQUSERNAME 和 JQUSERPASSWD 修改为自己的账号密码
jqdatasdk.auth("JQUSERNAME", "JQUSERPASSWD")
except:
raise ModuleNotFoun... | [
"\n 聚宽实现方式\n save current day's stock_min data\n ",
"\n 处理 jqdata 分钟数据为 qa 格式,并存入数据库\n 1. jdatasdk 数据格式:\n open close high low volume money\n 2018-12-03 09:31:00 10.59 10.61 10.61 10.59 8339100.0 88377836.0\n 2. 与 QUANTAXIS.QAFetc... |
Please provide a description of the function:def execute(command, shell=None, working_dir=".", echo=False, echo_indent=0):
if shell is None:
shell = True if isinstance(command, str) else False
p = Popen(command, stdin=PIPE, stdout=PIPE,
stderr=STDOUT, shell=shell, cwd=working_dir)
... | [
"Execute a command on the command-line.\n :param str,list command: The command to run\n :param bool shell: Whether or not to use the shell. This is optional; if\n ``command`` is a basestring, shell will be set to True, otherwise it will\n be false. You can override this behavior by setting thi... |
Please provide a description of the function: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... | [] |
Please provide a description of the function:def MACD_JCSC(dataframe, SHORT=12, LONG=26, M=9):
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)
ZERO = 0
... | [
"\n 1.DIF向上突破DEA,买入信号参考。\n 2.DIF向下跌破DEA,卖出信号参考。\n "
] |
Please provide a description of the function:def _create(self, cache_file):
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 KEY, descri... | [
"Create the tables needed to store the information."
] |
Please provide a description of the function:def get(self, id):
self.cur.execute("SELECT * FROM jobs WHERE hash=?", (id,))
item = self.cur.fetchone()
if item:
return dict(zip(
("id", "description", "last-run", "next-run", "last-run-result"),
i... | [
"Retrieves the job with the selected ID.\n :param str id: The ID of the job\n :returns: The dictionary of the job if found, None otherwise\n "
] |
Please provide a description of the function:def update(self, job):
self.cur.execute('''UPDATE jobs
SET last_run=?,next_run=?,last_run_result=? WHERE hash=?''', (
job["last-run"], job["next-run"], job["last-run-result"], job["id"])) | [
"Update last_run, next_run, and last_run_result for an existing job.\n :param dict job: The job dictionary\n :returns: True\n "
] |
Please provide a description of the function:def add_job(self, job):
self.cur.execute("INSERT INTO jobs VALUES(?,?,?,?,?)", (
job["id"], job["description"], job["last-run"], job["next-run"], job["last-run-result"]))
return True | [
"Adds a new job into the cache.\n :param dict job: The job dictionary\n :returns: True\n "
] |
Please provide a description of the function:def add_result(self, job):
self.cur.execute(
"INSERT INTO history VALUES(?,?,?,?)",
(job["id"], job["description"], job["last-run"], job["last-run-result"]))
return True | [
"Adds a job run result to the history table.\n :param dict job: The job dictionary\n :returns: True\n "
] |
Please provide a description of the function:def QA_data_tick_resample_1min(tick, type_='1min', if_drop=True):
tick = tick.assign(amount=tick.price * tick.vol)
resx = pd.DataFrame()
_dates = set(tick.date)
for date in sorted(list(_dates)):
_data = tick.loc[tick.date == date]
# morn... | [
"\n tick 采样为 分钟数据\n 1. 仅使用将 tick 采样为 1 分钟数据\n 2. 仅测试过,与通达信 1 分钟数据达成一致\n 3. 经测试,可以匹配 QA.QA_fetch_get_stock_transaction 得到的数据,其他类型数据未测试\n demo:\n df = QA.QA_fetch_get_stock_transaction(package='tdx', code='000001', \n start='2018-08-01 09:25:00',\n ... |
Please provide a description of the function:def QA_data_tick_resample(tick, type_='1min'):
tick = tick.assign(amount=tick.price * tick.vol)
resx = pd.DataFrame()
_temp = set(tick.index.date)
for item in _temp:
_data = tick.loc[str(item)]
_data1 = _data[time(9,
... | [
"tick采样成任意级别分钟线\n\n Arguments:\n tick {[type]} -- transaction\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def QA_data_ctptick_resample(tick, type_='1min'):
resx = pd.DataFrame()
_temp = set(tick.TradingDay)
for item in _temp:
_data = tick.query('TradingDay=="{}"'.format(item))
try:
_data.loc[time(20, 0):time(21, 0), 'volume'] = 0
... | [
"tick采样成任意级别分钟线\n\n Arguments:\n tick {[type]} -- transaction\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def QA_data_min_resample(min_data, type_='5min'):
try:
min_data = min_data.reset_index().set_index('datetime', drop=False)
except:
min_data = min_data.set_index('datetime', drop=False)
CONVERSION = {
'code': 'first',
'open':... | [
"分钟线采样成大周期\n\n\n 分钟线采样成子级别的分钟线\n\n\n time+ OHLC==> resample\n Arguments:\n min {[type]} -- [description]\n raw_type {[type]} -- [description]\n new_type {[type]} -- [description]\n "
] |
Please provide a description of the function:def QA_data_futuremin_resample(min_data, type_='5min'):
min_data.tradeime = pd.to_datetime(min_data.tradetime)
CONVERSION = {
'code': 'first',
'open': 'first',
'high': 'max',
'low': 'min',
'close': 'last',
'trade... | [
"期货分钟线采样成大周期\n\n\n 分钟线采样成子级别的分钟线\n\n future:\n\n vol ==> trade\n amount X\n "
] |
Please provide a description of the function:def QA_data_day_resample(day_data, type_='w'):
# return day_data_p.assign(open=day_data.open.resample(type_).first(),high=day_data.high.resample(type_).max(),low=day_data.low.resample(type_).min(),\
# vol=day_data.vol.resample(type_).sum() if 'vol' i... | [
"日线降采样\n\n Arguments:\n day_data {[type]} -- [description]\n\n Keyword Arguments:\n type_ {str} -- [description] (default: {'w'})\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def QA_SU_save_stock_info(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_stock_info(client=client) | [
"save stock info\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_list(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_stock_list(client=client) | [
"save stock_list\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_index_list(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_index_list(client=client) | [
"save index_list\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_etf_list(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_etf_list(client=client) | [
"save etf_list\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_future_day(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_future_day(client=client) | [
"save future_day\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_future_day_all(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_future_day_all(client=client) | [
"save future_day_all\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_future_min(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_future_min(client=client) | [
"save future_min\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_future_min_all(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_future_min_all(client=client) | [
"[summary]\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_day(engine, client=DATABASE, paralleled=False):
engine = select_save_engine(engine, paralleled=paralleled)
engine.QA_SU_save_stock_day(client=client) | [
"save stock_day\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function: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) | [] |
Please provide a description of the function: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) | [] |
Please provide a description of the function:def QA_SU_save_stock_min(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_stock_min(client=client) | [
"save stock_min\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_index_day(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_index_day(client=client) | [
"save index_day\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_index_min(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_index_min(client=client) | [
"save index_min\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_etf_day(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_etf_day(client=client) | [
"save etf_day\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_etf_min(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_etf_min(client=client) | [
"save etf_min\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_xdxr(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_stock_xdxr(client=client) | [
"save stock_xdxr\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_block(engine, client=DATABASE):
engine = select_save_engine(engine)
engine.QA_SU_save_stock_block(client=client) | [
"save stock_block\n\n Arguments:\n engine {[type]} -- [description]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function: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
'''
... | [] |
Please provide a description of the function:def QA_fetch_stock_day(code, start, end, format='numpy', frequence='day', collections=DATABASE.stock_day):
start = str(start)[0:10]
end = str(end)[0:10]
#code= [code] if isinstance(code,str) else code
# code checking
code = QA_util_code_tolist(code... | [
"'获取股票日线'\n\n Returns:\n [type] -- [description]\n\n 感谢@几何大佬的提示\n https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/#return-the-specified-fields-and-the-id-field-only\n\n "
] |
Please provide a description of the function: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 ['1... | [] |
Please provide a description of the function: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) | [] |
Please provide a description of the function: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) | [] |
Please provide a description of the function: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) | [] |
Please provide a description of the function: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) | [] |
Please provide a description of the function:def QA_fetch_stock_basic_info_tushare(collections=DATABASE.stock_info_tushare):
'''
purpose:
tushare 股票列表数据库
code,代码
name,名称
industry,所属行业
area,地区
pe,市盈率
outstanding,流通股本(亿)
totals,总股本(亿)
totalA... | [] |
Please provide a description of the function: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(... | [] |
Please provide a description of the function: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']:
fre... | [] |
Please provide a description of the function: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']:
f... | [] |
Please provide a description of the function: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) | [] |
Please provide a description of the function:def QA_fetch_ctp_tick(code, start, end, frequence, format='pd', collections=DATABASE.ctp_tick):
code = QA_util_code_tolist(code, auto_fill=False)
cursor = collections.find({
'InstrumentID': {'$in': code}, "time_stamp": {
"$gte": QA_util_time... | [
"仅供存储的ctp tick使用\n\n Arguments:\n code {[type]} -- [description]\n\n Keyword Arguments:\n format {str} -- [description] (default: {'pd'})\n collections {[type]} -- [description] (default: {DATABASE.ctp_tick})\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function: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)
da... | [] |
Please provide a description of the function: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... | [] |
Please provide a description of the function:def QA_fetch_account(message={}, db=DATABASE):
collection = DATABASE.account
return [res for res in collection.find(message, {"_id": 0})] | [
"get the account\n\n Arguments:\n query_mes {[type]} -- [description]\n\n Keyword Arguments:\n collection {[type]} -- [description] (default: {DATABASE})\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def QA_fetch_risk(message={}, params={"_id": 0, 'assets': 0, 'timeindex': 0, 'totaltimeindex': 0, 'benchmark_assets': 0, 'month_profit': 0}, db=DATABASE):
collection = DATABASE.risk
return [res for res in collection.find(message, params)] | [
"get the risk message\n\n Arguments:\n query_mes {[type]} -- [description]\n\n Keyword Arguments:\n collection {[type]} -- [description] (default: {DATABASE})\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function:def QA_fetch_user(user_cookie, db=DATABASE):
collection = DATABASE.account
return [res for res in collection.find({'user_cookie': user_cookie}, {"_id": 0})] | [
"\n get the user\n\n Arguments:\n user_cookie : str the unique cookie_id for a user\n Keyword Arguments:\n db: database for query\n\n Returns:\n list --- [ACCOUNT]\n "
] |
Please provide a description of the function:def QA_fetch_strategy(message={}, db=DATABASE):
collection = DATABASE.strategy
return [res for res in collection.find(message, {"_id": 0})] | [
"get the account\n\n Arguments:\n query_mes {[type]} -- [description]\n\n Keyword Arguments:\n collection {[type]} -- [description] (default: {DATABASE})\n\n Returns:\n [type] -- [description]\n "
] |
Please provide a description of the function: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:
... | [] |
Please provide a description of the function:def QA_fetch_financial_report(code, report_date, ltype='EN', db=DATABASE):
if isinstance(code, str):
code = [code]
if isinstance(report_date, str):
report_date = [QA_util_date_str2int(report_date)]
elif isinstance(report_date, int):
... | [
"获取专业财务报表\n Arguments:\n code {[type]} -- [description]\n report_date {[type]} -- [description]\n Keyword Arguments:\n ltype {str} -- [description] (default: {'EN'})\n db {[type]} -- [description] (default: {DATABASE})\n Raises:\n e -- [description]\n Returns:\n ... |
Please provide a description of the function: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 = ... | [] |
Please provide a description of the function:def QA_SU_save_stock_day(client=DATABASE, ui_log=None, ui_progress=None):
'''
save stock_day
保存日线数据
:param client:
:param ui_log: 给GUI qt 界面使用
:param ui_progress: 给GUI qt 界面使用
:param ui_progress_int_value: 给GUI qt 界面使用
'''
stock_list = Q... | [] |
Please provide a description of the function:def QA_SU_save_stock_week(client=DATABASE, ui_log=None, ui_progress=None):
stock_list = QA_fetch_get_stock_list().code.unique().tolist()
coll_stock_week = client.stock_week
coll_stock_week.create_index(
[("code",
pymongo.ASCENDING),
... | [
"save stock_week\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_xdxr(client=DATABASE, ui_log=None, ui_progress=None):
stock_list = QA_fetch_get_stock_list().code.unique().tolist()
# client.drop_collection('stock_xdxr')
try:
coll = client.stock_xdxr
coll.create_index(
[('c... | [
"[summary]\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_min(client=DATABASE, ui_log=None, ui_progress=None):
stock_list = QA_fetch_get_stock_list().code.unique().tolist()
coll = client.stock_min
coll.create_index(
[
('code',
pymongo.ASCENDING),
('... | [
"save stock_min\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_index_day(client=DATABASE, ui_log=None, ui_progress=None):
__index_list = QA_fetch_get_stock_list('index')
coll = client.index_day
coll.create_index(
[('code',
pymongo.ASCENDING),
('date_stamp',
pymongo.AS... | [
"save index_day\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_index_min(client=DATABASE, ui_log=None, ui_progress=None):
__index_list = QA_fetch_get_stock_list('index')
coll = client.index_min
coll.create_index(
[
('code',
pymongo.ASCENDING),
('time_stamp',
... | [
"save index_min\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_list(client=DATABASE, ui_log=None, ui_progress=None):
client.drop_collection('stock_list')
coll = client.stock_list
coll.create_index('code')
try:
# 🛠todo 这个应该是第一个任务 JOB01, 先更新股票列表!!
QA_util_log_info(
'#... | [
"save stock_list\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_etf_list(client=DATABASE, ui_log=None, ui_progress=None):
try:
QA_util_log_info(
'##JOB16 Now Saving ETF_LIST ====',
ui_log=ui_log,
ui_progress=ui_progress,
ui_progress_int_value=5000
)
... | [
"save etf_list\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_block(client=DATABASE, ui_log=None, ui_progress=None):
client.drop_collection('stock_block')
coll = client.stock_block
coll.create_index('code')
try:
QA_util_log_info(
'##JOB09 Now Saving STOCK_BlOCK ====',
... | [
"save stock_block\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_info(client=DATABASE, ui_log=None, ui_progress=None):
client.drop_collection('stock_info')
stock_list = QA_fetch_get_stock_list().code.unique().tolist()
coll = client.stock_info
coll.create_index('code')
err = []
def __savi... | [
"save stock_info\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_stock_transaction(
client=DATABASE,
ui_log=None,
ui_progress=None
):
stock_list = QA_fetch_get_stock_list().code.unique().tolist()
coll = client.stock_transaction
coll.create_index('code')
err = []
def __savin... | [
"save stock_transaction\n\n Keyword Arguments:\n client {[type]} -- [description] (default: {DATABASE})\n "
] |
Please provide a description of the function:def QA_SU_save_option_commodity_day(
client=DATABASE,
ui_log=None,
ui_progress=None
):
'''
:param client:
:return:
'''
_save_option_commodity_cu_day(
client=client,
ui_log=ui_log,
ui_progress=ui_prog... | [] |
Please provide a description of the function:def QA_SU_save_option_commodity_min(
client=DATABASE,
ui_log=None,
ui_progress=None
):
'''
:param client:
:return:
'''
# 测试中发现, 一起回去,容易出现错误,每次获取一个品种后 ,更换服务ip继续获取 ?
_save_option_commodity_cu_min(
client=client,
... | [] |
Please provide a description of the function:def QA_SU_save_option_min(client=DATABASE, ui_log=None, ui_progress=None):
'''
:param client:
:return:
'''
option_contract_list = QA_fetch_get_option_contract_time_to_market()
coll_option_min = client.option_day_min
coll_option_min.create_index(
... | [] |
Please provide a description of the function:def QA_SU_save_option_day(client=DATABASE, ui_log=None, ui_progress=None):
'''
:param client:
:return:
'''
option_contract_list = QA_fetch_get_option_50etf_contract_time_to_market()
coll_option_day = client.option_day
coll_option_day.create_index(... | [] |
Please provide a description of the function:def QA_SU_save_future_day(client=DATABASE, ui_log=None, ui_progress=None):
'''
save future_day
保存日线数据
:param client:
:param ui_log: 给GUI qt 界面使用
:param ui_progress: 给GUI qt 界面使用
:param ui_progress_int_value: 给GUI qt 界面使用
:return:
'''
... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.