Skip to content
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

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

Open
femtotrader opened this issue Nov 9, 2016 · 1 comment

Comments

@femtotrader
Copy link
Owner

femtotrader commented Nov 9, 2016

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')
@femtotrader
Copy link
Owner Author

femtotrader commented Nov 9, 2016

Same for H (instead of 1H) ...
Y should be A (or AS) ...

@femtotrader femtotrader changed the title Some shortcuts for TimeFrame doesn't work like Pandas Some shortcuts for TimeFrame doesn't work like Pandas DateOffsets shortcuts Nov 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant