Coder Social home page Coder Social logo

yahoofinanceapi's People

Contributors

dshe avatar jeffsbailey avatar karlwancl avatar krissiegel avatar ridicoulous avatar sergemat avatar tranb3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yahoofinanceapi's Issues

Exchange rate?

Hi. Really nice to be able to get stock quotes.

Any way to get the exchange rate for some currencies like USD-to-CAD?

'Yahoo' Does not exist in the current context

Hello, I am looking at the sample code and I am seeing a reference to Yahoo. However, when I try to run the samples, I get the error 'Yahoo' Does not exist in the current context. I tried using the classes YahooQuotes and YahooHistory then I get the error that Symbols does not exist in the current context.

Where are you getting the Yahoo class?

Suggestions: Historical Prices

Hi there,
Great Library

Allow for historical prices to pass in multiple stocks
It would be nice to be able to pass in a list of stocks for historical prices. Perhaps your api can then loop through the list and make each call (perhaps in parallel)

Invalid / NotFound
Firstly I realise you kinda addressed it with #7
I think from an api point of view, and to be consistent with await Yahoo.Symbols, an error result should be sent back rather than an exception.

Error code 500 (Cannot find server.): GET https://fc.yahoo.com

Flurl.Http.FlurlHttpException: Call failed with status code 500 (Cannot find server.): GET https://fc.yahoo.com
image

Code

[TestMethod]
public async Task GetDailyData_Should_Work()
{
    // 设置时间范围(过去1年)
    var toDate = DateTime.UtcNow;
    var fromDate = toDate.AddMonths(-1);

    // 创建一个标的(BTC/USD)并请求历史数据
    var symbol = "BTC-USD";
    var candles = await Yahoo.GetHistoricalAsync(symbol, fromDate, toDate, Period.Daily); // Daily, Weekly, Monthly

    // 访问OHLCV数据
    foreach (var candle in candles)
    {
        Console.WriteLine($"Date: {candle.DateTime}, Open: {candle.Open}, High: {candle.High}, Low: {candle.Low}, Close: {candle.Close}, Volume: {candle.Volume}");
    }
    Assert.IsTrue(candles != null && candles.Any());
}

Failed with status code 403 on Android

Hi.
I'm writing a C# .NET MAUI application and tested it with using the package but also with using the source directly. Same result:

Works perfectly when I use it on the "Windows Machine" but gets back "Call failed with status code 403 (Forbidden)
GET https://query1.finance.yahoo.com/v1/test/getcrumb."
on my Android device.

Using simply
var quotes = await Yahoo.Symbols(mySymbol).Fields(
Field.RegularMarketOpen,
Field.RegularMarketDayHigh,
Field.RegularMarketDayLow,
Field.RegularMarketPrice,
Field.RegularMarketVolume,
Field.RegularMarketTime,
Field.Currency,
Field.Exchange
)
.QueryAsync();

Thanks for any hint.

YahooFinanceApi not compatible with CsvHelper V15

Hi
I have just started using this package, but came unstuck today because I had installed CsvHelper 15.0 with exception on

    var history = await Yahoo.GetHistoricalAsync(symbol, new DateTime(2020, 1, 1), new DateTime(2020, 7, 1), Period.Daily);

The exception was:

**Exception: Method not found: 'Void CsvHelper.CsvReader..ctor(System.IO.TextReader)'.
  Line: YahooFinanceApi
  StackTrace:    at YahooFinanceApi.Yahoo.<GetTicksAsync>d__5`1.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at YahooFinanceApi.Yahoo.GetTicksAsync[ITick](String symbol, Nullable`1 startTime, Nullable`1 endTime, Period period, ShowOption showOption, Func`2 instanceFunction, CancellationToken token)
   at YahooFinanceApi.Yahoo.<GetHistoricalAsync>d__2.MoveNext()

I have downgraded the project now to CsvHelper 7.1.1 and the all to GetHistoricalAsync works.

The code changes (comment out code) I made in order to downgrade from CsvHelper 15.0 online documented examples were:

    using (var csv = new CsvReader(reader /*, CultureInfo.InvariantCulture*/))
    AutoMap(/*CultureInfo.InvariantCulture*/);

I hope the above clues assist in quickly updating YahooFinanceApi to support the latest CsvHelper package.
In the meantime, is there a better way forward?

Thanks

After Hours Pricing?

The Yahoo Finance Quote API includes support for after hours pricing via the following fields:
postMarketChangePercent
postMarketTime
postMarketPrice
postMarketChange

