{"id":19514182,"url":"https://github.com/bhftbootcamp/timearrays.jl","last_synced_at":"2025-11-20T10:02:30.080Z","repository":{"id":242938846,"uuid":"810995698","full_name":"bhftbootcamp/TimeArrays.jl","owner":"bhftbootcamp","description":"Time series handling for Julia","archived":false,"fork":false,"pushed_at":"2024-11-22T01:39:16.000Z","size":1701,"stargazers_count":32,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T21:11:23.364Z","etag":null,"topics":["timeseries"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bhftbootcamp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-05T18:34:26.000Z","updated_at":"2025-02-20T22:29:54.000Z","dependencies_parsed_at":"2024-06-16T08:22:27.081Z","dependency_job_id":"b7b3d189-586b-4496-b98d-3f942832f229","html_url":"https://github.com/bhftbootcamp/TimeArrays.jl","commit_stats":null,"previous_names":["bhftbootcamp/timearrays.jl"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhftbootcamp%2FTimeArrays.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhftbootcamp%2FTimeArrays.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhftbootcamp%2FTimeArrays.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhftbootcamp%2FTimeArrays.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhftbootcamp","download_url":"https://codeload.github.com/bhftbootcamp/TimeArrays.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240762527,"owners_count":19853497,"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":["timeseries"],"created_at":"2024-11-10T23:35:23.056Z","updated_at":"2025-11-20T10:02:30.075Z","avatar_url":"https://github.com/bhftbootcamp.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=docs/src/assets/animation_dark.gif\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=docs/src/assets/animation_light.gif\u003e\n  \u003cimg src=docs/src/assets/animation_light.gif\u003e\n\u003c/picture\u003e\n\n# TimeArrays.jl\n\n[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://bhftbootcamp.github.io/TimeArrays.jl/stable/)\n[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://bhftbootcamp.github.io/TimeArrays.jl/dev/)\n[![Build Status](https://github.com/bhftbootcamp/TimeArrays.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/bhftbootcamp/TimeArrays.jl/actions/workflows/CI.yml?query=branch%3Amaster)\n[![Coverage](https://codecov.io/gh/bhftbootcamp/TimeArrays.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/bhftbootcamp/TimeArrays.jl)\n[![Registry](https://img.shields.io/badge/registry-General-4063d8)](https://github.com/JuliaRegistries/General)\n\nTimeArrays simplifies working with time series data. It offers features like basic math operations, sliding window techniques, data resampling, and handling of missing values.\n\n## Installation\nTo install TimeArrays, simply use the Julia package manager:\n\n```julia\n] add TimeArrays\n```\n\n## Usage\n\nIn this example we perform math operations on several sets of time series.\n\n```julia\nusing Dates\nusing TimeArrays\n\na = TimeArray{DateTime,Float64}([\n    TimeTick(DateTime(\"2024-01-01\"), 1.0),\n    TimeTick(DateTime(\"2024-01-02\"), 4.0),\n    TimeTick(DateTime(\"2024-01-05\"), 2.0),\n    TimeTick(DateTime(\"2024-01-07\"), 5.0),\n])\n\nb = TimeArray{DateTime,Float64}([\n    (DateTime(\"2024-01-02\"), 4.0),\n    (DateTime(\"2024-01-06\"), 2.0),\n    (DateTime(\"2024-01-10\"), 1.0),\n])\n\nc = TimeArray{DateTime,Float64}([\n    DateTime(\"2024-01-01\") =\u003e 2.0,\n    DateTime(\"2024-01-09\") =\u003e 5.0,\n    DateTime(\"2024-01-11\") =\u003e 4.0,\n])\n\njulia\u003e 2(a * b) + b / c\n8-element TimeArray{DateTime, Float64}:\n TimeTick(2024-01-01T00:00:00, NaN)\n TimeTick(2024-01-02T00:00:00, 34.0)\n ⋮\n TimeTick(2024-01-11T00:00:00, 10.25)\n```\n\n\u003e [!NOTE]\n\u003e Since our implementation of arithmetic operations between elements of two TimeArray's is somewhat different from the usual work with arrays, a diagram is provided below that shows how exactly the elements of the time series are related to each other. For more information see [arithmetic section](https://bhftbootcamp.github.io/TimeArrays.jl/stable/pages/arithmetic/) in documentation.\n\n\u003cpre\u003e\ntime:     - - - 1 - - - - 2 - - - - 3 - - - - 4 - - - - 5 - - - - 6 - - - - 7 - - - \u003e\n\n               2.0                 4.0﹉﹉﹉﹉﹉﹉﹉﹉﹉﹉⤵                   6.0\nt_array1:       ● - - - - - - - - - ● - - - - - - - - - - - - - - - - - - - ● - - - \u003e\n                ┊                   ┊                   ┊                   ┊\n   +       [2.0 + NaN]         [4.0 + 3.0]         [4.0 + 5.0]         [6.0 + 5.0]\n                ┊                   ┊                   ┊                   ┊\nt_array2:       X                   ● - - - - - - - - - ● - - - - - - - - - - - - - \u003e\n               NaN                 3.0                 5.0 ﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍⤴\n\nresult:         ● - - - - - - - - - ● - - - - - - - - - ● - - - - - - - - - ● - - - \u003e\n               NaN                 7.0                 9.0                11.0\n\u003c/pre\u003e\n\n\nTimeArrays can also deal with missing values.\n\n```julia\nusing Dates\nusing TimeArrays\n\nnan_values = TimeArray{DateTime,Float64}([\n    TimeTick(DateTime(\"2024-01-02\"), 2.0),\n    TimeTick(DateTime(\"2024-01-04\"), NaN),\n    TimeTick(DateTime(\"2024-01-06\"), NaN),\n    TimeTick(DateTime(\"2024-01-08\"), 8.0),\n])\n\njulia\u003e ta_forward_fill(nan_values)\n4-element TimeArray{DateTime, Float64}:\n TimeTick(2024-01-02T00:00:00, 2.0)\n TimeTick(2024-01-04T00:00:00, 8.0)\n TimeTick(2024-01-06T00:00:00, 8.0)\n TimeTick(2024-01-08T00:00:00, 8.0)\n\njulia\u003e ta_linear_fill(nan_values)\n4-element TimeArray{DateTime, Float64}:\n TimeTick(2024-01-02T00:00:00, 2.0)\n TimeTick(2024-01-04T00:00:00, 4.0)\n TimeTick(2024-01-06T00:00:00, 6.0)\n TimeTick(2024-01-08T00:00:00, 8.0)\n```\n\nHere we calculate the average price between two time series of high and low prices.\n\n```julia\nusing TimeArrays\n\njulia\u003e high_prices = ta_high_price_sample_data()\n2416-element TimeArray{DateTime, Float64}:\n TimeTick(2023-01-01T00:00:08.998, 0.2457)\n TimeTick(2023-01-01T00:00:43.315, 0.2458)\n ⋮\n TimeTick(2023-01-01T23:59:43.246, 0.25)\n\njulia\u003e low_prices = ta_low_price_sample_data()\n2396-element TimeArray{DateTime, Float64}:\n TimeTick(2023-01-01T00:00:08.995, 0.2456)\n TimeTick(2023-01-01T00:00:43.319, 0.2457)\n ⋮\n TimeTick(2023-01-01T23:59:43.252, 0.2499)\n\njulia\u003e (low_prices + high_prices) / 2\n3930-element TimeArray{DateTime, Float64}:\n TimeTick(2023-01-01T00:00:08.995, NaN)\n TimeTick(2023-01-01T00:00:08.998, 0.24565)\n ⋮\n TimeTick(2023-01-01T23:59:43.252, 0.24995)\n```\n\n\u003cdiv align=right\u003e\n\u003cimg src=docs/src/assets/middle_price.png\u003e\n\nVisualized with [LightweightCharts.jl](https://github.com/bhftbootcamp/LightweightCharts.jl).\n\u003c/div\u003e\n\n\u003cbr\u003e\n\nYou can smooth the price data by using different [Moving Average](https://en.wikipedia.org/wiki/Moving_average) algorithms.\n\n```julia\nusing TimeArrays\n\njulia\u003e prices = ta_price_sample_data()\n7777-element TimeArray{DateTime, Float64}:\n TimeTick(2024-04-01T00:00:00.661, 0.6501)\n TimeTick(2024-04-01T00:05:57.481, 0.6505)\n ⋮\n TimeTick(2024-04-30T23:42:11.920, 0.4417)\n\njulia\u003e sma_prices = ta_sma(prices, 20)\n7777-element TimeArray{DateTime, Float64}:\n TimeTick(2024-04-01T00:00:00.661, NaN)\n TimeTick(2024-04-01T00:05:57.481, NaN)\n ⋮\n TimeTick(2024-04-30T23:42:11.920, 0.4403)\n\njulia\u003e wma_prices = ta_wma(prices, 20)\n7777-element TimeArray{DateTime, Float64}:\n TimeTick(2024-04-01T00:00:00.661, NaN)\n TimeTick(2024-04-01T00:05:57.481, NaN)\n ⋮\n TimeTick(2024-04-30T23:42:11.920, 0.4409)\n\njulia\u003e ema_prices = ta_ema(prices, 20)\n7777-element TimeArray{DateTime, Float64}:\n TimeTick(2024-04-01T00:00:00.661, 0.6501)\n TimeTick(2024-04-01T00:05:57.481, 0.6501)\n ⋮\n TimeTick(2024-04-30T23:42:11.920, 0.4399)\n```\n\n\u003cdiv align=right\u003e\n\u003cimg src=docs/src/assets/smoothed_prices.png\u003e\n\nVisualized with [LightweightCharts.jl](https://github.com/bhftbootcamp/LightweightCharts.jl).\n\u003c/div\u003e\n\n\u003cbr\u003e\n\nYou can also use custom types with TimeArrays. Below we convert prices into four-hour candlesticks using resampling.\n\n```julia\nusing Dates\nusing TimeArrays\n\nstruct OHLC\n    open::Float64\n    high::Float64\n    low::Float64\n    close::Float64\nend\n\nfunction ohlc(x::AbstractVector{\u003c:Number})\n    return if isempty(x)\n        ta_nan(OHLC)\n    else\n        OHLC(x[1], maximum(x), minimum(x), x[end])\n    end\nend\n\nTimeArrays.ta_nan(::Type{OHLC}) = OHLC(NaN, NaN, NaN, NaN)\nTimeArrays.return_type(::typeof(ohlc), ::Type{\u003c:Number}) = OHLC\n\njulia\u003e prices = ta_price_sample_data()\n7777-element TimeArray{DateTime, Float64}:\n TimeTick(2024-04-01T00:00:00.661, 0.6501)\n TimeTick(2024-04-01T00:05:57.481, 0.6505)\n ⋮\n TimeTick(2024-04-30T23:42:11.920, 0.4417)\n\njulia\u003e ta_resample(ohlc, prices, Hour(2); closed = CLOSED_RIGHT, label = LABEL_RIGHT)\n360-element TimeArray{DateTime, OHLC}:\n TimeTick(2024-04-01T02:00:00, OHLC(0.6501, 0.6505, 0.6462, 0.6491))\n TimeTick(2024-04-01T04:00:00, OHLC(0.6478, 0.6480, 0.6443, 0.6452))\n ⋮\n TimeTick(2024-05-01T00:00:00, OHLC(0.4396, 0.4436, 0.4396, 0.4417))\n```\n\n\u003cdiv align=right\u003e\n\u003cimg src=docs/src/assets/price_to_candles.png\u003e\n\nVisualized with [LightweightCharts.jl](https://github.com/bhftbootcamp/LightweightCharts.jl).\n\u003c/div\u003e\n\n## Tables.jl Integration\n\nTimeArrays.jl provides seamless integration with the Tables.jl ecosystem, enabling easy interoperability with DataFrames, CSV files, and other tabular data formats.\n\n```julia\nusing TimeArrays, DataFrames, CSV, Dates\nimport Tables\n\n# Create a TimeArray\nta = TimeArray([DateTime(\"2024-01-01\"), DateTime(\"2024-01-02\")], [1.0, 2.0])\n\n# Convert to DataFrame\ndf = DataFrame(ta)\n\n# Convert to any Tables.jl-compatible format\ntable_data = Tables.columntable(ta)\n\n# Create TimeArray from table data\nta_restored = TimeArray(table_data)\n\n# Save to and load from CSV\nCSV.write(\"data.csv\", ta)\nta_from_csv = TimeArray(CSV.File(\"data.csv\"))\n```\n\nFor more details, see the [Tables.jl integration documentation](https://bhftbootcamp.github.io/TimeArrays.jl/stable/pages/tables/).\n\n## Contributing\n\nContributions to TimeArrays are welcome! If you encounter a bug, have a feature request, or would like to contribute code, please open an issue or a pull request on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhftbootcamp%2Ftimearrays.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhftbootcamp%2Ftimearrays.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhftbootcamp%2Ftimearrays.jl/lists"}