Skip to content

Instantly share code, notes, and snippets.

View sptutusukanta's full-sized avatar
🎯
Focusing

Sukanta Paul sptutusukanta

🎯
Focusing
View GitHub Profile
{
"items": [
{
"a": "com.example.myapplication",
"r": [
{"packageName": "com.example.newapplication", "title": "New Application", "icon": "https://cdn0.iconfinder.com/data/icons/kameleon-free-pack-rounded/110/Online-Shopping-512.png"},
{"packageName": "com.example.simpleapplication", "title": "Simple Application", "icon": "https://gatearchitecture.com/wp-content/uploads/2017/11/online-icon.png"}
]
}
]
@sptutusukanta
sptutusukanta / raw-prices-to-stock-open-close-high-low-prices.sql
Last active May 10, 2020 14:48
STOCK MARKET : MySQL - Convert Raw Purchases to Open, Close, High & Low within a range of time & represented as an interval.
SELECT `stock_id_main` AS `stock_id`, `price_open`, `price_close`, `price_low`, `price_high`, DATE_FORMAT( FROM_UNIXTIME( `created_at_main` * 300), '%Y-%m-%d %H:%i:00' ) AS `created_at`
FROM
(
SELECT `stock_id` AS `stock_id_main`, MIN( `price` ) AS `price_low`, MAX(`price`) AS `price_high`, UNIX_TIMESTAMP(`created_at`) DIV 300 AS `created_at_main`
FROM `raw_stock_prices`
WHERE `stock_id` = 1 AND `created_at` BETWEEN '2020-05-09 00:00:00' AND '2020-05-09 23:59:59'
GROUP BY `stock_id`, UNIX_TIMESTAMP(`created_at`) DIV 300
) AS `t_high_low`
INNER JOIN
(