{"id":13741251,"url":"https://github.com/eddelbuettel/td","last_synced_at":"2025-06-20T17:07:10.216Z","repository":{"id":44631767,"uuid":"336553726","full_name":"eddelbuettel/td","owner":"eddelbuettel","description":"R interface to 'twelvedata' API","archived":false,"fork":false,"pushed_at":"2024-11-17T23:26:44.000Z","size":181,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-20T17:06:12.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eddelbuettel.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-02-06T14:16:09.000Z","updated_at":"2025-06-18T13:04:50.000Z","dependencies_parsed_at":"2025-06-20T17:05:34.929Z","dependency_job_id":null,"html_url":"https://github.com/eddelbuettel/td","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":0.05660377358490565,"last_synced_commit":"3975d64f3fe887bfa89a992f45cc8daf6cdebc0b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eddelbuettel/td","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Ftd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Ftd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Ftd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Ftd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eddelbuettel","download_url":"https://codeload.github.com/eddelbuettel/td/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Ftd/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260985166,"owners_count":23092885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T04:00:57.210Z","updated_at":"2025-06-20T17:07:05.193Z","avatar_url":"https://github.com/eddelbuettel.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":["Data Sources"],"readme":"\n## td: R Access to twelvedata\n\n[![CI](https://github.com/eddelbuettel/td/workflows/ci/badge.svg)](https://github.com/eddelbuettel/td/actions?query=workflow%3Aci)\n[![License](https://eddelbuettel.github.io/badges/GPL2+.svg)](https://www.gnu.org/licenses/gpl-2.0.html)\n[![CRAN](https://www.r-pkg.org/badges/version/td)](https://cran.r-project.org/package=td)\n[![Dependencies](https://tinyverse.netlify.app/badge/td)](https://cran.r-project.org/package=td)\n[![Downloads](https://cranlogs.r-pkg.org/badges/td?color=brightgreen)](https://www.r-pkg.org/pkg/td)\n[![Last Commit](https://img.shields.io/github/last-commit/eddelbuettel/td)](https://github.com/eddelbuettel/td)\n\n### Motivation\n\n[twelvedata](https://twelvedata.com) provides a very rich REST API, see\nthe [documentation](https://twelvedata.com/docs).  While a (free) login\nand a (free, permitting limited but possibly sufficient use) API key are\nrequired, the provided access is rich to set up simple R routines.  This\npackage does that.\n\n### Example\n\nHere we are running (some) code from shown in `example(time_series)` \n\n```r\n\u003e library(td)\n\u003e data \u003c- time_series(\"SPY\", \"5min\", outputsize=500, as=\"xts\")\n\u003e if (requireNamespace(\"quantmod\", quietly=TRUE)) {\n\u003e     suppressMessages(library(quantmod))   # suppress some noise\n\u003e     chartSeries(data, name=attr(data, \"symbol\"), theme=\"white\")  # convenient plot for OHLCV\n\u003e }\n```\n\nretrieves an `xts` object (provided [xts](https://cran.r-project.org/package=xts) is installed) \nand produces a chart like this:\n\n![](https://eddelbuettel.github.io/td/spy.png)\n\nThe package can also be used without attaching it. The next example retrieves twenty years of weekly\nCAD/USD foreign exchange data using a direct `td::time_series()` call with having the package\nloaded.  The API key is automagically set (if it is in fact provided either in the user config file\nor as an environment variable).  Also shown by calling `str()` on the return object is the metadata\nattach after each request:\n\n```r\n\u003e cadusd \u003c- td::time_series(sym=\"CAD/USD\", interval=\"1week\", outputsize=52.25*20, as=\"xts\")\n\u003e str(cadusd)\nAn ‘xts’ object on 2001-02-27/2021-02-01 containing:\n  Data: num [1:1045, 1:4] 0.651 0.646 0.644 0.638 0.642 ...\n - attr(*, \"dimnames\")=List of 2\n  ..$ : NULL\n  ..$ : chr [1:4] \"open\" \"high\" \"low\" \"close\"\n  Indexed by objects of class: [Date] TZ: UTC\n  xts Attributes:  \nList of 6\n $ symbol        : chr \"CAD/USD\"\n $ interval      : chr \"1week\"\n $ currency_base : chr \"Canadian Dollar\"\n $ currency_quote: chr \"US Dollar\"\n $ type          : chr \"Physical Currency\"\n $ accessed      : chr \"2021-02-06 15:16:29.209635\"\n\u003e \n```\n\nAs before, it can be plotted using a function from package\n[quantmod](https://cran.r-project.org/package=quantmod); this time we use the newer\n`chart_Series()`:\n\n```r\n\u003e quantmod::chart_Series(cadusd, name=attr(data, \"symbol\"))\n```\n\n![](https://eddelbuettel.github.io/td/cadusd.png)\n\nAs the returned is a the very common and well-understood [xts] format, many other plotting functions\ncan be used as-is. Here is an example also showing how historical data can be accessed.  We retrieve\nminute-resolution data for `GME` during the late January / early February period:\n\n```r\n\u003e gme \u003c- time_series(\"GME\", \"1min\",\n+                    start_date=\"2021-01-25 09:30:00\",\n+                    end_date=\"2021-02-04 16:00:00\", as=\"xts\")\n```\n\nNote the use of exchange timestamps (NYSE is open from 9:30 to 16:00 local time).\n\nWe can plot this again using `quantmod::chart_Series()` showing how to display ticker symbol\nand exchange as a header:\n\n```r\n\u003e quantmod::chart_Series(gme, name=paste0(attr(gme, \"symbol\"), \"/\", attr(gme, \"exchange\")))\n```\n\n![](https://eddelbuettel.github.io/td/gme.png)\n\nNaturally, other plotting functions and packages can be used. Here we use the _same dataset but\nefficiently subset_ using a key `xts` feature and fed into CRAN package\n[rtsplot](https://rtsvizteam.bitbucket.io/pkg/rtsplot/#/) and requesting OHLC instead of line plot.\n\n```r\n\u003e rtsplot::rtsplot(gme[\"20210128\"], main=\"GME on 2021-Jan-28\", type=\"ohlc\")\n```\n\n![](https://eddelbuettel.github.io/td/gme_20210128.png)\n\n\nIf a vector of symbols is used in the query, a list of results is returned:\n\n```r\n\u003e res \u003c- time_series(c(\"SPY\", \"QQQ\", \"IWM\", \"EEM\"), outputsize=300, as=\"xts\")\n\u003e op \u003c- par(mfrow=c(2,2))\n\u003e sapply(res, function(x) quantmod::chart_Series(x, name=attr(x, \"symbol\")))\n\u003e par(op)\n```\n\nAs of version 0.0.2, additional `get_quote()` and `get_price()` accessors are available.\n\nAs of version 0.0.5, support for reference data has been added.\n\n### Status\n\nStill relatively, but already fairly feature-complete. The package is also officially [recommended\nand approved](https://github.com/twelvedata/twelvedata-r-sdk) by [Twelve\nData](https://twelvedata.com), but is developed independently.  For an officially supported package,\nsee their [twelvedata-python](https://github.com/twelvedata/twelvedata-python) package.\n\n### Contributing\n\nAny problem, bug report, or feature request for the package can be submitted and handled most\nconveniently as a [Github issue](https://github.com/eddelbuettel/td/issues) in the repository.\n\nBefore submitting pull requests, it is frequently preferable to first discuss need and scope in such\nan issue ticket.  See the file\n[Contributing.md](https://github.com/RcppCore/Rcpp/blob/master/Contributing.md) (in the\n[Rcpp](https://github.com/RcppCore/Rcpp) repo) for a brief discussion.\n\n### Author\n\nDirk Eddelbuettel and Kenneth Rose\n\n### License\n\nGPL (\u003e= 2)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Ftd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddelbuettel%2Ftd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Ftd/lists"}