def tick(symbol): """ 获取指定股票的实时数据 :param symbol: 例如:"sh601003",或者"sz002307",前者是沪市,后者是深市 :return:返回一个字典 """ logger.debug("It is recommended to increase the time interval when calling real-time data !") return SinaData.get_realtime_data(symbol)
def stock_zh_index_spot(): """ 描述: 股票指数数据是从新浪财经获取的数据 限量: 单次返回所有指数的实时行情数据 """ logger.debug( "It is recommended to increase the time interval when calling real-time data !" ) return AkShareData.stock_zh_index_spot()
def all_stock_tick(): """ 描述: A 股数据是从新浪财经获取的数据, 重复运行本函数会被新浪暂时封 IP, 建议增加时间间隔 限量: 单次返回所有 A 股上市公司的实时行情数据 """ logger.debug( "It is recommended to increase the time interval when calling real-time data !" ) return AkShareData.all_stock_tick()
def markdown(content): """ 推送markdown类型信息至钉钉 :param content:例如: content = "### 订单更新推送\n\n"\ "> **订单ID:** 1096989546123445\n\n"\ "> **订单状态:** FILLED\n\n"\ "> **时间戳:** 2021年1月2日" :return:推送结果,例如推送成功时的结果:{"errcode":0,"errmsg":"ok"} """ url = config.dingtalk headers = {'Content-Type': 'application/json'} body = { "msgtype": "markdown", "markdown": { "title": "交易提醒", "text": content } } body = json.dumps(body) response = requests.post(url, data=body, headers=headers) logger.debug("dingtalk markdown result:", response) return response
def text(text): """ 推送文本类型信息至钉钉 :param data: 要推送的数据内容,字符串格式 :return: """ json_text = { "msgtype": "text", "at": { "atMobiles": [""], "isAtAll": False }, "text": { "content": text } } headers = {'Content-Type': 'application/json;charset=utf-8'} api_url = config.dingtalk result = requests.post(api_url, json.dumps(json_text), headers=headers) # 发送钉钉消息并返回发送结果 logger.debug("dingtalk text result:{} message:{}".format(result, text)) return result