实时股票数据接口大全

合集下载

python获取股票数据方法

python获取股票数据方法

python获取股票数据方法
1.使用 tushare
Tushare是一个免费、开源的python财经数据接口包,它能够为用户提供便捷的获取股票数据的方法。

Tushare支持大量的股票数据,包括股票列表、股票细节数据、历史价格数据、技术行情数据等。

使用Tushare,只需要简单的函数调用即可获得数据,非常方便快捷。

使用tushare可以很容易获取各类股票数据,以下是一些核心函数的使用示例:
1.获取股票的基本信息:
ts.get_stock_basic
2.获取历史上只股票价格:
3.获取股票历史行情:
4.获取当日实时行情:
ts.get_today_all
使用tushare获取股票数据,需要先安装tushare模块,安装方法如下:
pip install tushare
安装完成后,就可以使用tushare模块来获取股票数据了。

2.使用 Wind Python
Wind Python是Wind财经研究院推出的python接口,用于获取全球财经数据信息,包括国内主板、中小板、创业板的历史价格、财务指标、市场交易数据等。

使用 Wind Python 可以方便的获取港股、美股和A股数据。

使用Wind Python获取股票数据,只需要简单的函数调用即可,以下是一些常用的核心函数的使用示例:
1.获取指定时间段只股票数据:
2.获取指定期间只股票的日收益。

股票实时数据接口

股票实时数据接口
[56]
[36] 成交量(手)
[37] 成交额(万)
[38] 换手率
[39] 市盈率
[40]
[41] 最高
[42] 最低
[43] 振幅
[44] 流通市值
[45] 总市值
[46] 市净率
[47] 涨停价
[48] 跌停价
[49] 量比
[50]
[51] 均价
[52] 市盈率(动)
[53] 市盈率(静)
[54]
[55]
说明
对双引号内的字符串按“~”进行分割,数据项依次为:
[0] 证券所代码
[1] 股票简称
[2] 股代码
[3] 当前价格
[4] 昨收
[5] 今开
[6] 成交量(手)
[7] 外盘
[8] 内盘
[9] 买一
[10] 买一量(手)
[11] 买二
[12] 买二量
[13] 买三
[14] 买三量
[15] 买四
[16] 买四量
股票实时数据接口
请求
举例
/q=sh600660
说明
sh600600是股票代码,将其更换为其他股票代码即可。上证股票代码前加“sh”,深圳股票代码前加“sz”。
响应
举例
v_sh600660="1~福耀玻璃~600660~18.81~18.92~18.92~86578~39928~46619~18.81~3083~18.80~4095~18.79~505~18.78~858~18.77~437~18.82~280~18.83~271~18.84~97~18.85~214~18.86~224~15:00:04/18.81/1473/S/2770713/26114|14:57:02/18.82/9/B/16581/25808|14:56:57/18.81/2/S/3762/25802|14:56:55/18.82/28/B/52696/25800|14:56:52/18.81/35/S/65847/25794|14:56:48/18.81/86/S/161836/25789~20200422153002~-0.11~-0.58~18.92~18.71~18.82/85105/159982368~86578~16275~0.43~14.72~~18.92~18.71~1.11~376.76~471.87~2.26~20.81~17.03~0.58~7892~18.80~15.08~11.45~~~1.06~16275.3081~0.0000~0~ ~GP-A~-21.59~~3.99~15.34~7.97";

股票助手接口文档

股票助手接口文档

目录一、香港股市列表 (2)二、美国股市列表 (3)三、深圳股市列表 (5)四、沪股列表 (6)五、沪深股市 (8)六、香港股市 (11)七、美国股市 (13)八、百度天气 ......................................................................................... 错误!未定义书签。

一、香港股市列表1.接口地址::8080/finance/stock/hkall2.支持格式:json3.请求方式:get/post4.请求示例::8080/finance/stock/hkall?key=您申请的KEY&page=1 请求参数说明返回参数说明JSON返回示例:{"error_code" : 0,"reason" : "SUCCESSED!","result" : {"totalCount" : "317","page" : "1","num" : "20","data" : [ {"symbol" : "00001","name" : "长和","engname" : "CHEUNG KONG","tradetype" : "EQTY","lasttrade" : "82.050","prevclose" : "83.350","open" : "83.000","high" : "83.000","low" : "81.850","volume" : "3919972","currentvolume" : "12000","amount" : "322563957","ticktime" : "2016-07-08 11:59:55","buy" : "82.050","sell" : "82.150","high_52week" : "116.800","low_52week" : "80.600","eps" : "30.720","dividend" : "2.550","stocks_sum" : "3859678500","pricechange" : "-1.300","changepercent" : "-1.5596881"},...]}}二、美国股市列表1.接口地址::8080/finance/stock/usaall2.支持格式:json3.请求方式:get/post4.请求示例::8080/finance/stock/usaall?key=您申请的KEY&page=1 请求参数说明JSON返回示例:{"error_code" : 0,"reason" : "SUCCESSED!","result" : {"totalCount" : "8965","page" : "1","num" : "20","data" : [ {"cname" : "HSBC Holdings, plc. Perpetual Sub Cap Secs", "category" : null,"symbol" : "HSEA","price" : "27.00","diff" : "0.07","chg" : "0.26","preclose" : "26.93","open" : "26.87","high" : "27.07","low" : "26.87","amplitude" : "0.74%","volume" : "67734","mktcap" : "580930009842","market" : "NYSE"},...]}}三、深圳股市列表1.接口地址::8080/finance/stock/szall2.支持格式:json3.请求方式:get/post4.请求示例::8080/finance/stock/szall?key=您申请的APPKEY&page=1JSON返回示例:{"error_code": 0,"reason": "SUCCESSED!","result": {"totalCount": "1822","page": "1","num": "20","data": [{"symbol": "sz000001","name": "平安银行","trade": "8.960","pricechange": "0.020","changepercent": "0.224","buy": "8.960","sell": "8.970","settlement": "8.940","open": "8.950","high": "8.990","low": "8.910","volume": 243674,"amount": 218229439,"code": "000001","ticktime": "13:40:30"},...]}}四、沪股列表1.接口地址::8080/finance/stock/shall2.支持格式:json3.请求方式:get/post4.请求示例::8080/finance/stock/shall?key=您申请的KEY&page=1返回参数说明JSON返回示例:{"error_code": 0, "reason": "SUCCESSED!", "result": { "totalCount": "1116", "page": "1","num": "20", "data": [{ "symbol": "sh600000", "name": "浦发银行", "trade": "15.680", "pricechange": "-0.020", "changepercent": "-0.127", "buy": "15.680", "sell": "15.690", "settlement": "15.700", "open": "15.710", "high": "15.750", "low": "15.650", "volume": 89537, "amount": 140465568, "code": "600000","ticktime": "13:44:46"},...]}}五、沪深股市1.接口地址::8080/finance/stock/hs2.支持格式:json3.请求方式:get4.请求示例::8080/finance/stock/hs?gid=sh601009&key=您申请的APPKEY请求参数说明JSON返回示例:{"resultcode": "200", "reason": "SUCCESSED!", "result": [{"data": { "buyFive": "451800", "buyFivePri": "10.050", "buyFour": "211900", "buyFourPri": "10.060", "buyOne": "345301", "buyOnePri": "10.090", "buyThree": "90919", "buyThreePri": "10.070", "buyTwo": "50200", "buyTwoPri": "10.080", "competitivePri": "10.090", "date": "2016-07-15", "gid": "sh601009", "increPer": "0.50","increase": "0.050","name": "南京银行","nowPri": "10.100","reservePri": "10.100","sellFive": "231198","sellFivePri": "10.140","sellFour": "109115","sellFourPri": "10.130","sellOne": "468699","sellOnePri": "10.100","sellThree": "27216","sellThreePri": "10.120","sellTwo": "35400","sellTwoPri": "10.110","time": "14:10:14","todayMax": "10.170","todayMin": "10.030","todayStartPri": "10.040","traAmount": "157977741.000","traNumber": "156345","yestodEndPri": "10.050"},"dapandata": {"dot": "10.100","name": "南京银行","nowPic": "0.050","rate": "0.50","traAmount": "15798","traNumber": "156345"},"gopicture": {"minurl": "/newchart/min/n/sh601009.gif", "dayurl": "/newchart/daily/n/sh601009.gif", "weekurl": "/newchart/weekly/n/sh601009.gif", "monthurl": "/newchart/monthly/n/sh601009.gif"}}],"error_code": 0}六、香港股市1.接口地址::8080/finance/stock/hk2.支持格式:json3.请求方式:get4.请求示例::8080/finance/stock/hk?num=00001&key=您申请的APPKEY请求参数说明返回参数说明JSON返回示例:{"resultcode": "200","reason": "SUCCESSED!","result": [{"data": {"gid": "hk00001","ename": "CKH HOLDINGS","name": "长和","openpri": "86.950","formpri": "86.450","maxpri": "87.400","minpri": "86.100","lastestpri": "87.000","uppic": "0.550","limit": "0.636","inpic": "87.000","outpic": "87.050","traAmount": "375859081.900","traNumber": "4324747","priearn": "2.832","max52": "116.800","min52": "80.600","date": "2016/07/15","time": "14:43:35"},"gopicture": {"minurl": "/newchart/hk_stock/min/00001.gif", "dayurl": "/newchart/hk_stock/daily/00001.gif", "weekurl": "/newchart/hk_stock/weekly/00001.gif", "monthurl": "/newchart/hk_stock/monthly/00001.gif"},"hengsheng_data": {"date": "2016/07/15","formpri": "21561.059","lastestpri": "21593.779","limit": "0.150","max52": "25634.320","maxpri": "21739.209","min52": "18278.801","minpri": "21515.350","openpri": "21589.080","time": "14:43:44","traAmount": "54904135.744000","uppic": "32.720"}}],"error_code": 0}七、美国股市1.接口地址::8080/finance/stock/usa2.支持格式:json3.请求方式:get4.请求示例::8080/finance/stock/usa?gid=aapl&key=您申请的APPKEY请求参数说明返回参数说明JSON返回示例:{"resultcode": "200", "reason": "SUCCESSED!", "result": [{"data": {"gid": "aapl","name": "苹果", "lastestpri": "98.79", "openpri": "97.39", "formpri": "96.87", "maxpri": "98.99", "minpri": "97.32", "uppic": "1.92","limit": "1.98", "traAmount": "38918997", "avgTraNumber": "28355453", "markValue": "541369200000", "max52": "132.97","min52": "89.47", "EPS": "8.98", "priearn": "11.00","beta": "1.43","divident": "2.13","ROR": "2.20","capital": "5480000000","afterpic": "98.60","afterlimit": "-0.19","afteruppic": "-0.19","aftertime": "Jul 14 07:59PM EDT","ustime": "Jul 14 04:00PM EDT","chtime": "2016-07-15 08:19:31"},"gopicture": {"minurl": "/newchartv5/usstock/min/aapl.gif","min_weekpic": "/newchartv5/usstock/min_week/aapl.gif", "dayurl": "/newchartv5/usstock/daily/aapl.gif", "weekurl": "/newchartv5/usstock/weekly/aapl.gif", "monthurl": "/newchartv5/usstock/monthly/aapl.gif"}}],"error_code": 0}。

