Skip to content

Some shortcuts for TimeFrame doesn't work like Pandas DateOffsets shortcuts #3

@femtotrader

Description

@femtotrader
TimeFrame("1W")

works as expected but

TimeFrame("W")

raises

ERROR: ArgumentError: invalid base: base must be 2 ≤ base ≤ 62, got 0
 in tryparse_internal(::Type{Int64}, ::SubString{String}, ::Int64, ::Int64, ::Int64, ::Bool) at ./parse.jl:66
 in parse(::Type{Int64}, ::SubString{String}) at ./parse.jl:152
 in parse(::Type{Int64}, ::SubString{String}) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
 in TimeFrames.TimeFrame(::String) at /Users/femto/.julia/v0.5/TimeFrames/src/TimeFrames.jl:7

see femtotrader/TimeSeriesResampler.jl#3

PS:
see also Python Pandas

In [1]: from pandas.tseries.frequencies import to_offset
In [2]: from pandas.tseries.offsets import YearBegin, YearEnd, Hour

In [3]: YearBegin().apply(datetime.datetime(2016, 7, 20, 13, 14, 35, 245))
Out[3]: Timestamp('2017-01-01 13:14:35.000245')

In [4]: YearEnd().apply(datetime.datetime(2016, 7, 20, 13, 14, 35, 245))
Out[4]: Timestamp('2016-12-31 13:14:35.000245')

In [5]: to_offset('AS').apply(datetime.datetime(2016, 7, 20, 13, 14, 35, 245))
Out[5]: Timestamp('2017-01-01 13:14:35.000245')

In [6]: to_offset('A').apply(datetime.datetime(2016, 7, 20, 13, 14, 35, 245))
Out[6]: Timestamp('2016-12-31 13:14:35.000245')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions