{"id":19113541,"url":"https://github.com/adiled/ohlc-resample","last_synced_at":"2025-08-08T02:40:39.348Z","repository":{"id":42634944,"uuid":"379534766","full_name":"adiled/ohlc-resample","owner":"adiled","description":":candle: Resample (inter-convert) market trades, ticks or OHLCV data to different time frames.","archived":false,"fork":false,"pushed_at":"2025-06-15T20:03:52.000Z","size":383,"stargazers_count":25,"open_issues_count":5,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-09T08:43:26.063Z","etag":null,"topics":["candlestick","candlestick-chart","crypto","ohlcv","ohlcv-convert","ohlcv-resample","technical-analysis","trading"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ohlc-resample","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adiled.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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-06-23T08:35:21.000Z","updated_at":"2025-06-15T18:15:04.000Z","dependencies_parsed_at":"2025-06-28T08:41:04.186Z","dependency_job_id":null,"html_url":"https://github.com/adiled/ohlc-resample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adiled/ohlc-resample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiled%2Fohlc-resample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiled%2Fohlc-resample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiled%2Fohlc-resample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiled%2Fohlc-resample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adiled","download_url":"https://codeload.github.com/adiled/ohlc-resample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiled%2Fohlc-resample/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269355378,"owners_count":24403429,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["candlestick","candlestick-chart","crypto","ohlcv","ohlcv-convert","ohlcv-resample","technical-analysis","trading"],"created_at":"2024-11-09T04:36:34.948Z","updated_at":"2025-08-08T02:40:39.286Z","avatar_url":"https://github.com/adiled.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eohlc-resample 🕯️\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\nResample (inter-convert) trade, ticks or OHLCV data to different time frames\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/ohlc-resample\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Version\" src=\"https://img.shields.io/npm/v/ohlc-resample.svg\"\u003e\n  \u003c/a\u003e\n  \u003cimg alt=\"Downloads\" src=\"https://img.shields.io/npm/dt/ohlc-resample\"\u003e\n  \u003ca href=\"https://github.com/adiled/ohlc-resample#readme\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/badge/documentation-yes-brightgreen.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/adiled/ohlc-resample/graphs/commit-activity\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Maintenance\" src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://coveralls.io/github/adiled/ohlc-resample?branch=master\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Coverage Status\" src=\"https://coveralls.io/repos/github/adiled/ohlc-resample/badge.svg?branch=master\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/adiled/ohlc-resample/blob/master/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: LGPL--3.0\" src=\"https://img.shields.io/github/license/adiled/ohlc-resample\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n- Typescript support\n- CCXT support\n- Single dependency\n- Low time complexity grouping based aggregations\n- Optional gap filling\n\n## Install\n\n```sh\nnpm install --save ohlc-resample\n```\n\n## Supported formats\n\n- OHLCV (CCXT format) `[[time,open,high,low,close,volume]]`\n- OHLCV JSON `[{time: number, open: number, high: number, low: number close: number, volume: number}]`\n- Trade JSON `[{time: number, price: number, quantity: number}]`\n\n## Reference\n\n```typescript\nimport {\n  resampleOhlcv,\n  resampleTicksByTime,\n  resampleTicksByCount,\n} from \"ohlc-resample\";\n\n// OHLCV resampled from 1 minute to 5 minute\n\nresampleOhlcv(objectOhlcv as IOHLCV[], {\n  baseTimeframe: 60,\n  newTimeframe: 5 * 60,\n}); // return IOHLCV[]\nresampleOhlcv(arrayOhlcv as OHLCV[], {\n  baseTimeframe: 60,\n  newTimeframe: 5 * 60,\n}); // return OHLCV[]\n\n// Ticks grouped and resampled to 1m OHCLV\n// option.includeLatestCandle is by default `true`\n// options.fillGaps is by default `false`\n\nresampleTicksByTime(tickData as TradeTick[], {\n  timeframe: 60,\n  includeLatestCandle: false,\n  fillGaps: true,\n}); // return IOHLCV[]\n\n// Ticks grouped and resampled by every 5 ticks\n\nresampleTicksByCount(tickData as TradeTick[], { tickCount: 5 }); // return IOHLCV[]\n```\n\n## Types\n\n```typescript\nexport type IOHLCV = {\n  time: number;\n  open: number;\n  high: number;\n  low: number;\n  close: number;\n  volume: number;\n};\n\nexport type OHLCV = [number, number, number, number, number, number];\n\nexport type TradeTick = {\n  price: number;\n  quantity: number;\n  time: number;\n};\n```\n\n**Note:** Input time for all above types must be in milliseconds\n\n## Examples\n\n**Resample CCXT (Object) OHLCV based on timeframe**\n\n```typescript\nimport { resampleOhlcv } from \"ohlc-resample\";\n\nconst link_btc_1m = [\n  {\n    time: 1563625680000,\n    open: 0.00024824,\n    high: 0.00024851,\n    low: 0.00024798,\n    close: 0.00024831,\n    volume: 2264,\n  },\n  {\n    time: 1563625740000,\n    open: 0.00024817,\n    high: 0.00024832,\n    low: 0.00024795,\n    close: 0.00024828,\n    volume: 3145,\n  },\n];\n\nconst baseTimeframe = 60; // 60 seconds\nconst newTimeframe = 120; // 120 seconds\n\n// Candles made up of ticks within 2 minute timeframes\n\nconst link_btc_2m = resampleOhlcv(link_btc_1m, {\n  baseTimeframe,\n  newTimeframe,\n});\n```\n\n**Resample ticks to OHLCV based on tick count**\n\n```typescript\nimport { resampleTicksByCount, TradeTick } from \"ohlc-resample\";\n\nconst adabnb_trades = [\n  {\n    time: \"1564502620356\",\n    side: \"sell\",\n    quantity: \"4458\",\n    price: \"0.00224\",\n    tradeId: \"1221272\",\n  },\n  {\n    time: \"1564503133949\",\n    side: \"sell\",\n    quantity: \"3480\",\n    price: \"0.002242\",\n    tradeId: \"1221273\",\n  },\n  {\n    time: \"1564503134553\",\n    side: \"buy\",\n    quantity: \"51\",\n    price: \"0.002248\",\n    tradeId: \"1221274\",\n  },\n];\n\nconst airbnb_ticks: TradeTick[] = adabnb_trades.map((trade: any) =\u003e ({\n  time: Number(trade.time),\n  quantity: Number(trade.quantity),\n  price: Number(trade.price),\n}));\n\n// Candles made up of two ticks\n\nconst tickChart = resampleTicksByCount(airbnb_ticks, {\n  tickCount: 2,\n});\n```\n\n## Contributors\n\n👤 **Adil Shaikh \u003chello@adils.me\u003e (https://adils.me)**\n\n- Website: https://adils.me\n- Github: [@adiled](https://github.com/adiled)\n\n👤 Past authors of `candlestick-convert`\n\n## 🤝 Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check [issues page](https://github.com/adiled/ohlc-resample/issues). You can also take a look at the [contributing guide](https://github.com/adiled/ohlc-resample/blob/master/CONTRIBUTING.md).\n\n### Run tests\n\n```sh\nyarn test\n```\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n## 📝 License\n\nCopyright © 2022 [Adil Shaikh \u003chello@adils.me\u003e (https://adils.me)](https://github.com/adiled).\u003cbr /\u003e\nThis project is [LGPL--3.0](https://github.com/adiled/ohlc-resample/blob/master/LICENSE) licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadiled%2Fohlc-resample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadiled%2Fohlc-resample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadiled%2Fohlc-resample/lists"}