Yahoo finance REST api for historical stock data - yahoo-api

I can't seem to locate documentation for the following REST api (similar to):
http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json
In my particular case I want to fetch historical stock quote data (daily stock quote for last 7 years so for a particular stock).

You can query for historical stocks by using yahoo.finance.historicaldata, which is an undocumented data table maintained by the community:
Try this on YQL console:
select * from yahoo.finance.historicaldata where symbol = "GOOG" and startDate = "2012-06-06" and endDate = "2013-01-01"
Be warned that since this is unofficial and not maintained by Yahoo, this query is somewhat unreliable...

Related

Why doesn't end_time work on FTX REST API

I have been trying to fetch historical prices of Bitcoin on FTX using their REST API. I created a small Python script that does that for me. The scripts works but it seems like the API is bugging.
This is the request that FTX has in its docs to fetch historical prices :
GET /markets/{market_name}/candles?resolution={resolution}&start_time={start_time}&end_time={end_time}
So I tried it with resolution = 60 (in seconds)
market_name = BTC-PERP start_time = 1559881511 (which is a timestamp) and end_time = 1559881711 [ actually these numbers are in an example given by FTX on their API page]
And the result of that request was : {"success":true,"result":[]} which clearly means that something is wrong.
I tried again without end_time and it worked perfectly, and if I put only end_time and no start_time it does the same bug.
Can't really figure it out
Is there data still available via API from that far back (2019)? I believe it works without end_date because it queries in reverse-chronological order, so it is just showing you the most recent candles.
The end_date parameter seems to work with more recent chunks of time:
https://ftx.com/api/markets/BTC-PERP/candles?resolution=60&start_time=1654097434&end_time=1656689434
e.g. June to July this year, above.

How to ask NetSuite saved search to return client records, when a related record does not exist, within a date range

I have client records that may have related-records indicating they attended a conference. I want to tag client records that have not attended a conference in the last 3 years. They may have conference records prior to 3 years past, but will have none onward from that.
I'm asking Netsuite to search from 3 years ago, and return client records where conference records do not exist.
My question is, how can I get NetSuite to work with a system date range, today-3 years and out into the future, in a saved search?
The first criteria is, for example, 'conference record ID is NULL.'
The date criteria something like, 'after today -1095 days.'
I got this to work by adding a 'Formula (Date)' filter as a criteria in the saved search. Then, in the description, 'after 3 years ago (relative), and the field typed-in as {today}. This worked to filter the other criteria within the date range.

Query to retrieve stock quotes variation from a single day

I'm quite new YQL and i've found the query to retrieve a single quote from a stock
select * from yahoo.finance.quote symbol = "YHOO"
and another query to get this same information but on date range
select * from yahoo.finance.historicaldata symbol = "YHOO" and startDate = "2016-09-01" and endDate = "2016-09-22"
What i could not figure out was: how could we retrieve quotes from a full day of trading?
I'm currently using the Yahoo finance app and notice they provide a good graphic about the price variation, so i presume there is a way to achieve it.
I also tried to read yql tables repository but on both table that i am using there is no (at least explicit) clue of how to pass hour range.
You can retrieve the complete quotes of a day by querying the Yahoo Finance API endpoint directly (not via YQL) and receiving a list in JSON format.
The end point is http://chartapi.finance.yahoo.com/instrument/1.0/$symbol/chartdata;type=$type;range=$range/json/, where:
$symbol is the stock ticker symbol, e.g. AAPL for Apple or BAS.DE for BASF traded at Xetra
$type is the type of the query, you can query for quote, sma, close, volume
$range is the desired latest days with 1d, 5d, 10d, 15d
An example query would be
http://chartapi.finance.yahoo.com/instrument/1.0/aapl/chartdata;type=quote;range=1d/json/
which gives you all quotes from AAPL from the last day.
As far as I know, you can only query for the quotes up to the last 15 days. I have not yet found a way to query for some other day further in the past.
Just my self-centric hint: check out my PHP package YahooFinanceQuery on Github, which uses an implementation of the above query and handles the returning JSON to filter the results.
As an update/extension to my previous answer I found a new API endpoint to download daily quotes.
Yahoo changed their API endpoints in early 2017.
The new endpoint is:
https://query1.finance.yahoo.com/v8/finance/chart/{$symbol}?range={$range}&interval={$interval}, where:
$symbol is the stock ticker symbol, e.g. AAPL for Apple
$range is the desired range of the query, allowed parameters are [1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max]
$interval is the desired interval of the quote, e.g. every 5 minutes, allowed parameters are [1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo]
An example would be: https://query1.finance.yahoo.com/v8/finance/chart/AAPL?range=10d&interval=1m where you receive OHLCV quotes for the AAPL stock from the last 10 trading days with a 1 minute interval. All in a nicely JSON format.
Not all $range parameters will return results with the specified $interval, but will return the nearest possible combination. For example, the "max" range will return all quotes with a "1mo" interval.

MongoId perform day / month specific queries on the date

I am using MongoId 3,Rails 3.2 ,Ruby 1.9.3.
I wanted to query only part of a date, such as the day, week or month.
So for example, let's say we need to find all users that signed up on a Wednesday OR
get all users whose birthday is on 25 day Or get all users who born in April month(not specific to particular year here) etc..
In Mysql we have select * from users where extract(dow from created_at) = 3;
But how can we perform this using MongoId.
Here is a pretty handy cookbook on querying data ranges on Mongodb: http://cookbook.mongodb.org/patterns/date_range/ . and you can just create the query almost in the same way on Mongoid, using .where
I think the aggregation framework is a better fit for this. This question discusses the use of date operators in aggregation.
I've not had much experience with Mongoid, but it seems like it should support aggregation just fine, as long as you are using a recent version.

neo4j 2.0 / cypher searching by date

I have looked at previous SO questions about using neo4j with dates and this blog post
http://blog.nigelsmall.com/2012/09/modelling-dates-in-neo4j.html
I'm not exactly sure how to get this to work however. Basically I need two things, to add a date to a node and then to query nodes by date.
As an example of something similar to what I like, imagine I have the movie The Matrix in my graph. Text examples for queries that should include then the movie The Matrix:
Movies released in Q1, 1999
Movies relased on March 31, 1999
Movies released in March 1999
Movies released before 2000
Movies released between 1998 and 20000
What I've tried for now as a start is building the date graph as described in the blog post. I tried with the following query, but I guess it's not constructed correctly
CREATE UNIQUE p = (CAL)-[:YEAR]->(1999 { number:1999 })-[:QUARTER]->(1 { number:1} )-[:MONTH]->(3 { number:3})-[:DAY]->(31 { number:31}) return p;
I guess then after I've made a node for a specific date, I would add a released_on->(that_date) to The Matrix.
So now I'm wondering if this is the way to go for the kind of queries I'd like to do, and how to actually make it work.
If those are the only queries you are planning to do, I would say that a property and an index query might be a better idea.
For each movie, you add a date property as a string in the following format : YYYYMMDD
You can then query for a specific date from a date_index, or have where conditions like : > 19990101 and <19990401 for the first quarter of 1999.
There are of course few shortcomings with this approach, one that comes to my mind being that you can't get movies by "seasonality", say for examples all summer movies for all the years ! In this, the in graph data index is a better idea.
I ended up putting the dates in the graph in a similar way to what is described in the blog post.
To add a date I use the following query:
MERGE (n0:Calendar) CREATE UNIQUE (n0)-[r0:YEAR]->(n1 {number: 2003})-[:QUARTER]->(q { number: 1} )-[r1:MONTH]->(n2 {number: 3})-[r2:DAY]->(n3 {number: 31}) RETURN n3;
Then I use queries similar to this to get nodes and their dates:
MATCH (r)-[:has_date]->(day)<-[:DAY]-(month)<-[:MONTH]-(quarter)<-[:QUARTER]-(year) return day,month,quarter,year;