Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

add tests and CI #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- run: git config [email protected]:.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="[email protected]:HakoSwede/PrivateRegistry"))'
- uses: julia-actions/julia-runtest@master
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Binary file removed data/test-market
Binary file not shown.
6 changes: 6 additions & 0 deletions src/Markets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import TradingBase:
is_closed

export
# Re-exports
Close,
OHLC,
OHLCV,
get_close,

Market,
Tick,
BidAsk,
Expand Down
44 changes: 44 additions & 0 deletions test/Manifest.toml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
33 changes: 33 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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