January 2020
Intermediate to advanced
532 pages
13h 31m
English
In order to fully utilize the compiler's specialization feature, we should define parametric methods that also make use of the parametric type, like so:
# Return + or - sign for the direction of tradefunction sign(t::SingleTrade{T}) where {T} return t.type == Long ? 1 : -1end# Calculate payment amount for the tradefunction payment(t::SingleTrade{T}) where {T} return sign(t) * t.quantity * t.priceend
Let's test this out:

But hey, we just found a little bug. The option of $3.50 seems too good to be true! When looking at buying/selling options, each option contract actually represents 100 shares of the underlying ...
Read now
Unlock full access