Skip to content

Commit

Permalink
Fix shortcut without 1
Browse files Browse the repository at this point in the history
  • Loading branch information
femtotrader committed Nov 11, 2016
1 parent c04e7ab commit 92740ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/TimeFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ function TimeFrame(s::String)
if m == nothing
error("Can't parse %s to TimeFrame")
else
tf_typ = _D_STR2TIMEFRAME[m[2]]
value = parse(Int, m[1])
s_freq = m[2]
tf_typ = _D_STR2TIMEFRAME[s_freq]
if m[1] != ""
value = parse(Int, m[1])
else
value = 1
end
tf_typ(value)
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/test_timeframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ tf = TimeFrame("15T")
@test tf.time_period.value == 15
@test typeof(tf) == Minutely

tf = TimeFrame("T")
@test tf.time_period.value == 1
@test typeof(tf) == Minutely

# Grouper
dt = DateTime(2016, 7, 20, 13, 24, 35, 245)

Expand Down

1 comment on commit 92740ce

@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.

Helps #3

Please sign in to comment.