Skip to content

Commit cdd4bed

Browse files
committed
More coverage
1 parent 29d2ec0 commit cdd4bed

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

Diff for: test/ext/test_interactivebrokers_ext.jl

+13-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,20 @@ using InteractiveBrokers
3232
# TODO Test all other contract types (Cash, Bond, Fut, etc.)
3333
end
3434
@testset "Lucky.Instrument" begin
35-
future = InteractiveBrokers.Contract(691439932, "M6E", "FUT", "20240916", 0.0, "", "12500", "", "", "USD", "M6EU4", "M6E", false, "", "", "", "", "", "", InteractiveBrokers.ComboLeg[], nothing)
36-
bond = InteractiveBrokers.Contract(573330472, "US-T", "BOND", "20250715", 0.0, "", "", "", "", "USD", "IBCID573330472", "US-T", false, "", "", "", "", "", "", InteractiveBrokers.ComboLeg[], nothing)
35+
futureC = InteractiveBrokers.Contract(691439932, "M6E", "FUT", "20240916", 0.0, "", "12500", "", "", "USD", "M6EU4", "M6E", false, "", "", "", "", "", "", InteractiveBrokers.ComboLeg[], nothing)
36+
bondC = InteractiveBrokers.Contract(573330472, "US-T", "BOND", "20250715", 0.0, "", "", "", "", "USD", "IBCID573330472", "US-T", false, "", "", "", "", "", "", InteractiveBrokers.ComboLeg[], nothing)
3737

38-
# TODO test Lucky.Instrument() for each instrument
38+
futureI = Lucky.Instrument(futureC)
39+
bondI = Lucky.Instrument(bondC)
40+
41+
@test futureI isa Future
42+
@test bondI isa Bond
43+
44+
@test currency(futureI) == CurrencyType("USD")
45+
@test currency(bondI) == CurrencyType("USD")
46+
47+
@test futureI.expiration == Date("2024-09-16")
48+
@test bondI.maturity == Date("2025-07-15")
3949
end
4050
end
4151
end

Diff for: test/instruments/test_bonds.jl

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@testset "Bonds" begin
2+
ticker = :WHATEVER
3+
USD = Currency(:USD)
4+
mat = today()
5+
@testset "Constructors" begin
6+
@test Bond(ticker, :USD, mat) isa Bond{:WHATEVER, Currency{:USD}}
7+
end
8+
@testset "Interfaces" begin
9+
bond = Bond(ticker, :USD, mat)
10+
@test InstrumentType(bond) === Bond{:WHATEVER, Currency{:USD}}
11+
@test currency(bond) == Currency{:USD}
12+
end
13+
end

Diff for: test/instruments/test_futures.jl

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@testset "Futures" begin
2+
ticker = :WHATEVER
3+
USD = Currency(:USD)
4+
exp = today()
5+
@testset "Constructors" begin
6+
@test Future(ticker, :USD, exp) isa Future{:WHATEVER, Currency{:USD}}
7+
end
8+
@testset "Interfaces" begin
9+
fut = Future(ticker, :USD, exp)
10+
@test InstrumentType(fut) === Future{:WHATEVER, Currency{:USD}}
11+
@test currency(fut) == Currency{:USD}
12+
end
13+
end

Diff for: test/runtests.jl

+2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ with_logger(debugLogger) do
2020
include("test_currencies.jl")
2121

2222
include("test_instruments.jl")
23+
include("instruments/test_bonds.jl")
2324
include("instruments/test_cash.jl")
25+
include("instruments/test_futures.jl")
2426
include("instruments/test_stocks.jl")
2527

2628
include("test_quotes.jl")

0 commit comments

Comments
 (0)