mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-19 11:08:05 +00:00
COVAR
semver fix VAR test fix new: COVAR, ZSCORE, CORR, LINREG versioning refactoring
This commit is contained in:
@@ -17,12 +17,11 @@ public class Alphavantage_Feed : TBars
|
||||
public Alphavantage_Feed(string Symbol = "IBM", string APIkey = "demo")
|
||||
{
|
||||
System.Net.Http.HttpClient client = new();
|
||||
JsonElement json = new();
|
||||
|
||||
string req = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED" + "&symbol=" + Symbol + "&apikey=" + APIkey;
|
||||
var msg = client.GetStringAsync(req).Result;
|
||||
var jres = JsonSerializer.Deserialize<JsonDocument>(msg).RootElement;
|
||||
jres.TryGetProperty("Time Series (Daily)", out json);
|
||||
jres.TryGetProperty("Time Series (Daily)", out JsonElement json);
|
||||
|
||||
if (json.ValueKind == JsonValueKind.Undefined) {throw new InvalidOperationException("Stock symbol "+Symbol+" not found"); }
|
||||
foreach (var val in json.EnumerateObject()) { base.Add(GetOHLC(val)); }
|
||||
|
||||
@@ -9,12 +9,13 @@ Yahoo Finance - Free API feed to collect daily market quotes
|
||||
Period: number of days of collected history (default: 252)
|
||||
Usage:
|
||||
Yahoo_Feed ticker = new("MSFT", 20)
|
||||
|
||||
|
||||
</summary> */
|
||||
|
||||
public class Yahoo_Feed : TBars
|
||||
{
|
||||
public Yahoo_Feed(string Symbol = "IBM", int Period = 252) {
|
||||
Period = (int)(Period*1.45);
|
||||
string requestUrl = "https://query1.finance.yahoo.com/v8/finance/chart/"+
|
||||
Symbol+"?interval=1d&period1="+
|
||||
(int)new DateTimeOffset(DateTime.UtcNow.AddDays(-Period+1)).ToUnixTimeSeconds()+"&period2="+
|
||||
@@ -22,7 +23,7 @@ public class Yahoo_Feed : TBars
|
||||
System.Net.Http.HttpClient client = new();
|
||||
var msg = client.GetStringAsync(requestUrl).Result;
|
||||
var jresult = JsonSerializer.Deserialize<JsonDocument>(msg).RootElement;
|
||||
|
||||
|
||||
jresult.TryGetProperty("chart",out JsonElement json);
|
||||
json.TryGetProperty("result",out json);
|
||||
json[0].TryGetProperty("timestamp",out JsonElement datetime);
|
||||
@@ -33,7 +34,7 @@ public class Yahoo_Feed : TBars
|
||||
json[0].TryGetProperty("low",out JsonElement low);
|
||||
json[0].TryGetProperty("close",out JsonElement close);
|
||||
json[0].TryGetProperty("volume",out JsonElement volume);
|
||||
|
||||
|
||||
for (int i=0; i<datetime.GetArrayLength(); i++) {
|
||||
DateTime d = DateTimeOffset.FromUnixTimeSeconds(long.Parse(datetime[i].GetRawText())).DateTime;
|
||||
double o = Math.Round(double.Parse(open[i].GetRawText()),3);
|
||||
|
||||
Reference in New Issue
Block a user