pradeeps01 / yahoo-finance-managed

Automatically exported from code.google.com/p/yahoo-finance-managed
0 stars 0 forks source link

Strange Behaviour on QuoteDownload #24

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi Maas,
I've found that the Quotes Download has a strange behaviour on a single ticker 
download on a non us exchange(BUL.MI -->Bulgari) and I've found that the old 
call is working (QuotesDownload.vb):

New funct:
        Private Function DownloadURL(ByVal unmanagedIDs As IEnumerable(Of String), ByVal properties() As QuoteProperty) As String
            Dim lst() As String = mHelper.EnumToArray(unmanagedIDs)
            If lst.Length > 0 Then
                Dim ids As New Text.StringBuilder
                For Each s As String In lst
                    ids.Append(mHelper.CleanYqlParam(s))
                    ids.Append("+"c)
                Next
                Return "http://download.finance.yahoo.com/d/quotes.csv?s=" & Uri.EscapeDataString(ids.ToString) & "&f=" & mFinanceHelper.CsvQuotePropertyTags(properties) & "&e=.csv"
            Else
                Throw New NotSupportedException("An empty id list will not be supported.")
            End If
        End Function

the old:
        Private Function DownloadURL(ByVal unmanagedIDs As IEnumerable(Of String), ByVal properties() As QuoteProperty, ByVal server As Server) As String
            Dim lst() As String = mHelper.EnumToArray(unmanagedIDs)
            If lst.Length > 0 Then

                If server = server.YQL Then
                    Dim fields As String = String.Empty
                    If properties Is Nothing OrElse properties.Length = 0 Then
                        fields = "*"
                    Else
                        Dim sb As New Text.StringBuilder
                        For Each p As QuoteProperty In properties
                            sb.Append(p.ToString)
                            sb.Append(",")
                        Next
                        sb.Remove(sb.Length - 1, 1)
                        fields = sb.ToString
                    End If

                    Dim whereClause As New Text.StringBuilder()
                    whereClause.Append("symbol in (")
                    For Each id As String In lst
                        whereClause.Append(""""c)
                        whereClause.Append(mHelper.CleanYqlParam(id))
                        whereClause.Append(""",")
                    Next
                    whereClause.Remove(whereClause.Length - 1, 1)
                    whereClause.Append(")"c)

                    Return mHelper.YqlUrl(fields, "yahoo.finance.quotes", whereClause.ToString, Nothing, False)

                Else
....

and if the server is the standard, the request goes to:
http://query.yahooapis.com/v1/public/yql

and not to:
http://download.finance.yahoo.com/d/quotes.csv

Regards /// Angel

Original issue reported on code.google.com by i...@advancedcomputing.ch on 4 Aug 2011 at 12:40

GoogleCodeExporter commented 8 years ago
Hi,
What do you mean with "strange behaviour"? I've tested it and it seems 
allright. 
What is the "standard server"? In old code you have USA and YQL server.
Can you give me some example code?

greetz

Maas

p/s: I removed the server parameter, because it makes no sense. Every non-USA 
server was redirected to "download.finance.yahoo.com". Also the YQL server is 
just requesting the USA-CSV server. You can see it here: 

http://www.datatables.org/yahoo/finance/yahoo.finance.quotes.xml

It's the source of the open YQL datatable for quotes download 
(yahoo.finance.quotes). 
The Community Tables in YQL are just containers for existing Yahoo! APIs. They 
don't really have an additional value, except the SQL like syntax and XML/JSON 
format. Also the YQL table doesn't support Currency and SharesOutstanding 
properties.

Original comment by Maas...@gmail.com on 4 Aug 2011 at 1:50

GoogleCodeExporter commented 8 years ago
Hi Maas, I'll attach my function, try it with ticker BUL.MI or FIA.MI, you 
won't get any value with the new version but with the old, you'll get values 
(I've compiled your source renaming (the old version from 0.8.4) the 
QuoteDownload class in QuoteDownloadExt.

Regards /// Angel

Original comment by i...@advancedcomputing.ch on 4 Aug 2011 at 2:51

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Angel,
The problem is LastTradeSize. It's also not defined in YQL. The result in CSV 
is something like ...,"8/4/2011",122,382,"11:30am",... -> TradeSize between 
TradeDate and TradeTime.
It sometimes returns a different value, but it's always in this format. So 
there is the problem of comma separation, because it's not enclosed in [""] and 
it's an Integer in US-format with [,] as thousand separator. The parser gets 
one value more than the requested properties and then it's not possible to 
decide, which value has which property.
Like I said, it's not available in YQL, and also it's an error source (and it 
returns different values for same request), I decided to remove the property in 
next version. It's a too buggy property not only in format, also in the value 
itself.

greetz

Maas

Original comment by Maas...@gmail.com on 4 Aug 2011 at 7:33

GoogleCodeExporter commented 8 years ago
Hi Maas, 
thanks, it also seems to have problem (intermittent) with AskSize and BidSize.

Regards, 
Angel

Original comment by i...@advancedcomputing.ch on 5 Aug 2011 at 7:14

GoogleCodeExporter commented 8 years ago
I observed that the different value results are not only limited to 
LastTradeSize. Also other values like Change have this problem (with some IDs). 
So I will look to solve the bigger-than-thousand-Integer-problem. I think it's 
not really acceptable to remove the properties just because of wrong 
formatting. 
Against wrong values from Yahoo! I can't do anything.

Maas

Original comment by Maas...@gmail.com on 8 Aug 2011 at 12:29

GoogleCodeExporter commented 8 years ago
I'ven't fixed the problem 100%. You shouldn't use/request two of these critical 
integer properties directly near by themself. So, having a double or date 
property between these properties, there should be everything fine.

greetz

Maas

Original comment by Maas...@gmail.com on 20 Aug 2011 at 11:58