python获取股票数据接口

python获取股票数据接口

python获取股票数据接⼝# encoding: utf8#部分⽹站api数据有bug,这个bug问题不是⾃⾝程序的问题,⽽是第三⽅公司股票的问题__author__ = 'nooper'import refrom math import ceilimport datetimefrom httpGet import httpGetContentfrom common import decimaldef _get_content(content):"处理腾讯股票数据接⼝信息"regex = pile(r'"(.*)"')result = regex.findall(content)if result:return result[0].split('~')def getStockPosition(code, market):"""处理股票盘⼝数据分析,分析所占的百分⽐率/q=s_pksz000858v_s_pksz000858="0.196~0.258~0.221~0.325";以 ~ 分割字符串中内容,下标从0开始,依次为:0: 买盘⼤单1: 买盘⼩单2: 卖盘⼤单3: 卖盘⼩单所占有的百分⽐百分⽐率"""if code and market:url = "/q=s_pk%s%s" % (market, code)content = httpGetContent(url)if content:result_list = _get_content(content)if result_list:stock_dict = {}stock_dict["code"] = codestock_dict["market"] = marketstock_dict["buy_big_percent"] = float(result_list[0]) # 买盘⼤单所占百分⽐stock_dict["buy_small_percent"] = float(result_list[1]) # 买盘⼩单所占百分⽐stock_dict["sell_big_percent"] = float(result_list[2]) # 卖盘⼤单所占⽐重stock_dict["sell_small_percent"] = float(result_list[3]) # 买盘⼩单所占⽐重stock_dict["date"] = datetime.date.today()return stock_dict# todo 数据对不上def getStockCashFlow(code, market):"""得到股票是资⾦流⼊流出/q=ff_sz000858v_ff_sz000858="sz000858~41773.67~48096.67~-6322.99~-5.53~10200.89~14351.02~-4150.13~-3.63~114422.25~53015.90~59770.57~五粮液~20121221";以 ~ 分割字符串中内容,下标从0开始,依次为:0: 代码1: 主⼒流⼊2: 主⼒流出3: 主⼒净流⼊4: 主⼒净流⼊/资⾦流⼊流出总和5: 散户流⼊6: 散户流出7: 散户净流⼊8: 散户净流⼊/资⾦流⼊流出总和9: 资⾦流⼊流出总和1+2+5+610: 未知11: 未知12: 名字13: ⽇期"""if code and market:url = "/q=ff_%s%s" % (market, code)content = httpGetContent(url)if content:result_list = _get_content(content)if result_list:stock_dict = {}stock_dict["code"] = codestock_dict["main_outflow"] = float(result_list[2]) # 主⼒流出stock_dict["main_netflow"] = float(result_list[3]) # 主⼒净流⼊stock_dict["small_inflow"] = float(result_list[5]) # 散户流⼊stock_dict["small_outflow"] = float(result_list[6]) # 散户流出stock_dict["small_netflow"] = float(result_list[7]) # 散户净流⼊income = stock_dict["main_inflow"] + stock_dict["small_inflow"]outcome = stock_dict["main_outflow"] + stock_dict["main_outflow"]print incomeprint outcomeprint income - outcomestock_dict["unknown_1"] = float(result_list[10])stock_dict["unknwon_2"] = float(result_list[11])stock_dict["date"] = result_list[13] # ⽇期return stock_dictdef getStockCurrentDay(code, Market):'''获取股票当⽇数据腾讯APIAPI地址:/q=sh600383sh:上海sz:深圳返回当天成交数据code:股票代码market:股票市场数据返回@return dict'''if code and Market:url = '/q=%s%s' % (Market, code)headers = {'Content-type': 'application/x-javascript; charset=GBK'}result = httpGetContent(url=url, headers=headers, charset='gbk')if result:stocklist = _get_content(result)if stocklist:stockdict = {}stockdict['code'] = code # 股票代码stockdict['name'] = unicode(stocklist[1], 'utf8') # 股票名称stockdict['last_closing'] = float(stocklist[4]) # 昨⽇收盘价格stockdict['start'] = float(stocklist[5]) # 开盘价格stockdict['end'] = float(stocklist[3]) # 当前收盘价格(可以是当前价格) stockdict['high'] = float(stocklist[33]) # 最⾼价格stockdict['low'] = float(stocklist[34]) # 最低价格stockdict['buyvol'] = int(stocklist[7]) # 外盘 todo 数据对不上stockdict["sellvol"] = int(stocklist[8]) # 内盘 todo 数据对不上stockdict['range_price'] = float(stocklist[31]) # 涨跌价格stockdict['range_percent'] = float(stocklist[32]) # 涨跌⽐%stockdict['volume'] = int(stocklist[6]) # 成交量(⼿)stockdict['total_price'] = int(stocklist[37]) # 成交额(万元)stockdict['change_rate'] = decimal(stocklist[38]) # 换⼿率stockdict['pe'] = decimal(stocklist[39]) # 市盈率stockdict['swing'] = float(stocklist[43]) # 振幅stockdict['pb'] = float(stocklist[46]) # 股票市净率stockdict['date'] = stocklist[30][:8] # 时间stockdict["block"] = False if stockdict["start"] else True #股票是否停牌return stockdictdef getStockMarket(code):"""⼤盘数据接⼝信息上证:code:000001 set=zs深证:code:399001 set=zs中⼩板:code:399005 set=zs创业板: code:399006 set=zs/qp/hq?type=snapshot&code=000001&set=zs"""url = "/qp/hq?type=snapshot&code=%s&set=zs" % coderesult = httpGetContent(url=url, charset="gbk")if result:result = eval(result)stock_dict = {}stock_dict["date"] = result[0][:10] #⽇期stock_dict["name"] = unicode(result[2], 'utf8') #名称stock_dict["range_price"] = float(result[4]) #上涨价格stock_dict["start"] = float(result[9]) #开盘价格stock_dict["high"] = float(result[11]) #最⾼价格stock_dict["low"] = float(result[13]) #最低价格stock_dict["last_closing"] = float(result[7]) #昨⽇收stock_dict["end"] = float(result[3]) #收盘价格stock_dict["total_sum"] = int(result[18]) #多少万元stock_dict["volume"] = int(result[14]) #多少⼿return stock_dicttonghuashun_headers = {"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding": "gzip,deflate,sdch","Accept-Language": "zh-CN,zh;q=0.8","Cache-Control": "no-cache","Connection": "keep-alive","Host": "","User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36"}# def getstockBlock():# """# 新浪股票⿊名单数据# ”需要得到单点登录信息“## 新浪股票⿊名单个股# /stock/disallowStock# """# headers = {# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',# 'Cache-Control': "max-age=0",# 'Host': '',# 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36', # 'Cookie': "PHPSESSID=c32fbi3m3sf0he8v1rdem3t006; gxqSignId=02d9c361fe5fc1ab; WBStore=d6acd6adea5a82d3|undefined"## }# url = "/stock/disallowStock"# content = httpGetContent(url=url, headers=headers)# if content:# soup = BeautifulSoup(content)# td_list = soup.find_all(text=pile('\d+'))# return td_listdef__convert_MIN(content):content = content.split('=')[1]content_list = content.split('|')stock_dict = {}for sub in content_list:if sub:items = sub.split('~')date = items[0]price_list = items[1].split(';')price_dict = {}for a in price_list:b = a.split(',')start = float(b[0]) #开盘价high = float(b[1]) #最⾼价格low = float(b[2]) #最低价格end = float(b[3]) #结束价格volum = int(ceil(float(b[4]))) #成交量多少买⼊total_price = int(ceil(float(b[5]))) #成交额time = b[6] #时间格式是1030,11:30,1400,1500price_dict[time] = {"high": high,'low': low,"end": end,"start": start,"volumn": volum,"total_price": total_price}stock_dict[date] = price_dictreturn stock_dictdef getStock60MIN(code, market, type=''):"""不推荐向后复权得到股票60分钟数据线API接⼝数据/api.php?p=stock_min60&info=k_sz_000005&fq=qq是向前复权b事项后复权q= 空是不复权"""if market not in ('sz', 'sh'):returnurl = "/api.php?p=stock_min60&info=k_%s_%s&fq=%s" % (market, code, type) content = httpGetContent(url=url)if content:return__convert_MIN(content)def getStock30MIN(code, market, type=''):"""30分钟数据接⼝信息/api.php?p=stock_min30&info=k_sz_000005&fq="""if market not in ('sz', 'sh'):returnurl = "/api.php?p=stock_min30&info=k_%s_%s&fq=%s" % (market, code, type) content = httpGetContent(url=url)if content:return__convert_MIN(content)def getStock15MIN(code, market, type=''):"""15分钟数据接⼝/api.php?p=stock_min15&info=k_sz_000005&fq="""if market not in ('sz', 'sh'):returnurl = "/api.php?p=stock_min15&info=k_%s_%s&fq=%s" % (market, code, type) content = httpGetContent(url=url)if content:return__convert_MIN(content)def__convert_inner(stock, stock_dict={}):stock_day = stock.split(',')if all(stock_day):date = stock_day[0] #⽇期start = float(stock_day[1]) #开盘价格high = float(stock_day[2]) #最⾼价格low = float(stock_day[3]) #最低价格end = float(stock_day[4]) #收盘价格volume = int(ceil(float(stock_day[5]))) #成交量total = int(ceil(float(stock_day[6]))) #成交额stock_dict[date] = {"date": date,'start': start,'high': high,'low': low,'end': end,'volume': volume,'total': total,}return stock_dictdef__convert_day(content):stock_list = content.split('=')[1].split('|')stock_dict = {}for stock in stock_list:if stock and stock.strip():__convert_inner(stock, stock_dict)# stock_day = stock.split(',')# date = stock_day[0] #⽇期# start = stock_day[1] #开盘价格# high = stock_day[2] #最⾼价格# low = stock_day[3] #最低价格# end = stock_day[4] #收盘价格# volume = int(ceil(float(stock_day[5]))) #成交量# total = int(ceil(float(stock_day[6]))) #成交额# stock_dict[date] = {# "date": date,# 'start': start,# 'high': high,# 'low': low,# 'end': end,# 'volume': volume,# 'total': total,# }return stock_dictdef__convert_week(content):content_list = content.split(';')regex = pile('=(.*)$')stock_dict = {}for s in content_list:p = regex.findall(s)[0]stock_list = p.split('|')for week in stock_list:if week:__convert_inner(week, stock_dict)return stock_dict#todo 测试完成def getStockDayHistory(code, market, year='2013', type=''):"""/api.php?p=stock_day&info=k_sz_000005&year=2012,2013&fq=sz:深证sh:上海return dict"""url = "/api.php?p=stock_day&info=k_%s_%s&year=%s&fq=%s" % (market, code, year, type) content = httpGetContent(url=url)if content:return__convert_day(content)#todo 测试完成def getStockWeekHistory(code, market, year='2012,2013', type=''):"""x/api.php?p=stock_week&info=k_sz_000005&year=2011,2012,2013&fq=pass"""url = "/api.php?p=stock_week&info=k_%s_%s&year=%s&fq=%s" % (market, code, year, type ) content = httpGetContent(url, tonghuashun_headers)if content:return__convert_week(content)def__convertMonth(content):passdef getStockMonthHistory(code, market, type=''):"""/api.php?p=stock_month&info=k_sz_000671&fq="""url = "/api.php?p=stock_month&info=k_%s_%s&fq=%s" % (market, code, type)content = httpGetContent(url)if content:passdef main():# g = getStock60MIN('600847', 'sh')# for k in g:# print k# print g[k]# g = getStockDayHistory("600198", "sh")# print g# import config## print getStockMarket(config.SHANGHAI)print getStockCurrentDay("600383", "sh")if__name__ == "__main__":main()。