I noticed in both Security.cs and Fields.cs, none of these are specified. I also noticed this line (https://github.com/lppkarl/YahooFinanceApi/blob/master/YahooFinanceApi/Security.cs#L16) that states Secure.cs is automatically generated but I'm not sure how that process works considering it dropped off a few items.

DividendDate issue

Hi there,
quick question. DividendDate is wrong even after converting it from unix.
let's make an example. If I call symbol "LAMR", the right ex-dividend date is 18-03-2021 while YahooFinanci API returns the long value 1617148800 equals to 30-03-2021 after FromUnixTimeMilliseconds NodaTime conversion.
Where I am wrong?
Many Thks for your help
Regards
LUCA

How to detect when yahoo data returns $0 price error

Hi there,

This is a question more than a bug, I'm wondering how I would detect when yahoo data is pretty much returning the wrong data, $0 price for multiple stocks.

I.e. I recently noticed that when I requested 100 stocks, the stock price was 0 on yahoo's end, is there something in the API that tells me if the data being requested isn't right? or do I just have to loop through each stock and check if the value is 0?

Exception for corrupted data

Unfortunately some of the data seems to got corrupted by Yahoo. If I download CSV file manually using the browser, corrupted data lines show as "yyyy-MM-dd,null,null,null,null,null,nulll", and they cause the formatting exceptions and failure in YahooFinanceApi. For example, this happened to me with symbols VAW and FSESX. Could it be possible to just place nulls in the affected list entries, to mimic the manual download?

Premarket data

Does his API give premarket data? I was not able to find it.

Does anyone know any other API's which offer premarket data?

Comment

A great project and one of the few projects these days that still actually work after Yahoo closed the formal API.

Thank you

Fig

401 (Unauthorized) error on Azure

I am getting the following error on Azure:
Flurl.Http.FlurlHttpException: Request to https://query1.finance.yahoo.com/v7/finance/download/MCD?period1=1436745600&period2=1499817600&interval=1d&events=history&crumb= failed with status code 401 (Unauthorized). at Flurl.Http.Configuration.FlurlMessageHandler.d__1.MoveNext() in C:\projects\flurl\src\Flurl.Http.Shared\Configuration\FlurlMessageHandler.cs:line 59 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Net.Http.HttpClient.d__58.MoveNext()

It works flawlessly for a day or two with requests made every few hours, then the above exception starts being thrown. It looks like the crumb parameter is empty? What could cause that?

FlurlHttpException with StatusCode: 429, ReasonPhrase: 'Too Many Requests'

Since last night, prices cannot be retrieved from Yahoo Finance.
The failure occurs in Yahoo - Quote.cs in the following method

public async Task<IReadOnlyDictionary<string, Security>> QueryAsync(CancellationToken token = default)

Below, the FlurlHttpException ex is caught.

            try
            {
                data = await url
                    .WithCookie(YahooSession.Cookie.Name, YahooSession.Cookie.Value)
                    .GetAsync(token)
                    .ReceiveJson()
                    .ConfigureAwait(false);
            }
            catch (FlurlHttpException ex)

The message in ex contains:

ResponseMessage = {StatusCode: 429, ReasonPhrase: 'Too Many Requests'

How does one get the history data of a stock

I'm sorry if this is a redundant or stupid question. However, I copied the code given in the README.md file for getting historical data for a stock, yet the program did not display any data - rather, it simply terminated after the function Yahoo.GetHistoricalAsync().
Sorry again if this is a stupid question. I'm only a beginner and still trying to get the hang of coding...

This is the code by the way:

var history = await Yahoo.GetHistoricalAsync("AAPL", new DateTime(2016, 1, 1), 
    new DateTime(2016, 7, 1), Period.Daily);

foreach (var candle in history)
{
    Console.WriteLine($"DateTime: {candle.DateTime}, Open: {candle.Open}, High: {candle.High}, 
    Low: {candle.Low}, Close: {candle.Close}, Volume: {candle.Volume}, 
    AdjustedClose: {candle.AdjustedClose}");
}

System.Net.Http dependency problem?

Could not load file or assembly 'System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

latest is 4.3.3??

Trying use with .NET 4.6.1

Hello,

I am trying use this library with .NET framework 4.6.1 but I am getting the error: "Could not load file or assembly 'System.Runtime.Serialization.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."

Observations:

  • I am trying with console apps and when I try with Console app .NET core, everything works

  • Everytime that I create one new console app(.NET framework 4.6.1) and try, I get the same error, but with different assembly

Thank you very much for the library, and sorry about my english :(

Handling missing historical info

There are some stocks that were lightly traded in previous years, and on some days, they had zero volume, zero trades.

ex: DRIP -- June 2, 2015.
or YINN for many days in 2015.

Yahoo finance historical prices shows these days as entries with all zeros.

It seems that this library just omits these days, and its difficult to determine in code if missing days are a result of yahoo finance having bad data, or if its valid no trading for the day.

What do you think about replicating the zero entries for those dates in this library? I could do this in my own code, but others might have this issue as well, so might make more sense to fix it here.

Call failed with status code 500

Anyone else experiencing this issue ?

This call is failing with 500 cannot find server - Call failed with status code 500 (Cannot find server.): GET https://fc.yahoo.com
var response = await "https://fc.yahoo.com"
.AllowHttpStatus("502")
.AllowHttpStatus("404")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);

Dividend Date

Hello guys,

What exactly the Dividend Date should return?

When I get the Dividend Date for MSFT, it returns this: "1591833600".

Thanks for your great work,

Looking forward to answering from you

Query Performance

Getting historical data takes much longer than getting the historical data through postman. Is there any way of increasing the speed for this?

It is particularly obvious when querying for many symbols.

Sorry, Unable to process request at this time -- error 999

Yahoo seems terminated their free api service

Flurl.Http.FlurlHttpException occurred
HResult=0x80131500
Message=GET https://download.finance.yahoo.com/d/quotes.csv?s=AAPL%2BGOOG&f=l1ohgp failed with status code 999 (Request denied).
Response body:

<title>Yahoo! - 999 Unable to process request at this time -- error 999</title>Sorry, Unable to process request at this time -- error 999. Source= StackTrace: at Flurl.Http.FlurlRequest.d__18.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Flurl.Http.FlurlRequest.d__18.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Flurl.Http.FlurlRequest.d__18.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Flurl.Http.HttpResponseMessageExtensions.d__4.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at YahooFinanceApi.Yahoo.Builder.d__9.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at WindowsFormsApp1.Form1.d__2.MoveNext() in d:\temp\WindowsFormsApp1\WindowsFormsApp1\Form1.cs:line 27

Exception: Failure to create client

Hi there,

I have always successfully used YahooFinanceApi. Today I am getting the following exception using "GetHistoricalAsync": Exception: Failure to create client. Could you kindly tell me what I can do to resolve the exception?

Many Thks for your help
Regards
error

LUCA

Is there a limit to amount of symbols you can request at once?

Great Library, I was wondering if there is a limit to the amount of stocks you can request at once?

The reason I ask is sometimes I request 200 stocks and I get like 197 back, then other times it returns 196

I did another test where I would request 100 symbols, and most of the time I get 99 back and a couple of times it returned 100, all within the space of seconds of testing

I'm just wondering if there is limitation somehow?

UPDATE
I think the issue I'm facing is that yahoo sometimes returns "invalid / non strading" stocks with their results, other times it omits them.

image
https://au.finance.yahoo.com/quote/AIO.AX?p=AIO.AX

So from the above screenshot you can see that the stock returns 0 for ask / bid price. It's usually an indication that the stock might not be trading.

Just thought it would be good information for others who tend to see different results coming back

Update this library and Quandle.NET to use .NET core 2.0?

Each time I am using this library in a project targeting .NET Framework 4.6.2, it causes a crazy number of references to System.* assemblies to be added. My understanding is that this issue has been solved with .NET core 2.0. Could you look into upgrading YahooFinanceApi (and also Quandle.NET which I see you authored) for better support?

Flurl.Http dependencies issues

Hi

After updating my Flurl.Http NuGet packages from 3.4.2 to 4.0.2, I suddenly get a compile error saying "Error CS1503 Argument 2: cannot convert from 'System.Threading.CancellationToken' to 'System.Net.Http.HttpCompletionOption'" in methods like QueryAsync and InitAsync of the YahooSession class.

Any idea on how to fix?

Update dependencies

Request: support the latest versions of the dependencies, particularly Flurl.

Empty dictionary?

I'm using the following:

Yahoo.Symbols("AAPL", "TSLA", "AMC").Fields(Field.Symbol, Field.RegularMarketPrice).QueryAsync()

But randomly each of these will have empty RegularMarketPrice values causing a dictionary exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.