关键词不能为空

当前您在: 首页 > 股市 >

机器人的股票通过新浪网股票接口获取股票信息

作者:admin
来源:http://www.ycssp0359.com/gupiao
日期:2020-10-16 12:04

日盈股票-国鲁中投股票

2020年10月16日发(作者:邓朴方)
通过新浪网股票接口获取股票信息

以下函数全是静态方法,可以在C#中直接调用

using System;
using c;
using
using
using
using
using
using rExpressions;

namespace GzyFunctionLibrary
{
public class GetStockInfo
{
public static string[] StockItems = new string[32] { 股票名字今日开盘价昨日 收
盘价当前价格今日最高价今日最低价竞买价,即买一报价竞卖价,即卖一报
价成交的股票数成 交金额买一申请多少股买一报价买二买二买三买
三买四买四买五买五卖一申报股数卖一报价卖二申报股数 卖二报价
卖三申报股数卖三报价卖四申报股数卖四报价卖五申报股数卖五报价
日期时间

public static string[] PastStockItems = new string[] { 指数名称当前点数涨跌点
数涨跌率成交量(手)成交额(万元)

private static string url =
private static string PastUrl =

生成


private static string GetUrl(string StockID, int ValueType)
{
string id =
if (StockID ==
{
return null;
}
string dm =
if (() ==
dm =
else if (() ==
dm =
else if (ing(0, 2) == 深圳
dm =
else if (ing(0, 2) ==
dm =
else if (ing(0, 2) == 上海基金
dm =
switch (ValueType)
{
case 0:
return url + dm + StockID;
case 1:
return PastUrl + dm + StockID;
default:
return url + dm + StockID;
}

}


获取服务实时及历史信息


public static string[] GetValue(string url)
{
try
{
string[] StockValue;
WebClient myWebClient = new WebClient();
Stream myStream = ad(url);
StreamReader sr = new StreamReader(myStream,
oding(
string strHTML = End();

();
();
int first = f(
strHTML = ing(first + 1, - first - 4);
StockValue = (',');
if ( >= 2)
return StockValue;
else
return null;
}
catch (Exception ex)
{
return null;
throw ex;
}
}

获取股票实时信息


public static string[] GetRealValue(string StockId)
{
return GetValue(GetUrl(StockId, 0));
}

获取股票历史信息


public static string[] GetPastValue(string StockId)
{
return GetValue(GetUrl(StockId, 1));
}

public static DataTable getHis(string stockId)
{
DataTable dt = new DataTable();
(
(
(
(
(
(

string url =
(
html
ent wc = new WebClient();
string Content = adString(url);
string reg = target='_blank'
href='http:es_serviceviewvMS_? symbol=s
hd{6}&date=d{4}-d{2}-d{2}'>s*([^s]+)s+ s*

你可能关注的内容