Ruby on rails 无法将quandl gem添加到我的rails应用程序

Ruby on rails 无法将quandl gem添加到我的rails应用程序,ruby-on-rails,Ruby On Rails,下午好,亲爱的rails开发者。我是Clement,ruby on rails beginer和我刚刚开始我的第一个项目,即创建一个在线商业平台。我的问题是如何在我的应用程序中添加股票图表,但幸运的是,我发现了quandl gem,我听说它非常适合使用。但我现在唯一的问题是如何通过创建查看、控制并将其配置为渲染股票图表,任何人都可以帮助我编写程序代码,并通过快速教程引导我完成该部分,从如何配置gem到如何在视图中渲染提要。非常感谢您的帮助。下面是 Quandl Ruby Client Build

下午好,亲爱的rails开发者。我是Clement,ruby on rails beginer和我刚刚开始我的第一个项目,即创建一个在线商业平台。我的问题是如何在我的应用程序中添加股票图表,但幸运的是,我发现了quandl gem,我听说它非常适合使用。但我现在唯一的问题是如何通过创建查看、控制并将其配置为渲染股票图表,任何人都可以帮助我编写程序代码,并通过快速教程引导我完成该部分,从如何配置gem到如何在视图中渲染提要。非常感谢您的帮助。下面是

Quandl Ruby Client Build Status

The official ruby gem for all your data needs! The Quandl client can be used to interact with the latest version of the Quandl RESTful API.
Deprecation of old package

With the release of our v3 API we are officially deprecating version 2 of the quandl_client ruby gem. We have re-written the package from the ground up and will be moving forward with a 1.x.x package with the name of quandl that will rely on version 3 of our restful api. During this transitional period you can continue to use the old package here:

https://rubygems.org/gems/quandl_client
Installation

gem 'quandl'

Configuration
Option  Explanation     Example
api_key     Your access key     tEsTkEy123456789
api_version     The version you wish to access the api with     2015-04-09

require 'quandl'
Quandl::ApiConfig.api_key = 'tEsTkEy123456789'
Quandl::ApiConfig.api_version = '2015-04-09'

Retrieving Data
Dataset

Retrieving dataset data can be done in a similar way to Databases. For example to retrieve a dataset use its full code:

require 'quandl'
Quandl::Dataset.get('WIKI/AAPL')
=> ... dataset ...

You can also retrieve a list of datasets associated to a database by using the Database helper method:

Quandl::Database.get('WIKI').datasets
=> ... datasets results ...

By default, each list query will return page 1 of the first 100 results (Please see the API Documentation for more detail)
Data

Dataset data can be queried through a dataset. For example:

require 'quandl'
Quandl::Dataset.get('WIKI/AAPL').data
=> ... data ...

you can access the data much like you would other lists. In addition all the data column fields are mapped to their column_names for convenience:

Quandl::Dataset.get('WIKI/AAPL').data.first.date
=> ... date ...

Database

To retrieve a database simply use its code with the get parameter:

require 'quandl'
Quandl::Database.get('WIKI')
=> ... wiki database ...

You can also retrieve a list of databases by using:

Quandl::Database.all
=> ... results ...

Download Entire Database (Bulk Download)

To get the url for downloading all dataset data of a database:

require 'quandl'
Quandl::ApiConfig.api_key = 'tEsTkEy123456789'
Quandl::Database.get('ZEA').bulk_download_url
=> "https://www.quandl.com/api/v3/databases/ZEA/data?api_key=tEsTkEy123456789"

To bulk download all dataset data of a database:

Quandl::ApiConfig.api_key = 'tEsTkEy123456789'
Quandl::Database.get('ZEA').bulk_download_to_file('/path/to/destination/file_or_folder')

The file or folder path can either be specified as a string or as a File.

For bulk download of premium databases, please ensure that a valid api_key is set, as authentication is required.

For both bulk_download_url and bulk_download_to_file, an optional download_type query parameter can be passed in:

Quandl::Database.get('ZEA').bulk_download_to_file('.', params: {download_type: 'partial'})

If download_type is not specified, a complete bulk download will be performed. Please see the API Documentation for more detail.
Working with results
Instance

All data once retrieved is abstracted into custom classes. You can get a list of the fields in each class by using the data_fields method.

require 'quandl'
database = Quandl::Database.get('WIKI')
database.data_fields
=> ["id", "name", "database_code", "description", "datasets_count", "downloads", "premium", "image"]

You can then uses these methods in your code. Additionally you can access the data by using the hash equalivalent lookup.

database = Quandl::Database.get('WIKI')
database.database_code
=> 'WIKI'
database['database_code']
=> 'WIKI'

In some cases name of the fields returned by the API may not be compatible with the ruby language syntax. These will be converted into compatible field names.

data = Quandl::Dataset.get('WIKI/AAPL').data(params: { limit: 1 }).first
data.column_names
=> ["Date", "Open", "High", "Low", "Close", "Volume", "Ex-Dividend", "Split Ratio", "Adj. Open", "Adj. High", "Adj. Low", "Adj. Close", "Adj. Volume"]
data.data_fields
=> ["date", "open", "high", "low", "close", "volume", "ex_dividend", "split_ratio", "adj_open", "adj_high", "adj_low", "adj_close", "adj_volume"]

List

Most list queries will return a paginated list of results. You can check whether the resulting list has more data by using the more_results? method. By default, each list query will return page 1 of the first 100 results (Please see the API Documentation for more detail). Depending on its results you can pass additional params to filter the data:

require 'quandl'
databases = Quandl::Database.all
=> ... results ...
databases.more_results?
=> true
Quandl::Database.all(params: { page: 2 })
=> ... more results ...

Lists also function as arrays and can be iterated through. Note however that using these features will only work on the current page of data you have locally. You will need to continue to fetch results and iterate again to loop through the full result set.

databases = Quandl::Database.all
databases.each { |d| puts d.database_code }
=> ... print database codes ...
databases.more_results?
=> true
Quandl::Database.all(params: { page: 2 }).each { |d| puts d.database_code }
=> ... print more database codes ...

Lists also return metadata associated with the request. This can include things like the current page, total results, etc. Each of these fields can be accessed through a hash or convenience method.

Quandl::Database.all.current_page
=> 1
Quandl::Database.all['current_page']
=> 1

As a convenience method lists can also return their data in CSV form. To do this simply issue the .to_csv method on a list:

databases = Quandl::Database.all.to_csv
=> "Id,Name,Database Code,Description,Datasets Count,Downloads,Premium,Image,Bundle Ids,Plan ...

Additional Links

    Quandl
    Quandl Tools
    API Docs

License