简体   繁体   English

使用雅虎财务

[英]Using Yahoo finance

I have a list of 1000 stocks of wich i am trying to get the price from yahoo finance. 我有一份清单,我正在尝试从Yahoo Finance获取价格的1000支威客。 How ever the program seems to skip some stocks and does not fill it in. The code i am using is 该程序似乎跳过了一些库存却没有填写。我使用的代码是

     void display(String symbol) throws IOException
       {

                    URL yahoofin = new URL("http://finance.yahoo.com/d/quotes.csv?s=" + symbol + "&f=l1kjm3m4r"); 
                    URLConnection yc = yahoofin.openConnection(); 

        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream())); 
        String inputLine; 

        while ((inputLine = in.readLine()) != null) 
        { 

            System.out.println("ing= "+ing+" "+inputLine);
            info[ing]=inputLine;


        } 
        System.out.println("ing = "+ing);

        in.close(); 
    /* 
    catch (Exception ex) 
    { 
       // log.error("Unable to get stockinfo for: " + symbol + ex); 
    } 
     */
 } 

I keep passing new symbols from another function ten at a time. 我不断从另一个函数传递新符号,每次十个。 BUt ing prints 7 sometimes.(that means stocks are skipped). 有时会打印7张。(这意味着跳过了库存)。 Where am i going wrong. 我要去哪里错了。

You might want to add a delay between your calls. 您可能希望在通话之间增加延迟。 Sometime Yahoo does not accept very high frequency requests and turns down some of them. 有时Yahoo不接受非常高的频率请求,因此拒绝了其中一些请求。

You can pass more than one symbol per request (I think up to 50) seperated by "+". 您可以为每个请求传递多个符号(我认为最多为50个),并用“ +”分隔。 This should imensely decrease the number of your requests. 这将大大减少您的请求数量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM