quandl 0.2.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +20 -0
  4. data/Gemfile +14 -0
  5. data/Guardfile +8 -0
  6. data/LICENSE +7 -0
  7. data/README.md +316 -0
  8. data/Rakefile +39 -0
  9. data/UPGRADE.md +143 -0
  10. data/bin/quandl +26 -0
  11. data/dist/resources/pkg/Distribution.erb +15 -0
  12. data/dist/resources/pkg/PackageInfo.erb +6 -0
  13. data/dist/resources/pkg/postinstall +45 -0
  14. data/dist/resources/pkg/quandl +25 -0
  15. data/dist/resources/ruby/PackageInfo +3 -0
  16. data/lib/commander/command/quandl_ext.rb +21 -0
  17. data/lib/quandl/command.rb +45 -0
  18. data/lib/quandl/command/client_ext.rb +1 -0
  19. data/lib/quandl/command/client_ext/user.rb +11 -0
  20. data/lib/quandl/command/compatibility_check.rb +11 -0
  21. data/lib/quandl/command/qconfig.rb +76 -0
  22. data/lib/quandl/command/tasks.rb +15 -0
  23. data/lib/quandl/command/tasks/base.rb +263 -0
  24. data/lib/quandl/command/tasks/delete.rb +58 -0
  25. data/lib/quandl/command/tasks/download.rb +111 -0
  26. data/lib/quandl/command/tasks/info.rb +46 -0
  27. data/lib/quandl/command/tasks/list.rb +40 -0
  28. data/lib/quandl/command/tasks/login.rb +46 -0
  29. data/lib/quandl/command/tasks/update.rb +205 -0
  30. data/lib/quandl/command/tasks/upload.rb +69 -0
  31. data/lib/quandl/command/version.rb +5 -0
  32. data/lib/quandl/utility.rb +2 -0
  33. data/lib/quandl/utility/config.rb +43 -0
  34. data/lib/quandl/utility/ruby_version.rb +143 -0
  35. data/quandl.gemspec +39 -0
  36. data/scripts/compile_ruby_pkg.sh +34 -0
  37. data/scripts/install.sh +51 -0
  38. data/scripts/win/quandl_toolbelt.iss +82 -0
  39. data/spec/lib/quandl/command/delete_spec.rb +31 -0
  40. data/spec/lib/quandl/command/download_spec.rb +42 -0
  41. data/spec/lib/quandl/command/upload_spec.rb +39 -0
  42. data/spec/lib/quandl/command_spec.rb +46 -0
  43. data/spec/spec_helper.rb +20 -0
  44. data/tasks/toolbelt.rake +133 -0
  45. data/tasks/toolbelt.rb +92 -0
  46. data/tasks/toolbelt/build.rb +2 -0
  47. data/tasks/toolbelt/build/darwin.rb +71 -0
  48. data/tasks/toolbelt/build/ruby.rb +105 -0
  49. data/tasks/toolbelt/build/tarball.rb +73 -0
  50. data/tasks/toolbelt/build/windows.rb +25 -0
  51. data/tasks/toolbelt/push.rb +15 -0
  52. data/tasks/toolbelt/storage.rb +28 -0
  53. data/tasks/toolbelt/tar.rb +21 -0
  54. metadata +354 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzJlZmNhNmQ0NWI4MTFlYTEyYjkxZDk1NTM0YTUxMWJlZDBlNzdkZg==
