Skip to content

Commit

Permalink
Merge pull request #45 from JuliaQuant/update_testing
Browse files Browse the repository at this point in the history
update to testing framework and indentation fixes
  • Loading branch information
milktrader committed Nov 4, 2014
2 parents 95edcd1 + f1f9127 commit 28a76af
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 99 deletions.
22 changes: 12 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
language: cpp
compiler:
- gcc
compiler:
- clang
notifications:
email: false
env:
matrix:
- JULIAVERSION="juliareleases"
- JULIAVERSION="julianightlies"
before_install:
- sudo add-apt-repository ppa:staticfloat/julia-deps -y
- sudo add-apt-repository ppa:staticfloat/julianightlies -y
- sudo add-apt-repository ppa:staticfloat/${JULIAVERSION} -y
- sudo apt-get update -qq -y
- sudo apt-get install libpcre3-dev julia -y
- git config --global user.name "Travis User"
- git config --global user.email "travis@example.net"
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
script:
- julia -e 'versioninfo(); Pkg.init();'
- julia -e 'Pkg.clone("git://github.com/JuliaQuant/MarketTechnicals.jl.git"); Pkg.add("TimeSeries"); Pkg.add("FactCheck"); Pkg.add("MarketData")'
- mkdir -p ~/.julia/MarketTechnicals
- cp -R ./* ~/.julia/MarketTechnicals/
- julia ./test/runtests.jl
- julia -e 'Pkg.init(); Pkg.clone(pwd())'
- julia -e 'Pkg.test("MarketTechnicals",coverage=true)'
after_success:
- julia -e 'cd(Pkg.dir("MarketTechnicals")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Build Status](https://travis-ci.org/JuliaQuant/MarketTechnicals.jl.png)](https://travis-ci.org/JuliaQuant/MarketTechnicals.jl)
[![MarketTechnicals](http://pkg.julialang.org/badges/MarketTechnicals_release.svg)](http://pkg.julialang.org/?pkg=MarketTechnicals&ver=release)
[![Coverage Status](https://coveralls.io/repos/JuliaQuant/MarketTechnicals.jl/badge.png?branch=master)](https://coveralls.io/r/JuliaQuant/MarketTechnicals.jl?branch=master)

#### A toolkit for technical analysis of financial time series in Julia

Expand Down
1 change: 0 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
julia 0.3-
TimeSeries
StatsBase
Reexport
13 changes: 11 additions & 2 deletions src/MarketTechnicals.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
if VERSION < v"0.4-"
using Dates, TimeSeries, StatsBase
else
using Base.Dates, TimeSeries, StatsBase
end

module MarketTechnicals

using TimeSeries, StatsBase, Reexport
@reexport using TimeSeries
if VERSION < v"0.4-"
using Dates, TimeSeries, StatsBase
else
using Base.Dates, TimeSeries, StatsBase
end

export sma, ema,
bollingerbands, truerange, atr, #keltnerbands,
Expand Down
2 changes: 2 additions & 0 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FactCheck
MarketData
10 changes: 5 additions & 5 deletions test/candlesticks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ using MarketData

facts("Candlesticks") do

context("doji") do
@fact ohlc[findall(doji(ohlc))].timestamp[1] => Date(2000, 5, 30)
@fact ohlc[findall(doji(ohlc))].timestamp[2] => Date(2000, 12, 11)
@fact length(ohlc[findall(doji(ohlc))]) => 5
end
context("doji") do
@fact ohlc[findall(doji(ohlc))].timestamp[1] => Date(2000, 5, 30)
@fact ohlc[findall(doji(ohlc))].timestamp[2] => Date(2000, 12, 11)
@fact length(ohlc[findall(doji(ohlc))]) => 5
end
end
46 changes: 23 additions & 23 deletions test/levels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ using MarketData

facts("Levels") do

context("floor pivots") do
@fact floorpivots(ohlc)["r3"].values[1] => roughly(123.310) # values verified by various website calculators
@fact floorpivots(ohlc)["r2"].values[1] => roughly(119.52)
@fact floorpivots(ohlc)["r1"].values[1] => roughly(115.73)
@fact floorpivots(ohlc)["pivot"].values[1] => roughly(108.71)
@fact floorpivots(ohlc)["s1"].values[1] => roughly(104.92)
@fact floorpivots(ohlc)["s2"].values[1] => roughly(97.900)
@fact floorpivots(ohlc)["s3"].values[1] => roughly(94.110)
@fact floorpivots(ohlc).timestamp[end] => Date(2001,12,31)
end

context("woodiespivots") do
# # @fact_approx_eq 97.37500000000001 value(wr4)[2] # values NEED to be verified with online calculators
# # @fact_approx_eq 88.62500000000001 value(ws4)[2]
@fact woodiespivots(ohlc)["r3"].values[1] => roughly(124.465)
@fact woodiespivots(ohlc)["r2"].values[1] => roughly(118.480)
@fact woodiespivots(ohlc)["r1"].values[1] => roughly(113.655)
@fact woodiespivots(ohlc)["pivot"].values[1] => roughly(107.670)
@fact woodiespivots(ohlc)["s1"].values[1] => roughly(102.845)
@fact woodiespivots(ohlc)["s2"].values[1] => roughly(96.8625)
@fact woodiespivots(ohlc)["s3"].values[1] => roughly(92.035)
@fact woodiespivots(ohlc).timestamp[end] => Date(2001,12,31)
end
context("floor pivots") do
@fact floorpivots(ohlc)["r3"].values[1] => roughly(123.310) # values verified by various website calculators
@fact floorpivots(ohlc)["r2"].values[1] => roughly(119.52)
@fact floorpivots(ohlc)["r1"].values[1] => roughly(115.73)
@fact floorpivots(ohlc)["pivot"].values[1] => roughly(108.71)
@fact floorpivots(ohlc)["s1"].values[1] => roughly(104.92)
@fact floorpivots(ohlc)["s2"].values[1] => roughly(97.900)
@fact floorpivots(ohlc)["s3"].values[1] => roughly(94.110)
@fact floorpivots(ohlc).timestamp[end] => Date(2001,12,31)
end
context("woodiespivots") do
# # @fact_approx_eq 97.37500000000001 value(wr4)[2] # values NEED to be verified with online calculators
# # @fact_approx_eq 88.62500000000001 value(ws4)[2]
@fact woodiespivots(ohlc)["r3"].values[1] => roughly(124.465)
@fact woodiespivots(ohlc)["r2"].values[1] => roughly(118.480)
@fact woodiespivots(ohlc)["r1"].values[1] => roughly(113.655)
@fact woodiespivots(ohlc)["pivot"].values[1] => roughly(107.670)
@fact woodiespivots(ohlc)["s1"].values[1] => roughly(102.845)
@fact woodiespivots(ohlc)["s2"].values[1] => roughly(96.8625)
@fact woodiespivots(ohlc)["s3"].values[1] => roughly(92.035)
@fact woodiespivots(ohlc).timestamp[end] => Date(2001,12,31)
end
end
86 changes: 43 additions & 43 deletions test/movingaverages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@ using MarketData

facts("Moving Averages") do

context("sma") do
@fact sma(cl, 10).values[1] => roughly(98.782) # TTR value 98.782
@fact sma(cl, 10).values[2] => roughly(97.982) # TTR value 97.982
@fact sma(cl, 10).values[3] => roughly(98.388) # TTR value 98.388
@fact sma(cl, 10).values[490] => roughly(21.266) # TTR value 21.266
@fact sma(cl, 10).values[491] => roughly(21.417) # TTR value 21.417
@fact sma(cl, 10).timestamp[491] => Date(2001,12,31)
end
context("sma") do
@fact sma(cl, 10).values[1] => roughly(98.782) # TTR value 98.782
@fact sma(cl, 10).values[2] => roughly(97.982) # TTR value 97.982
@fact sma(cl, 10).values[3] => roughly(98.388) # TTR value 98.388
@fact sma(cl, 10).values[490] => roughly(21.266) # TTR value 21.266
@fact sma(cl, 10).values[491] => roughly(21.417) # TTR value 21.417
@fact sma(cl, 10).timestamp[491] => Date(2001,12,31)
end

context("ema") do
@fact ema(cl, 10).values[1] => roughly(98.78200) # TTR value 98.78200
@fact ema(cl, 10).values[2] => roughly(99.71982) # TTR value 99.71982
@fact ema(cl, 10).values[3] => roughly(100.96349) # TTR value 100.96349
@fact ema(cl, 10).values[490] => roughly(21.58580) # TTR value 21.58580
@fact ema(cl, 10).values[491] => roughly(21.64293) # TTR value 21.64293
@fact ema(cl, 10).timestamp[491] => Date(2001,12,31)
end

context("ema") do
@fact ema(cl, 10).values[1] => roughly(98.78200) # TTR value 98.78200
@fact ema(cl, 10).values[2] => roughly(99.71982) # TTR value 99.71982
@fact ema(cl, 10).values[3] => roughly(100.96349) # TTR value 100.96349
@fact ema(cl, 10).values[490] => roughly(21.58580) # TTR value 21.58580
@fact ema(cl, 10).values[491] => roughly(21.64293) # TTR value 21.64293
@fact ema(cl, 10).timestamp[491] => Date(2001,12,31)
end

context("ema wilder true") do
@fact ema(cl, 10, wilder=true).values[1] => roughly(98.7820) # TTR value 98.7820
@fact ema(cl, 10, wilder=true).values[2] => roughly(99.2978) # TTR value 99.2978
@fact ema(cl, 10, wilder=true).values[3] => roughly(100.0240) # TTR value 100.0240
@fact ema(cl, 10, wilder=true).values[490] => roughly(21.34556) # TTR value 21.34556
@fact ema(cl, 10, wilder=true).values[491] => roughly(21.40100) # TTR value 21.40100
@fact ema(cl, 10, wilder=true).timestamp[491] => Date(2001,12,31)
end

context("Array dispatch is correct too") do
@fact sma(cl.values, 10)[1] => roughly(98.782) # same values as above TimeArray dispatch
@fact sma(cl.values, 10)[2] => roughly(97.982)
@fact sma(cl.values, 10)[3] => roughly(98.388)
@fact sma(cl.values, 10)[490] => roughly(21.266)
@fact sma(cl.values, 10)[491] => roughly(21.417)
@fact ema(cl.values, 10)[1] => roughly(98.78200)
@fact ema(cl.values, 10)[2] => roughly(99.71982)
@fact ema(cl.values, 10)[3] => roughly(100.96349)
@fact ema(cl.values, 10)[490] => roughly(21.58580)
@fact ema(cl.values, 10)[491] => roughly(21.64293)
@fact ema(cl.values, 10, wilder=true)[1] => roughly(98.7820)
@fact ema(cl.values, 10, wilder=true)[2] => roughly(99.2978)
@fact ema(cl.values, 10, wilder=true)[3] => roughly(100.0240)
@fact ema(cl.values, 10, wilder=true)[490] => roughly(21.34556)
@fact ema(cl.values, 10, wilder=true)[491] => roughly(21.40100)
end
context("ema wilder true") do
@fact ema(cl, 10, wilder=true).values[1] => roughly(98.7820) # TTR value 98.7820
@fact ema(cl, 10, wilder=true).values[2] => roughly(99.2978) # TTR value 99.2978
@fact ema(cl, 10, wilder=true).values[3] => roughly(100.0240) # TTR value 100.0240
@fact ema(cl, 10, wilder=true).values[490] => roughly(21.34556) # TTR value 21.34556
@fact ema(cl, 10, wilder=true).values[491] => roughly(21.40100) # TTR value 21.40100
@fact ema(cl, 10, wilder=true).timestamp[491] => Date(2001,12,31)
end

context("Array dispatch is correct too") do
@fact sma(cl.values, 10)[1] => roughly(98.782) # same values as above TimeArray dispatch
@fact sma(cl.values, 10)[2] => roughly(97.982)
@fact sma(cl.values, 10)[3] => roughly(98.388)
@fact sma(cl.values, 10)[490] => roughly(21.266)
@fact sma(cl.values, 10)[491] => roughly(21.417)
@fact ema(cl.values, 10)[1] => roughly(98.78200)
@fact ema(cl.values, 10)[2] => roughly(99.71982)
@fact ema(cl.values, 10)[3] => roughly(100.96349)
@fact ema(cl.values, 10)[490] => roughly(21.58580)
@fact ema(cl.values, 10)[491] => roughly(21.64293)
@fact ema(cl.values, 10, wilder=true)[1] => roughly(98.7820)
@fact ema(cl.values, 10, wilder=true)[2] => roughly(99.2978)
@fact ema(cl.values, 10, wilder=true)[3] => roughly(100.0240)
@fact ema(cl.values, 10, wilder=true)[490] => roughly(21.34556)
@fact ema(cl.values, 10, wilder=true)[491] => roughly(21.40100)
end
end
6 changes: 3 additions & 3 deletions test/utilities.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
facts("Utilities") do

context("Base.abs returns all positive numbers") do
@fact sum((abs(cl .- op) .>= 0).values) => length(cl)
end
context("Base.abs returns all positive numbers") do
@fact sum((abs(cl .- op) .>= 0).values) => length(cl)
end
end
24 changes: 12 additions & 12 deletions test/volume.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ using MarketData

facts("Volume") do
# commented tests that require a volume object not currently available in MarketData
context("obv") do
# @fact obv(ohlc).values[1] => 50480000.00 # TTR value is 50480000
# @fact obv(ohlc).values[end] => 1145460000.00 # TTR value is 1145460000
# @fact obv(ohlc).timestamp[end] => Date(2001,12,31)
end

# commented tests that require a volume object not currently available in MarketData
context("vwap") do
# @fact vwap(ohlc).values[1] => roughly(109.0703) # TTR value 109.0703
# @fact vwap(ohlc).values[end] => roughly(122.7716) # TTR value 122.7716
# @fact vwap(ohlc).timestamp[end] => Date(2001,12,31)
end
context("obv") do
# @fact obv(ohlc).values[1] => 50480000.00 # TTR value is 50480000
# @fact obv(ohlc).values[end] => 1145460000.00 # TTR value is 1145460000
# @fact obv(ohlc).timestamp[end] => Date(2001,12,31)
end
# commented tests that require a volume object not currently available in MarketData
context("vwap") do
# @fact vwap(ohlc).values[1] => roughly(109.0703) # TTR value 109.0703
# @fact vwap(ohlc).values[end] => roughly(122.7716) # TTR value 122.7716
# @fact vwap(ohlc).timestamp[end] => Date(2001,12,31)
end
end

0 comments on commit 28a76af

Please sign in to comment.