Skip to content

Commit

Permalink
TimePeriodFrame using Period
Browse files Browse the repository at this point in the history
  • Loading branch information
femtotrader committed Nov 11, 2016
1 parent 30e4897 commit 20e6e4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/TimeFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function TimeFrame(f_group::Function)
end

function TimeFrame(td::Dates.Period; boundary=Begin::Boundary)
CustomTimeFrame(dt-> _d_f_boundary[boundary](dt, td))
T = typeof(td)
TimePeriodFrame{T}(td.value, boundary=boundary)
end


Expand Down
4 changes: 2 additions & 2 deletions test/test_timeframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ dt = DateTime(2016, 7, 20, 13, 24, 35, 245)
tf = TimeFrame(dt -> floor(dt, Dates.Minute(15))) # custom TimeFrame with lambda function as DateTime grouper
@test apply(tf, dt) == DateTime(2016, 7, 20, 13, 15, 0, 0)

tf = TimeFrame(Dates.Minute(15)) # custom TimeFrame using TimePeriod
tf = TimeFrame(Dates.Minute(15)) # TimePeriodFrame using TimePeriod
@test apply(tf, dt) == DateTime(2016, 7, 20, 13, 15, 0, 0)

tf = TimeFrame(Dates.Day(1)) # custom TimeFrame using DatePeriod
tf = TimeFrame(Dates.Day(1)) # TimePeriodFrame using DatePeriod
@test apply(tf, dt) == DateTime(2016, 7, 20, 0, 0, 0, 0)

tf = Yearly()
Expand Down

1 comment on commit 20e6e4e

@femtotrader
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #8

Please sign in to comment.