Home » How To Get Historical Stock Market Data in C# | sensex historical data | वेबसाइट जो गाने के तार प्रदान करती है #1

How To Get Historical Stock Market Data in C# | sensex historical data | वेबसाइट जो गाने के तार प्रदान करती है #1

by Brahma Aditya

How To Get Historical Stock Market Data in C# | नए गाने यहां अपडेट किए गए हैं

नीचे वीडियो देखें

In this video I describe how to get historical stock market data with the C# programming language. I utilize the YahooFinanceAPI nuget package to asynchronously fetch the historical stock data. I also show how to handle the return of said asynchronous task and how to continuously get new symbols and timespans for the data from the user. Thank you for watching this video!!!

Link to github repo for this video:

Link to my Discord Channel for C# questions, comments, suggestions and discussions:

विषय से संबंधित चित्र How To Get Historical Stock Market Data in C#

How To Get Historical Stock Market Data in C#

How To Get Historical Stock Market Data in C#


>>https://hin.egyptchord.com/ उम्मीद है कि यह जानकारी आपके लिए बहुत महत्वपूर्ण है

आपका बहुत बहुत धन्यवाद

विषय से संबंधित खोजें sensex historical data.

#Historical #Stock #Market #Data

C#,Stocks,Stock Data,Historical Stock Data,YahooFinance

How To Get Historical Stock Market Data in C#

sensex historical data.

9 comments

You may also like

9 comments

JUju shekhtmee 06/08/2022 - 05:44

Hi. Great Video! I am getting the "failed to get symbol" error. All my code is correct, and i am using correct tickers (AAPL, TSLA). I saw something about the developer having an issue but it was resolved so now im struggling. Please get back as soon as possible. Thank you. (I am using the same versions you did)

using System;

using YahooFinanceApi;

using System.Threading.Tasks;

using System.Linq;

namespace stocks_data

{

class Program

{

static void Main(string[] args)

{

char continueStr = 'y';

while (continueStr == 'y')

{

Console.WriteLine("Enter a stock ticker that u want historic data for: ");

string symbol = Console.ReadLine().ToUpper();

Console.WriteLine("Enter the amnount of months of historic data that you want to retrieve: ");

int timespan = Convert.ToInt32(Console.ReadLine());

DateTime endDate = DateTime.Today;

DateTime startDate = DateTime.Today.AddMonths(-timespan);

StockData stock = new StockData();

var awaiter = stock.getStockData(symbol, startDate, endDate);

if (awaiter.Result == 1)

{

Console.WriteLine();

Console.WriteLine("Do you want to get historical data for another ticker? [y/n]");

continueStr = Convert.ToChar(Console.ReadLine());

}

}

Console.WriteLine();

Console.WriteLine("have a nice day");

}

}

class StockData

{

public async Task<int> getStockData(string symbol, DateTime startDate, DateTime endDate)

{

try

{

var historic_data = await Yahoo.GetHistoricalAsync(symbol, startDate, endDate);

var security = await Yahoo.Symbols(symbol).Fields(Field.LongName).QueryAsync();

var ticker = security[symbol];

var companyName = ticker[Field.LongName];

for (int i = 0; i < historic_data.Count; i++)

{

Console.WriteLine(companyName + " Closing price on: " + historic_data.ElementAt(i).DateTime.Month + "/" + historic_data.ElementAt(i).DateTime.Day + "/" + historic_data.ElementAt(i).DateTime.Year + ": $" + Math.Round(historic_data.ElementAt(i).Close, 2));

}

}

catch

{

Console.WriteLine("Failed to get symbol: " + symbol);

}

return 1;

}

}

}

Reply
Vesna Cvetkovic 06/08/2022 - 05:44

Hi Vere, Love the program. It was working great until last week, but since then I keep getting "Failed to get symbol…" for any symbol I use. Is it working now when you run it from your desktop? Maybe Yahoo changed something in their API? They've done things like that in the past.

Reply
tht85 06/08/2022 - 05:44

hello, it is very nice, but i receive always "Failed to get symbol: AAPL" or other stock, what could be ? thanks

Reply
Dewald Swart 06/08/2022 - 05:44

Hi
Great video
Any idea how to put it in a loop for all stocks available

Reply
CHANDRA 06/08/2022 - 05:44

Very Nice video, but when i use the same program, i am getting result
Id = 15, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
don't know whats the reason, cau please correct me where i went wrong

public class GetShareData

{

public void GetData()

{

stockData data = new stockData();

var waiter = data.getStockData("TATAPOWER", DateTime.Now.AddDays(-5), DateTime.Now);

}

}

public class stockData

{

public async Task<int> getStockData(string symbol,DateTime startDate, DateTime endDate)

{

try

{

var historic_data = await Yahoo.GetHistoricalAsync(symbol, startDate, endDate);

var security = await Yahoo.Symbols(symbol).Fields(Field.LongName).QueryAsync();

var ticker = security[symbol];

var companyName = ticker[Field.LongName];

for (int i = 0; i < historic_data.Count; i++)

{

Console.WriteLine(companyName + " Closing price on:" + historic_data.ElementAt(i).DateTime.Month + "/" +

historic_data.ElementAt(i).DateTime.Day + "/" + historic_data.ElementAt(i).DateTime.Year + ": $" +

Math.Round(historic_data.ElementAt(i).Close, 2));

}

}

catch (Exception)

{

throw;

}

return 1;

}

}

}

Reply
awiggans 06/08/2022 - 05:44

Great video – well communicated and excellent tutorial

Reply
Mert Can Tas 06/08/2022 - 05:44

How do I pull Bitcoin data ?

Reply
Erik Zámečník 06/08/2022 - 05:44

Hi, is company's fundamentals also available? Revenue, net income, cash flows, etc…

Reply
Sebastian Veum 06/08/2022 - 05:44

Great and simple. Nicely done

Reply

Leave a Comment