沪深、香港、美国股票数据接口

沪深、香港、美国股票数据接口

沪深、香港、美国股票数据接口在即将到来的双十二,在聚合数据平台上的股票数据接口将参与活动,首先我们将分享下股票数据接口代码文档及返回示例,提供沪深、香港、美国股市信息。

接口名称:股票数据接口接口平台:聚合数据接口地址::8080/finance/stock/hs支持格式:json请求方式:get请求示例::8080/finance/stock/hs?gid=sh601009&key=您申请的APPKEY 调用样例及调试工具:API测试工具请求参数说明:名称类型必填说明gid string 是股票编号,上海股市以sh开头,深圳股市以sz开头如:sh601009(type为0或者1时gid不是必须)key String 是APP Keytype int 否0代表上证指数,1代表深证指数返回参数说明:名称类型说明见JSON返回示例- -JSON返回示例:{"resultcode":"200", /*返回码,200:正常*/ "reason":"SUCCESSED!","result":[{"data":{"gid":"sh601009", /*股票编号*/"name":"南京银行", /*股票名称*/"todayStartPri":"8.26", /*今日开盘价*/"yestodEndPri":"8.26", /*昨日收盘价*/"nowPri":"8.37", /*当前价格*/"todayMax":"8.55", /*今日最高价*/"todayMin":"8.25", /*今日最低价*/"competitivePri":"8.37", /*竞买价*/"reservePri":"8.38", /*竞卖价*/"traNumber":"34501453", /*成交量*/"traAmount":"290889560", /*成交金额*/"buyOne":"10870", /*买一*/"buyOnePri":"8.37", /*买一报价*/"buyTwo":"177241", /*买二*/"buyTwoPri":"8.36", /*买二报价*/"buyThree":"92600", /*买三*/"buyThreePri":"8.35", /*买三报价*/"buyFour":"87200" /*买四*/"buyFourPri":"8.34", /*买四报价*/"buyFive":"113700", /*买五*/"buyFivePri":"8.42", /*买五报价*/"sellOne":"47556", /*卖一*/"sellOnePri":"8.38", /*卖一报价*/"sellTwo":"103057", /*卖二*/"sellTwoPri":"8.39", /*卖二报价*/"sellThree":"186689", /*卖三*/"sellThreePri":"8.40", /*卖三报价*/"sellFour":"49000", /*卖四*/"sellFourPri":"8.41", /*卖四报价*/"sellFive":"214535", /*卖五*/"sellFivePri":"15.21", /*卖五报价*/"date":"2012-12-11", /*日期*/"time":"15:03:06", /*时间*/},"dapandata":{"name":"南京银行", /*大盘指数名称*/"dot":"8.37" /*大盘当前点数*/"nowPic":"0.11", /*大盘当前价格*/"rate":"1.33", /*大盘涨跌率*/"traNumber":"345014", /*大盘成交量(手)*/"traAmount":"29088", /*大盘成交金额(万元)*/ },"gopicture":{"minurl":"/newchart/min/n/sh601009.gif",/*分时K线图*/ "dayurl":"/newchart/daily/n/sh601009.gif",/*日K线图*/"weekurl":"/newchart/weekly/n/sh601009.gif",/*周K线图*/"monthurl":"/newchart/monthly/n/sh601009.gif"/*月K线图*/ }}]}----------------------------------深(上)证指数示例------------------------------------------------------------------{"error_code": 0"reason": "SUCCESSED!","result": {"dealNum": "24388041799",/*成交量*/"dealPri": "340674441059.270",/*成交额*/"highPri": "10357.417",/*最高*/"lowpri": "10121.741",/*最低*/"name": "深证成指",/*名称*/"nowpri": "10270.855",/*当前价格*/"openPri": "10200.547",/*今开*/"time": "2015-09-22 14:45:25",/*时间*/"yesPri": "10176.727"/*昨收*/},}数据接口API服务也是大数据企业的重要方向,数据API是每一个开发者必备的,也是需求量最大的数据产品。

基于php的股票查询接口调用代码实例

基于php的股票查询接口调用代码实例

基于php的股票查询接口调用代码实例代码描述:基于php的股票查询接口调用代码实例代码平台:聚合数据<!--?php// +----------------------------------------------------------------------// | JuhePHP [ NO ZUO NO DIE ]// +----------------------------------------------------------------------// | Copyright (c) 2010-2015 All rights reserved.// +----------------------------------------------------------------------// | Author: Juhedata <info@-->// +----------------------------------------------------------------------//----------------------------------// 股票查询调用示例代码-聚合数据// 在线接口文档:/docs/81//----------------------------------header('Content-type:text/html;charset=utf-8');//配置您申请的appkey$appkey= "*********************";//************1.股票查询************$url= "/onebox/stock/query ";$params= array("key"=> $appkey,//应用APPKEY(应用详细页查询)"dtype"=> "",//返回数据的格式,xml或json,默认json"stock"=> "",//股票名称);$paramstring= http_build_query($params);$content= juhecurl($url,$paramstring);$result= json_decode($content,true);if($result){if($result['error_code']=='0'){print_r($result);}else{echo$result['error_code'].":".$result['reason'];}}else{echo"请求失败";}//**************************************************/*** 请求接口返回内容* @param string $url[请求的URL地址]* @param string $params[请求的参数]* @param int $ipost[是否采用POST形式]* @return string*/function juhecurl($url,$params=false,$ispost=0){$httpInfo= array();$ch= curl_init();curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData');curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );curl_setopt( $ch, CURLOPT_TIMEOUT , 60);curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);if( $ispost){curl_setopt( $ch, CURLOPT_POST , true );curl_setopt( $ch, CURLOPT_POSTFIELDS , $params);curl_setopt( $ch, CURLOPT_URL , $url);}else{if($params){curl_setopt( $ch, CURLOPT_URL , $url.'?'.$params);}else{curl_setopt( $ch, CURLOPT_URL , $url);}}$response= curl_exec( $ch);if($response=== FALSE) {//echo "cURL Error: " . curl_error($ch);return false;}$httpCode= curl_getinfo( $ch, CURLINFO_HTTP_CODE );$httpInfo= array_merge( $httpInfo, curl_getinfo( $ch) );curl_close( $ch);return$response;}。

沪深分析数据板块资金流向信息API接口(十九)

沪深分析数据板块资金流向信息API接口(十九)
mc
string
概念板块名称
dm
string
概念板块代码
jj
number
均价(元)
zdf
number
涨跌幅(%)
lrzj
number
流入资金(元)
lczj
number
流出资金(元)
jlr
number
净流入(元)
jlrl
number
净流入率(%)
lzgmc
string
领涨股名称
lzgdm
string
领涨股代码
lzgjlrl
number
领涨股净流入率(%)
·接口说明:证监会行业资金流向,根据流入资金倒序排列。
·数据更新:每天15:30
·请求频率:1分钟20次
·返回格式:标准Json格式[{},...{}]
字段名称
数据类型
字段说明
t
string
服务器更新时间yyyy-MM-dd HH:mm:ss
mc
string
行业名称
dm
string
行业代码
jj
number
均价(元)
zdf
number
涨跌幅(%)
lrzj
numberΒιβλιοθήκη 流入资金(元)lczj
number
流出资金(元)
jlr
number
净流入(元)
jlrl
number
净流入率(%)
lzgmc
string
领涨股名称
lzgdm
string
领涨股代码
lzgjlrl
number
领涨股净流入率(%)
概念板块

通过新浪网股票接口获取股票信息

通过新浪网股票接口获取股票信息

