tests dir added
This commit is contained in:
parent
4b93f39375
commit
c909415847
66
debug.lisp
66
debug.lisp
|
|
@ -1,80 +1,16 @@
|
|||
(print "Debug starts")
|
||||
|
||||
; define a function `fact` that takes an argument `n`
|
||||
; (defun fact (n)
|
||||
; (if (<= n 1)
|
||||
; 1
|
||||
; (* n (fact (- n 1)))
|
||||
; ))
|
||||
|
||||
; (print (fact 5))
|
||||
|
||||
|
||||
; (define json_list (parse-json "{\"k1\":\"v1\", \"k2\":42, \"k3\":[\"a\",123,true,false,null]}"))
|
||||
; (print json_list)
|
||||
; (for x json_list
|
||||
; (print x))
|
||||
|
||||
; nefunguje - api.nasdaq.com
|
||||
;(define nasdaq_headers (quote (("Accept" "application/json, text/plain, */*") ("Connection" "keep-alive") ("Origin" "https://www.nasdaq.com/") ("User-Agent" "Mozilla/5.0 (Windows NT 10.0)"))))
|
||||
;(define json_list2 (parse-json (read-url "https://api.nasdaq.com/api/calendar/dividends/?date=2021-02-01" nasdaq_headers)))
|
||||
; (for x json_list2
|
||||
; (print x))
|
||||
|
||||
;; (include "tmp/example.lisp")
|
||||
;; (print "sorted: " (qs '(10 9 8 7 6 5 4 3 2 1)))
|
||||
|
||||
|
||||
; (define csv (read-file "tmp/data.csv"))
|
||||
; (define csv_list (parse-csv csv))
|
||||
; (for x csv_list
|
||||
; (print x))
|
||||
|
||||
;; (define web_page (read-url "https://query1.finance.yahoo.com/v7/finance/download/FDX?period1=1581272585&period2=1612894985&interval=1d&events=history&includeAdjustedClose=true"))
|
||||
;; (print web_page)
|
||||
;; (define fdx_list (parse-csv (index web_page 1)))
|
||||
;; (print fdx_list)
|
||||
|
||||
|
||||
;; (define curl "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=2021-02-01 2>/dev/null")
|
||||
;; (define curl_out (system-cmd curl))
|
||||
;; (define json_list (parse-json (last curl_out)))
|
||||
;; ;(print json_list)
|
||||
;; (define data (first json_list))
|
||||
;; ;(print data)
|
||||
;; ;(print (index data 1)) ; druhy prvek
|
||||
;; (define calendar (index data 1))
|
||||
;; ;(print calendar)
|
||||
;; (define calendar_data (index (index calendar 0) 1))
|
||||
;; ;(print calendar_data)
|
||||
;; (define header (index (index calendar_data 0) 1))
|
||||
;; ;(print header)
|
||||
;; (define rows (index (index calendar_data 1) 1))
|
||||
;; ;(print rows)
|
||||
;; (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))))
|
||||
(print (make-csv '(("r1c1" "r1c2") ("r2c1" "r2c2"))))
|
||||
|
||||
;; ;(print symbol edate pdate divrate)
|
||||
;; '(symbol edate pdate divrate)
|
||||
;; )
|
||||
|
||||
|
||||
;(print (ls-dir "/tmp"))
|
||||
;(write-file "/tmp/file" "write-file test\n")
|
||||
;(print (is-file? "/tmp/file"))
|
||||
;(print (is-file? "/tmp/hovinko"))
|
||||
;(print (is-dir? "/tmp/powerlog"))
|
||||
|
||||
(print (get-universal-time))
|
||||
(print (date-to-str (get-universal-time) "%d.%m.%Y"))
|
||||
(print (str-to-date "01.01.1970" "%d.%m.%Y"))
|
||||
(print (date-add (str-to-date "01.01.1970" "%d.%m.%Y") 1 "day"))
|
||||
|
||||
(print "Debug ends")
|
||||
|
|
|
|||
|
|
@ -40,3 +40,24 @@
|
|||
|
||||
|
||||
|
||||
; from list of lists creates csv string
|
||||
; (print (make-csv '(("r1c1" "r1c2") ("r2c1" "r2c2"))))
|
||||
(defun make-csv (csv_list)
|
||||
(do
|
||||
(define rows_str "")
|
||||
(define r 0)
|
||||
(for row csv_list
|
||||
(define cols_str "")
|
||||
(define c 0)
|
||||
(for col row
|
||||
(if (= c 0)
|
||||
(define cols_str col)
|
||||
(define cols_str (+ cols_str "," (display col))))
|
||||
(define c (inc c)))
|
||||
(if (= r 0)
|
||||
(define rows_str cols_str)
|
||||
(define rows_str (+ rows_str "\n" cols_str)))
|
||||
(define r (inc r)))
|
||||
|
||||
rows_str
|
||||
))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,254 @@
|
|||
Date,Open,High,Low,Close,Adj Close,Volume
|
||||
2020-02-10,158.800003,160.289993,156.199997,156.779999,154.462021,3948600
|
||||
2020-02-11,158.270004,159.559998,156.869995,158.000000,155.663986,2016800
|
||||
2020-02-12,159.199997,159.809998,157.229996,158.509995,156.166443,1607500
|
||||
2020-02-13,157.789993,161.830002,156.479996,161.470001,159.082703,2624400
|
||||
2020-02-14,160.460007,161.289993,158.000000,158.619995,156.274826,1679000
|
||||
2020-02-18,159.309998,160.910004,156.389999,158.570007,156.225571,1924000
|
||||
2020-02-19,159.000000,161.690002,158.830002,161.139999,158.757568,1699300
|
||||
2020-02-20,161.070007,165.250000,159.500000,164.910004,162.471817,2602500
|
||||
2020-02-21,163.259995,164.139999,161.690002,163.250000,160.836365,1645300
|
||||
2020-02-24,156.259995,157.720001,152.619995,154.850006,152.560577,3116300
|
||||
2020-02-25,155.660004,155.800003,144.809998,145.600006,143.447342,4223800
|
||||
2020-02-26,147.419998,149.389999,143.559998,144.529999,142.393143,2766300
|
||||
2020-02-27,140.759995,145.490005,136.479996,138.759995,136.708435,3535000
|
||||
2020-02-28,135.000000,141.199997,134.059998,141.169998,139.082825,4395600
|
||||
2020-03-02,142.179993,142.520004,135.279999,139.750000,137.683823,4418600
|
||||
2020-03-03,140.000000,142.169998,132.559998,133.089996,131.122284,4373300
|
||||
2020-03-04,135.059998,136.460007,132.179993,136.410004,134.393204,2854700
|
||||
2020-03-05,132.009995,133.139999,128.750000,129.929993,128.009003,3150000
|
||||
2020-03-06,125.750000,130.649994,123.790001,127.680000,126.424728,3886300
|
||||
2020-03-09,120.400002,121.580002,113.849998,115.699997,114.562508,4048100
|
||||
2020-03-10,120.139999,121.750000,113.870003,120.669998,119.483650,3564900
|
||||
2020-03-11,117.389999,118.300003,108.529999,111.010002,109.918625,4746400
|
||||
2020-03-12,103.199997,105.180000,96.199997,97.000000,96.046356,5156500
|
||||
2020-03-13,102.459999,106.680000,96.000000,106.629997,105.581680,4275000
|
||||
2020-03-16,92.000000,99.870003,90.489998,90.489998,89.600357,4417400
|
||||
2020-03-17,92.900002,100.150002,88.690002,94.959999,94.026405,5548700
|
||||
2020-03-18,90.389999,100.699997,89.800003,99.680000,98.700012,6997700
|
||||
2020-03-19,98.849998,116.160004,97.370003,111.680000,110.582031,4646900
|
||||
2020-03-20,113.879997,118.699997,106.589996,111.059998,109.968124,4479200
|
||||
2020-03-23,110.940002,115.050003,107.250000,111.760002,110.661247,3933900
|
||||
2020-03-24,118.000000,121.800003,115.430000,120.040001,118.859840,3014400
|
||||
2020-03-25,121.360001,126.940002,114.930000,118.309998,117.146843,4133200
|
||||
2020-03-26,119.360001,127.000000,119.010002,125.599998,124.365181,2713900
|
||||
2020-03-27,120.050003,124.349998,116.000000,120.580002,119.394531,2619400
|
||||
2020-03-30,122.379997,125.610001,119.250000,124.309998,123.087868,2281000
|
||||
2020-03-31,122.500000,124.849998,119.260002,121.260002,120.067856,2643800
|
||||
2020-04-01,116.010002,118.750000,112.300003,113.480003,112.364342,2569600
|
||||
2020-04-02,112.529999,117.300003,111.589996,116.639999,115.493271,2336100
|
||||
2020-04-03,115.239998,116.000000,107.690002,109.220001,108.146217,3205200
|
||||
2020-04-06,113.040001,119.809998,113.010002,119.019997,117.849861,3512600
|
||||
2020-04-07,124.910004,125.480003,115.750000,115.949997,114.810051,3189300
|
||||
2020-04-08,123.000000,127.230003,119.919998,125.540001,124.305771,5576500
|
||||
2020-04-09,129.610001,130.000000,120.160004,122.290001,121.087715,4750500
|
||||
2020-04-13,125.190002,125.190002,121.739998,123.529999,122.315529,2821800
|
||||
2020-04-14,125.739998,126.980003,122.050003,125.080002,123.850296,3084200
|
||||
2020-04-15,121.690002,121.690002,118.150002,119.900002,118.721222,2945000
|
||||
2020-04-16,119.730003,121.000000,117.120003,119.080002,117.909279,2238700
|
||||
2020-04-17,121.000000,124.959999,120.730003,124.849998,123.622551,2464000
|
||||
2020-04-20,122.529999,125.669998,121.830002,122.639999,121.434280,2242000
|
||||
2020-04-21,120.629997,122.180000,119.620003,120.480003,119.295517,1605600
|
||||
2020-04-22,122.519997,122.970001,118.449997,118.540001,117.374588,2085800
|
||||
2020-04-23,118.639999,122.419998,118.500000,120.879997,119.691582,2021100
|
||||
2020-04-24,121.410004,123.190002,119.480003,123.059998,121.850151,2111600
|
||||
2020-04-27,124.160004,128.500000,122.320000,127.290001,126.038559,2395900
|
||||
2020-04-28,129.809998,129.889999,125.160004,127.739998,126.484138,2738700
|
||||
2020-04-29,130.000000,131.800003,128.460007,129.479996,128.207031,2172500
|
||||
2020-04-30,127.930000,127.930000,125.750000,126.769997,125.523674,1970400
|
||||
2020-05-01,124.519997,124.559998,117.500000,118.199997,117.037926,3141800
|
||||
2020-05-04,117.120003,117.559998,114.610001,115.849998,114.711029,2410400
|
||||
2020-05-05,117.830002,120.120003,117.129997,117.669998,116.513138,1703100
|
||||
2020-05-06,118.889999,119.419998,115.080002,115.120003,113.988213,1917100
|
||||
2020-05-07,116.940002,118.870003,116.150002,116.739998,115.592285,1842100
|
||||
2020-05-08,118.250000,120.889999,118.180000,120.440002,119.255913,1771700
|
||||
2020-05-11,118.389999,119.370003,116.279999,117.559998,116.404221,1863500
|
||||
2020-05-12,118.000000,118.110001,113.080002,113.139999,112.027672,1979400
|
||||
2020-05-13,113.080002,113.150002,108.250000,109.339996,108.265038,2905900
|
||||
2020-05-14,107.360001,109.180000,103.400002,109.110001,108.037300,3254700
|
||||
2020-05-15,107.540001,108.959999,106.250000,107.519997,106.462921,2940000
|
||||
2020-05-18,113.489998,120.000000,112.790001,119.190002,118.018204,3603900
|
||||
2020-05-19,119.000000,119.400002,114.650002,114.790001,113.661461,2484600
|
||||
2020-05-20,116.800003,119.480003,115.830002,117.010002,115.859627,2604100
|
||||
2020-05-21,116.580002,118.430000,115.529999,115.769997,114.631821,1740300
|
||||
2020-05-22,115.750000,117.559998,114.919998,117.000000,115.849724,2245900
|
||||
2020-05-26,122.989998,126.739998,122.010002,124.809998,123.582947,3823000
|
||||
2020-05-27,128.000000,130.779999,125.500000,130.429993,129.147675,3203000
|
||||
2020-05-28,131.000000,133.910004,129.300003,131.149994,129.860596,3238000
|
||||
2020-05-29,130.190002,130.889999,126.440002,130.559998,129.276413,3410100
|
||||
2020-06-01,129.050003,130.460007,127.459999,129.710007,128.434784,1990300
|
||||
2020-06-02,130.830002,134.589996,130.710007,134.199997,132.880630,2522000
|
||||
2020-06-03,137.000000,139.880005,136.529999,138.080002,136.722473,2728800
|
||||
2020-06-04,137.300003,139.250000,135.649994,139.210007,137.841385,2001300
|
||||
2020-06-05,143.000000,145.770004,142.000000,142.210007,140.811905,3583900
|
||||
2020-06-08,144.940002,149.990005,144.139999,149.380005,147.911407,2709900
|
||||
2020-06-09,145.880005,145.929993,142.100006,144.690002,143.267502,2253100
|
||||
2020-06-10,144.000000,144.410004,140.320007,140.399994,139.019653,2079600
|
||||
2020-06-11,133.949997,134.470001,127.809998,128.809998,127.543610,4389300
|
||||
2020-06-12,134.589996,135.000000,129.139999,132.720001,131.415192,2272900
|
||||
2020-06-15,128.419998,134.630005,127.290001,133.679993,132.365738,1835300
|
||||
2020-06-16,138.149994,139.369995,133.000000,135.539993,134.207458,1651800
|
||||
2020-06-17,136.710007,137.399994,134.869995,135.660004,134.326279,1214400
|
||||
2020-06-18,134.919998,139.339996,134.500000,138.389999,137.029434,2416200
|
||||
2020-06-19,140.759995,140.880005,135.619995,137.630005,136.276917,2828500
|
||||
2020-06-22,136.550003,137.750000,135.199997,137.380005,136.029358,1448100
|
||||
2020-06-23,138.550003,139.839996,137.380005,139.070007,137.702744,1385200
|
||||
2020-06-24,137.649994,138.000000,134.130005,135.089996,133.761871,2357300
|
||||
2020-06-25,133.720001,136.279999,132.229996,136.110001,134.771866,2310900
|
||||
2020-06-26,135.199997,135.380005,129.279999,130.080002,129.419174,3282000
|
||||
2020-06-29,131.300003,134.729996,130.119995,134.550003,133.866470,2336200
|
||||
2020-06-30,136.220001,140.750000,134.919998,140.220001,139.507675,6473300
|
||||
2020-07-01,158.850006,163.649994,155.759995,156.660004,155.864151,17967500
|
||||
2020-07-02,158.600006,159.720001,155.279999,155.479996,154.690140,4046900
|
||||
2020-07-06,157.899994,158.399994,153.660004,156.270004,155.476135,3015800
|
||||
2020-07-07,154.270004,159.949997,154.130005,158.539993,157.734589,2582800
|
||||
2020-07-08,158.119995,159.380005,156.270004,158.559998,157.754501,2110700
|
||||
2020-07-09,158.000000,158.750000,155.320007,155.740005,154.948837,2238300
|
||||
2020-07-10,156.199997,159.009995,155.970001,158.589996,157.784332,1746200
|
||||
2020-07-13,160.000000,160.220001,155.660004,156.229996,155.436325,1735900
|
||||
2020-07-14,156.229996,158.919998,155.529999,158.500000,157.694809,1641100
|
||||
2020-07-15,160.419998,162.529999,159.039993,161.250000,160.430832,3332800
|
||||
2020-07-16,161.770004,167.100006,160.470001,166.100006,165.256210,4100000
|
||||
2020-07-17,167.279999,168.119995,164.910004,165.979996,165.136795,2047900
|
||||
2020-07-20,164.889999,165.550003,162.809998,164.130005,163.296204,1593300
|
||||
2020-07-21,165.100006,167.559998,164.410004,165.500000,164.659241,1731700
|
||||
2020-07-22,164.639999,165.940002,163.440002,165.139999,164.301071,1231800
|
||||
2020-07-23,165.410004,167.389999,164.649994,165.990005,165.146759,1387200
|
||||
2020-07-24,164.690002,166.880005,164.190002,165.039993,164.201569,1545900
|
||||
2020-07-27,165.000000,170.720001,163.860001,170.639999,169.773132,2926400
|
||||
2020-07-28,169.419998,170.330002,166.710007,166.929993,166.081970,2374500
|
||||
2020-07-29,167.100006,171.369995,167.009995,169.550003,168.688675,4623800
|
||||
2020-07-30,174.149994,174.500000,169.860001,172.710007,171.832626,5407300
|
||||
2020-07-31,172.000000,172.710007,167.990005,168.399994,167.544510,2488000
|
||||
2020-08-03,169.550003,170.589996,168.529999,169.220001,168.360352,1503400
|
||||
2020-08-04,169.220001,171.479996,169.199997,170.660004,169.793030,1264000
|
||||
2020-08-05,171.850006,172.419998,170.240005,171.699997,170.827744,1310000
|
||||
2020-08-06,172.000000,173.479996,171.320007,172.240005,171.365021,1364900
|
||||
2020-08-07,172.470001,183.880005,172.470001,183.529999,182.597641,6311100
|
||||
2020-08-10,188.160004,200.460007,187.339996,199.979996,198.964066,10815100
|
||||
2020-08-11,199.990005,203.589996,195.139999,196.449997,195.452011,5998200
|
||||
2020-08-12,200.000000,206.240005,199.020004,201.960007,200.934021,6239400
|
||||
2020-08-13,200.679993,204.789993,199.610001,203.860001,202.824371,3663800
|
||||
2020-08-14,202.070007,209.639999,201.860001,208.600006,207.540298,4633000
|
||||
2020-08-17,210.000000,211.559998,206.039993,206.639999,205.590240,2662000
|
||||
2020-08-18,206.369995,208.429993,204.179993,206.970001,205.918579,3040400
|
||||
2020-08-19,206.839996,210.940002,206.839996,207.880005,206.823959,2218000
|
||||
2020-08-20,206.229996,209.199997,205.059998,208.820007,207.759186,1532800
|
||||
2020-08-21,209.160004,212.940002,208.500000,210.490005,209.420685,2034100
|
||||
2020-08-24,212.960007,217.949997,211.990005,217.399994,216.295578,3393700
|
||||
2020-08-25,219.169998,219.580002,213.220001,214.309998,213.221283,2160200
|
||||
2020-08-26,215.729996,217.119995,214.080002,215.770004,214.673874,1518200
|
||||
2020-08-27,216.100006,218.880005,215.080002,218.210007,217.101471,2014900
|
||||
2020-08-28,218.229996,223.660004,218.009995,221.899994,220.772720,2996100
|
||||
2020-08-31,221.800003,224.199997,219.800003,219.839996,218.723175,1839300
|
||||
2020-09-01,219.990005,226.550003,219.139999,225.460007,224.314636,1904800
|
||||
2020-09-02,227.119995,229.000000,223.070007,227.910004,226.752182,1680700
|
||||
2020-09-03,228.130005,231.580002,218.589996,220.970001,220.476257,4003800
|
||||
2020-09-04,222.460007,228.240005,217.399994,226.119995,225.614746,2879800
|
||||
2020-09-08,223.789993,225.750000,219.720001,221.050003,220.556076,2121100
|
||||
2020-09-09,226.000000,228.850006,224.119995,225.750000,225.245575,3222700
|
||||
2020-09-10,229.490005,229.490005,222.889999,224.440002,223.938507,2443300
|
||||
2020-09-11,226.440002,233.669998,225.470001,232.789993,232.269836,4865200
|
||||
2020-09-14,240.990005,241.000000,232.570007,236.339996,235.811905,6583700
|
||||
2020-09-15,234.990005,239.850006,230.509995,236.669998,236.141174,9847300
|
||||
2020-09-16,253.029999,256.179993,246.300003,250.300003,249.740723,17073300
|
||||
2020-09-17,242.630005,249.800003,242.110001,244.080002,243.534622,4254300
|
||||
2020-09-18,242.970001,248.199997,241.949997,242.779999,242.237518,4348700
|
||||
2020-09-21,237.949997,239.190002,230.270004,238.740005,238.206558,4109500
|
||||
2020-09-22,239.509995,243.779999,235.630005,243.419998,242.876083,2651700
|
||||
2020-09-23,244.990005,250.509995,241.039993,241.419998,240.880554,3083000
|
||||
2020-09-24,244.009995,247.199997,239.500000,244.220001,243.674301,3048300
|
||||
2020-09-25,241.679993,251.899994,241.470001,250.169998,249.611008,3212400
|
||||
2020-09-28,255.270004,259.950012,254.080002,254.440002,253.871460,3309800
|
||||
2020-09-29,254.990005,258.200012,249.119995,253.500000,252.933563,2195400
|
||||
2020-09-30,253.470001,257.510010,249.500000,251.520004,250.957993,2506000
|
||||
2020-10-01,255.259995,257.790009,252.880005,254.080002,253.512268,2862300
|
||||
2020-10-02,250.550003,258.549988,250.000000,255.199997,254.629761,3015300
|
||||
2020-10-05,258.799988,260.959991,257.730011,259.209991,258.630798,2427800
|
||||
2020-10-06,260.119995,264.980011,258.179993,259.269989,258.690674,3152200
|
||||
2020-10-07,263.850006,270.660004,263.500000,268.260010,267.660583,2986500
|
||||
2020-10-08,269.730011,272.519989,266.350006,271.059998,270.454315,1993000
|
||||
2020-10-09,274.399994,275.000000,269.540009,271.549988,270.943207,2172000
|
||||
2020-10-12,272.260010,274.209991,271.320007,273.500000,272.888885,2063600
|
||||
2020-10-13,272.320007,275.239990,271.850006,272.739990,272.130554,1657100
|
||||
2020-10-14,274.750000,278.959991,273.769989,276.239990,275.622742,2080600
|
||||
2020-10-15,273.089996,282.140015,271.750000,282.109985,281.479614,2254700
|
||||
2020-10-16,284.000000,287.160004,282.000000,283.869995,283.235687,2990300
|
||||
2020-10-19,284.809998,291.220001,279.559998,281.970001,281.339966,3453100
|
||||
2020-10-20,284.000000,292.690002,283.109985,287.399994,286.757813,3924900
|
||||
2020-10-21,289.160004,293.299988,282.260010,282.279999,281.649261,3219200
|
||||
2020-10-22,283.579987,285.640015,274.019989,275.950012,275.333405,2962900
|
||||
2020-10-23,278.290009,283.869995,276.859985,283.559998,282.926392,2498300
|
||||
2020-10-26,279.989990,280.500000,273.399994,277.619995,276.999664,2321400
|
||||
2020-10-27,279.940002,280.350006,274.390015,274.410004,273.796844,1912300
|
||||
2020-10-28,262.730011,266.920013,258.000000,259.989990,259.409058,4039200
|
||||
2020-10-29,260.209991,269.739990,260.059998,267.019989,266.423340,2680700
|
||||
2020-10-30,264.600006,265.989990,255.559998,259.470001,258.890228,2706900
|
||||
2020-11-02,262.700012,267.489990,259.010010,266.980011,266.383453,2042900
|
||||
2020-11-03,271.950012,276.920013,268.119995,274.480011,273.866699,2630800
|
||||
2020-11-04,276.709991,278.799988,268.529999,269.100006,268.498718,2810600
|
||||
2020-11-05,273.000000,282.269989,273.000000,279.070007,278.446442,2234600
|
||||
2020-11-06,278.519989,284.299988,277.119995,279.769989,279.144867,1894800
|
||||
2020-11-09,274.239990,274.500000,256.350006,263.880005,263.290375,5907200
|
||||
2020-11-10,264.380005,268.769989,258.000000,267.269989,266.672791,2874000
|
||||
2020-11-11,271.170013,271.309998,266.000000,267.809998,267.211578,1937700
|
||||
2020-11-12,269.230011,270.890015,263.989990,267.160004,266.563049,1924000
|
||||
2020-11-13,267.989990,273.720001,267.989990,271.910004,271.302429,1593700
|
||||
2020-11-16,273.519989,280.880005,270.420013,279.829987,279.204712,2474800
|
||||
2020-11-17,281.869995,286.200012,276.899994,285.049988,284.413055,2816700
|
||||
2020-11-18,285.700012,289.760010,282.489990,282.500000,281.868774,2874800
|
||||
2020-11-19,283.769989,285.000000,276.880005,279.850006,279.224701,2375000
|
||||
2020-11-20,280.970001,281.660004,276.690002,276.690002,276.071747,1885500
|
||||
2020-11-23,280.209991,286.399994,280.200012,286.350006,285.710175,2431600
|
||||
2020-11-24,289.589996,296.079987,285.299988,291.679993,291.028259,3711400
|
||||
2020-11-25,291.809998,292.779999,286.559998,288.299988,287.655792,2299600
|
||||
2020-11-27,290.799988,291.200012,285.350006,287.410004,286.767792,1248000
|
||||
2020-11-30,287.989990,290.899994,280.540009,286.579987,285.939636,3189000
|
||||
2020-12-01,293.559998,297.660004,287.600006,287.760010,287.117035,3053800
|
||||
2020-12-02,287.220001,293.839996,285.029999,291.720001,291.068176,2518000
|
||||
2020-12-03,291.720001,296.339996,289.779999,292.700012,292.045990,1955800
|
||||
2020-12-04,294.359985,298.980011,293.119995,294.880005,294.221100,1847700
|
||||
2020-12-07,296.899994,297.040009,293.200012,297.040009,296.376282,1483400
|
||||
2020-12-08,298.000000,303.649994,297.720001,301.450012,300.776428,2889100
|
||||
2020-12-09,303.500000,305.660004,293.459991,295.320007,294.660126,2644900
|
||||
2020-12-10,291.260010,294.380005,288.609985,290.899994,290.250000,2961000
|
||||
2020-12-11,289.779999,291.880005,286.190002,289.470001,289.470001,2354500
|
||||
2020-12-14,296.000000,296.350006,285.410004,285.540009,285.540009,2933900
|
||||
2020-12-15,286.010010,289.459991,283.109985,285.739990,285.739990,3026400
|
||||
2020-12-16,287.380005,290.850006,286.609985,288.809998,288.809998,2611800
|
||||
2020-12-17,289.410004,293.899994,286.220001,292.260010,292.260010,6006900
|
||||
2020-12-18,283.500000,284.519989,274.959991,275.570007,275.570007,15457100
|
||||
2020-12-21,271.660004,273.500000,268.510010,271.940002,271.940002,4989500
|
||||
2020-12-22,272.500000,273.339996,268.279999,273.279999,273.279999,3553600
|
||||
2020-12-23,273.640015,276.640015,270.619995,270.709991,270.709991,2350800
|
||||
2020-12-24,271.359985,272.029999,267.190002,268.820007,268.820007,1649400
|
||||
2020-12-28,269.839996,270.100006,261.809998,262.940002,262.940002,3633100
|
||||
2020-12-29,263.950012,265.450012,259.670013,261.559998,261.559998,2676600
|
||||
2020-12-30,262.200012,262.679993,258.359985,259.980011,259.980011,2694100
|
||||
2020-12-31,259.600006,260.459991,257.510010,259.619995,259.619995,2606000
|
||||
2021-01-04,260.399994,260.500000,250.899994,253.190002,253.190002,3797100
|
||||
2021-01-05,251.500000,254.770004,250.050003,253.179993,253.179993,3271100
|
||||
2021-01-06,250.460007,258.980011,250.380005,253.559998,253.559998,3605300
|
||||
2021-01-07,254.089996,256.209991,245.449997,246.029999,246.029999,5657300
|
||||
2021-01-08,246.520004,247.360001,242.419998,244.960007,244.960007,4573000
|
||||
2021-01-11,243.000000,246.460007,242.720001,245.309998,245.309998,3416300
|
||||
2021-01-12,246.080002,249.619995,243.000000,249.039993,249.039993,4376400
|
||||
2021-01-13,250.500000,253.869995,248.199997,252.220001,252.220001,3012800
|
||||
2021-01-14,254.259995,258.339996,253.399994,256.269989,256.269989,2867100
|
||||
2021-01-15,255.759995,255.759995,250.979996,252.559998,252.559998,2803500
|
||||
2021-01-19,253.929993,256.399994,248.899994,249.520004,249.520004,2357600
|
||||
2021-01-20,251.190002,252.350006,247.619995,251.960007,251.960007,2157300
|
||||
2021-01-21,253.770004,257.279999,252.369995,253.940002,253.940002,1951200
|
||||
2021-01-22,252.000000,255.440002,250.009995,254.080002,254.080002,1689200
|
||||
2021-01-25,252.449997,254.779999,248.289993,253.479996,253.479996,2009700
|
||||
2021-01-26,254.199997,254.839996,249.339996,249.669998,249.669998,1836100
|
||||
2021-01-27,245.610001,246.399994,240.610001,242.830002,242.830002,2698500
|
||||
2021-01-28,246.009995,246.289993,242.619995,242.789993,242.789993,2179000
|
||||
2021-01-29,242.960007,243.380005,234.789993,235.339996,235.339996,3231600
|
||||
2021-02-01,237.380005,239.750000,235.320007,239.240005,239.240005,2731200
|
||||
2021-02-02,246.389999,246.589996,240.830002,242.500000,242.500000,2859600
|
||||
2021-02-03,242.600006,243.600006,239.350006,241.289993,241.289993,2160500
|
||||
2021-02-04,241.380005,248.179993,240.869995,248.119995,248.119995,2898900
|
||||
2021-02-05,251.000000,255.399994,249.000000,255.009995,255.009995,2814200
|
||||
2021-02-08,256.760010,259.380005,255.570007,257.450012,257.450012,2135400
|
||||
2021-02-09,257.269989,260.500000,254.000000,259.130005,259.130005,1758100
|
||||
|
File diff suppressed because one or more lines are too long
132
tests/test.lisp
132
tests/test.lisp
|
|
@ -1,80 +1,90 @@
|
|||
(print "Debug starts")
|
||||
; it is expected to be called from parent directory ie: ml -f tests/test.lisp
|
||||
|
||||
; define a function `fact` that takes an argument `n`
|
||||
; (defun fact (n)
|
||||
; (if (<= n 1)
|
||||
; 1
|
||||
; (* n (fact (- n 1)))
|
||||
; ))
|
||||
(print "Test starts")
|
||||
|
||||
; (print (fact 5))
|
||||
(defun fact (n)
|
||||
(if (<= n 1)
|
||||
1
|
||||
(* n (fact (- n 1)))
|
||||
))
|
||||
|
||||
(print (fact 1000))
|
||||
|
||||
|
||||
; (define json_list (parse-json "{\"k1\":\"v1\", \"k2\":42, \"k3\":[\"a\",123,true,false,null]}"))
|
||||
; (print json_list)
|
||||
; (for x json_list
|
||||
; (print x))
|
||||
|
||||
; nefunguje - api.nasdaq.com
|
||||
;(define nasdaq_headers (quote (("Accept" "application/json, text/plain, */*") ("Connection" "keep-alive") ("Origin" "https://www.nasdaq.com/") ("User-Agent" "Mozilla/5.0 (Windows NT 10.0)"))))
|
||||
;(define json_list2 (parse-json (read-url "https://api.nasdaq.com/api/calendar/dividends/?date=2021-02-01" nasdaq_headers)))
|
||||
; (for x json_list2
|
||||
; (print x))
|
||||
|
||||
;; (include "tmp/example.lisp")
|
||||
;; (print "sorted: " (qs '(10 9 8 7 6 5 4 3 2 1)))
|
||||
(define json_list (parse-json "{\"k1\":\"v1\", \"k2\":42, \"k3\":[\"a\",123,true,false,null]}"))
|
||||
(print json_list)
|
||||
(for x json_list
|
||||
(print x))
|
||||
|
||||
|
||||
; (define csv (read-file "tmp/data.csv"))
|
||||
; (define csv_list (parse-csv csv))
|
||||
; (for x csv_list
|
||||
; (print x))
|
||||
|
||||
;; (define web_page (read-url "https://query1.finance.yahoo.com/v7/finance/download/FDX?period1=1581272585&period2=1612894985&interval=1d&events=history&includeAdjustedClose=true"))
|
||||
;; (print web_page)
|
||||
;; (define fdx_list (parse-csv (index web_page 1)))
|
||||
;; (print fdx_list)
|
||||
(print "sorted: " (quick-sort '(10 9 8 7 6 5 4 3 2 1)))
|
||||
|
||||
|
||||
;; (define curl "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=2021-02-01 2>/dev/null")
|
||||
;; (define curl_out (system-cmd curl))
|
||||
;; (define json_list (parse-json (last curl_out)))
|
||||
;; ;(print json_list)
|
||||
;; (define data (first json_list))
|
||||
;; ;(print data)
|
||||
;; ;(print (index data 1)) ; druhy prvek
|
||||
;; (define calendar (index data 1))
|
||||
;; ;(print calendar)
|
||||
;; (define calendar_data (index (index calendar 0) 1))
|
||||
;; ;(print calendar_data)
|
||||
;; (define header (index (index calendar_data 0) 1))
|
||||
;; ;(print header)
|
||||
;; (define rows (index (index calendar_data 1) 1))
|
||||
;; ;(print rows)
|
||||
;; (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))))
|
||||
|
||||
;; ;(print symbol edate pdate divrate)
|
||||
;; '(symbol edate pdate divrate)
|
||||
;; )
|
||||
(define csv_str (read-file "tests/data.csv"))
|
||||
(define csv_list (parse-csv csv_str))
|
||||
(for x csv_list
|
||||
(print x))
|
||||
|
||||
|
||||
;(print (ls-dir "/tmp"))
|
||||
;(write-file "/tmp/file" "write-file test\n")
|
||||
;(print (is-file? "/tmp/file"))
|
||||
;(print (is-file? "/tmp/hovinko"))
|
||||
;(print (is-dir? "/tmp/powerlog"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; to create test file with csv
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; (define web_page (read-url "https://query1.finance.yahoo.com/v7/finance/download/FDX?period1=1581272585&period2=1612894985&interval=1d&events=history&includeAdjustedClose=true"))
|
||||
; (write-file "tests/csv_data.csv" (last web_page))
|
||||
|
||||
(define fdx_list (parse-csv (read-file "tests/csv_data.csv")))
|
||||
(print fdx_list)
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; to create test file with json
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; (define curl "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=2021-02-01 2>/dev/null")
|
||||
; (define curl_out (system-cmd curl))
|
||||
; (write-file "tests/json_data.json" (last curl_out))
|
||||
; (define json_list (parse-json (last curl_out)))
|
||||
|
||||
(define json_list (parse-json (read-file "tests/json_data.json")))
|
||||
|
||||
|
||||
(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)))
|
||||
1)
|
||||
|
||||
|
||||
(print (make-csv csv_list))
|
||||
|
||||
|
||||
|
||||
(print (ls-dir "/tmp"))
|
||||
(write-file "/tmp/file" "write-file test\n")
|
||||
(print (is-file? "/tmp/file"))
|
||||
(print (is-file? "/tmp/file_not_exists"))
|
||||
(print (is-dir? "/tmp"))
|
||||
|
||||
(print (get-universal-time))
|
||||
(print (date-to-str (get-universal-time) "%d.%m.%Y"))
|
||||
(print (str-to-date "01.01.1970" "%d.%m.%Y"))
|
||||
(print (date-add (str-to-date "01.01.1970" "%d.%m.%Y") 1 "day"))
|
||||
|
||||
(print "Debug ends")
|
||||
(print "Test ends")
|
||||
Loading…
Reference in New Issue