{"id":36346561,"url":"https://github.com/theorycraft-trading/theory_craft","last_synced_at":"2026-01-11T13:13:20.960Z","repository":{"id":319791461,"uuid":"880229150","full_name":"theorycraft-trading/theory_craft","owner":"theorycraft-trading","description":"Backtesting engine in Elixir","archived":false,"fork":false,"pushed_at":"2025-12-26T09:03:50.000Z","size":445,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-12-27T19:11:04.783Z","etag":null,"topics":["algo-trading","algorithmic-trading","backtesting","backtesting-engine","backtesting-frameworks","backtesting-trading-strategies","finance","financial-markets","forex","forex-trading","investing","investment","investment-strategies","stocks","theorycraft-trading","trading","trading-algorithms","trading-simulator","trading-strategies"],"latest_commit_sha":null,"homepage":"https://theorycraft-trading.com/","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theorycraft-trading.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-29T11:02:11.000Z","updated_at":"2025-12-26T09:03:54.000Z","dependencies_parsed_at":"2025-12-14T00:00:34.155Z","dependency_job_id":null,"html_url":"https://github.com/theorycraft-trading/theory_craft","commit_stats":null,"previous_names":["imnotavirus/theory_craft","theorycraft-trading/theory_craft"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/theorycraft-trading/theory_craft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorycraft-trading%2Ftheory_craft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorycraft-trading%2Ftheory_craft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorycraft-trading%2Ftheory_craft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorycraft-trading%2Ftheory_craft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theorycraft-trading","download_url":"https://codeload.github.com/theorycraft-trading/theory_craft/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorycraft-trading%2Ftheory_craft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28304265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T11:18:18.743Z","status":"ssl_error","status_checked_at":"2026-01-11T11:07:56.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["algo-trading","algorithmic-trading","backtesting","backtesting-engine","backtesting-frameworks","backtesting-trading-strategies","finance","financial-markets","forex","forex-trading","investing","investment","investment-strategies","stocks","theorycraft-trading","trading","trading-algorithms","trading-simulator","trading-strategies"],"created_at":"2026-01-11T13:13:20.423Z","updated_at":"2026-01-11T13:13:20.953Z","avatar_url":"https://github.com/theorycraft-trading.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/theorycraft-trading/theory_craft/actions/workflows/ci.yml/badge.svg)\n[![Documentation](https://img.shields.io/badge/hex.pm-docs-green.svg?style=flat)](https://hexdocs.pm/theory_craft)\n[![Package](https://img.shields.io/hexpm/v/theory_craft.svg)](https://hex.pm/packages/theory_craft)\n\n\u003c!-- MDOC --\u003e\n\n# TheoryCraft\n\n[TheoryCraft](https://github.com/theorycraft-trading/theory_craft) is an open-source, event-driven backtesting and execution engine for quantitative trading, written in Elixir.\n\nTheoryCraft provides a GenStage-based streaming architecture for processing market data through configurable processors and data feeds. Build complex trading strategies with multiple timeframes, technical indicators, and custom processors using a fluent, composable API.\n\nFor tutorials and guides, see the user documentation:\n- https://theorycraft-trading.com/docs/\n\n## ⚠️ Development Status\n\n**This library is under active development and the API is subject to frequent changes.**\n\nBreaking changes may occur between releases as we refine the interface and add new features. We recommend pinning to a specific commit hash if you need stability.\n\n## Installation\n\nTheoryCraft is not yet available on Hex. To use it in your project, add it to your `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:theory_craft, github: \"theorycraft-trading/theory_craft\"}\n  ]\nend\n```\n\n## Quick Start\n\n### Basic Pipeline\n\nBuild a simple market data pipeline with resampling:\n\n```elixir\nalias TheoryCraft.MarketSource\n\n# Create a pipeline that loads tick data and resamples to 5-minute and 1-hour bars\nmarket =\n  %MarketSource{}\n  |\u003e MarketSource.add_data_ticks_from_csv(\"ticks.csv\", name: \"XAUUSD\")\n  |\u003e MarketSource.resample(\"m5\", name: \"XAUUSD_m5\")\n  |\u003e MarketSource.resample(\"h1\", name: \"XAUUSD_h1\")\n\n# Stream events through the pipeline\nfor event \u003c- MarketSource.stream(market) do\n  IO.inspect(event)\nend\n```\n\n### With Technical Indicators\n\nAdd technical indicators using parallel processing:\n\n```elixir\nrequire TheoryCraftTA.TA, as: TA\n\nalias TheoryCraft.MarketSource.MarketEvent\n\nmarket =\n  %MarketSource{}\n  |\u003e MarketSource.add_data_ticks_from_csv(\"ticks.csv\", name: \"XAUUSD\")\n  |\u003e MarketSource.resample(\"m5\", name: \"XAUUSD_m5\")\n  # Indicators are processed in parallel with `add_indicators_layer/2`\n  |\u003e MarketSource.add_indicators_layer([\n    TA.sma(XAUUSD_m5[:close], 20, name: \"sma_20\"),\n    TA.ema(XAUUSD_m5[:close], 50, name: \"ema_50\"),\n    TA.rsi(XAUUSD_m5[:close], 14, name: \"rsi_14\")\n  ])\n  |\u003e MarketSource.add_indicator(TA.atr(\"XAUUSD_m5\", 14, name: \"atr_14\"))\n\nmarket\n|\u003e MarketSource.stream()\n|\u003e Enum.take(100)\n|\u003e Enum.each(fn %MarketEvent{data: data} -\u003e\n  %{\n    \"XAUUSD_m5\" =\u003e bar,\n    \"sma_20\" =\u003e sma,\n    \"ema_50\" =\u003e ema,\n    \"rsi_14\" =\u003e rsi,\n    \"atr_14\" =\u003e atr\n  } = data\n\n  # Your strategy logic here\nend)\n```\n\n### Aggregate Only Completed Bars\n\nFilter out incomplete bars to avoid redundant calculations:\n\n```elixir\nmarket =\n  %MarketSource{}\n  |\u003e MarketSource.add_data_ticks_from_csv(\"ticks.csv\", name: \"XAUUSD\")\n  |\u003e MarketSource.resample(\"m5\", name: \"XAUUSD_m5\", bar_only: true)\n  |\u003e MarketSource.add_indicators_layer([\n    TA.sma(XAUUSD_m5[:close], 20, name: \"sma_20\")\n  ])\n\n# Only emits events when bars are complete\nfor event \u003c- MarketSource.stream(market) do\n  # Process only completed bars\nend\n```\n\n## Features\n\n- **GenStage Pipeline Architecture**: Backpressure-aware streaming with automatic termination handling\n- **Parallel Processing**: Automatic parallelization of independent processors\n- **Multiple Timeframes**: Resample tick data to any timeframe (m1, m5, h1, D, etc.)\n- **Bar Aggregation**: Filter out incomplete bars to reduce redundant calculations\n- **Technical Indicators**: Integration with TheoryCraftTA for technical analysis\n- **Custom Processors**: Implement the `Processor` behaviour for custom transformations\n- **Fluent API**: Build complex pipelines with an intuitive, chainable interface\n- **Memory-Efficient**: Streaming architecture processes data without loading everything into memory\n\n## Examples\n\nFor detailed examples and tutorials, check out the notebooks in the [livebooks](https://github.com/theorycraft-trading/theory_craft/tree/main/livebooks/) directory.\n\n## License\n\nCopyright (C) 2025 TheoryCraft Trading\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheorycraft-trading%2Ftheory_craft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheorycraft-trading%2Ftheory_craft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheorycraft-trading%2Ftheory_craft/lists"}