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

Provide an example in doc with random values (instead of remote data) #12

Closed
femtotrader opened this issue Dec 1, 2017 · 5 comments
Closed
Assignees
Labels

Comments

@femtotrader
Copy link
Contributor

femtotrader commented Dec 1, 2017

Hello,

A very simple example with random value should probably be given in doc. Maybe something like this (to avoid to rely on remote data, but with a random seed to ensure reproducibility)

srand(1234)
idx=DateTime(2010,1,1):Dates.Hour(1):DateTime(2017,1,1)-Dates.Hour(1)
n = length(idx)
price=100+cumsum(2*(rand(n)-0.5))
volume=rand(n)*1000
ts = TS([price volume], collect(idx), [:price, :volume])

Kind regards

@dysonance
Copy link
Owner

dysonance commented Dec 1, 2017

@femtotrader Thanks for the suggestion, much appreciated. I will try to get to this very soon. This actually raises a good point about having better docs about all the different ways to do constructors.

Like for random number generation, the following would work as well.

using Temporal, Base.Dates
n = 100
k = 4
seed = 1234

srand(seed)
X = TS(rand(n, k))

srand(seed)
Y = TS(rand(n, k), today()-Day(n-1):Day(1):today())

srand(seed)
Z = TS(rand(n, k), today()-Day(n-1):Day(1):today(), [:A,:B,:C,:D])

X == Y == Z  # true

@dysonance dysonance self-assigned this Dec 1, 2017
@dysonance dysonance added the docs label Dec 1, 2017
@femtotrader
Copy link
Contributor Author

k is useless.
What I prefer in my example using cumsum is that you can easily show plots after (like plotting price of a stock)

About doc, you might try Documenter.jl
@iblis17 did an excellent work on JuliaStats/TimeSeries.jl#342

@dysonance
Copy link
Owner

dysonance commented Dec 1, 2017

Good point, will make sure to include cumsum in what gets into the docs

And whoops on k, updated comment to make it non-useless. What is it with me and DRY struggles lately...

But will do both univariate (k=1) and univariate (k>1) examples when I add to docs.

@dysonance
Copy link
Owner

And I've been meaning to spend the time to learn how to use Documenter and finally just get it done but haven't ever gotten around to it. It's on my todo list but feel free to fork and open a PR if you're getting impatient with my documentation laziness and wanna get the process started a bit.

@femtotrader femtotrader mentioned this issue Dec 1, 2017
@dysonance
Copy link
Owner

Made some changes to the readme to include examples with random values, so going to close this for now. Let me know if more to be done on this and can re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants