Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMA200 SMA50 SMA10 #62

Open
vomikan opened this issue Nov 9, 2019 · 1 comment
Open

SMA200 SMA50 SMA10 #62

vomikan opened this issue Nov 9, 2019 · 1 comment

Comments

@vomikan
Copy link
Member

vomikan commented Nov 9, 2019

I've creared SQL query for calculate (Simple Moving Average) SMA200 50 10 for AAPL

WITH d as (
WITH RECURSIVE
  cnt(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM cnt WHERE x<365)
SELECT 
'AAPL' s
, x 
, date('now', '-'||x||' days') d
FROM cnt)
select d.x
, d.d date
, case when d.d= date(d.d, 'start of month') then d.d else '' end label
, (select value from STOCKHISTORY where DATE = date(d.d)  and SYMBOL = d.s  ) Value_
, (select value from STOCKHISTORY where DATE >= date(d.d, '-3 days') and DATE <= date(d.d)  and SYMBOL = d.s and value is not null order by 1 desc limit 1 ) Value
, (select avg(value)  from STOCKHISTORY where DATE <= d.d and DATE > date(d.d, '-50 days') and SYMBOL = d.s) avg50
, (select avg(value)  from STOCKHISTORY where DATE <= d.d and DATE > date(d.d, '-200 days') and SYMBOL = d.s) avg200
 from d 
where x < 100

I need graph for this data like this one:

image

https://marketrealist.com/2019/10/amzn-aapl-msft-tech-stocks-averages-pre-earnings/

@vomikan
Copy link
Member Author

vomikan commented Nov 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant