-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownloadStock.cs
62 lines (51 loc) · 2 KB
/
DownloadStock.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* A Dynamo zero-touch library to pull stock values from the Yahoo Finance web service.
* This code is loosely based on this yahoo finance managed code sample:
* https://code.google.com/p/yahoo-finance-managed/wiki/sampleYahooManagedAPIHistQuotesDownload
*
* Copyright (c) 2015 Matt Jezyk
* Licened under the MIT License, see project README.md file
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MaasOne;
namespace PlotStock
{
public class DownloadStock
{
public static List<List<double>> DownloadData(List<string> stockNameList, System.DateTime fromDate,
System.DateTime toDate)
{
//Parameters
IEnumerable<string> ids = stockNameList;
//new string[] {"ADSK", "APPL",};
string result = "";
List<List<double>> stockList = new List<List<double>>();
MaasOne.Finance.YahooFinance.HistQuotesInterval interval =
MaasOne.Finance.YahooFinance.HistQuotesInterval.Monthly;
//Download
MaasOne.Finance.YahooFinance.HistQuotesDownload dl = new MaasOne.Finance.YahooFinance.HistQuotesDownload();
MaasOne.Base.Response<MaasOne.Finance.YahooFinance.HistQuotesResult> resp = dl.Download(ids, fromDate,
toDate, interval);
//Response/Result
if (resp.Connection.State == MaasOne.Base.ConnectionState.Success)
{
foreach (MaasOne.Finance.HistQuotesDataChain qd in resp.Result.Chains)// just one stock for now
{
List<double> stockHighList = new List<double>();
string id = qd.ID;
//result = qd.ID;
foreach (MaasOne.Finance.HistQuotesData qx in qd)
{
stockHighList.Add(qx.High);
}
stockList.Add(stockHighList);
}
}
return stockList;
}
}
}