5
+ data.tar.gz: !binary |-
6
+ ZGVmYmQ2YzZiZWFmNGRkNjM2YjBiYmVjMTA1MTdjMTZlMGFhNzY2ZQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OGY2YmY4Njk4MGU1ZjQ1ODIzOWIyN2RlYjFiZTZjZjY1MjRjZDg3YWVmNzNm
10
+ NDJhNzk3OTY3MTJkZDRlMjJmYTJhNzRlN2Q5NjU3YTNlYjRlYjRhNzIwZDVh
11
+ ODExM2YwMGU5YzBiZDNiNjU2MDE3NzE5Y2MxOTc3YmNlZGIxMmE=
12
+ data.tar.gz: !binary |-
13
+ YzU4MzFiNDI5ZjNmNGY5M2JjZjYxMzEzZTI2YTkwODJmZTVjZjdlYTdmN2Mx
14
+ YWQ5YzdjZmJjNTFiYjU3YjI2NWQxOGUxMjRlMjI5ZTY5MDEwNjE2MzcwZTAz
15
+ NWY5MjE0ODUzNzBlYWZhODNlM2Y1NDU2MGY5OWFlYzY5NGYwM2E=
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /Gemfile.lock
2
+ /.idea
3
+ /pkg
4
+ /tmp
5
+ quandl_client-*
6
+ .rvmrc
7
+ *.gem
8
+ *.log
9
+ *.qdf
10
+ data/*
11
+ *.DS_Store
12
+ vendor/*
13
+ build/*
14
+ playground/*
15
+ update/*
16
+ .bundle
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - 1.9.2
7
+ - 1.8.7
8
+
9
+ gemfile:
10
+ - Gemfile
11
+ - gemfiles/activemodel-4.0.gemfile
12
+
13
+ matrix:
14
+ exclude:
15
+ - rvm: 1.8.7
16
+ gemfile: gemfiles/activemodel-4.0.gemfile
17
+ - rvm: 1.9.2
18
+ gemfile: gemfiles/activemodel-4.0.gemfile
19
+
20
+ script: "echo 'COME ON!' && bundle exec rake spec"
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ use_local_gems = ENV['BUNDLE_LOCAL_GEMS'] == "true" && ENV['BUNDLE_LOCAL_DIR']
5
+ local_gem_dir = ENV['BUNDLE_LOCAL_DIR']
6
+
7
+ if use_local_gems
8
+ gem 'quandl_format', path: "#{local_gem_dir}/quandl/format"
9
+ gem 'quandl_client', path: "#{local_gem_dir}/quandl/client"
10
+ gem 'quandl_data', path: "#{local_gem_dir}/quandl/data"
11
+ gem 'quandl_babelfish', path: "#{local_gem_dir}/quandl/babelfish"
12
+ gem 'quandl_operation', path: "#{local_gem_dir}/quandl/operation"
13
+ gem 'quandl_logger', path: "#{local_gem_dir}/quandl/logger"
14
+ end
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ group :specs do
2
+ guard :rspec, cmd: 'bundle exec rspec --fail-fast -f doc --color' do
3
+ watch(%r{^spec/.+_spec\.rb$})
4
+ watch(%r{^(lib/.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5
+ watch('spec/spec_helper.rb') { 'spec' }
6
+ end
7
+ end
8
+
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012-2013 Blake Hilscher
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,316 @@
1
+ # Getting Started
2
+
3
+ The Quandl toolbelt enables you to create and maintain time series data on Quandl.com. The Quandl toolbelt is extremly simple to understand and use. (We use it to maintain the 8 million datasets currently on the site.)
4
+
5
+ ## Installation
6
+
7
+ ### Mac or Linux
8
+
9
+ curl -s http://s3.amazonaws.com/quandl-command/install.sh | bash
10
+
11
+ ### Windows
12
+
13
+ [Executable Installer](http://s3.amazonaws.com/quandl-command/Quandl+Setup.exe)
14
+
15
+ ## Login
16
+
17
+ Once the toolbelt is installed, the next step is to login to Quandl:
18
+
19
+ $ quandl login
20
+ Obtain your token from the API tab on this page: http://www.quandl.com/users/info
21
+ Token: ***************
22
+ You have successfully authenticated!
23
+ username: tammer1
24
+ email: tammer@quandl.com
25
+
26
+ If you have a Quandl password, you can do this:
27
+
28
+ $ quandl login --method password
29
+ quandl login
30
+ Username or Email: Tammer1
31
+ Password: ******
32
+ You've successfully authorized Tammer1!
33
+
34
+ (You might not have a Quandl password if you log in using Github, Google, Linkedin or Twitter)
35
+
36
+ ## Create a Dataset
37
+
38
+ Create [data.csv](https://raw2.github.com/quandl/toolbelt_help/master/data.csv) that looks something like this:
39
+
40
+ code: AAA
41
+ name: My first dataset
42
+ description: It only has two rows.
43
+ -----
44
+ 1999-12-31, 1.23
45
+ 2000-01-01, 4.56
46
+
47
+ Now send it to Quandl:
48
+
49
+ $ quandl upload data.csv
50
+
51
+ <!-- You just created a dataset on Quandl.com: [www.quandl.com/<your username>/AAA](#) -->
52
+
53
+ You just created a dataset on Quandl.com: `www.quandl.com/<your-username>/AAA`
54
+
55
+ ## Update a Dataset
56
+
57
+ The new dataset will now exist on Quandl forever. You can send new data and/or update metadata whenever you want. For example, create [data_update.csv](https://raw2.github.com/quandl/toolbelt_help/master/data_udpate.csv):
58
+
59
+ code: AAA
60
+ description: I am updating this description.
61
+ --
62
+ 2000-01-02, 99.9
63
+
64
+ Now send to Quandl:
65
+
66
+ $ quandl upload data_update.csv
67
+
68
+ Notice that the dataset now has three rows and a new description:
69
+ <!-- [www.quandl.com/<your user name>/AAA](#) -->
70
+ `www.quandl.com/<your-username>/AAA`
71
+
72
+ <!--
73
+ ## An Alternate Update Method
74
+ You might also want to edit it more at [www.quandl.com/edit/<your user name>/FOO](#)
75
+ -->
76
+
77
+ ## Delete a Dataset
78
+
79
+ You can delete the dataset:
80
+
81
+ $ quandl delete AAA
82
+ source_code … created_at: '2014-01-21T15:53:22Z'
83
+ Are you sure? (y/n)
84
+ y
85
+ OK 1241ms AAA
86
+
87
+
88
+
89
+ ## Scrapers and Other Data Producing Programs
90
+
91
+ As long as your program outputs Quandl flavored CSV as above, it is ready for use with the Quandl toolbelt. Consider this scraper, written in both Ruby ([scraper1.rb](https://raw2.github.com/quandl/toolbelt_help/master/scraper1.rb)) and Python ([scraper1.py](https://raw2.github.com/quandl/toolbelt_help/master/scraper1.py)):
92
+
93
+ # This is script that pulls the history of Facebook (FB) stock price from Google.
94
+ # It then prints the data to the screen in CSV format.
95
+ # It prepends the CSV with Quandl metadata (code, name, description)
96
+ #
97
+
98
+
99
+
100
+ If I were to run this script on Jan 31, 2014 I would get this:
101
+
102
+ $ ruby scraper.rb
103
+ code: FB
104
+ name: Facebook Stock Price
105
+ ----
106
+ Date,Open,High,Low,Close,Volume
107
+ 30-Jan-14,62.12,62.50,60.46,61.08,150438699
108
+ 29-Jan-14,54.61,54.95,53.19,53.53,98089932
109
+ ...
110
+
111
+ I can turn the output of this script into a Quandl dataset like this:
112
+
113
+ $ ruby scraper.rb | quandl upload
114
+
115
+ or
116
+
117
+ $ python scraper.py | quandl upload
118
+
119
+ If you download the script and run the above command, you would see the result here:
120
+ <!-- [www.quandl.com/YOU/FB](#) -->
121
+ `www.quandl.com/<your-username>/FB`
122
+
123
+ You can pipe the script to `quandl upload` each day to keep the dataset up to date on Quandl.com. Everytime you send data to an existing dataset the new data is merged with what is already there. (Hence the Quandl toolbelt is ideal for daily data harvesting or loading entire datasets or some combination of the two.)
124
+
125
+ <!--
126
+ Now I send my script to Quandl for regular execution:
127
+
128
+ $ quandl schedule scraper.rb daily 17:30
129
+
130
+ The scraper will be run daily at 17:30 (in your time zone). Every day when it runs, if the script's output is not valid OR the script reports something to STDERR, then you receive an alert email.
131
+
132
+ You now have a dataset on Quandl that refreshes daily!
133
+ -->
134
+
135
+ ## Scheduling Your Scripts
136
+
137
+ This feature is not ready for use yet. When it is ready you will be able to send any script to Quandl. Quandl will then run the script on a schedule and send the output to `quandl upload` for you. You can (optionally) receive emails when the script succeeds or fails.
138
+
139
+ ## Many Datasets via One Input Stream
140
+
141
+ You can send multiple datasets with a single call to `quandl upload`. [Scraper2.rb](https://raw2.github.com/quandl/toolbelt_help/master/scraper2.rb) ([Scraper2.py](https://raw2.github.com/quandl/toolbelt_help/master/scraper2.py)) produces the most recent closing data for two stocks:
142
+
143
+ code: AAPL
144
+ --
145
+ 2000-01-15,88.32,...
146
+
147
+ code: MSFT
148
+ --
149
+ 2000-01-15,44.20,...
150
+
151
+ Then
152
+
153
+ $ python scraper.py | quandl upload
154
+
155
+ Creates or updates both `quandl.com/<your-username>/AAPL` and `quandl.com/<your-username>/MSFT`
156
+
157
+ You can send an infinite number of datasets via one call to `quandl upload`.
158
+
159
+ ## Quandl Flavored CSV
160
+
161
+ Quandl "flavored" CSV is just just plain vanilla CSV prepended with metadata in [YAML](http://en.wikipedia.org/wiki/YAML) format. Metadata is seperated from data by a single line containing one or more dashes "-".
162
+
163
+ ### Quick Reference
164
+
165
+ Here is the entire specification by example for quick reference:
166
+
167
+ # This is a comment. Also note blank lines are allowed; they are simply ignored
168
+
169
+ code: A01 # only (uppercase) letters, numbers and "_" can be used
170
+
171
+ name: My Dataset
172
+
173
+ description: "This data is my dataset. Note the use of quotes so
174
+ that I can use two lines and also use the reserved character ':'"
175
+
176
+ reference_url: www.wsj.com/somewhere # any valid url
177
+
178
+ frequency: daily # frequency is inferred if you omit this field
179
+
180
+ private: true # true => only you can see the dataset on Quandl
181
+
182
+ ----
183
+
184
+ Date,Price,Volume # if omitted on new dataset, default headings are created
185
+ 2012-01-01,32.23 # the csv data. date can be almost any format you want
186
+
187
+ ### Metadata Specifications
188
+
189
+ |Field|Description|Required?|
190
+ |-----|------------|--------|
191
+ |code|a unique id for the dataset; uppercase letters, numbers and "_" are the only characters allowed.|Required|
192
+ |name|a name for the dataset|Strongly Recomended|
193
+ |description|a description for the dataset|Recomended|
194
+ |reference_url|An external URL where the data can be validated. Most datasets on Quandl cite an external source to maximize credability|Optional|
195
+ |frequency|daily, weekly, monthly,quarterly or annual|optional; inferred if omitted|
196
+ |private|true or false; default is false|private data is visible to only you|
197
+
198
+
199
+ ## Example Scrapers
200
+
201
+ ### Shibor
202
+
203
+ [www.shibor.org](http://www.shibor.org) publishes Shibor rates which Quandl republishes at [www.quandl.com/TAMMER1/SHIBOR](http://www.quandl.com/USER_YY/SHIBOR)
204
+
205
+ This dataset is maintained via [this ruby script](https://github.com/tammer/scrapers/blob/master/shibor.rb) that fetches the 10 most recent days of data from Shibor.org.
206
+
207
+ You can run the script to print 10 days of Shibor rates to the screen:
208
+
209
+ curl "https://raw.github.com/tammer/scrapers/master/shibor.rb" | ruby
210
+
211
+ To maintain this dataset on Quandl, we simply run the following on a daily basis:
212
+
213
+ curl "https://raw.github.com/tammer/scrapers/master/shibor.rb" | ruby | quandl upload
214
+
215
+ Each day 10 rows are sent to Quandl. Usually 9 of those rows are redundant, but that is harmless since we replace existing data with exactly the same data. Notice how old data is not affected by the updates.
216
+
217
+ The backfill for this dataset was manually downloaded and converted into a simple CSV file which we then pushed to the site:
218
+
219
+ quandl upload shibor_backfill.csv
220
+
221
+ ### Hsieh Trend Following Factors
222
+
223
+ Professor David Hsieh maintains hedge fund trend following risk factors at [faculty.fuqua.duke.edu/~dah7/HFRFData.htm](https://faculty.fuqua.duke.edu/~dah7/HFRFData.htm). They are available on Quandl at [quandl.com/TAMMER1/TFRF](http://www.quandl.com/USER_YY/TFRF).
224
+
225
+ The data is maintained by running [hsieh.rb](https://github.com/tammer/scrapers/blob/master/hsieh.rb) every day. To see the output of the script:
226
+
227
+ curl "https://raw.github.com/tammer/scrapers/master/hsieh.rb" | ruby
228
+
229
+ To keep the data up to date, we scheduled a daily run of:
230
+
231
+ curl "https://raw.github.com/tammer/scrapers/master/hsieh.rb" | ruby | quandl upload
232
+
233
+ ### Copyright Data
234
+
235
+ Some data publishers provide data on the condition that you not republish it. When scraping such sites, be sure to set the private flag to be true so that only you can see the data, at which point you should be in compliance, since you are simply storing a single copy on a private cloud based repository; (no different from storing a copy on Google Docs or Dropbox).
236
+
237
+ For example, if you happen to need the MSCI Far East Index on Quandl, you can scrape it with a program like [this](https://github.com/tammer/scrapers/blob/master/msci.rb). You then pipe to Quandl as usual, ensuring the private flag is true:
238
+
239
+ curl "https://raw.github.com/tammer/scrapers/master/msci.rb" | ruby | quandl upload
240
+
241
+ Now you have the data you need on Quandl while remaining compliant with MSCI's terms of use.
242
+
243
+ ### Additional Examples
244
+
245
+ |Dataset|Scraper|
246
+ |-------|----|
247
+ | [Litecoin vs USD](http://quandl.com/TAMMER1/LTCUSD)| [litecoin.rb](https://github.com/tammer/scrapers/blob/master/litecoin.rb)|
248
+
249
+ ## Full Reference
250
+
251
+ Other features of the Toolbelt including `quandl download`, `quandl info`, `quandl list` and other minor features are documented in the [Quandl Toolbelt Reference](#) page.
252
+
253
+ ## FAQ
254
+
255
+ ### How can I use ":" in the name or description field?
256
+
257
+ You should put the text in double quotes:
258
+
259
+ code: FOO
260
+ name: My Dataset
261
+ description: "I love colons : : :"
262
+
263
+ From Ruby:
264
+
265
+ puts "description: \"I love colons : : :\" "
266
+
267
+ or
268
+
269
+ puts ' description: "I love colons : : :" '
270
+
271
+ From Python:
272
+
273
+ print "description: \"I love colons : : :\""
274
+
275
+
276
+ ### Are the Datasets Publicly Accessible?
277
+
278
+ You decide. By default it is public. use:
279
+
280
+ private: true
281
+
282
+ To make the dataset visible only to you.
283
+
284
+ ### Can you handle high frequency (intra-day) data?
285
+
286
+ No.
287
+
288
+ ### How to I including Blank or Nils
289
+
290
+ This is how you include nil datums:
291
+
292
+ Code: NIL
293
+ Name: Example Data with Missing Points
294
+ Description: This dataset is for example only.
295
+ --
296
+ Date, High, Low, Mid
297
+ 2005, 1, 2, 3
298
+ 2004, 5, nil, 4
299
+ 2003, ,,9
300
+ 2002, 1, 2, N.a.
301
+
302
+ This dataset can be seen on Quandl right [here](http://www.quandl.com/TAMMER1/NIL)
303
+
304
+ ### Your SHIBOR script seems to download the past 10 days' worth of data...
305
+
306
+ ...Assuming that happens daily, then you'll have overlapping data (e.g., the most recent day's data is new, but the prior nine days worth of data should be in the database already). How does Quandl deal with that? What if the underlying data changes - will Quandl update the previous nine days of data? Will it record what the data used to be based on the 'original' dataset?
307
+
308
+ Answer: If you upload data for dates where data already exists, the new data over-writes the old data. Thus if you send redundant data, it is harmless. Shibor.rb is written this way for two reason: 1) helpful in case the publisher changes something a few days later. 2) helpful if we miss run for a couple of days for some reason.
309
+
310
+ ### A given municipal bond doesn't trade every day. So, if I set up a separate 'id' for each bond, then each day there will be some bonds that get pricing updates and others that don't. Are there any issues with this, or can Quandl handle this kind of 'sparse' data?
311
+
312
+ Sparse data is not a problem.
313
+
314
+ ### My Question is not answered!
315
+
316
+ You best <a href='mailto:connect@quandl.com'>email</a> me then. Put "Toolbelt" in the subject and you go right to the top of my inbox.
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require "bundler"
2
+ require "rake"
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require 'quandl/command'
6
+ require 'pry'
7
+
8
+ task :default => :spec
9
+
10
+ Dir[File.expand_path("../tasks/*.rake", __FILE__)].each do |task|
11
+ puts task
12
+ load task
13
+ end
14
+
15
+ desc "Run all specs"
16
+ RSpec::Core::RakeTask.new(:spec) do |task|
17
+ task.pattern = "spec/**/*_spec.rb"
18
+ end
19
+
20
+
21
+ namespace :rubies do
22
+
23
+ rubies = [
24
+ 'ruby-1.9.3-p194',
25
+ 'ruby-1.9.3-p484',
26
+ 'ruby-2.0.0-p353',
27
+ ]
28
+
29
+ desc "rspec all the rubies"
30
+ task :spec do |t, args|
31
+ rubies.each do |ruby|
32
+ cmd = "rvm #{ruby} do bundle exec rspec"
33
+ puts(cmd)
34
+ system(cmd)
35
+ end
36
+ end
37
+
38
+ end
39
+