新版eoLinkerAPIShop股票行情数据API接口C#调用示例代码docWord格式文档下载.docx
- 文档编号:21820850
- 上传时间:2023-02-01
- 格式:DOCX
- 页数:35
- 大小:18.16KB
新版eoLinkerAPIShop股票行情数据API接口C#调用示例代码docWord格式文档下载.docx
《新版eoLinkerAPIShop股票行情数据API接口C#调用示例代码docWord格式文档下载.docx》由会员分享,可在线阅读,更多相关《新版eoLinkerAPIShop股票行情数据API接口C#调用示例代码docWord格式文档下载.docx(35页珍藏版)》请在冰豆网上搜索。
注意,该示例代码仅适用于网站下API使用该产品前,您需要通过申请API服务
1.股票k线
usingSystem;
usingSystem.Collections.Generic;
usingSystem.IO;
usingSystem.Net;
usingSystem.Text;
usingSystem.Web.Script.Serialization;
namespaceapishop_sdk
{
classProgram
{
/**
*转发请求到目的主机
*@parammethodstring请求方法
*@paramurlstring请求地址
*@paramparamsDictionary<
string,string>
请求参数
*@paramheadersDictionary<
请求头
*@returnstring
**/
staticstringapishop_send_request(stringmethod,stringurl,Dictionary<
string,string>
param,Dictionary<
headers)
stringresult=string.Empty;
try
stringparamData="
"
;
if(param!
=null&
&
param.Count>
0)
StringBuildersbuilder=newStringBuilder();
foreach(variteminparam)
if(sbuilder.Length>
sbuilder.Append("
);
}
sbuilder.Append(item.Key+"
="
+item.Value);
paramData=sbuilder.ToString();
method=method.ToUpper();
if(method=="
GET"
)
url=string.Format("
{0}?
{1}"
url,paramData);
HttpWebRequestwbRequest=(HttpWebRequest)WebRequest.Create(url);
wbRequest.Method="
elseif(method=="
POST"
wbRequest.ContentType="
application/x-www-form-urlencoded"
wbRequest.ContentLength=Encoding.UTF8.GetByteCount(paramData);
using(StreamrequestStream=wbRequest.GetRequestStream())
using(StreamWriterswrite=newStreamWriter(requestStream))
swrite.Write(paramData);
HttpWebResponsewbResponse=(HttpWebResponse)wbRequest.GetResponse();
using(StreamresponseStream=wbResponse.GetResponseStream())
using(StreamReadersread=newStreamReader(responseStream))
result=sread.ReadToEnd();
catch
return"
returnresult;
classResponse
publicstringstatusCode;
staticvoidMain(string[]args)
stringmethod="
stringurl="
Dictionary<
param=newDictionary<
();
param.Add("
apiKey"
"
your_api_key"
//需要从获取
stock_code"
//股票代码
period"
//1:
1分钟2:
5分钟3:
15分钟4:
30分钟5:
60分钟6:
日k线7:
周k线8:
月k线
request_num"
//请求行数
position_str"
//定位串,默认-1从头开始
headers=null;
stringresult=apishop_send_request(method,url,param,headers);
if(result=="
//返回内容异常,发送请求失败
Console.WriteLine("
发送请求失败"
return;
Responseres=newJavaScriptSerializer().Deserialize<
Response>
(result);
if(res.statusCode=="
000000"
//状态码为000000,说明请求成功
Console.WriteLine(string.Format("
请求成功:
{0}"
result));
else
//状态码非000000,说明请求失败
请求失败:
Console.ReadLine();
}
2.实时行情查询
3.查询股票列表
stock_type"
//市场类别
//定位串,传空默认为20
//起始位空,从应答中获取
4.查询股票市场
using(StreamrequestStream=wbRequest.G
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 新版 eoLinkerAPIShop 股票行情 数据 API 接口 C# 调用 示例 代码 doc
![提示](https://static.bdocx.com/images/bang_tan.gif)
链接地址:https://www.bdocx.com/doc/21820850.html