Skip to content

Commit

Permalink
julia 0.7 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin authored Aug 25, 2018
1 parent 9e00565 commit 5be5cab
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
- linux

julia:
- 0.6
- 0.7

notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.6.3
julia 0.7
TimeSeries 0.9.0
HTTP 0.6.12
Reexport
5 changes: 4 additions & 1 deletion docs/src/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ financial time series columns. The five column names that are supported
include `o()` for Open, `h()` for High, `l()` for Low, `c()` for Close
and `v()` for Volume.:

```@repl
```@setup helper
using MarketData
```

```@repl helper
o(AAPL)
```
2 changes: 0 additions & 2 deletions src/MarketData.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
__precompile__()

module MarketData

using TimeSeries
Expand Down
33 changes: 19 additions & 14 deletions src/const.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@

const DATADIR = joinpath(dirname(pathof(@__MODULE__)), "..", "data")

# US Equities from A to E (so far)
const AAPL = readtimearray(Pkg.dir("MarketData/data/AAPL.csv"), meta = "AAPL")
const BA = readtimearray(Pkg.dir("MarketData/data/BA.csv"), meta = "BA")
const CAT = readtimearray(Pkg.dir("MarketData/data/CAT.csv"), meta = "CAT")
const DELL = readtimearray(Pkg.dir("MarketData/data/DELL.csv"), meta = "DELL")
const EBAY = readtimearray(Pkg.dir("MarketData/data/EBAY.csv"), meta = "EBAY")
const F = readtimearray(Pkg.dir("MarketData/data/F.csv"), meta = "F")
const GE = readtimearray(Pkg.dir("MarketData/data/GE.csv"), meta = "GE")
const TX = readtimearray(Pkg.dir("MarketData/data/TX.csv"), meta = "TX")
const AAPL = readtimearray(joinpath(DATADIR, "AAPL.csv"), meta = "AAPL")
const BA = readtimearray(joinpath(DATADIR, "BA.csv"), meta = "BA")
const CAT = readtimearray(joinpath(DATADIR, "CAT.csv"), meta = "CAT")
const DELL = readtimearray(joinpath(DATADIR, "DELL.csv"), meta = "DELL")
const EBAY = readtimearray(joinpath(DATADIR, "EBAY.csv"), meta = "EBAY")
const F = readtimearray(joinpath(DATADIR, "F.csv"), meta = "F")
const GE = readtimearray(joinpath(DATADIR, "GE.csv"), meta = "GE")
const TX = readtimearray(joinpath(DATADIR, "TX.csv"), meta = "TX")

# smaller datasets used for testing time-related packages
const cl = AAPL["Close"][Date(2000,1,1):Date(2001,12,31)]
const op = AAPL["Open"][Date(2000,1,1):Date(2001,12,31)]
const ohlc = AAPL["Open", "High", "Low", "Close"][Date(2000,1,1):Date(2001,12,31)]
const ohlcv = AAPL["Open", "High", "Low", "Close", "Volume"][Date(2000,1,1):Date(2001,12,31)]
const datetime1 = readtimearray(Pkg.dir("MarketData/data/datetime1.csv"))
const datetime2 = readtimearray(Pkg.dir("MarketData/data/datetime2.csv"), format="yyyy-mm-dd HH:MM:SS")
const dates = Date(2000,1,1):Day(1):Date(2001,12,31)
const cl = AAPL["Close"][dates]
const op = AAPL["Open"][dates]
const ohlc = AAPL["Open", "High", "Low", "Close"][dates]
const ohlcv = AAPL["Open", "High", "Low", "Close", "Volume"][dates]
const datetime1 = readtimearray(joinpath(DATADIR, "datetime1.csv"))
const datetime2 = readtimearray(joinpath(DATADIR, "datetime2.csv"),
format="yyyy-mm-dd HH:MM:SS")
const mdata = TimeArray(cl.timestamp, cl.values, cl.colnames, "Apple") # data with meta field occupied
11 changes: 5 additions & 6 deletions src/downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ References
http://www.finance.yahoo.com
See Also
fred() which accesses the St. Louis Federal Reserve financial and economic data sets.
"""

function yahoo(data::String="^GSPC")
Base.depwarn("Yahoo Finance API changed, this function may not work anymore", :yahoo)
url = "http://ichart.yahoo.com/table.csv?s=$data"
Expand All @@ -60,8 +59,8 @@ Method Signature(s)
Details
The fred() method takes a string argument that corresponds to a series code from the St. Louis Federal
Reserve (FRED) database. It returns the data in the TimeSeries.TimeArray data structure. When no argument
is provided, the default data set is the Consumer Price Index for All Urban Consumers: All Items (CPIAUCNS).
Reserve (FRED) database. It returns the data in the TimeSeries.TimeArray data structure. When no argument
is provided, the default data set is the Consumer Price Index for All Urban Consumers: All Items (CPIAUCNS).
References
Expand All @@ -87,15 +86,15 @@ function TimeArray(resp::APIResponse)
# Extract the head and body of the data
head = strip(data[1])
body = data[2:end]
# Parse body
# Parse body
body[end] == "" ? pop!(body) : nothing # remove trailing empty string if it's there
body = [split(line, ",") for line in body] # split on comma
######### Timestamp
# take the first row (assuming it's date)
# TODO: regex query needed to catch edge cases
dates = [line[1] for line in body]
timestamp = Date[Date(d) for d in dates] # parse dates
######### Values
######### Values
svals = [line[2:end] for line in body] # get rows 2 to the end
fvals = zeros(length(svals),length(svals[1]))
for r in 1:size(fvals,1)
Expand Down
2 changes: 1 addition & 1 deletion test/const.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MarketData
using Base.Test
using Test


@testset "TimeSeries readwrite parses csv file correctly" begin
Expand Down
2 changes: 1 addition & 1 deletion test/downloads.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MarketData
using Base.Test
using Test

@testset "remote" begin
@testset "FRED" begin
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MarketData
using Base.Test
using Test

@testset "helper method" begin
@testset "single-letter methods work" begin
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("const.jl")
include("helpers.jl")
Expand Down

0 comments on commit 5be5cab

Please sign in to comment.