diff --git a/Project.toml b/Project.toml index 62f27ab..7b76fe7 100644 --- a/Project.toml +++ b/Project.toml @@ -15,19 +15,21 @@ URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" [weakdeps] Rocket = "df971d30-c9d6-4b37-b8ff-e965b2cb3a40" +TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e" + +[extensions] +RocketExt = "Rocket" +TimeSeriesExt = "TimeSeries" [compat] -julia = "1.9" HTTP = "1.9.15" JSON3 = "1.13.2" Preferences = "1.4.1" URIs = "1.5.0" - -[extensions] -RocketExt = "Rocket" +julia = "1.9" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["Test", "Rocket", "TimeSeries"] diff --git a/ext/TimeSeriesExt.jl b/ext/TimeSeriesExt.jl new file mode 100644 index 0000000..d5b5220 --- /dev/null +++ b/ext/TimeSeriesExt.jl @@ -0,0 +1,31 @@ +module TimeSeriesExt + +using DydxV3 + +using TimeSeries + +function TimeSeries.TimeArray(pnl::Vector{DydxV3.HistoricalPnl}) + timestamp = Vector{DateTime}() + equity = Vector{Float64}() + totalPnl = Vector{Float64}() + netTransfers = Vector{Float64}() + accountId = Vector{String}() + + for idx in eachindex(pnl) + push!(timestamp, pnl[idx].createdAt) + push!(equity, pnl[idx].equity) + push!(totalPnl, pnl[idx].totalPnl) + push!(netTransfers, pnl[idx].netTransfers) + push!(accountId, pnl[idx].accountId) + end + + return TimeArray(( + timestamp=timestamp, + equity=equity, + totalPnl=totalPnl, + netTransfers=netTransfers, + accountId=accountId + )) +end + +end \ No newline at end of file