nasdaq.bat
@echo off
:: ref: https://qiita.com/zono_0/items/dc9e824cc6c4d9c62bce
set LINE[1]= dBBBBb dBBBBBb .dBBBBP dBBBBb dBBBBBb dBBBBP
set LINE[2]= dBP BB BP dB' BB dB'.BP
set LINE[3]= dBP dBP dBP BB `BBBBb dBP dB' dBP BB dB'.BP
set LINE[4]= dBP dBP dBP BB dBP dBP dB' dBP BB dB'.BB
set LINE[5]= dBP dBP dBBBBBBBdBBBBP' dBBBBB' dBBBBBBB dBBBB'B
set BL=10900
set BS=16400
setlocal enabledelayedexpansion
cls
echo.
for /l %%i in (1, 1, 5) do (echo !LINE[%%i]!)
echo.
echo Gathering information, please wait ...
echo.
echo DATE OPEN CLOSE VOLUME STATE
echo ---------- ----- ----- ---------- --------------------
for /f "usebackq tokens=*" %%a in (`powershell -NoProfile -ExecutionPolicy Unrestricted -Command "& { $UNIXTIME = ((Get-Date('%DATE% 00:00:00')) - (Get-Date('1970/01/01 00:00:00 GMT'))).TotalSeconds; return $UNIXTIME; }"`) do (
set TO=%%a
)
set /a FROM=%TO% - (60 * 60 * 24 * 365)
set Y=%DATE:~0,4%
call :is_leap_year %Y% || set /a FROM -= 60 * 60 * 24
for /f "skip=1 tokens=1-12 delims=,." %%a in ('curl -s "https://query1.finance.yahoo.com/v7/finance/download/%%5ENDX?period1=%FROM%&period2=%TO%"') do (
if %%b leq %BL% (echo %%a %%b %%h %%l △ Hit the big long)
if %%b geq %BS% (echo %%a %%b %%h %%l ▼ Hit the big short)
)
echo.
echo Press any key to continue ...
pause > NUL
endlocal
goto :EOF
:is_leap_year
setlocal
set n=0
set /a n=%1%%400
if %n% equ 0 exit /b 1
set /a n=%1%%100
if %n% equ 0 exit /b 0
set /a n=%1%%4
if %n% equ 0 exit /b 1
exit /b 0
endlocal
goto :EOF