-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using parametric types #5
Comments
Why not using
|
On an higher level, I'd proposed to using the following structure, keeping in mind that it would be used as something like
|
To my understanding, it's generally a bad idea to use abstract types https://docs.julialang.org/en/v1/manual/performance-tips/index.html Moreover type for volume can be different depending of the assets Volume for shares is for example integer |
I indeed suspected a performance implication... Parametric type it is then to cover both |
I think we absolutely need to support volume of several types see https://en.wikibooks.org/wiki/Introducing_Julia/Types same for price so we don't have to be explicit about type to use here It can be |
I personally don't use them... but some people may also want to use Unums! |
I had a const Price = Float64 #Nullable{Float64}
const Volume = Float64 #Nullable{Float64}
const Ticket = Integer #Nullable{Integer}
const Magic = Integer #Nullable{Integer}
const Slippage = Integer #Nullable{Integer}
null_price = NaN #Price()
null_volume = NaN #Volume()
null_datetime = DateTime(0)
null_ticket = -1 #Ticket()
null_magic = -1 #Magic()
null_slippage = -1 #Slippage()
function isnullprice(price::Price)
isnan(price)
end
function isnullvolume(volume::Volume)
isnan(volume)
end
function isnulldatetime(dt::DateTime)
dt == null_datetime
end
function isnullmagic(magic::Magic)
magic == null_magic
end
function isnullslippage(slippage::Slippage)
slippage == null_slippage
end but const Price = Float64 #Nullable{Float64}
const Volume = Float64 #Nullable{Float64} is definitely not the correct way of doing... (that's why I'm not adding this to this repository) |
I also had abstract type AbstractPriceData{Tprice,Tvol} end
struct TickData{Tprice,Tvol} <: AbstractPriceData{Tprice,Tvol}
ask::Tprice
bid::Tprice
volume::Tvol
end
struct BarData{Tprice,Tvol} <: AbstractPriceData{Tprice,Tvol}
open::Tprice
high::Tprice
low::Tprice
close::Tprice
volume::Tvol
adj_close::Tprice
function BarData(open::Tprice, high::Tprice, low::Tprice, close::Tprice, volume::Tvol) where {Tprice, Tvol}
new{Tprice,Tvol}(open, high, low, close, volume, close)
end
function BarData(open::Tprice, high::Tprice, low::Tprice, close::Tprice, volume::Tvol, adj_close::Tprice) where {Tprice, Tvol}
new{Tprice,Tvol}(open, high, low, close, volume, adj_close)
end
end
struct PriceTimedData
time::DateTime
data::AbstractPriceData
end I have just add currently abstract type AbstractPriceData{Tprice,Tvol} end in this repository ( |
I like the |
I think we should absolutely avoid to decide this now! and we should have our structs / functions able to manage any |
I don't either, let's park it for now, we may still explore in the future
Agreed, nothing is set in stone, just brainstorming :) |
Working with |
Similar code improvement than #10 should probably be done in
Unfortunately I can't spend more time on this this week... I let you @roshii have a look at this |
MarketObservables.jl/src/orderbook/base.jl
Lines 7 to 8 in 392499d
doesn't use parametric type but it should because volume can be integer or float
see #3 (comment)
The text was updated successfully, but these errors were encountered: