From 0ba8536aa23ae654952303af1beaa0a4c8936523 Mon Sep 17 00:00:00 2001 From: VaclavT Date: Sat, 20 Feb 2021 01:30:46 +0100 Subject: [PATCH] priprava na zkouskysinple fixes --- debug.lisp | 32 ++++++++++++++++++++++++++++++-- ml.cpp | 1 - 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/debug.lisp b/debug.lisp index fa8b5be..fde17ef 100644 --- a/debug.lisp +++ b/debug.lisp @@ -1,9 +1,37 @@ (print "Debug starts") - - ; (print (make-csv '(("r1c1" "r1c2") ("r2c1" "r2c2")))) +(defun divi-dates (date-str) + (do + (define curl_cmd (+ "curl -H \"Accept: application/json, text/plain, */*\" -H \"Origin: https://www.nasdaq.com/\" -H \"User-Agent: Mozilla/5.0 (Windows NT 10.0)\" https://api.nasdaq.com/api/calendar/dividends/?date=" date-str " 2>/dev/null")) + (define curl_out (system-cmd curl_cmd)) + + (define json_list (parse-json (last curl_out))) + + (define data (first json_list)) + (define calendar (index data 1)) + (define calendar_data (index (index calendar 0) 1)) + (define header (index (index calendar_data 0) 1)) + (define rows (index (index calendar_data 1) 1)) + + (define csv_list '()) + (for e rows + ; (("announcement_Date" "01/07/2021") ("companyName" "Itau Unibanco Banco Holding SA") ("dividend_Ex_Date" "02/01/2021") ("dividend_Rate" 0.003) ("indicated_Annual_Dividend" 0.033) ("payment_Date" "03/11/2021") ("record_Date" "02/02/2021") ("symbol" "ITUB")) + (define symbol (second (first (filter (lambda (x) (= (first x) "symbol")) e)))) + (define divrate (second (first (filter (lambda (x) (= (first x) "dividend_Rate")) e)))) + (define adate (second (first (filter (lambda (x) (= (first x) "announcement_Date")) e)))) + (define name (second (first (filter (lambda (x) (= (first x) "companyName")) e)))) + (define edate (second (first (filter (lambda (x) (= (first x) "dividend_Ex_Date")) e)))) + (define pdate (second (first (filter (lambda (x) (= (first x) "payment_Date")) e)))) + (define rdate (second (first (filter (lambda (x) (= (first x) "record_Date")) e)))) + + (define csv_list (push csv_list (list symbol edate pdate divrate)))) + csv_list + )) + + +(print (make-csv (divi-dates "2021-02-01"))) (print "Debug ends") diff --git a/ml.cpp b/ml.cpp index 7c2b18f..bbb6c33 100644 --- a/ml.cpp +++ b/ml.cpp @@ -1730,7 +1730,6 @@ int main(int argc, const char **argv) { srand(time(NULL)); try { - // Load std library load_std_lib(env); if (argc == 1 || (argc == 2 && std::string(argv[1]) == "-i"))