I know I can get historical intraday data (up 15 days) using chart api as follows
http://chartapi.finance.yahoo.com/instrument/1.1/GOOG/chartdata;type=quote;range=5d/xml/
Using YQL, and
env 'store://datatables.org/alltableswithkeys'
I can use .quotes and .historicaldata:
select * from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT")
select * from yahoo.finance.historicaldata where symbol in ("YHOO","AAPL","GOOG","MSFT") and startDate = "2012-09-13" and endDate = "2012-09-13"
What I can't figure out is how to use a YQL statement to obtain historical intraday data (like using chartapi; probably limited to a few days in range).
Is there any documentation about this somewhere?
Alex
Related
I'm trying to display a bar chart that shows the performance of a Google ad between the 1st of March to the 31st of March. Each bar indicates a day in that range.
At the moment my query looks like
SELECT
ad_group_ad.ad.id,
ad_group_ad.ad.name,
metrics.average_cost
FROM
ad_group_ad
WHERE
segments.date
BETWEEN '2021-03-01' AND '2021-03-31' AND ad_group_ad.status = 'ENABLED'
The data I get back are totals within the range. I need the totals of each day within the range. Is there a way to get this information in one request?
I found a segment that segments the data into weekly slices.
SELECT
ad_group_ad.ad.id,
ad_group_ad.ad.name,
metrics.average_cost,
segments.week,
segments.keyword.info.text
FROM
ad_group_ad
WHERE
segments.date
BETWEEN '2021-03-01' AND '2021-03-31' AND ad_group_ad.status = 'ENABLED'
https://developers.google.com/google-ads/api/fields/v6/ad_group_ad#segments.week
segments.day is not documented but I can see on the google ads dashboard you can segment by days if the date range isn't greater than 16 days. I'm going to keep snooping around and see if I can find how that's done.
You just need to add segments.date to your select.
Executing my code (using the Google Adwords Library to build an oauth user etc) works when using a query with Month as a segment
String query = "SELECT EffectiveFinalUrl, Cost, Clicks, Impressions,
Month FROM FINAL_URL_REPORT";
But it aggregates across all time, split into months. I am trying to pull in the data as daily aggregates. The documentation has both Month and Date (splitting data into yyyy-MM-dd) as a segment you can include in the query, but Date does not work.
String query = "SELECT EffectiveFinalUrl, Cost, Clicks, Impressions,
Date FROM FINAL_URL_REPORT";
Results in Error 400: Bad Request.
Am I missing something in the documentation that tells me how to resolve this?
Adwords Final_URL_Report Documentation
Try set a date range by adding something like DURING ... to your query.
I am trying to query the adwords api (v201603) and am using/extending the Java examples provided.
The problem I am encountering is being able to specify a specific date to download the report data for the CLICK_PERFORMANCE_REPORT report. This report is restricted to returning a single days worth of data at a time (for up to the last 90 days).
I can get todays and yesterdays data using the specifiers : ReportDefinitionDateRangeType.TODAY and ReportDefinitionDateRangeType.YESTERDAY, but what I really need to do is be able to specify a specific date within the last 90 days in order to get as much historical data as possible.
I have tried the following:
DateRange dr = new DateRange();
dr.setMin("20160401");
dr.setMax("20160402");
selector.setDateRange(dr);
reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.CUSTOM_DATE);
reportDefinition.setReportType(ReportDefinitionReportType.CLICK_PERFORMANCE_REPORT);
reportDefinition.setDownloadFormat(DownloadFormat.CSV);
Both with and without the custom date specifier - and either gives the following error:
Report was not downloaded due to: HTTP Response Code: 400, Trigger: A single day DateRange is required for reportType: CLICK_PERFORMANCE_REPORT, Type: ReportDefinitionError.INVALID_DATE_RANGE_FOR_REPORT
Any help much appreciated, thanks in advance
You're going to have to use DURING and the same date string.
... + 'DURING 20161004,20161004';
Single Day Iterator for AdWords Scripts CLICK_PERFORMANCE_REPORT:
var start = new Date("12/01/2016");
var end = new Date("12/18/2016");
while(start < end){
var newDate = start.setDate(start.getDate() + 1);
start = new Date(newDate);
singleDay = start.toISOString().substring(0, 10).replace(/-/g,"");
console.log(singleDay);
}
Utilities.formatDate(start, timeZone, "yyyyMMdd"); formats date object as an 8-digit integer, so:
singleDay = Utilities.formatDate(start, timeZone, "yyyyMMdd");
Use singleDay in 'DURING ' + singleDay + ',' + singleDay);
Working with Dates and Times #Reporting — AdWords Scripts
Is there a way to return a series of records in OData by specifying a "Date greater than xxxxx" filter...but using a Date that was previously obtained form an OData feed?
Use Case: Pretend that I want to build a web page that displays a list of the most recently completed online orders. This is what I'm aiming for:
Load the page
Hit my OData service asynchronously, returning the last 100 orders (ordering by date descending so that the most recently completed order shows up first)
Build the HTML on the page using the OData data
Store the MAX date into a global variable (looks like this: /Date(1338336000000)/)
Hit the OData service on a 30 second interval but this time specify a filter to only return records where the order date is greater than the previous MAX Date. In this case: /Date(1338336000000)/
If any records are returned, build the HTML for those records and prepend the items to the previously loaded items.
Where I am struggling is in specifying the Date "greater than" filter. For some reason, the date filters in OData do not seem to play very nice with OData's own native date format. Do I need to convert the date originally obtained into a different format that can be used for filtering?
I want to do something like this:
http://mydomain/Services/v001.svc/Orders?$filter=close_dt%20gt%201338336000000
FYI: I'm using V2
Figured this out.
OData V2 out-of-the-box returns dates out of SQL in JSON Date format like so:
/Date(1338282808000)/
However, in order to use a date as a filter within an OData call, your date has to be in EDM format, looking like this:
2012-05-29T09:13:28
So, I needed to get the date from my initial OData call, then convert it to the EDM format for use in my subsequent OData calls, which look like this:
/Services/v001.svc/Orders?$filter=close_dt gt DateTime'2012-05-29T09:13:28'
I ended up creating a javascript function that does the formatting switcharoo:
function convertJSONDate(jsonDate, returnFormat) {
var myDate = new Date(jsonDate.match(/\d+/)[0] * 1);
myDate.add(4).hours(); //using {date.format.js} to add time to compensate for timezone offset
return myDate.format(returnFormat); //using {date.format.js} plugin to format :: EDM FORMAT='yyyy-MM-ddTHH:mm:ss'
}
A couple of notes:
The JSON format does not seem to adjust for timezone, so the date returned does not match the date I see in my database. So I had to add time manually to compensate (someone please explain this).
I am using the date.format.js plugin which you can download here for formatting the date and adding time.
In OData V4 date filtering format has changed to $filter=close_dt gt 2006-12-30T23:59:59.99Z
For example
http://services.odata.org/V4/OData/OData.svc/Products?$filter=ReleaseDate%20gt%202006-12-30T23:59:59.99Z
For previous versions of OData see previous answers
If you use the datetime logic, you can do lt or gt.
e.g.
...mydomain/Services/v001.svc/Orders?$filter=close_dt gt datetime'20141231'
Just an FYI: in V3 of the protocol the non-tick-based datetime format is now the default:
http://services.odata.org/Experimental/OData/OData.svc/Products%280%29?$format=application/json;odata=verbose&$select=ReleaseDate
..."ReleaseDate":"1992-01-01T00:00:00"...
I will just try to make the answer of #avitenberg more clear:
var date= DateTime.Now;
//Convert time to UTC format
$"filter={close_dt} gt {date:yyyy-MM-ddTHH:mm:ss.FFFZ}";
See Microsoft:
I'm trying to write a small javascript code to query data filtered by date.
If I write the following sentence in my browser, I can get data :
"http://www.google.com/fusiontables/gvizdata?tq=SELECT Date, Poids FROM 3049883"
but if I write the same thing, except I want only data after a certain date :
"http://www.google.com/fusiontables/gvizdata?tq=SELECT Date, Poids FROM 3049883 WHERE Date > 2/29/12"
From the SQL-like API, https://developers.google.com/fusiontables/docs/developers_reference#Select, it should work
I get an error witch is "'internal_error', message:'Could not parse query'"
-Date is a DATETIME format in my fusion table.
-I've tried different format, but I can not get data.
What am I doing wrong?
Thank you very much for your help.
The Date value must be quoted and the format is MM/dd/yy so you must pad single digits with leading zeros.
I had success with:
select Date,Poids from 3049883 where Date >= '02/29/12'
Note: I did not test with gvizdata, just with the FT JSONP API