0

I'm using the Yahoo Finance Streaming API to get stock quotes, I wanted to save these into a DB table for historical reference.

I'm looking for something which can easily parse various strings which have a format that varies like the examples below:

<script>try{parent.yfs_mktmcb({"unixtime":1310957222});}catch(e){}</script>   
<script>try{parent.yfs_u1f({"ASX.AX":{c10:"-0.06"}});}catch(e){}</script>
<script>try{parent.yfs_u1f({"AWC.AX":{l10:"2.16",c10:"+0.01",p20:"+0.47"}});}catch(e){}</script>
<script>try{parent.yfs_u1f({"ALZ.AX":{l10:"2.6900",c10:"-0.1200",p20:"-4.27"}});}catch(e){}</script>

I want to parse these strings to a MySQL database and I was thinking the easiest way will be using Java to do this parsing. Basically these entries are line by line in a text file. I want to extract the time, the stock code, the price and the change values in a simple table.

The table looks like StockCode | Date | Time | Price | ChangeDol | ChangePer

Are there any tools or frameworks which would make this process easy?

Thanks!

NightWolf
  • 7,694
  • 9
  • 74
  • 121

2 Answers2

1

You could have a look there http://www.wikijava.org/wiki/Downloading_stock_market_quotes_from_Yahoo!_finance

They get finencial data as csv from yahoo.

hanoo
  • 4,175
  • 2
  • 26
  • 19
1

I don't how you get your quote, but if you could use YQL, any XML parser would do:

YQL

<quote symbol="YHOO">
    <Ask>14.76</Ask>
    <AverageDailyVolume>28463800</AverageDailyVolume>
    <Bid>14.51</Bid>
    <AskRealtime>14.76</AskRealtime>
    <BidRealtime>14.51</BidRealtime>
    <BookValue>9.826</BookValue>
    <Change_PercentChange>0.00 - 0.00%</Change_PercentChange>
    ....
</quote>

List of XML Parsers for Java

Community
  • 1
  • 1
Jacob
  • 41,721
  • 6
  • 79
  • 81