l2数据接口在股票交易中常常需要挖掘股票数据,可以是l1和l2接口来执行获取股票实时行情数据的原理,将自己需要查询的需求就可以数据接口上搜索就可以很快的获取数据了。那么,在获取的过程中,是需要基于开发员将股票数据接口介入开发源码,才能执行自助选股,常见的例子如下:
l2数据接口对TickRecord d1逐笔成交:
源码表示:
import requests;
import time;
import json;
import pandas as pd;
def fenshishuju_dfcf(daima);
//这里我们要定义数组来区分开来,让打印结果更加详细化,实现l2数据接口实时抓取的数据按时间详细化分割,精准的打印出来;
if daima[:2] == "sh":
lsbl = '1.'+daima[2:]
else:
lsbl = '0.' + daima[2:]
wangzhi = "/api/qt/stock/trends2/get?&fields1=f1%2Cf2%2Cf3%2Cf4%2Cf5%2Cf6%2Cf7%2Cf8%2Cf9" \
"%2Cf10%2Cf11%2Cf12%2Cf13&fields2=f51%2Cf52%2Cf53%2Cf54%2Cf55%2Cf56%2Cf57%2Cf58&" \
"ut=7eea3edcaed734bea9cbfc24409ed989&ndays=1&iscr=0&secid="+lsbl+ \
"&_=1643253749790"+str(time.time)
resp = requests.get(wangzhi, timeout=6)
# print (resp)
#打印请求结果的状态码
data = json.loads(resp.text)
shuju = {'日期时间': [], '最新价': [], '均价': [], '成交额': []}
for k in data['data']['trends']:
lsbl = k.split(",")
shuju['日期时间'].append(lsbl[0])
shuju['最新价'].append(lsbl[2])
shuju['均价'].append(lsbl[-1])
shuju['成交额'].append(lsbl[-2])
shuju = pd.DataFrame(shuju)
print(shuju)
return shuju
if __name__ == '__main__':
while 1:
fenshishuju_dfcf('sh603102')
time.sleep(3)
return{
}
当然了,各种股票数据接口同时也能支持多个数据同时进行查询,不会起冲突。