diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..c989344 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,25 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: ['1.3'] + os: [ubuntu-latest, macOS-latest] + + steps: + - uses: actions/checkout@v1.0.0 + - uses: webfactory/ssh-agent@v0.2.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + - run: git config url.git@github.com:.insteadOf https://github.com/ + - run: git config --global user.name "RollenRegistratorBot" + - run: git config --global user.password "${{ secrets.PAT }}" + - uses: julia-actions/setup-julia@latest + with: + version: ${{ matrix.julia-version }} + - run: julia -e 'using Pkg; Pkg.Registry.add(RegistrySpec(url="https://github.com/JuliaRegistries/General")); Pkg.Registry.add(RegistrySpec(url="git@github.com:HakoSwede/PrivateRegistry"))' + - uses: julia-actions/julia-runtest@master diff --git a/Project.toml b/Project.toml index 3c8adc1..05398b3 100644 --- a/Project.toml +++ b/Project.toml @@ -18,4 +18,4 @@ DataFrames = "0.20" HTTP = "0.8" Polygon = "2.0" ProgressMeter = "1.2" -TradingBase = "0.2, 0.3" +TradingBase = "0.2, 0.3, 0.4" diff --git a/data/test-market b/data/test-market deleted file mode 100644 index fe2bb2f..0000000 Binary files a/data/test-market and /dev/null differ diff --git a/src/Markets.jl b/src/Markets.jl index ce6e599..48aaf95 100644 --- a/src/Markets.jl +++ b/src/Markets.jl @@ -26,6 +26,12 @@ import TradingBase: is_closed export + # Re-exports + Close, + OHLC, + OHLCV, + get_close, + Market, Tick, BidAsk, diff --git a/test/Manifest.toml b/test/Manifest.toml new file mode 100644 index 0000000..fafb30a --- /dev/null +++ b/test/Manifest.toml @@ -0,0 +1,44 @@ +# This file is machine-generated - editing it directly is not advised + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[Test]] +deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..d8cd789 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,3 @@ +[deps] +Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl new file mode 100644 index 0000000..74356a5 --- /dev/null +++ b/test/runtests.jl @@ -0,0 +1,33 @@ +using Test, Markets, Dates + +@testset "All tests" begin + prices = Close.(rand(32)) + dates = collect(DateTime(2020, 1, 1):Day(1):DateTime(2020, 2, 1)) + + daily_close_market = Market( + Day(1), + dates, + ["TEST"], + Dict("TEST" => Dict(d => p for (d, p) in zip(dates, prices))), + Dict("TEST" => (dividends = [],)) + ) + @test get_clock(daily_close_market) == DateTime(2020,1,1,0,0,0) + @test is_preopen(daily_close_market) + tick!(daily_close_market) + @test is_opening(daily_close_market) + tick!(daily_close_market) + @test is_open(daily_close_market) + @test Markets.get_current(daily_close_market, "TEST") == get_close(prices[1]) + tick!(daily_close_market) + @test is_closing(daily_close_market) + tick!(daily_close_market) + tick!(daily_close_market) + @test get_clock(daily_close_market) == DateTime(2020,1,2,0,0,0) + @test get_last(daily_close_market, "TEST") == get_close(prices[1]) + @test Markets.get_current(daily_close_market, "TEST") == get_close(prices[2]) + hist = @test_logs (:warn, r"Can only get") get_historical(daily_close_market, "TEST", 10) + @test length(hist) == 1 + @test hist[] == prices[1] + reset!(daily_close_market) + @test get_clock(daily_close_market) == DateTime(2020,1,1,0,0,0) +end