-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyfinance.ijs
42 lines (32 loc) · 913 Bytes
/
yfinance.ijs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
NB. Working with Yahoo!Finance CSV files
load 'tables/csv'
strtodayno=: [: todayno getdate
data_dir=: '~/projects/qstk/yahoo/'
NB. Read CSV file for given path string
read_csv=: |. @: }. @: readcsv @: jpath
NB. Read CSV file for given stock symbol
NB. Example:
NB. AAPL=. read_csv_symbol 'AAPL'
read_csv_symbol=: read_csv @: (data_dir&,) @: (,&'.csv')
NB. Columns in Yahoo!Finance CSV file
date=: 0&{"1
open=: 1&{"1
high=: 2&{"1
low=: 3&{"1
close=: 4&{"1
volume=: 5&{"1
adj_close=: 6&{"1
date_close=: date ,. adj_close
dayno=: strtodayno @: > @: {."1
between=: 4 : 0
'from to' =. strtodayno"1 > x
dates=. dayno y
filter=. from&<: *. to&>:
i=. filter dates
i # y
)
price=: ". @: > @: adj_close
NB. Read prices for given date range and stock symbol
NB. Example:
NB. AAPL=. ('2011-01-01';'2011-12-31') read_price 'AAPL'
read_price=: price@:between [: read_csv_symbol ]