淘宝上的大智慧L2数据,月卡最便宜是8元钱,这个也可以获取BBD、DDX等数据!

时间:2024-02-21 07:31:13

Want:从顶牛股网上下载DDX数据。

1、下载历史DDE数据:获取最近120个交易日的DDE数据

#define SFURL_DNG_SINGLEL"http://www.dingniugu.com/ddedata/gegu_ddedata.php?&code="

strUrl.Format(L"%s%06d", SFURL_DNG_SINGLE, iStockCode);

OpenURL获取的数据如下:

var data=new Array(

[55.16,60.68,66.75,73.43,80.77,87,88.16,84.79,93.27,102.6,108.99,119.89,113.9,116.3,104.67,104.8,105.8,98.86,99.77,104.6,98.4,98.05,102,92.24,92.18,93.88,96.5,102.7,112.97,105.88,109.6,98.64,94,92.68,87.19,87],[2720,20378,28466,26158,43471,46255,33398,30534,9707,57219,47797,37917,64825,44135,39158,32326,31746,34983,19440,34521,24065,18375,20442,38770,17194,20324,17993,36975,47697,30685,27241,24062,25480,11137,17151,14465],[0,9496.15,3045.86,837.06,-652.07,-2127.73,-367.38,-305.34,1795.79,1945.45,-812.55,1592.51,-2268.88,1015.1,-1096.42,-64.65,-698.41,-489.76,136.08,-586.86,-457.24,147,102.21,-4032.08,223.52,-101.62,305.88,1442.03,476.97,-828.5,-326.89,-1179.04,-687.96,-200.47,-428.78,0],[0,15.268,4.208,2.732,1.951,-2.558,-0.208,-0.861,2.143,1.738,-0.457,2.089,-2.941,1.318,-2.254,0.023,-0.814,-0.388,0.124,0.088,-0.932,0.417,0.388,-4.556,0.145,0.148,0.472,1.916,0.892,-0.891,-0.233,-1.272,-0.89,-0.369,-0.627,0.239],[1,3.504,1.198,1.211,1.142,0.911,0.991,0.964,2.371,1.066,0.983,1.133,0.915,1.055,0.892,1.001,0.954,0.982,1.01,1.004,0.937,1.035,1.031,0.804,1.012,1.012,1.045,1.117,1.041,0.946,0.985,0.91,0.939,0.949,0.942,1.027],[0,-50.2,-13.1,-4,3.3,2.2,1,1.5,-8.2,-0.7,1,-1.8,2.5,-1.3,2.8,0.6,1.1,1.4,-0.3,0.3,2.6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,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[\'2014-01-29\',\'2014-01-30\',\'2014-02-07\',\'2014-02-10\',\'2014-02-13\',\'2014-02-14\',\'2014-02-17\',\'2014-02-18\',\'2014-02-19\',\'2014-02-20\',\'2014-02-21\',\'2014-02-24\',\'2014-02-25\',\'2014-02-26\',\'2014-02-27\',\'2014-02-28\',\'2014-03-03\',\'2014-03-04\',\'2014-03-05\',\'2014-03-06\',\'2014-03-07\',\'2014-03-10\',\'2014-03-11\',\'2014-03-12\',\'2014-03-13\',\'2014-03-14\',\'2014-03-17\',\'2014-03-18\',\'2014-03-19\',\'2014-03-20\',\'2014-03-21\',\'2014-03-24\',\'2014-03-25\',\'2014-03-26\',\'2014-03-27\',\'2014-03-28\'],[45.96,60.68,60.48,71.50,80.77,80.00,87.02,87.50,93.27,96.27,100.01,112.90,121.70,111.10,116.00,102.75,103.00,103.80,98.99,99.41,101.95,95.92,99.50,102.90,91.00,90.80,95.10,96.00,103.00,111.00,104.21,107.01,95.01,92.89,92.00,85.99],[55.16,60.68,66.75,73.43,80.77,88.85,89.97,89.20,93.27,102.60,112.18,119.89,127.94,119.69,116.00,105.50,107.37,106.90,102.50,106.98,103.40,103.19,102.66,104.66,92.70,95.44,97.32,106.15,112.97,113.45,113.00,108.10,96.00,94.88,92.68,90.58],[45.96,60.68,59.46,70.00,79.00,78.98,84.93,83.88,93.27,94.50,100.01,111.00,108.11,109.90,104.67,98.86,100.83,96.98,97.51,95.03,97.00,95.00,96.03,91.80,89.66,90.77,93.80,95.53,102.00,105.88,102.00,98.64,90.92,92.58,86.67,85.00],[0,46.6,10.7,3.2,-1.5,-4.6,-1.1,-1,18.5,3.4,-1.7,4.2,-3.5,2.3,-2.8,-0.2,-2.2,-1.4,0.7,-1.7,-1.9,0.8,0.5,-10.4,1.3,-0.5,1.7,3.9,1,-2.7,-1.2,-4.9,-2.7,-1.8,-2.5,0]);

var area=new Array([55.16,119.89],[0,64825],[-4032.08,9496.15],[-4.556,15.268],[0,3.504],[-50.2,6.5],[-10.3,3.9],[-24.3,11.6],[-8.7,42.8],[45.96,121.70],[55.16,127.94],[45.96,111.00]);

解释:

最开始的var data=new Array(下面有20个[]字符串组,将他们分割出来。

他们依次是:收盘价、成交额、BBD金额、DDY、单数比、小单差、中单差、大单差、特大单差、涨跌幅、DDX、保留1、保留2、保留3、保留4、日期、开盘价、最高价、最低价、通吃率。

第二个var area=new Array(里面的[]对应的是出了价格、日期,其它项的Range。

2、下载今日实时DDE数据(值,非波形)

#define SFURL_DNG_ALLDATA    L"http://www.dingniugu.com/sydata/ddxxgdata26.php?orderby=0&page="

enum enumDNG_ALLDATA_INDEX
{
    DNG_ALLDATA_INDEX_StockCode,
    DNG_ALLDATA_INDEX_CurrentPrice,
    DNG_ALLDATA_INDEX_RisePercent,
    DNG_ALLDATA_INDEX_HuanShouLv,
    DNG_ALLDATA_INDEX_LiangBi,
    DNG_ALLDATA_INDEX_DDX1,
    DNG_ALLDATA_INDEX_DDY1,
    DNG_ALLDATA_INDEX_DDZ,
    DNG_ALLDATA_INDEX_DDX3,
    DNG_ALLDATA_INDEX_DDX5,
    DNG_ALLDATA_INDEX_DDX10,
    DNG_ALLDATA_INDEX_DDX60,
    DNG_ALLDATA_INDEX_DDX5Red,
    DNG_ALLDATA_INDEX_DDX10Red,
    DNG_ALLDATA_INDEX_DDXContinueRed,
    DNG_ALLDATA_INDEX_DDXContinueUp,
    DNG_ALLDATA_INDEX_Rise3,
    DNG_ALLDATA_INDEX_Rise5,
    DNG_ALLDATA_INDEX_Rise10,
    DNG_ALLDATA_INDEX_DDY3,
    DNG_ALLDATA_INDEX_DDY5,
    DNG_ALLDATA_INDEX_DDY10,
    DNG_ALLDATA_INDEX_DDY60,
    DNG_ALLDATA_INDEX_Turnover,
    DNG_ALLDATA_INDEX_BBD,
    DNG_ALLDATA_INDEX_TCL1,
    DNG_ALLDATA_INDEX_TCL5,
    DNG_ALLDATA_INDEX_TCL10,
    DNG_ALLDATA_INDEX_TCL20,
    DNG_ALLDATA_INDEX_DSB,
    DNG_ALLDATA_INDEX_TDDC,
    DNG_ALLDATA_INDEX_DDC,
    DNG_ALLDATA_INDEX_ZDC,
    DNG_ALLDATA_INDEX_XDC,
    DNG_ALLDATA_INDEX_ZDL1,
    DNG_ALLDATA_INDEX_ZDL5,
    DNG_ALLDATA_INDEX_ZDL10,
    DNG_ALLDATA_INDEX_LTA,

    DNG_ALLDATA_INDEX_Max
};

bool CSF_DNGDataReader::GetAllStockDDEData(StockDngDataMap& dngMap)
{
    static int s_iMaxPage = 0;

    bool bRet = false;
    CString strUrl;
    CSF_HttpDataReader httpReader;

    int i,idx1,idx2,len;
    int nPage,nItem;
    string sRead;

    int iDate = 0;

    //only get 20 items in one page, and the data is about 4.5KB
    char* buf = new char[8*1024];

    if (s_iMaxPage == 0)
    {
        strUrl.Format(L"%s%d",SFURL_DNG_ALLDATA, 1);
        len = httpReader.GetHttpData(strUrl, buf, 8*1024);
        if (len > 0)
        {
            buf[len] = 0;

            sRead = "";
            sRead.append(buf);

            //  "total":2351,
            idx1 = sRead.find("total");
            idx2 = sRead.find(",", idx1);
            if ((idx1 != -1) && (idx2 != -1))
            {
                int iMaxItem = atoi(sRead.substr(idx1+7, idx2-idx1-7).c_str());
                s_iMaxPage =  iMaxItem/ DNG_ITEM_InOnePage;  //20 Item In One Page
                if ((iMaxItem%DNG_ITEM_InOnePage) != 0)
                {
                    s_iMaxPage++;
                }
            }
        }
    }

    if (s_iMaxPage)
    {
        for (nPage=1; nPage<=s_iMaxPage; nPage++)
        {
            strUrl.Format(L"%s%d",SFURL_DNG_ALLDATA, nPage);
            len = httpReader.GetHttpData(strUrl, buf, 8*1024);
            if (len > 0)
            {
                buf[len] = 0;

                sRead = "";
                sRead.append(buf);

                //Parse date
                //  "updatetime":"2014-03-07
                idx1 = sRead.find("updatetime");
                if (idx1 != -1)
                {
                    string sdate = sRead.substr(idx1+13, 10);

                    iDate = atoi(sdate.substr(0,4).c_str())*10000 
                        + atoi(sdate.substr(5,2).c_str())*100 + atoi(sdate.substr(8,2).c_str());
                }

                idx1 = sRead.find("[[");
                idx2 = sRead.rfind("]]");
                if ((idx1 != -1) && (idx2 != -1))
                {
                    sRead = sRead.substr(idx1+2, idx2-idx1-2);

                    vector<string> vecItems;
                    TF_SplitString(sRead, "\\],\\[", vecItems);
                    if (vecItems.size())
                    {
                        for (nItem=0; nItem<vecItems.size(); nItem++)
                        {
                            vector<string> vecDetail;
                            TF_SplitString(vecItems[nItem], ",", vecDetail);
                            if (vecDetail.size() == DNG_ALLDATA_INDEX_Max)
                            {
                                int iStockCode;
                                DNG_DATA objData;

                                iStockCode = atoi(vecDetail[DNG_ALLDATA_INDEX_StockCode].c_str());
                                objData.dde[DDE_ITEM_INDEX_BBD] = atof(vecDetail[DNG_ALLDATA_INDEX_BBD].c_str());
                                objData.dde[DDE_ITEM_INDEX_DDX] = atof(vecDetail[DNG_ALLDATA_INDEX_DDX1].c_str());
                                objData.dde[DDE_ITEM_INDEX_DDY] = atof(vecDetail[DNG_ALLDATA_INDEX_DDY1].c_str());
                                objData.dde[DDE_ITEM_INDEX_DDZ] = atof(vecDetail[DNG_ALLDATA_INDEX_DDZ].c_str());
                                objData.dde[DDE_ITEM_INDEX_DSB] = atof(vecDetail[DNG_ALLDATA_INDEX_DSB].c_str());
                                objData.dde[DDE_ITEM_INDEX_XDC] = atof(vecDetail[DNG_ALLDATA_INDEX_XDC].c_str());
                                objData.dde[DDE_ITEM_INDEX_ZDC] = atof(vecDetail[DNG_ALLDATA_INDEX_ZDC].c_str());
                                objData.dde[DDE_ITEM_INDEX_DDC] = atof(vecDetail[DNG_ALLDATA_INDEX_DDC].c_str());
                                objData.dde[DDE_ITEM_INDEX_TDDC] = atof(vecDetail[DNG_ALLDATA_INDEX_TDDC].c_str());
                                objData.dde[DDE_ITEM_INDEX_TCL] = atof(vecDetail[DNG_ALLDATA_INDEX_TCL1].c_str());
                                objData.date = iDate;

                                StockDngDataMapIter it = dngMap.find(iStockCode);
                                if (it != dngMap.end())
                                {
                                    it->second = objData;
                                }
                                else
                                {
                                    dngMap.insert(make_pair<int, DNG_DATA>(iStockCode, objData));
                                }
                            }
                        }
                    }
                }
            }
        }

        bRet = (dngMap.size() > 0);
    }

    delete[] buf;

    return bRet;
}

只能一个Page一个Page去获取,初始根据"total":2343这个值,去计算有多少页吧,每页20项,起始Page为1。

老办法,分割,具体Item意义,见enum。

 参考网页:http://www.dingniugu.com/ddxxg.html