通过新浪网股票接口获取股票信息以下函数全是静态方法,可以在C#中直接调用using System;using System.Collections.Generic;using System.Linq;using System.Text;using ;using System.IO;using System.Data;using System.Text.RegularExpressions;namespace GzyFunctionLibrary{public class GetStockInfo{public static string[] StockItems = new string[32] { "股票名字", "今日开盘价", "昨日收盘价", "当前价格", "今日最高价", "今日最低价", "竞买价,即买一报价", "竞卖价,即卖一报价", "成交的股票数", "成交金额", "买一申请多少股", "买一报价", "买二", "买二", "买三", "买三", "买四", "买四", "买五", "买五", "卖一申报股数", "卖一报价", "卖二申报股数", "卖二报价", "卖三申报股数", "卖三报价", "卖四申报股数", "卖四报价", "卖五申报股数", "卖五报价", "日期", "时间" };public static string[] PastStockItems = new string[] { "指数名称", "当前点数", "涨跌点数", "涨跌率", "成交量(手)", "成交额(万元)" };private static string url = "/list=";private static string PastUrl = "/list=s_";/// <summary>/// 生成/// </summary>/// <param name="StockID"></param>/// <param name="ValueType"></param>/// <returns></returns>private static string GetUrl(string StockID, int ValueType){string id = string.Empty;if (StockID == "" || StockID.Length != 6){return null;}string dm = "sh";if (StockID.Trim() == "000001")dm = "sh";else if (StockID.Trim() == "399001")dm = "sz";else if (StockID.Substring(0, 2) == "00")//深圳dm = "sz";else if (StockID.Substring(0, 2) == "60")dm = "sh";else if (StockID.Substring(0, 2) == "51")//上海基金dm = "sh";switch (ValueType){case 0:return url + dm + StockID;case 1:return PastUrl + dm + StockID;default:return url + dm + StockID;}}/// <summary>/// 获取服务实时及历史信息/// </summary>/// <param name="url"></param>/// <returns></returns>public static string[] GetValue(string url){try{string[] StockValue;WebClient myWebClient = new WebClient();Stream myStream = myWebClient.OpenRead(url);StreamReader sr = new StreamReader(myStream, System.Text.Encoding.GetEncoding("gbk"));string strHTML = sr.ReadToEnd();myStream.Close();sr.Close();int first = strHTML.IndexOf("\"");strHTML = strHTML.Substring(first + 1, strHTML.Length - first - 4);StockValue = strHTML.Split(',');if (StockValue.Length >= 2)return StockValue;elsereturn null;}catch (Exception ex){return null;throw ex;}}/// <summary>/// 获取股票实时信息/// </summary>/// <param name="StockId"></param>/// <returns></returns>public static string[] GetRealValue(string StockId){return GetValue(GetUrl(StockId, 0));}/// <summary>/// 获取股票历史信息/// </summary>/// <param name="StockId"></param>/// <returns></returns>public static string[] GetPastValue(string StockId){return GetValue(GetUrl(StockId, 1));}public static DataTable getHis(string stockId){DataTable dt = new DataTable();dt.Columns.Add("StockId", typeof(string));dt.Columns.Add("iDate", typeof(DateTime));dt.Columns.Add("Opening", typeof(double));dt.Columns.Add("MaxHight", typeof(double));dt.Columns.Add("Closing", typeof(double));dt.Columns.Add("MaxLow", typeof(double));string url = string.Format("/corp/go.php/vMS_MarketHistory/stockid/{0}.p html", stockId);.WebClient wc = new WebClient();string Content = wc.DownloadString(url);string reg = "<a target='_blank'href='/quotes_service/view/vMS_tradehistory.php?symbol=s hd{6}&date=d{4}-d{2}-d{2}'>s*([^s]+)s+</a>s*</div></td>s*<td[^d]*([^<]*)</div></td>s+<td[^d] *([^<]*)</div></td>s+<td[^d]*([^<]*)</div></td>s+<td[^d]*([^<]*)</div></td>s+";MatchCollection result = Regex.Matches(Content, reg);foreach (Match item in result){DataRow dr = dt.NewRow();dr[0] = stockId;dr[1] = item.Groups[1].Value;//时间dr[2] = item.Groups[2].Value;//时间dr[3] = item.Groups[3].Value;//时间dr[4] = item.Groups[4].Value;//时间dr[5] = item.Groups[5].Value;//时间}return dt;}}}。

Python获取股票历史、实时数据与更新到数据库

Python获取股票历史、实时数据与更新到数据库

Python获取股票历史、实时数据与更新到数据库要做量化投资,数据是基础,正所谓“巧妇难为⽆⽶之炊”在免费数据⽅⾯,各⼤⽹站的财经板块其实已提供相应的api,如新浪、雅虎、搜狐。

可以通过urlopen相应格式的⽹址获取数据⽽TuShare正是这么⼀个免费、开源的python财经数据接⼝包,已将各类数据整理为dataframe类型供我们使⽤。

主要⽤到的函数:1.实时⾏情获取tushare.get_today_all()⼀次性获取当前交易所有股票的⾏情数据(如果是节假⽇,即为上⼀交易⽇,结果显⽰速度取决于⽹速)2.历史数据获取tushare.get_hist_data(code, start, end,ktype, retry_count,pause)参数说明:code:股票代码,即6位数字代码,或者指数代码(sh=上证指数 sz=深圳成指 hs300=沪深300指数 sz50=上证50 zxb=中⼩板 cyb=创业板)start:开始⽇期,格式YYYY-MM-DDend:结束⽇期,格式YYYY-MM-DDktype:数据类型,D=⽇k线 W=周 M=⽉ 5=5分钟 15=15分钟 30=30分钟 60=60分钟,默认为Dretry_count:当⽹络异常后重试次数,默认为3pause:重试时停顿秒数,默认为0⽽如果要进⾏完备详细的回测,每次在线获取数据⽆疑效率偏低,因此还需要⼊库下⾯是数据库设计部分表1:stocks股票表,第⼀列为股票代码,第⼆列为名称,如果get_today_all()中存在的股票stocks表中没有,则插⼊之。

表2:hdata_date⽇线表,由于分钟线只能获取⼀周内的数据,我们先对⽇线进⾏研究。

字段和get_hist_data返回值基本⼀致,多了stock_code列,并将record_date列本来是dataframe的indexstock_code,record_date, //主键open,high,close,low, //开盘,最⾼,收盘,最低volume, //成交量price_change,p_change, //价差,涨幅ma5,ma10,ma20 //k⽇收盘均价v_ma5,v_ma10,v_ma20, //(k⽇volume均值)turnover //换⼿率python⼯程⽬前有3个⽂件,main.py(主程序),Stocks.py(“股票们”类)以及Hdata.py(历史数据类)main.pyimport psycopg2 #使⽤的是PostgreSQL数据库import tushare as tsfrom Stocks import*from HData import*import datetimestocks=Stocks("postgres","123456")hdata=HData("postgres","123456")# stocks.db_stocks_create()#如果还没有表则需要创建#print(stocks.db_stocks_update())#根据todayall的情况更新stocks表#hdata.db_hdata_date_create()nowdate=datetime.datetime.now().date()codestock_local=stocks.get_codestock_local()hdata.db_connect()#由于每次连接数据库都要耗时0.0⼏秒,故获取历史数据时统⼀连接for i in range(0,len(codestock_local)):nowcode=codestock_local[i][0]#print(hdata.get_all_hdata_of_stock(nowcode))print(i,nowcode,codestock_local[i][1])maxdate=hdata.db_get_maxdate_of_stock(nowcode)print(maxdate, nowdate)if(maxdate):if(maxdate>=nowdate):#maxdate⼩的时候说明还有最新的数据没放进去continuehist_data=ts.get_hist_data(nowcode, str(maxdate+datetime.timedelta(1)),str(nowdate), 'D', 3, 0.001)hdata.insert_perstock_hdatadate(nowcode, hist_data)else:#说明从未获取过这只股票的历史数据hist_data = ts.get_hist_data(nowcode, None, str(nowdate), 'D', 3, 0.001)hdata.insert_perstock_hdatadate(nowcode, hist_data)hdata.db_disconnect()Stocks.pyimport tushare as tsimport psycopg2class Stocks(object):#这个类表⽰"股票们"的整体(不是单元)def get_today_all(self):self.todayall=ts.get_today_all()def get_codestock_local(self):#从本地获取所有股票代号和名称conn = psycopg2.connect(database="wzj_quant", user=er, password=self.password, host="127.0.0.1",port="5432")cur = conn.cursor()# 创建stocks表cur.execute('''select * from stocks;''')rows =cur.fetchall()mit()conn.close()return rowspassdef__init__(self,user,password):# self.aaa = aaaself.todayall=[]er=userself.password=passworddef db_perstock_insertsql(self,stock_code,cns_name):#返回的是插⼊语句sql_temp="insert into stocks values("sql_temp+="\'"+stock_code+"\'"+","+"\'"+cns_name+"\'"sql_temp +=");"return sql_temppassdef db_stocks_update(self):# 根据gettodayall的情况插⼊原表中没的。

雅虎和新浪股票接口调用方法收集

雅虎和新浪股票接口调用方法收集

