-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an extension to create TimeSeries from HistoricalPnl data
- Loading branch information
1 parent
ef13f6f
commit 8f2e0e2
Showing
2 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |