diff --git a/yahoo/finance/option_chain/yahoo.finance.option_chain.xml b/yahoo/finance/option_chain/yahoo.finance.option_chain.xml index f7089890..8e9c31d7 100644 --- a/yahoo/finance/option_chain/yahoo.finance.option_chain.xml +++ b/yahoo/finance/option_chain/yahoo.finance.option_chain.xml @@ -18,55 +18,55 @@ - - - + + + + + ]]> - \ No newline at end of file + diff --git a/yahoo/finance/option_contract/yahoo.finance.option_contract.xml b/yahoo/finance/option_contract/yahoo.finance.option_contract.xml index c12fb12f..9cf71d8f 100644 --- a/yahoo/finance/option_contract/yahoo.finance.option_contract.xml +++ b/yahoo/finance/option_contract/yahoo.finance.option_contract.xml @@ -14,69 +14,69 @@ - \ No newline at end of file + diff --git a/yahoo/finance/optionsSpecific/yahoo.finance.optionsSpecific.xml b/yahoo/finance/optionsSpecific/yahoo.finance.optionsSpecific.xml index 1964efab..7786b08a 100644 --- a/yahoo/finance/optionsSpecific/yahoo.finance.optionsSpecific.xml +++ b/yahoo/finance/optionsSpecific/yahoo.finance.optionsSpecific.xml @@ -18,98 +18,98 @@ - - - + + + ; - } - else - { - optionsChain = ; - } - - getOptionsChain(); - optionsChain.@["count"] = optionsChainCount; - response.object = optionsChain; - - ]]> + if ( expiration != null ) + { + var expPattern = /^[\d]{4}\-[\d]{2}$/; + + if ( expPattern.test( expiration ) ) + { + optionsChainURL += "&m=" + expiration; + queryHasExpiration = true; + } + } + + var yQuery = y.rest( optionsChainURL ); + var data = yQuery.accept( "text/html" ).get().response; + + var optionsChainQuery = y.xpath( + data, + "//table[@class='yfnc_datamodoutline1']/tr/td/table/tr[td[@class='yfnc_h' or " + + "@class='yfnc_tabledata1']]" + ); + + var expiresQuery = y.xpath( + data, + "//table[@class='yfnc_mod_table_title1']/tr/td[last()]/p" + ); + + var expiryDay = getExpiration(); + + var optionsChain; + var expDate = expiration; + + if ( queryHasExpiration == true ) + { + if ( expiryDay != null && + expiryDay != "" ) + { + expDate += "-" + expiryDay; + } + + optionsChain = ; + } + else + { + optionsChain = ; + } + + getOptionsChain(); + optionsChain.@["count"] = optionsChainCount; + response.object = optionsChain; + + ]]> - \ No newline at end of file + diff --git a/yahoo/finance/oquote/yahoo.finance.oquote.xml b/yahoo/finance/oquote/yahoo.finance.oquote.xml index 4bca168c..51b3c8b0 100644 --- a/yahoo/finance/oquote/yahoo.finance.oquote.xml +++ b/yahoo/finance/oquote/yahoo.finance.oquote.xml @@ -18,12 +18,12 @@ - + ; @@ -61,8 +61,8 @@ if (summary.hasComplexContent()) { - - ]]> + + ]]> diff --git a/yahoo/finance/quote/yahoo.finance.quote.xml b/yahoo/finance/quote/yahoo.finance.quote.xml index 6523687d..4b83fe21 100644 --- a/yahoo/finance/quote/yahoo.finance.quote.xml +++ b/yahoo/finance/quote/yahoo.finance.quote.xml @@ -1,21 +1,21 @@ - - - select * from {table} where symbol in ("YHOO","AAPL","GOOG","MSFT") - - - - + http://download.finance.yahoo.com/d/quotes.csv?s={-listjoin|,|symbol} + + + + + ; + var rows=results.results.row; var neededValues = { "Name" : true, "Symbol" : true, @@ -34,23 +34,23 @@ "StockExchange" : true }; - for each (var row in rows) { - for each (var item in row.*) { - var elname = item.localName(); - var txt = item.text().toString(); - if (txt=="N/A") txt=""; else if (txt=="-") txt=""; else { - txt = txt.replace(/"/g, ''); - } - row[elname]=txt; - if (!neededValues[elname]) { - delete row[elname]; - } - } - //split % change out - quotes.quote += {row.*}; - } - response.object = quotes; + for each (var row in rows) { + for each (var item in row.*) { + var elname = item.localName(); + var txt = item.text().toString(); + if (txt=="N/A") txt=""; else if (txt=="-") txt=""; else { + txt = txt.replace(/"/g, ''); + } + row[elname]=txt; + if (!neededValues[elname]) { + delete row[elname]; + } + } + //split % change out + quotes.quote += {row.*}; + } + response.object = quotes; ]]> - - + +
diff --git a/yahoo/finance/yahoo.finance.balancesheet.xml b/yahoo/finance/yahoo.finance.balancesheet.xml index 40af9984..9c2f7e62 100644 --- a/yahoo/finance/yahoo.finance.balancesheet.xml +++ b/yahoo/finance/yahoo.finance.balancesheet.xml @@ -18,52 +18,52 @@ - - - + + + ; - if ( query.*.length() !== 0 ) - { + if ( query.*.length() !== 0 ) + { var y = 0; var x = 0; var numcolumns = 0; var data_array = new Array(); - + // Read Column Headings data_array[0] = new Array() data_array[0][0] = "Headings" @@ -96,10 +96,10 @@ numcolumns = x; // Read Rows - y = 1; + y = 1; var i = 1; - while ( i < query.length()) - { + while ( i < query.length()) + { var row = query[i]; if(row.td.length() >= numcolumns){ x = 0; @@ -118,7 +118,7 @@ dataitem = Number(dataitem) * 1000; } data_array[x][y] = dataitem; - //outputdata.appendChild({dataitem}); + //outputdata.appendChild({dataitem}); x++; } } @@ -141,7 +141,7 @@ } // Return statsdata strucuture response.object = outputdata; - ]]> + ]]> diff --git a/yahoo/finance/yahoo.finance.cashflow.xml b/yahoo/finance/yahoo.finance.cashflow.xml index 52467d1e..91cefde3 100644 --- a/yahoo/finance/yahoo.finance.cashflow.xml +++ b/yahoo/finance/yahoo.finance.cashflow.xml @@ -18,52 +18,52 @@ - - - + + + ; - if ( query.*.length() !== 0 ) - { + if ( query.*.length() !== 0 ) + { //TODO: if re-write the reading of the columns slightly, same file can be shared //TODO: for all 3 financial statements. income statement is a td element, followed by 3 th elements //TODO: cash / balance sheet are simply 4 td elements - this is only difference between tables! @@ -86,7 +86,7 @@ var y = 0; var x = 0; var numcolumns = 0; var data_array = new Array(); - + // Read Column Headings data_array[0] = new Array() data_array[0][0] = "Headings" @@ -100,10 +100,10 @@ numcolumns = x; // Read Rows - y = 1; + y = 1; var i = 1; - while ( i < query.length()) - { + while ( i < query.length()) + { var row = query[i]; if(row.td.length() >= numcolumns){ x = 0; @@ -122,7 +122,7 @@ dataitem = Number(dataitem) * 1000; } data_array[x][y] = dataitem; - //outputdata.appendChild({dataitem}); + //outputdata.appendChild({dataitem}); x++; } } @@ -145,7 +145,7 @@ } // Return statsdata strucuture response.object = outputdata; - ]]> + ]]> diff --git a/yahoo/finance/yahoo.finance.com-info b/yahoo/finance/yahoo.finance.com-info index 352d4d0b..08005a90 100644 --- a/yahoo/finance/yahoo.finance.com-info +++ b/yahoo/finance/yahoo.finance.com-info @@ -10,19 +10,19 @@ http://finance.yahoo.com/q/ae?s=VZ+Analyst+Estimates YQL Java Code to Parse finance.yahoo.com tables (example from options chain): - var yQuery = y.rest( optionsChainURL ); - var data = yQuery.accept( "text/html" ).get().response; - - var optionsChainQuery = y.xpath( - data, - "//table[@class='yfnc_datamodoutline1']/tr/td/table/tr[td[@class='yfnc_h' or " + - "@class='yfnc_tabledata1']]" - ); - - var expiresQuery = y.xpath( - data, - "//table[@class='yfnc_mod_table_title1']/tr/td[last()]/p" - ); + var yQuery = y.rest( optionsChainURL ); + var data = yQuery.accept( "text/html" ).get().response; + + var optionsChainQuery = y.xpath( + data, + "//table[@class='yfnc_datamodoutline1']/tr/td/table/tr[td[@class='yfnc_h' or " + + "@class='yfnc_tabledata1']]" + ); + + var expiresQuery = y.xpath( + data, + "//table[@class='yfnc_mod_table_title1']/tr/td[last()]/p" + ); ** xpath( method is used to pull just the rows requested @@ -47,7 +47,7 @@ Key Statistics (COMPLETE) github live for yql: use "http://raw.github.com/canada4663/yql-tables/master/yahoo/finance/yahoo.finance.keystats.xml" as keystats; select * from keystats where symbol="T"; -raw for development: +raw for development: select * from html where url="http://finance.yahoo.com/q/ks?s=TXN" and xpath='//table[@class="yfnc_datamodoutline1"]/tr/td/table/tr/td[@class="yfnc_tabledata1" or @class="yfnc_tablehead1"]' Outputs: diff --git a/yahoo/finance/yahoo.finance.dividendhistory.xml b/yahoo/finance/yahoo.finance.dividendhistory.xml index ed3fdce4..74b36d68 100644 --- a/yahoo/finance/yahoo.finance.dividendhistory.xml +++ b/yahoo/finance/yahoo.finance.dividendhistory.xml @@ -22,30 +22,30 @@ {row.*}; } response.object = quotes; - + function getDay(date) { var n = date.substr(8,2); - if (n.substr(0, 1)=="0") + if (n.substr(0, 1)=="0") { n = n.substr(1, 1); } @@ -70,7 +70,7 @@ } function getMonth(date) { var n = date.substr(5,2); - if (n.substr(0, 1)=="0") + if (n.substr(0, 1)=="0") { n = n.substr(1, 1); } @@ -79,8 +79,8 @@ function getYear(date) { return date.substr(0,4) } - + ]]> - \ No newline at end of file + diff --git a/yahoo/finance/yahoo.finance.historicaldata.xml b/yahoo/finance/yahoo.finance.historicaldata.xml index 432d2976..16cb8532 100644 --- a/yahoo/finance/yahoo.finance.historicaldata.xml +++ b/yahoo/finance/yahoo.finance.historicaldata.xml @@ -1,86 +1,86 @@ - - Luigi Conti - iMobile.it - Yahoo Finance Stock historical prices - select * from {table} where symbol = "YHOO" and startDate = "2009-09-11" and endDate = "2010-03-10" - - - + http://ichart.finance.yahoo.com/table.csv + + + + + + + + + + + + + ; - rows=results.results.row; - for each (var row in rows) { - quotes.quote += {row.*}; - } - response.object = quotes; - - function getDay(date) { - var n = date.substr(8,2); - if (n.substr(0, 1)=="0") - { - n = n.substr(1, 1); - } - return '' + (parseInt(n)); - } - function getMonth(date) { - var n = date.substr(5,2); - if (n.substr(0, 1)=="0") - { - n = n.substr(1, 1); - } - return '' + (parseInt(n)-1); - } - function getYear(date) { - return date.substr(0,4) - } - + /* + Parameter Value + s Stock Ticker (for example, MSFT) + a Start Month (0-based; 0=January, 11=December) + b Start Day + c Start Year + d End Month (0-based; 0=January, 11=December) + e End Day + f End Year + g Always use the letter d + */ + + var encodedUrl = request.url; + encodedUrl = encodedUrl.replace('a=1','a=' + getMonth(startDate)); + encodedUrl = encodedUrl.replace('b=1','b=' + getDay(startDate)); + encodedUrl = encodedUrl.replace('c=2010','c=' + getYear(startDate)); + encodedUrl = encodedUrl.replace('d=1','d=' + getMonth(endDate)); + encodedUrl = encodedUrl.replace('e=30','e=' + getDay(endDate)); + encodedUrl = encodedUrl.replace('f=2010','f=' + getYear(endDate)); + + var results = y.query("select * from csv(0,1) where url=@url",{url:encodedUrl}); + var colNames=''; + var rows=results.results.row; + for each (var row in rows) { + for each (var item in row.*) { + var txt = item.text().toString(); + colNames=colNames + ',' + txt.replace(' ', '_'); + } + } + colNames = colNames.substring(1); + results = y.query("select * from csv(2,0) where url=@url and columns=@columnsNames",{url:encodedUrl,columnsNames:colNames}); + var quotes = ; + rows=results.results.row; + for each (var row in rows) { + quotes.quote += {row.*}; + } + response.object = quotes; + + function getDay(date) { + var n = date.substr(8,2); + if (n.substr(0, 1)=="0") + { + n = n.substr(1, 1); + } + return '' + (parseInt(n)); + } + function getMonth(date) { + var n = date.substr(5,2); + if (n.substr(0, 1)=="0") + { + n = n.substr(1, 1); + } + return '' + (parseInt(n)-1); + } + function getYear(date) { + return date.substr(0,4) + } + ]]> - - + +
diff --git a/yahoo/finance/yahoo.finance.incomestatement.xml b/yahoo/finance/yahoo.finance.incomestatement.xml index 16285a94..34a71214 100644 --- a/yahoo/finance/yahoo.finance.incomestatement.xml +++ b/yahoo/finance/yahoo.finance.incomestatement.xml @@ -18,52 +18,52 @@ - - - + + + ; - if ( query.*.length() !== 0 ) - { + if ( query.*.length() !== 0 ) + { var y = 0; var x = 1; var numcolumns = 0; var data_array = new Array(); - + // Read Column Headings data_array[0] = new Array() data_array[0][0] = "Headings" @@ -96,10 +96,10 @@ numcolumns = x; // Read Rows - y = 1; + y = 1; var i = 1; - while ( i < query.length()) - { + while ( i < query.length()) + { var row = query[i]; if(row.td.length() >= numcolumns){ x = 0; @@ -118,7 +118,7 @@ dataitem = Number(dataitem) * 1000; } data_array[x][y] = dataitem; - //outputdata.appendChild({data_array[x][y]}); + //outputdata.appendChild({data_array[x][y]}); x++; } } @@ -141,7 +141,7 @@ } // Return statsdata strucuture response.object = outputdata; - ]]> + ]]> diff --git a/yahoo/finance/yahoo.finance.industry.xml b/yahoo/finance/yahoo.finance.industry.xml index 264d4ebc..f19931c4 100644 --- a/yahoo/finance/yahoo.finance.industry.xml +++ b/yahoo/finance/yahoo.finance.industry.xml @@ -4,7 +4,7 @@ Tom Powers Yahoo Finance Industry Index - Industry + Stock Symbols select * from {table} where id="112" - http://wiki.github.com/tpowers/yql-tables + http://wiki.github.com/tpowers/yql-tables - - - - - + select * from {table} where symbol in ("US9843321061") + + + + - - \ No newline at end of file + + + diff --git a/yahoo/finance/yahoo.finance.keystats.xml b/yahoo/finance/yahoo.finance.keystats.xml index 69fb91cd..888f24cd 100644 --- a/yahoo/finance/yahoo.finance.keystats.xml +++ b/yahoo/finance/yahoo.finance.keystats.xml @@ -18,69 +18,69 @@ - + ; - if ( keystatsquery.*.length() != 0 ) - { + if ( keystatsquery.*.length() != 0 ) + { var i = 0; - while ( i < keystatsquery.length()) - { + while ( i < keystatsquery.length()) + { // Setup to Process Two 'td' Elements at a Time - Name and Value Pairs var td_param_name = keystatsquery[i]; var td_value = keystatsquery[i+1]; @@ -88,9 +88,9 @@ var attr = ""; var value = ""; i = i + 2; - + // Process Parameter Name and any Associated Attributes (Timeframe, Stock Split Info) - param_name = td_param_name.p.text().toString(); + param_name = td_param_name.text().toString(); param_name = String(param_name.replace(/:/g,"")); attr = String(param_name.match(/\(.*\)/)); attr = String(attr.trim()); @@ -105,7 +105,7 @@ param_name = param_name.trim(); // Process Value Information - value = td_value.p.text().toString(); + value = td_value.text().toString(); // Catch When it is Span Tag instead of P tag if( value == false){ value = td_value.span.text().toString(); @@ -119,17 +119,17 @@ if(attr !== "null"){ statsdata.appendChild(<{param_name} term={attr}> {value} );} else { statsdata.appendChild(<{param_name}> {value} );} - } - } + } + } // Return statsdata strucuture response.object = statsdata; - - - - ]]> + + + + ]]> diff --git a/yahoo/finance/yahoo.finance.onvista.xml b/yahoo/finance/yahoo.finance.onvista.xml index fe47593b..9893b24e 100644 --- a/yahoo/finance/yahoo.finance.onvista.xml +++ b/yahoo/finance/yahoo.finance.onvista.xml @@ -1,161 +1,161 @@ - - select * from {table} where symbol in ("DE0005200000") - - - - + + + + + ; - + var results = ebitQuery.results; stock.EbitMarge = results.td.p.toString().trim(); - + var results = eqratioQuery.results; stock.EquityRatio = results.td.p.toString().trim(); - + var results = per1Query.results; stock.PER1 = results.td.p.toString().trim(); - + var results = per2Query.results; stock.PER2 = results.td.p.toString().trim(); - + var results = per3Query.results; stock.PER3 = results.td.p.toString().trim(); - + var results = per4Query.results; stock.PER4 = results.td.p.toString().trim(); - + var results = per5Query.results; stock.PER5 = results.td.p.toString().trim(); - + var results = analystsQuery.results; stock.Analysts = results.dd.p.toString().trim(); - + var results = upgradeQuery.results; stock.Upgrade = results.td.p.toString().trim(); var results = confirmationQuery.results; stock.Confirmation = results.td.p.toString().trim(); - + var results = downgradeQuery.results; stock.Downgrade = results.td.p.toString().trim(); - + response.object = stock ]]> - - -
\ No newline at end of file + + + diff --git a/yahoo/finance/yahoo.finance.option_contracts.xml b/yahoo/finance/yahoo.finance.option_contracts.xml index b07a4780..e21c03f2 100644 --- a/yahoo/finance/yahoo.finance.option_contracts.xml +++ b/yahoo/finance/yahoo.finance.option_contracts.xml @@ -14,68 +14,68 @@ diff --git a/yahoo/finance/yahoo.finance.options.xml b/yahoo/finance/yahoo.finance.options.xml index 63c95a13..0b390d6b 100644 --- a/yahoo/finance/yahoo.finance.options.xml +++ b/yahoo/finance/yahoo.finance.options.xml @@ -18,212 +18,212 @@ - - + + ; - optionElem.appendChild({strikePrice}); - optionElem.appendChild({lastPrice}); - optionElem.appendChild({change}); - optionElem.appendChild({changeDir}); - optionElem.appendChild({bid}); - optionElem.appendChild({ask}); - optionElem.appendChild({vol}); - optionElem.appendChild({openInt}); - - optionsChain.appendChild( optionElem ); - } - - return true; - } - - function getExpiration() - { - var results = expiresQuery; - - y.log( "results.length(): " + results.length() ); - - elements = results.*.length(); - - if ( elements == 0 ) - { - y.log( "no elements" ); - return ""; - } - - var dateRegEx = /.*([\d]{2})\,\s+?[\d]{4}/g; - - var dateRes = dateRegEx.exec( results[0] ); - - var dd; - - if ( dateRes != null && - dateRes[ 1 ] != null ) - { - dd = dateRes[ 1 ]; - } - - return dd; - } - - - // Queue the query - - var optionsChainURL = "http://finance.yahoo.com/q/op?s=" + symbol; - var queryHasExpiration = false; - - if ( expiration != null ) - { - var expPattern = /^[\d]{4}\-[\d]{2}$/; - - if ( expPattern.test( expiration ) ) - { - optionsChainURL += "&m=" + expiration; - queryHasExpiration = true; - } - } - - var yQuery = y.rest( optionsChainURL ); - var data = yQuery.accept( "text/html" ).get().response; - - var optionsChainQuery = y.xpath( - data, - "//table[@class='yfnc_datamodoutline1']/tr/td/table/tr[td[@class='yfnc_h' or " + - "@class='yfnc_tabledata1']]" - ); - - var expiresQuery = y.xpath( - data, - "//table[@class='yfnc_mod_table_title1']/tr/td[last()]/p" - ); - - var expiryDay = getExpiration(); - - var optionsChain; - var expDate = expiration; - - if ( queryHasExpiration == true ) - { - if ( expiryDay != null && - expiryDay != "" ) - { - expDate += "-" + expiryDay; - } - - optionsChain = ; - } - else - { - optionsChain = ; - } - - getOptionsChain(); - - response.object = optionsChain; - - ]]> + + // pad string with leading char + + String.prototype.pad = function ( padchar, padlen ) + { + s = this + + while (s.length < padlen) + { + s = padchar + s; + } + + return s; + } + + String.prototype.trim = function () + { + var str = this.replace( /^\s\s*/, "" ), + ws = /\s/, + i = str.length; + while ( ws.test( str.charAt( --i ) ) ); + return str.slice( 0, i + 1 ); + } + + String.prototype.toInt = function () + { + // remove leading 0's because otherwise + // str can be interpreted as Octal + var str = this.replace( /^0+/, '' ); + + // also the thousands comma was cousing trouble + str = str.replace( /\,/g, '' ); + + return parseInt( str ); + } + + function getOptionsChain() + { + // Get the Options Chain for the given symbol from the Options page + + var results = optionsChainQuery; + + elements = results.*.length(); + + if ( elements == 0 ) + { + return false; + } + + var optionElem; + + var strikePrice; + var optionSymbol; + var optionType; + var lastPrice; + var change; + var changeDir; + var bid; + var ask; + var vol; + var volStr; + var openInt; + var openIntStr; + + var optTypeMatch; + + for each ( var tr in results ) + { + strikePrice = parseFloat( tr.td[0].a.strong.text().toString().replace(/\,/g,'') ); + optionSymbol = tr.td[1].a.text(); + + // Check to see what type of option + // the current option is + + optTypeMatch = optionSymbol.match( /^[\w]{7,}([P|C])/ ); + + if ( optTypeMatch != null ) + { + optionType = optTypeMatch[1]; + } + + lastPrice = tr.td[2].strong.text(); + change = tr.td[3].span.strong.text(); + changeDir = tr.td[3].span.img.@alt.toString(); + bid = parseFloat( tr.td[4].p.text() ); + ask = parseFloat( tr.td[5].p.text() ); + volStr = tr.td[6].p.text(); + vol = volStr.toInt(); + openIntStr = tr.td[7].p.text(); + openInt = openIntStr.toInt(); + + if ( changeDir.toLowerCase() == "down" ) + { + change = parseFloat( change ) * -1; + } + else + { + change = parseFloat( change ); + } + + optionElem = ; + optionElem.appendChild({strikePrice}); + optionElem.appendChild({lastPrice}); + optionElem.appendChild({change}); + optionElem.appendChild({changeDir}); + optionElem.appendChild({bid}); + optionElem.appendChild({ask}); + optionElem.appendChild({vol}); + optionElem.appendChild({openInt}); + + optionsChain.appendChild( optionElem ); + } + + return true; + } + + function getExpiration() + { + var results = expiresQuery; + + y.log( "results.length(): " + results.length() ); + + elements = results.*.length(); + + if ( elements == 0 ) + { + y.log( "no elements" ); + return ""; + } + + var dateRegEx = /.*([\d]{2})\,\s+?[\d]{4}/g; + + var dateRes = dateRegEx.exec( results[0] ); + + var dd; + + if ( dateRes != null && + dateRes[ 1 ] != null ) + { + dd = dateRes[ 1 ]; + } + + return dd; + } + + + // Queue the query + + var optionsChainURL = "http://finance.yahoo.com/q/op?s=" + symbol; + var queryHasExpiration = false; + + if ( expiration != null ) + { + var expPattern = /^[\d]{4}\-[\d]{2}$/; + + if ( expPattern.test( expiration ) ) + { + optionsChainURL += "&m=" + expiration; + queryHasExpiration = true; + } + } + + var yQuery = y.rest( optionsChainURL ); + var data = yQuery.accept( "text/html" ).get().response; + + var optionsChainQuery = y.xpath( + data, + "//table[@class='yfnc_datamodoutline1']/tr/td/table/tr[td[@class='yfnc_h' or " + + "@class='yfnc_tabledata1']]" + ); + + var expiresQuery = y.xpath( + data, + "//table[@class='yfnc_mod_table_title1']/tr/td[last()]/p" + ); + + var expiryDay = getExpiration(); + + var optionsChain; + var expDate = expiration; + + if ( queryHasExpiration == true ) + { + if ( expiryDay != null && + expiryDay != "" ) + { + expDate += "-" + expiryDay; + } + + optionsChain = ; + } + else + { + optionsChain = ; + } + + getOptionsChain(); + + response.object = optionsChain; + + ]]> diff --git a/yahoo/finance/yahoo.finance.quant.xml b/yahoo/finance/yahoo.finance.quant.xml index 8d4e83b5..65e6b56f 100644 --- a/yahoo/finance/yahoo.finance.quant.xml +++ b/yahoo/finance/yahoo.finance.quant.xml @@ -1,340 +1,340 @@ - - - select * from {table} where symbol in ("YHOO") - - - - + + + + + = 6) { var monthSix = month-6; var yearSix = year; } else { - var monthSix = month+7; - var yearSix = year-1; + var monthSix = month+7; + var yearSix = year-1; } var url = "http://finance.yahoo.com/q/hp?s=" + symbol + "&a=" + monthSix + "&b=" + day + "&c=" + yearSix + "&d=" + monthSix + "&e=" + day + "&f=" + yearSix + "&g=d"; var sixMonthsQuery = y.query( - "select * from html " + - "where url=@url and " + - "xpath='" + - "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 2]'", - {url:url}); + "select * from html " + + "where url=@url and " + + "xpath='" + + "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 2]'", + {url:url}); var day = now.getDate(); var month = now.getMonth(); var year = now.getYear(); - + if (year < 999) year += 1900; - + if (month == 0){ - var lastMonth = 12; - var lastYear = year-1; + var lastMonth = 12; + var lastYear = year-1; } else { - var lastMonth = month - 1; - var lastYear = year; + var lastMonth = month - 1; + var lastYear = year; } - + if (lastMonth == 0 || lastMonth == 2 || lastMonth == 4 || lastMonth == 6 || lastMonth == 7 || lastMonth == 9 || lastMonth == 11){ - var lastDay = 31; + var lastDay = 31; } else if (lastMonth == 1){ - var lastDay = 28; + var lastDay = 28; } else { - var lastDay = 30; + var lastDay = 30; } var url = "http://finance.yahoo.com/q/hp?s=" + symbol + "&a=" + lastMonth + "&b=" + lastDay + "&c=" + lastYear + "&d=" + lastMonth + "&e=" + lastDay + "&f=" + lastYear + "&g=d"; var lastMonthQuery = y.query( - "select * from html " + - "where url=@url and " + - "xpath='" + - "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 5]'", - {url:url}); - - + "select * from html " + + "where url=@url and " + + "xpath='" + + "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 5]'", + {url:url}); + + if (lastMonth == 0){ - var twoMonthsAgo = 12; - var lastYear = year-1; + var twoMonthsAgo = 12; + var lastYear = year-1; } else { - var twoMonthsAgo = lastMonth - 1; - var lastYear = year; + var twoMonthsAgo = lastMonth - 1; + var lastYear = year; } - + if (twoMonthsAgo == 0 || twoMonthsAgo == 2 || twoMonthsAgo == 4 || twoMonthsAgo == 6 || twoMonthsAgo == 7 || twoMonthsAgo == 9 || twoMonthsAgo == 11){ - var lastDay = 31; + var lastDay = 31; } else if (twoMonthsAgo == 1){ - var lastDay = 28; + var lastDay = 28; } else { - var lastDay = 30; + var lastDay = 30; } - + var url = "http://finance.yahoo.com/q/hp?s=" + symbol + "&a=" + twoMonthsAgo + "&b=" + lastDay + "&c=" + lastYear + "&d=" + twoMonthsAgo + "&e=" + lastDay + "&f=" + lastYear + "&g=d"; var twoMonthsAgoQuery = y.query( - "select * from html " + - "where url=@url and " + - "xpath='" + - "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 5]'", - {url:url}); + "select * from html " + + "where url=@url and " + + "xpath='" + + "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 5]'", + {url:url}); if (twoMonthsAgo == 0){ - var threeMonthsAgo = 12; - var lastYear = year-1; + var threeMonthsAgo = 12; + var lastYear = year-1; } else { - var threeMonthsAgo = twoMonthsAgo - 1; - var lastYear = year; + var threeMonthsAgo = twoMonthsAgo - 1; + var lastYear = year; } - + if (threeMonthsAgo == 0 || threeMonthsAgo == 2 || threeMonthsAgo == 4 || threeMonthsAgo == 6 || threeMonthsAgo == 7 || threeMonthsAgo == 9 || threeMonthsAgo == 11){ - var lastDay = 31; + var lastDay = 31; } else if (threeMonthsAgo == 1){ - var lastDay = 28; + var lastDay = 28; } else { - var lastDay = 30; + var lastDay = 30; } var url = "http://finance.yahoo.com/q/hp?s=" + symbol + "&a=" + threeMonthsAgo + "&b=" + lastDay + "&c=" + lastYear + "&d=" + threeMonthsAgo + "&e=" + lastDay + "&f=" + lastYear + "&g=d"; var threeMonthsAgoQuery = y.query( - "select * from html " + - "where url=@url and " + - "xpath='" + - "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 5]'", - {url:url}); + "select * from html " + + "where url=@url and " + + "xpath='" + + "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 5]'", + {url:url}); if (threeMonthsAgo == 0){ - var fourMonthsAgo = 12; - var lastYear = year-1; + var fourMonthsAgo = 12; + var lastYear = year-1; } else { - var fourMonthsAgo = threeMonthsAgo - 1; - var lastYear = year; + var fourMonthsAgo = threeMonthsAgo - 1; + var lastYear = year; } - + if (fourMonthsAgo == 0 || fourMonthsAgo == 2 || fourMonthsAgo == 4 || fourMonthsAgo == 6 || fourMonthsAgo == 7 || fourMonthsAgo == 9 || fourMonthsAgo == 11){ - var lastDay = 31; + var lastDay = 31; } else if (fourMonthsAgo == 1){ - var lastDay = 28; + var lastDay = 28; } else { - var lastDay = 30; + var lastDay = 30; } - + var url = "http://finance.yahoo.com/q/hp?s=" + symbol + "&a=" + fourMonthsAgo + "&b=" + lastDay + "&c=" + lastYear + "&d=" + fourMonthsAgo + "&e=" + lastDay + "&f=" + lastYear + "&g=d"; var fourMonthsAgoQuery = y.query( - "select * from html " + - "where url=@url and " + - "xpath='" + - "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 5]'", - {url:url}); + "select * from html " + + "where url=@url and " + + "xpath='" + + "//table/tr/td[@class = \"yfnc_tabledata1\" and position() = 5]'", + {url:url}); var stock = ; - + var results = equityQuery.results; stock.ReturnOnEquity = results.td.p.text().toString().trim(); - + var results = stockholdersQuery.results; stock.Stockholders = results.strong.text().toString().trim(); - + var results = totalAssetsQuery.results; stock.TotalAssets = results.strong.text().toString().trim(); - + var results = trailingPEQuery.results; stock.TrailingPE = results.td.p.toString().trim(); - + var results = analystsQuery.results; stock.Analysts = results.td.p.toString().trim(); - + var results = earningsGrowthQuery.results; stock.EarningsGrowth = results.td.p.toString().trim(); - + var results = ebitQuery.results; stock.EbitMarge = results.td.p.toString().trim(); var results = lastyearQuery.results; stock.LastYear = results.td.p.toString().trim(); - + var results = sixMonthsQuery.results; stock.SixMonths = results.td.p.toString().trim(); - + var results = todayQuery.results; stock.Today = results.span.toString().trim(); - + var results = lastMonthQuery.results; stock.LastMonth = results.td.p.toString().trim(); - + var results = twoMonthsAgoQuery.results; stock.TwoMonthsAgo = results.td.p.toString().trim(); - + var results = threeMonthsAgoQuery.results; stock.ThreeMonthsAgo = results.td.p.toString().trim(); - + var results = fourMonthsAgoQuery.results; stock.FourMonthsAgo = results.td.p.toString().trim(); - + getQuoteInfo(); - + response.object = stock ]]> - - + +
diff --git a/yahoo/finance/yahoo.finance.quant2.xml b/yahoo/finance/yahoo.finance.quant2.xml index 3126693c..a0bf4500 100644 --- a/yahoo/finance/yahoo.finance.quant2.xml +++ b/yahoo/finance/yahoo.finance.quant2.xml @@ -1,169 +1,169 @@ - - - select * from {table} where symbol in ("YHOO") - - - - + + + + + ; - + var results = lastMonthQuery.results; stock.LastMonth = results.td.p.toString().trim(); - + var results = twoMonthsAgoQuery.results; stock.TwoMonthsAgo = results.td.p.toString().trim(); - + var results = threeMonthsAgoQuery.results; stock.ThreeMonthsAgo = results.td.p.toString().trim(); - + var results = fourMonthsAgoQuery.results; stock.FourMonthsAgo = results.td.p.toString().trim(); - + response.object = stock ]]> - - + +
diff --git a/yahoo/finance/yahoo.finance.quotes.xml b/yahoo/finance/yahoo.finance.quotes.xml index d097f530..f1cabec2 100644 --- a/yahoo/finance/yahoo.finance.quotes.xml +++ b/yahoo/finance/yahoo.finance.quotes.xml @@ -1,37 +1,37 @@ - - - select * from {table} where symbol in ("YHOO","AAPL","GOOG","MSFT") - - - - + http://download.finance.yahoo.com/d/quotes.csv?s={-listjoin|,|symbol} + + + + + ; + var rows=results.results.row; + for each (var row in rows) { + for each (var item in row.*) { + var elname = item.localName(); + var txt = item.text().toString(); + if (txt=="N/A") txt=""; else if (txt=="-") txt=""; else { + txt = txt.replace(/"/g, ''); + } + row[elname]=txt; + } + //split % change out + var txt = row["Change_PercentChange"].text().toString(); + row["PercentChange"]=txt.substring(txt.indexOf(" - ")+2); + quotes.quote += {row.*}; + } + response.object = quotes; ]]> - - + +
diff --git a/yahoo/finance/yahoo.finance.quoteslist.xml b/yahoo/finance/yahoo.finance.quoteslist.xml index 52854f65..c7e496d1 100644 --- a/yahoo/finance/yahoo.finance.quoteslist.xml +++ b/yahoo/finance/yahoo.finance.quoteslist.xml @@ -1,40 +1,40 @@ - - - select * from {table} where symbol='^IBEX' - - - - + http://download.finance.yahoo.com/d/quotes.csv?s={-listjoin|,|symbol} - - - - - - - ; - var rows=results.results.row; - for each (var row in rows) { - for each (var item in row.*) { - var elname = item.localName(); - var txt = item.text().toString(); - if (txt=="N/A") txt=""; else if (txt=="-") txt=""; else { - txt = txt.replace(/"/g, ''); - } - row[elname]=txt; - } - //split % change out - //var txt = row["Change_PercentChange"].text().toString(); - //row["PercentChange"]=txt.substring(txt.indexOf(" - ")+2); - quotes.quote += {row.*}; - } - response.object = quotes; + + + + + + + ; + var rows=results.results.row; + for each (var row in rows) { + for each (var item in row.*) { + var elname = item.localName(); + var txt = item.text().toString(); + if (txt=="N/A") txt=""; else if (txt=="-") txt=""; else { + txt = txt.replace(/"/g, ''); + } + row[elname]=txt; + } + //split % change out + //var txt = row["Change_PercentChange"].text().toString(); + //row["PercentChange"]=txt.substring(txt.indexOf(" - ")+2); + quotes.quote += {row.*}; + } + response.object = quotes; ]]> - - + +
diff --git a/yahoo/finance/yahoo.finance.sectors.xml b/yahoo/finance/yahoo.finance.sectors.xml index 807d6b79..6caa4634 100644 --- a/yahoo/finance/yahoo.finance.sectors.xml +++ b/yahoo/finance/yahoo.finance.sectors.xml @@ -4,7 +4,7 @@ Tom Powers Yahoo Finance Industry Index - Sector + Industries select * from {table} - http://wiki.github.com/tpowers/yql-tables + http://wiki.github.com/tpowers/yql-tables - - - - + Mike Telis + Retrieves currency exchange rate data for given pair(s). Accepts both where pair='eurusd, gbpusd' and where pair in ('eurusd', 'gpbusd, usdaud') + select * from {table} where pair in ("EURUSD","GBPUSD") + + + - - \ No newline at end of file + var tag = row.Symbol.text().toString().substr(0,6); + delete row.Symbol; + rates.rate += {row.*}; + } + response.object = rates; + ]]> + + +