雅虎和新浪股票接口调用方法收集[]获取股票数据的2个简单方法blog.science./home.php?mod=space&uid=461456&do=blog&id=4552 111.原文地址:实时股票数据接口大全股票数据的获取目前有如下两种方法可以获取:1. /javascript接口取数据2. web-service接口1./javascript接口取数据1.1Sina股票数据接口以大秦铁路(股票代码:601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据接口:hq.sinajs./list=sh601006这个url会返回一串文本,例如:var hq_str_sh601006="大秦铁路, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92, 22114263, 589824680, 4695, 26.91, 57590, 26.90, 14700, 26.89, 14300,26.88, 15100, 26.87, 3100, 26.92, 8900, 26.93, 14230, 26.94, 25150, 26.95, 15220, 26.96, xx-01-11, 15:05:32";这个字符串由许多数据拼接在一起,不同含义的数据用逗号隔开了,按照程序员的思路,顺序号从0开始。

0:”大秦铁路”,股票名字;1:”27.55″,今日开盘价;2:”27.25″,昨日收盘价;4:”27.55″,今日最高价;5:”26.20″,今日最低价;6:”26.91″,竞买价,即“买一”报价;7:”26.92″,竞卖价,即“卖一”报价;8:”22114263″,成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百;9:”589824680″,成交金额,单位为“元”,为了一目了然,通常以“万元”为成交金额的单位,所以通常把该值除以一万;10:”4695″,“买一”申请4695股,即47手;11:”26.91″,“买一”报价;12:”57590″,“买二”14:”14700″,“买三”15:”26.89″,“买三”16:”14300″,“买四”17:”26.88″,“买四”18:”15100″,“买五”19:”26.87″,“买五”20:”3100″,“卖一”申报3100股,即31手;21:”26.92″,“卖一”报价(22, 23), (24, 25), (26,27), (28, 29)分别为“卖二”至“卖四的情况”30:”xx-01-11″,日期;31:”15:05:32″,时间;一个简单的JavaScript应用例子:这段代码输出大秦铁路(股票代码:601006)的当前股价current price:14.20如果你要同时查询多个股票,那么在URL最后加上一个逗号,再加上股票代码就可以了;比如你要一次查询大秦铁路(601006)和大同煤业(601001)的行情,就这样使用URL:hq.sinajs./list=sh601003,sh601001查询大盘指数,比如查询上证综合指数(000001):hq.sinajs./list=s_sh000001服务器返回的数据为:var hq_str_s_sh000001="上证指数,3094.668,-128.073,-3.97,436653,5458126";数据含义分别为:指数名称,当前点数,当前价格,涨跌率,成交量(手),成交额(万元);查询深圳成指数:hq.sinajs./list=s_sz399001对于股票的K线图,日线图等的获取可以通过请求image.sinajs./…./…/*.gif此URL获取,其中*代表股票代码,详见如下:查看日K线图:image.sinajs./newchart/daily/n/sh601006.gif分时线的查询:image.sinajs./newchart/min/n/sh000001.gif日K线查询:image.sinajs./newchart/daily/n/sh000001.gif周K线查询:image.sinajs./newchart/weekly/n/sh000001.gif月K线查询:image.sinajs./newchart/monthly/n/sh000001.gif1.2 Baidu&Google的财经数据第一条搜索结果如下图:通过点击左边的图片我们发现会将此图片链接到sina财经频道上,也就是说google股票数据的获取也是从sina获取。

美股港股 股票查询接口

美股港股 股票查询接口

美股港股股票查询接口每到年底,普通人都在烦恼什么时候放假、年终奖有多少、如何正确打开12306的验证码……但是作为除了有普通人身份,还是处于“特殊人群关爱中心”的程序猿们,还在烦恼明年项目需要的数据哪家最物美价廉。

平时一件T恤行走江湖的程序猿,只会在公司项目上面操碎了心。

为解救程序员于水深火热之中,今天就和大家分享一个免费api数据接口平台——聚合数据,当然它也不全是免费的,但是在现在“暖冬不如低价”活动中,短信API和车辆违章查询都降到3分5一次,加油卡充值低至9.75折,都是非常不错的。

接下来我们就简单分享一个股票查询接口文档吧!目前支持美股,港股。

接口名称:股票查询接口接口平台:聚合数据接口地址:/onebox/stock/query支持格式:json/xml请求方式:http get/post请求示例:/onebox/stock/query?key=APPKEY&stock=%E6%B1%BD%E8%BD%A6%E4%B9%8B%E5%AE%B6请求参数说明:名称类型必填说明key string 是应用APPKEY(应用详细页查询)dtype string 否返回数据的格式,xml或json,默认jsonstock string 是股票名称返回参数说明:名称类型说明股票查询接口调用JSON返回示例:{"reason": "查询成功","result": {"type": "美股","list": {"datetime": "03月09日16:00","data": [{"dk1": "今开:","dk2": "成交量:","dv1": "44.02","dv2": "163.26万"},{"dk1": "昨收:","dk2": "换手率:","dv1": "43.84","dv2": "1.57%"},{"dk1": "最高:","dk2": "市值:","dv1": "45.98","dv2": "43.77亿"},{"dk1": "最低:","dk2": "市盈率:","dv1": "41.45","dv2": "37.59"}],"address": "中国北京市海淀区丹棱街3号中国电子大厦B座10层"}},"error_code": 0}。

搜狐股票接口获取数据方法

搜狐股票接口获取数据方法

搜狐股票接⼝获取数据⽅法对于⼀些喜欢研究分析股票数据的朋友来说,获取股票历史数据是分析的第⼀步,这⾥简单介绍⼀下如何通过搜狐提供的接⼝获取数据。

以股票上海机场(600009)为例,获取7⽉16到20号的⽇线数据。

在浏览器中输⼊/hisHq? code=cn_600009&start=20180716&end=20180720&stat=1&order=D&period=d&callback=historySearchHandler&rt=jsonp就可以得到这些数据,格式是json.如下:historySearchHandler([{"status":0,"hq":[["2018-07-20","61.22","61.83","0.61","1.00%","61.22","62.69","57637","35856.55","0.53%"],["2018-07-19","63.00","61.22","-1.54","-2.45%","60.27","63.19","61372","37656.60","0.56%"],["2018-07-18","62.28","62.76","0.48","0.77%","61.75","63.80","48778","30629.53","0.45%"],["2018-07-17","62.70","62.28","-0.25","-0.40%","61.16","62.70","48519","29986.43","0.44%"],["2018-07-16","62.00","62.53","0.80","1.30%","62.00","64.30","76005","47872.05","0.70%"]],"code":"cn_600009","stat":["累计:","2018-07-16⾄2018-07-20","0.10","0.16%",60.27,64.3,292311,182001.16,"2.68%"]}])各参数的含义为:code:股票代码,以cn_开头,start:起始时间,end:截⽌时间,stat:统计信息,为0的时候就不返回stat对应的值了,order:排序⽅法(D表⽰降序排,A表⽰升序排),period:数据周期(d表⽰⽇线,m表⽰⽉线,w表⽰周线)。

股票实时API数据接口

股票实时API数据接口

股票实时API数据接口http/javascript接口取数据以大秦铁路(股票代码:601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据接口:/list=sh601006这个url会返回一串文本,例如:var hq_str_sh601006="大秦铁路, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92,22114263, 589824680, 4695, 26.91, 57590, 26.90, 14700, 26.89, 14300,26.88, 15100, 26.87, 3100, 26.92, 8900, 26.93, 14230, 26.94, 25150, 26.95, 15220, 26.96, 2008-01-11, 15:05:32";这个字符串由许多数据拼接在一起,不同含义的数据用逗号隔开了,按照程序员的思路,顺序号从0开始。

0:”大秦铁路”,股票名字;1:”27.55″,今日开盘价;2:”27.25″,昨日收盘价;3:”26.91″,当前价格;4:”27.55″,今日最高价;5:”26.20″,今日最低价;6:”26.91″,竞买价,即“买一”报价;7:”26.92″,竞卖价,即“卖一”报价;8:”22114263″,成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百;9:”589824680″,成交金额,单位为“元”,为了一目了然,通常以“万元”为成交金额的单位,所以通常把该值除以一万;10:”4695″,“买一”申请4695股,即47手;11:”26.91″,“买一”报价;12:”57590″,“买二”13:”26.90″,“买二”14:”14700″,“买三”15:”26.89″,“买三”16:”14300″,“买四”17:”26.88″,“买四”18:”15100″,“买五”19:”26.87″,“买五”20:”3100″,“卖一”申报3100股,即31手;21:”26.92″,“卖一”报价(22, 23), (24, 25), (26,27), (28, 29)分别为“卖二”至“卖四的情况”30:”2008-01-11″,日期;31:”15:05:32″,时间;这个接口对于JavaScript程序非常方便,通常的使用方式为,静态或动态地在页面中插入:<script type="text/javascript" src="/list=sh601006" charset="gb2312"></script><script type="text/javascript">var elements=hq_str_sh601006.split(",");document.write("current price:"+elements[3]);</script>这段代码输出大秦铁路(股票代码:601006)的当前股价current price:14.20如果你要同时查询多个股票,那么在URL最后加上一个逗号,再加上股票代码就可以了;比如你要一次查询大秦铁路(601006)和大同煤业(601001)的行情,就这样使用URL:/list=sh601003,sh601001但如果你要查询大盘指数,情况会有不同,比如查询上证综合指数(000001),使用如下URL:/list=s_sh000001 服务器返回的数据为:var hq_str_s_sh000001="上证指数,3094.668,-128.073,-3.97,436653,5458126";数据含义分别为:指数名称,当前点数,当前价格,涨跌率,成交量(手),成交额(万元);查询深圳成指的URL为:/list=s_sz399001对于股票的K线图,日线图等的获取可以通过请求/…./…/*.gif此URL 获取,其中*代表股票代码,详见如下:查看日K线图:/newchart/daily/n/sh601006.gif分时线的查询:/newchart/min/n/sh000001.gif日K线查询:/newchart/daily/n/sh000001.gif周K线查询:/newchart/weekly/n/sh000001.gif月K线查询:/newchart/monthly/n/sh000001.gif来源:大CC古希腊哲学大师亚里士多德说:人有两种,一种即“吃饭是为了活着”,一种是“活着是为了吃饭”.一个人之所以伟大,首先是因为他有超于常人的心。

C# Sina股票接口

C# Sina股票接口

C# Sina股票接口(2011-01-25 14:05:52)转载需要注意的这个只是获取单只股票代码的用处,通过这个代码有炒股的朋友就可以写出简单的自动止损和按一定价格入场的程序了。

(国内正规券商不支持这种功能,可能是为了防止一些东西。

)我们先来看一下股票信息的类namespace .Library.Entity{public class StockInfo{public string Name{get;set;}public decimal TodayOpen{get;set;}public decimal YesterdayClose{get;set;}public decimal Current{get;set;}public decimal High{get;set;}public decimal Low{ get; set; }/// <summary>/// 竟买价买1/// </summary>public decimal Buy{ get; set; }/// <summary>/// 竟卖价卖1/// </summary>public decimal Sell { get; set; }/// <summary>/// 成交数单位股数通常除于100成为手/// </summary>public int VolAmount { get; set; }/// <summary>/// 成交多少钱,单位元/// </summary>public decimal V olMoney { get; set; }/// <summary>/// 新浪是可以看到5个,5档看盘,买1-买5 /// </summary>public List<GoodsInfo> BuyList { get; set; }/// <summary>/// 卖1-卖5/// </summary>public List<GoodsInfo> SellList { get; set; }/// <summary>/// Date and Time/// </summary>public DateTime Time { get; set; }public override string ToString(){return Name + ": " + V olAmount + ":" + Current;}}}namespace .Library{///股票数据获取接口,你可以自己实现新浪yahoo...public interface IDataService{StockInfo GetCurrent(string stockCode);}}namespace .DataServices{public class Sina : IDataService{private const string dataurl = "/list={0}";#region IStockInfo MembersHttpClient client;private StockInfo PrevInfo;public StockInfo GetCurrent(string stockCode){try{if (client == null){client = new HttpClient();}if (stockCode.Substring(0, 2) == "60")//上海是600打头{stockCode = "sh" + stockCode;}else if(stockCode.Substring(0,2)=="00")//深圳{stockCode = "sz" + stockCode;}else if (stockCode.Substring(0, 2) == "51")//上海基金{stockCode = "sh" + stockCode;}string url = string.Format(dataurl, stockCode);string data = client.DownloadString(string.Format(url, stockCode));PrevInfo = Parse(data);return PrevInfo;}catch{return PrevInfo;}}/// <summary>/// Parse Sina data to stock Info/// </summary>/// <param name="input"></param>/// <returns></returns>public static StockInfo Parse(string content){// var hq_str_sh600066 = "宇通客车,9.27,9.35,9.76,9.80,9.27,9.77,9.78,4567858,44306952,3100,9.77,1200,9.76,20500,9.75,1400,9. 74,15300,9.73,10030,9.78,28093,9.79,156827,9.80,2800,9.81,6400,9.82,2009-01-09,15:03:32";int start = content.IndexOf('"')+1;int end = content.IndexOf('"',start);string input = content.Substring(start, end - start);string[] temp = input.Split(',');if (temp.Length != 32){return null;}StockInfo info = new StockInfo(); = temp[0];info.TodayOpen = decimal.Parse(temp[1]);info.YesterdayClose = decimal.Parse(temp[2]);info.Current = decimal.Parse(temp[3]);info.High = decimal.Parse(temp[4]);info.Low = decimal.Parse(temp[5]);info.Buy = decimal.Parse(temp[6]);info.Sell = decimal.Parse(temp[7]);info.VolAmount = int.Parse(temp[8]);info.VolMoney = decimal.Parse(temp[9]);info.BuyList = new List<GoodsInfo>(5);int index = 10;for (int i = 0; i < 5; i++){GoodsInfo goods = new GoodsInfo();goods.State = GoodsState.Buy;goods.Amount = int.Parse(temp[index]);index++;goods.Price = decimal.Parse(temp[index]);index++;info.BuyList.Add(goods);}info.SellList = new List<GoodsInfo>(5);for (int i = 0; i < 5; i++){GoodsInfo goods = new GoodsInfo();goods.State = GoodsState.Sell;goods.Amount = int.Parse(temp[index]);index++;goods.Price = decimal.Parse(temp[index]);index++;info.SellList.Add(goods);}info.Time = DateTime.Parse(temp[30] + " " + temp[31]);return info;}#endregion}}public class GoodsInfo{public int Amount{ get; set; }public decimal Price{get;set;}public GoodsState State { get; set; }}如果C#新浪的股票接口满足不了你需要的话你还可以了解一些商业的股票接口行情写库/StockInfoSoft.aspx。

获取股票历史数据(详情)

获取股票历史数据(详情)

获取股票历史数据(详情)获取股票历史数据(详情)获取股票历史数据获取股票历史数据的方法有很多种,下面列出了一些常见的方法:1.公开信息:在证券交易所或证券公司网站上查询公开信息,可以获取股票的历史交易记录、财务数据等信息。

2.证券公司:可以向证券公司申请获取股票的历史数据,包括历史交易记录、成交单、涨跌幅等。

3.数据供应商:有一些数据供应商提供股票历史数据服务,可以向他们购买数据,如财华网。

4.API接口:有些数据提供商提供股票历史数据的API接口,可以通过API接口获取数据,如大智慧、同花顺等。

需要注意的是,获取股票历史数据需要遵守相关法律法规,不得用于非法用途。

同时,获取历史数据也需要支付一定的费用,具体费用标准可以向数据提供商咨询。

获取股票历史数据分析获取股票历史数据分析通常需要访问股票市场数据源,如金融数据提供商或交易所网站。

以下是一些获取股票历史数据分析的一般步骤:1.确定所需的数据:首先,您需要确定您需要分析的股票和时间段。

您可能需要分析过去一年的数据,或者需要分析过去十年的数据。

您还需要确定您需要分析哪些数据,例如股票价格、成交量、市盈率等。

2.访问数据源:访问金融数据提供商或交易所网站,这些网站通常提供股票历史数据。

例如,您可以访问YahooFinance、GoogleFinance、Bloomberg、CNBC等网站。

3.下载数据:在访问数据源后,您需要下载所需的数据。

通常,数据提供商提供CSV或Excel文件格式。

您可以选择按日期或股票代码下载数据。

4.分析数据:一旦您下载了数据,您可以开始分析数据。

您可以使用Excel、Python、R等编程语言和数据分析工具来分析数据。

您可以使用统计学和时间序列分析等方法来分析数据。

5.报告和分析:最后,您可以编写报告和分析,将数据呈现给其他人。

您可以使用文字处理软件、演示软件等工具来编写报告和分析。

需要注意的是,获取股票历史数据分析需要一些技术和金融知识。

实时股票数据接口

实时股票数据接口

实时股票数据接口大全股票数据的获取目前有如下两种方法可以获取:1. http/javascript接口取数据2. web-service接口1.http/javascript接口取数据1.1Sina股票数据接口以大秦铁路(股票代码:601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据接口:/list=sh601006这个url会返回一串文本,例如:var hq_str_sh601006="大秦铁路, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92, 22114263, 589824680, 4695, 26.91, 57590, 26.90, 14700, 26.89, 14300,26.88, 15100, 26.87, 3100, 26.92, 8900, 26.93, 14230, 26.94, 25150, 26.95, 15220, 26.96, 2008-01-11, 15:05:32";这个字符串由许多数据拼接在一起,不同含义的数据用逗号隔开了,按照程序员的思路,顺序号从0开始。

0:”大秦铁路”,股票名字;1:”27.55″,今日开盘价;2:”27.25″,昨日收盘价;3:”26.91″,当前价格;4:”27.55″,今日最高价;5:”26.20″,今日最低价;6:”26.91″,竞买价,即“买一”报价;7:”26.92″,竞卖价,即“卖一”报价;8:”22114263″,成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百;9:”589824680″,成交金额,单位为“元”,为了一目了然,通常以“万元”为成交金额的单位,所以通常把该值除以一万;10:”4695″,“买一”申请4695股,即47手;11:”26.91″,“买一”报价;12:”57590″,“买二”13:”26.90″,“买二”14:”14700″,“买三”15:”26.89″,“买三”16:”14300″,“买四”17:”26.88″,“买四”18:”15100″,“买五”19:”26.87″,“买五”20:”3100″,“卖一”申报3100股,即31手;21:”26.92″,“卖一”报价(22, 23), (24, 25), (26,27), (28, 29)分别为“卖二”至“卖四的情况”30:”2008-01-11″,日期;31:”15:05:32″,时间;一个简单的JavaScript应用例子:<script type="text/javascript"src="/list=sh601006"charset="gb2312"></script><script type="text/javascript">var elements=hq_str_sh601006.split(",");document.write("current price:"+elements[3]);</script>这段代码输出大秦铁路(股票代码:601006)的当前股价current price:14.20如果你要同时查询多个股票,那么在URL最后加上一个逗号,再加上股票代码就可以了;比如你要一次查询大秦铁路(601006)和大同煤业(601001)的行情,就这样使用URL:/list=sh601003,sh601001查询大盘指数,比如查询上证综合指数(000001):/list=s_sh000001服务器返回的数据为:var hq_str_s_sh000001="上证指数,3094.668,-128.073,-3.97,436653,5458126";数据含义分别为:指数名称,当前点数,当前价格,涨跌率,成交量(手),成交额(万元);查询深圳成指数:/list=s_sz399001对于股票的K线图,日线图等的获取可以通过请求http://image.sin /…./…/*.gif此URL 获取,其中*代表股票代码,详见如下:查看日K线图:/newchart/daily/n/sh601006.gif分时线的查询:/newchart/min/n/sh000001.gif日K线查询:/newchart/daily/n/sh000001.gif周K线查询:/newchart/weekly/n/sh000001.gif月K线查询:/newchart/monthly/n/sh000001.gif1.2 Baidu&Google的财经数据在baidu, google中搜索某只股票代码时,将会在头条显示此股票的相关信息,例如在google 搜索601006时,第一条搜索结果如下图:通过点击左边的图片我们发现会将此图片链接到sina财经频道上,也就是说google股票数据的获取也是从sina获取。

【获取股票数据代码教程01】Python等五种主流语言的实例代码演示如何获取股票实时交易数据

【获取股票数据代码教程01】Python等五种主流语言的实例代码演示如何获取股票实时交易数据

最近一两年,股票量化分析越来越受欢迎了。

想要入行,首先得搞定股票数据。

毕竟,所有量化分析都是建立在数据之上的,实时交易、历史交易、财务、基本面,这些数据咱们都得有。

咱们的目标就是挖掘这些数据中的价值,来指导咱们的投资策略。

为了找数据,我可是尝试了各种方法,自己动手写过网易、申万行业的爬虫,还试过同花顺问财的,连聚宽的免费API都用过。

但爬虫这东西,数据总是不稳定,给量化分析带来不少困扰。

在量化分析领域,实时、准确的数据接口太重要了。

现在我用Python、JavaScript (Node.js)、Java、C#和Ruby五种主流语言的实例代码给大家演示一下如何获取股票最新分时KDJ数据:最新分时KDJ数据是区分分时级别的,我这里演示的都是60分钟级别的最新分时KDJ 数据,其他级别可以参考下面的API文档自行修改参数就行了1、Pythonimport requestsurl = "http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a"response = requests.get(url)data = response.json()print(data)2、JavaScript (Node.js)const axios = require('axios');const url = "http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a";axios.get(url).then(response => {console.log(response.data);}).catch(error => {console.log(error);});3、Javaimport .URI;import .http.HttpClient;import .http.HttpRequest;import .http.HttpResponse;import java.io.IOException;public class Main {public static void main(String[] args) {HttpClient client = HttpClient.newHttpClient();HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a")).build();try {HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());} catch (IOException | InterruptedException e) {e.printStackTrace();}}}4、C#using System;using .Http;using System.Threading.Tasks;class Program{static async Task Main(){using (HttpClient client = new HttpClient()){string url = "http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a";HttpResponseMessage response = await client.GetAsync(url);string responseBody = await response.Content.ReadAsStringAsync();Console.WriteLine(responseBody);}}}5、Rubyrequire 'net/http'require 'json'url = URI("http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a")http = Net::HTTP.new(url.host, url.port)request = Net::HTTP::Get.new(url)response = http.request(request)data = JSON.parse(response.read_body)puts data返回的数据示例:{"fm":"-0.20","h":"10.26","hs":"0.67","lb":"1.38","l":"10.11","lt":"197161074084.00","o":"10.11" ,"pe":"3.81","pc":"0.30","p":"10.16","sz":"197164128892.00","cje":"1318858687.52","ud":"0.03" ,"v":"1294059","yc":"10.13","zf":"1.48","zs":"-0.20","sjl":"0.48","zdf60":"-0.20","zdfnc":"17.19"," t":"2024-08-30 15:29:03"}实时交易数据接口API文档API接口:http://api.mairui.club/hsrl/ssjy/股票代码(如000001)/licence证书接口说明:根据《股票列表》得到的股票代码获取实时交易数据(您可以理解为日线的最新数据)。

【获取股票数据代码教程01】Python等五种主流语言的实例代码演示如何获取股票实时交易数据

【获取股票数据代码教程01】Python等五种主流语言的实例代码演示如何获取股票实时交易数据

近年来,股票量化分析逐渐受到广泛关注,而作为入门的首要步骤,获取股票数据显得尤为重要。

无论是实时交易数据、历史记录、财务数据还是基本面信息,这些数据都是我们进行量化分析不可或缺的基石。

我们的核心任务是从这些数据中提炼出有价值的信息,从而为我们的投资策略提供指导。

在数据探索的旅途中,我尝试了多种途径,包括自编网易股票页面爬虫、申万行业数据爬虫,以及同花顺问财的爬虫,甚至还尝试了聚宽的免费数据API。

然而,爬虫作为数据源常常显得不够稳定,给我们的量化分析带来不小的挑战。

在量化分析的世界里,实时且精确的数据接口是成功的关键。

经过多次实战检验,我已确认以下数据接口均表现出色且稳定可靠。

现在我用Python、JavaScript(Node.js)、Java、C#和Ruby五种主流语言的实例代码给大家演示一下如何获取股票实时交易数据:1、Pythonimport requestsurl = "http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a"response = requests.get(url)data = response.json()print(data)2、JavaScript (Node.js)const axios = require('axios');const url = "http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a";axios.get(url).then(response => {console.log(response.data);}).catch(error => {console.log(error);});3、Javaimport .URI;import .http.HttpClient;import .http.HttpRequest;import .http.HttpResponse;import java.io.IOException;public class Main {public static void main(String[] args) {HttpClient client = HttpClient.newHttpClient();HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a")).build();try {HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());} catch (IOException | InterruptedException e) {e.printStackTrace();}}}4、C#using System;using .Http;using System.Threading.Tasks;class Program{static async Task Main(){using (HttpClient client = new HttpClient()){string url = "http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a";HttpResponseMessage response = await client.GetAsync(url);string responseBody = await response.Content.ReadAsStringAsync();Console.WriteLine(responseBody);}}}5、Rubyrequire 'net/http'require 'json'url = URI("http://api.mairui.club/hsrl/ssjy/000001/b997d4403688d5e66a")http = Net::HTTP.new(url.host, url.port)request = Net::HTTP::Get.new(url)response = http.request(request)data = JSON.parse(response.read_body)puts data返回的数据示例:{"fm":"-0.20","h":"10.26","hs":"0.67","lb":"1.38","l":"10.11","lt":"197161074084.00","o":"10.11" ,"pe":"3.81","pc":"0.30","p":"10.16","sz":"197164128892.00","cje":"1318858687.52","ud":"0.03" ,"v":"1294059","yc":"10.13","zf":"1.48","zs":"-0.20","sjl":"0.48","zdf60":"-0.20","zdfnc":"17.19"," t":"2024-08-30 15:29:03"}实时交易数据接口API文档API接口:http://api.mairui.club/hsrl/ssjy/股票代码(如000001)/licence证书接口说明:根据《股票列表》得到的股票代码获取实时交易数据(您可以理解为日线的最新数据)。

eoLinker-API_Shop_股票行情数据_API接口_C#调用示例代码

eoLinker-API_Shop_股票行情数据_API接口_C#调用示例代码

eoLinker-API Shop 股票行情数据 C#调用示例代码股票行情数据支持证券全市场行情数据,实时数据,K线数据,分笔数据,市场股票代码信息,历史数据等等,满足证券投资分析使用。

该产品拥有以下APIs:1.股票k线2.实时行情查询3.查询股票列表4.查询股票市场5.分笔6.分时查询7.指数实时报价8.组合行情查询9.综合排名注意,该示例代码仅适用于网站下API使用该产品前,您需要通过https:///#/api/detail/?productID=168申请API服务1.股票k线using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers)string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value);}paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt{using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/kline"; Dictionary<string, string> param = new Dictionary<string, s tring>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取param.Add("stock_code", ""); //股票代码param.Add("period", ""); //1:1分钟 2:5分钟 3:15分钟 4:30分钟 5:60分钟 6:日k线 7:周k线 8:月k线param.Add("request_num", ""); //请求行数param.Add("position_str", ""); //定位串,默认-1 从头开始Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Respo nse>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}2.实时行情查询using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers){string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value);}paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt ream()){using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/realti me";Dictionary<string, string> param = new Dictionary<string, s tring>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取param.Add("stock_code", ""); //股票代码Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Respo nse>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}3.查询股票列表using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers){string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value); }paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt ream()){using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/list"; Dictionary<string, string> param = new Dictionary<string, s tring>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取param.Add("stock_type", ""); //市场类别param.Add("request_num", ""); //定位串,传空默认为20 param.Add("position_str", ""); //起始位空,从应答中获取Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Respo nse>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}4.查询股票市场using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers){string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value); }paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt ream()){using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/market ";Dictionary<string, string> param = new Dictionary<string, string>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Respo nse>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}5.分笔using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers){string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value); }paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt ream()){using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/tick"; Dictionary<string, string> param = new Dictionary<string, s tring>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取param.Add("stock_code", ""); //股票代码param.Add("request_num", ""); //请求参数Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Respo nse>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}6.分时查询using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers){string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value);}paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt ream()){using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/trend"; Dictionary<string, string> param = new Dictionary<string, s tring>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取param.Add("stock_code", ""); //股票代码Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Respo nse>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}7.指数实时报价using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers){string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value); }paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt ream()){using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/index"; Dictionary<string, string> param = new Dictionary<string, s tring>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取param.Add("stock_code", ""); //代码Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Respo nse>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}8.组合行情查询using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers){string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value); }paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt ream()){using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/comb"; Dictionary<string, string> param = new Dictionary<string, s tring>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取param.Add("stock_code", ""); //股票代码Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Respo nse>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}9.综合排名using System;using System.Collections.Generic;using System.IO;using ;using System.Text;using System.Web.Script.Serialization;namespace apishop_sdk{class Program{/*** 转发请求到目的主机* @param method string 请求方法* @param url string 请求地址* @param params Dictionary<string,string> 请求参数* @param headers Dictionary<string,string> 请求头* @return string**/static string apishop_send_request(string method, string url, D ictionary<string, string> param, Dictionary<string, string> headers){string result = string.Empty;try{string paramData = "";if (param != null && param.Count > 0){StringBuilder sbuilder = new StringBuilder();foreach (var item in param){if (sbuilder.Length > 0){sbuilder.Append("&");}sbuilder.Append(item.Key + "=" + item.Value); }paramData = sbuilder.ToString();}method = method.ToUpper();if (method == "GET"){url = string.Format("{0}?{1}", url, paramData);}HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.C reate(url);if (method == "GET"){wbRequest.Method = "GET";}else if (method == "POST"){wbRequest.Method = "POST";wbRequest.ContentType = "application/x-www-form-url encoded";wbRequest.ContentLength = Encoding.UTF8.GetByteCoun t(paramData);using (Stream requestStream = wbRequest.GetRequestS tream()){using (StreamWriter swrite = new StreamWriter(r equestStream)){swrite.Write(paramData);}}}HttpWebResponse wbResponse = (HttpWebResponse)wbRequest. GetResponse();using (Stream responseStream = wbResponse.GetResponseSt ream()){using (StreamReader sread = new StreamReader(respon seStream)){result = sread.ReadToEnd();}}}catch{return "";}return result;}class Response{public string statusCode;}static void Main(string[] args){string method = "POST";string url = "https:///mlhexpsz/stock/sort"; Dictionary<string, string> param = new Dictionary<string, s tring>();param.Add("apiKey", "your_api_key"); //需要从www.apishop.ne t获取param.Add("stock_type", ""); //股票类别,参考市场查询返回值param.Add("sort_type", ""); //排序类别Dictionary<string, string> headers = null;string result = apishop_send_request(method, url, param, he aders);if (result == ""){//返回内容异常,发送请求失败Console.WriteLine("发送请求失败");return;}Response res = new JavaScriptSerializer().Deserialize<Response>(result);if (res.statusCode == "000000"){//状态码为000000, 说明请求成功Console.WriteLine(string.Format("请求成功: {0}", resul t));}else{//状态码非000000, 说明请求失败Console.WriteLine(string.Format("请求失败: {0}", resul t));}Console.ReadLine();}}}。

股票期货统一查询平台有哪些

股票期货统一查询平台有哪些

股票期货统一查询平台有哪些
股票期货统一查询平台是指能够提供股票和期货相关信息查询的综合平台。

这些平台通过整合不同的交易所和数据源,提供股票行情、交易数据、资金流向等信息的查询功能。

以下是一些常见的股票期货统一查询平台:
1. 东方财富网:东方财富网是国内最大的财经门户网站之一,提供股票、期货、基金等的实时行情、交易数据、资讯等。

平台通过手机App、网页等方式提供多种查询功能,用户可以通过股票代码、交易所等进行查询。

2. 同花顺:同花顺是国内领先的互联网金融终端品牌,提供股票、期货、外汇等实时行情、资讯,以及交易数据分析等功能。

同花顺的手机App和网页端都提供了查询平台,用户可以通
过股票代码、交易所、板块等进行查询。

3. 联通瑞信:联通瑞信是一家综合性金融信息服务提供商,提供股票、期货、外汇、基金等的行情、资讯和交易数据查询服务。

平台通过手机App、网页等方式提供了多种查询功能,用户可以根据自己的需求进行定制。

4. 金融界:金融界是一家专业的财经信息服务提供商,提供股票、期货、基金、债券等的行情、资讯以及交易数据查询。

平台通过手机App和网页端都提供了查询平台,用户可以个性
化定制查询内容和方式。

5. 中金在线:中金在线是中金公司旗下的综合金融信息服务平
台,提供股票、期货、外汇、基金等各类资产的行情、资讯和交易数据查询。

平台通过手机App和网页端都提供了查询服务,用户可以根据自己的需求进行个性化定制。

以上是一些常见的股票期货统一查询平台,它们通过整合不同的数据源和交易所,提供了全面的行情、资讯和交易数据查询服务。

用户可以根据自己的需求选择适合自己的平台进行查询。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实时股票数据接口大全股票数据的获取目前有如下两种方法可以获取:1. http/javascript接口取数据2. web-service接口1.http/javascript接口取数据1.1Sina股票数据接口以大秦铁路(股票代码:601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据接口:/list=sh601006这个url会返回一串文本,例如:var hq_str_sh601006="大秦铁路, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92,22114263, 589824680, 4695, 26.91, 57590, 26.90, 14700, 26.89, 14300, 26.88, 15100, 26.87, 3100, 26.92, 8900, 26.93, 14230, 26.94, 25150, 26.95, 15220, 26.96, 2008-01-11, 15:05:32";这个字符串由许多数据拼接在一起,不同含义的数据用逗号隔开了,按照程序员的思路,顺序号从0开始。

0:”大秦铁路”,股票名字;1:”27.55″,今日开盘价;2:”27.25″,昨日收盘价;3:”26.91″,当前价格;4:”27.55″,今日最高价;5:”26.20″,今日最低价;6:”26.91″,竞买价,即“买一”报价;7:”26.92″,竞卖价,即“卖一”报价;8:”22114263″,成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百;9:”589824680″,成交金额,单位为“元”,为了一目了然,通常以“万元”为成交金额的单位,所以通常把该值除以一万;10:”4695″,“买一”申请4695股,即47手;11:”26.91″,“买一”报价;12:”57590″,“买二”13:”26.90″,“买二”14:”14700″,“买三”15:”26.89″,“买三”16:”14300″,“买四”17:”26.88″,“买四”18:”15100″,“买五”19:”26.87″,“买五”20:”3100″,“卖一”申报3100股,即31手;21:”26.92″,“卖一”报价(22, 23), (24, 25), (26,27), (28, 29)分别为“卖二”至“卖四的情况”30:”2008-01-11″,日期;31:”15:05:32″,时间;一个简单的JavaScript应用例子:<script type="text/javascript"src="/list=sh601006" charset="gb2312"></script><script type="text/javascript">var elements=hq_str_sh601006.split(",");document.write("current price:"+elements[3]);</script>这段代码输出大秦铁路(股票代码:601006)的当前股价current price:14.20如果你要同时查询多个股票,那么在URL最后加上一个逗号,再加上股票代码就可以了;比如你要一次查询大秦铁路(601006)和大同煤业(601001)的行情,就这样使用URL:/list=sh601003,sh601001查询大盘指数,比如查询上证综合指数(000001):/list=s_sh000001服务器返回的数据为:var hq_str_s_sh000001="上证指数,3094.668,-128.073,-3.97,436653,5458126";数据含义分别为:指数名称,当前点数,当前价格,涨跌率,成交量(手),成交额(万元);查询深圳成指数:/list=s_sz399001对于股票的K线图,日线图等的获取可以通过请求http://imag /…./…/*.gif此URL获取,其中*代表股票代码,详见如下:查看日K线图:/newchart/daily/n/sh601006.gif分时线的查询:/newchart/min/n/sh000001.gif日K线查询:/newchart/daily/n/sh000001.gif周K线查询:/newchart/weekly/n/sh000001.gif月K线查询:/newchart/monthly/n/sh000001.gif1.2 Baidu&Google的财经数据在baidu, google中搜索某只股票代码时,将会在头条显示此股票的相关信息,例如在google搜索601006时,第一条搜索结果如下图:通过点击左边的图片我们发现会将此图片链接到sina财经频道上,也就是说google股票数据的获取也是从sina获取。

后经抓包分析,发现google也是采用1.1中介绍的接口。

Baidu的股票数据来自baidu的财经频道/1.3 其他方式除了sina,baidu等网站提供股票信息外,其他网站也有类似的接口。

我们分析了一款论坛上采用的股票插件,其中有关于实时股票数据获取的介绍,详见如下代码,其中可以看到有些数据来自sina。

以下是ASP示例:<%‘==========================‘ file: stock_getdata.asp‘ version: 1.0.0‘ copyright (c) all rights reserved.‘ web: ‘==========================function gethttp(rurl)dim xmlon error resume nextset xml=server.createobject("Microsoft.XMLHTTP")xml.open "get",rurl,falsexml.sendif not xml.readystate=4 or not xml.status=200 or err then gethttp="":exit functiongethttp=xml.responsetextset xml=nothingend functionfunction getstockdata(code)‘0=股票名称,1=开盘价格,2=昨收盘价格,3=当前价格,4=最高价,5=最低价,30,31=更新时间dim checkcode,stockdata,stockdatasplitif len(code)<5 thenstockdata="0,0,0,0,0,0,0,0,0,0,0,0":exit functioncheckcode=mid(code,len(code)-5,1)if int(checkcode)<=4 thenstockdata=gethttp("/li st=sz"&code&"")if not len(stockdata)=0 thenstockdata=split(stockdata,chr(34))(1)end ifif int(checkcode)>=5 thenstockdata=gethttp("/li st=sh"&code&"")if not len(stockdata)=0 thenstockdata=split(stockdata,chr(34))(1)end ifif len(stockdata)=0 thenstockdata="0,0,0,0,0,0,0,0,0,0,0,0"elsestockdatasplit=split(stockdata,",") stockdata=""&exstock.checkstr(stockdatasplit(0))&","&stockd atasplit(1)&","&stockdatasplit(2)&","&stockdatasplit(3)&","&stockdata split(4)&","&stockdatasplit(5)&","&formatdatetime(""&stockdatasplit(3 0)&" "&stockdatasplit(31)&"",0)&""end if‘0=股票名称,1=开盘价格,2=昨收盘价格,3=当前价格,4=最高价,5=最低价,6=更新时间getstockdata=stockdataend functionfunction getstockimg(code)dim rndnum,addnum,checkcode,imgsourceif len(code)<5 then exit functionaddnum=4randomize:rndnum=cint(rnd*addnum)select case rndnumcase 0getstockimg="http://www.10jqka.c /curve/kline/?code="&code&""imgsource=" .cn"case 1getstockimg="http://stock.jrj.co /htmdata/KLINE/"&code&".png"imgsource=". cn"case 2checkcode=mid(code,len(code)-5,1) if int(checkcode)<=4 thengetstockimg="http://im /newchart/daily/n/sz"&code&".gif"end ifif int(checkcode)>=5 thengetstockimg="http://im /newchart/daily/n/sh"&code&".gif"end ifimgsource="http://finance.sina.c "case 3getstockimg="http://hq.gazxfe.co m/stockchart/realline.chart?"&code&"&1003&SZ 500 330"imgsource="" case 4getstockimg="http://chartse.stoc /chartserver?code="&code&""imgsource="http://www.stockstar. com/"end selectgetstockimg=split(""&getstockimg&"||"&imgsource&"" ,"||")end functionfunction getastockimg()dim rndnum,addnum,checkcodedim getastockimgb,imgsourceaddnum=6randomize:rndnum=cint(rnd*addnum)select case rndnumcase 0getastockimg="http://202.109.106 .1/gifchartse/gif/000001.gif"getastockimgb="http://202.109.10 6.1/gifchartse/gif/399001.gif"imgsource="http://www.stockstar. com/"case 1getastockimg="http://money.163.c om/special/100.gif?C39"getastockimgb="http://money.163. com/special/101.gif?HrS"imgsource="" case 2getastockimg="http://www.10jqka. /curve/realtime/index2.php?code=1a0001&w=180&h=140"getastockimgb="http://www.10jqka /curve/realtime/index2.php?code=399001&w=180&h=140"imgsource=" .cn"case 3getastockimg="lis /stockchart/realline.chart?1a0001&1002&SZ 180 140"getastockimgb="li /stockchart/realline.chart?399001&1002&SZ 180 140"imgsource="list.c om/"case 4getastockimg="http://image.sinaj /newchart/small/ish000001.gif?1189176558328"getastockimgb="http://image.sina /newchart/small/isz399001.gif?1189176558328"imgsource="" case 5getastockimg="http://218.1.72.66 /cgi/pic/sh/realtime/JA000001164143.png"getastockimgb="http://218.1.72.6 6/cgi/pic/sz/realtime/JA399001164143.png"imgsource="stock.co m/"case 6getastockimg="http://222.73.29.8 5/img/000001.png"getastockimgb="http://222.73.29.85/img/399001.png"imgsource="http://www.eastmoney. com/"end selectgetastockimg=split(""&getastockimg&"||"&getastocki mgb&"||"&imgsource&"","||")end function%>2. web-service接口2.1 CHINAstock的web-service:/WebServices/ChinaStockWebService.asmx中国股票行情数据 WEB 服务(支持深圳和上海股市的全部基金、债券和股票),数据即时更新。

相关文档
最新文档