{"id":13876159,"url":"https://github.com/debut-js/Strategies","last_synced_at":"2025-07-16T10:33:11.294Z","repository":{"id":37040359,"uuid":"370119851","full_name":"debut-js/Strategies","owner":"debut-js","description":"Examples of trading strategies based on indicators. Pre-configured environment for working with the Debut algo-trading constructor. (Javascript)","archived":false,"fork":false,"pushed_at":"2024-03-06T16:26:35.000Z","size":14929,"stargazers_count":163,"open_issues_count":4,"forks_count":56,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-06T10:36:13.244Z","etag":null,"topics":["algo-trading","alpaca","binance","debut","tinkoff-invest","trading","trading-bot","trading-strategies"],"latest_commit_sha":null,"homepage":"https://debutjs.io","language":"TypeScript","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/debut-js.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"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}},"created_at":"2021-05-23T17:48:35.000Z","updated_at":"2025-05-20T00:37:17.000Z","dependencies_parsed_at":"2022-07-09T15:47:17.313Z","dependency_job_id":"d06a1acf-fd44-4b18-aabc-868eb79a186a","html_url":"https://github.com/debut-js/Strategies","commit_stats":{"total_commits":172,"total_committers":8,"mean_commits":21.5,"dds":"0.37790697674418605","last_synced_commit":"b16a007039a81045e9d2fb190a720619c8cc6834"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/debut-js/Strategies","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debut-js%2FStrategies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debut-js%2FStrategies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debut-js%2FStrategies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debut-js%2FStrategies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/debut-js","download_url":"https://codeload.github.com/debut-js/Strategies/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debut-js%2FStrategies/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265419721,"owners_count":23761864,"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":["algo-trading","alpaca","binance","debut","tinkoff-invest","trading","trading-bot","trading-strategies"],"created_at":"2024-08-06T06:01:05.125Z","updated_at":"2025-07-16T10:33:10.367Z","avatar_url":"https://github.com/debut-js.png","language":"TypeScript","funding_links":["https://patreon.com/businessduck","https://www.patreon.com/bePatron?u=57560983"],"categories":["TypeScript","trading-strategies"],"sub_categories":[],"readme":"![npm](https://img.shields.io/npm/v/@debut/community-core)\n![npm](https://img.shields.io/npm/dm/@debut/community-core)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Support me on Patreon](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dbusinessduck%26type%3Dpatrons%26suffix%3DEnterprise%2520users\u0026style=flat)](https://patreon.com/businessduck)\n[![Telegram crypto trading orders stream](https://badgen.net/badge/tg/crypt:stream/blue?icon=telegram)](https://t.me/debutjs)\n[![Telegram stocks trading orders stream](https://badgen.net/badge/tg/stocks:stream/cyan?icon=telegram)](https://t.me/debutjs2)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/debut-js/Core/raw/master/.github/assets/logo-small.png\" /\u003e\n\u003c/p\u003e\n\n# Debut - Trading Framework\n\nDebut is an ecosystem for developing and launching trading strategies. An analogue of the well-known `ZenBot`, but with much more flexible possibilities for constructing strategies. All you need to do is come up with and describe the entry points to the market and connect the necessary [plugins](https://github.com/debut-js/Plugins) to work. Everything else is a matter of technology: **genetic algorithms** - will help you choose the most effective parameters for the strategy (period, stops, and others), **ticker selection module** - will help you find an asset suitable for the strategy (token or share), on which it will work best.\n\nDebut is based on the architecture of the core and add-on plugins that allow you to flexibly customize any solution. The main goal of the entire Debut ecosystem is to simplify the process of creating and launching working trading robots on various exchanges.\n\n## Features\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/debut-js/Core/raw/master/.github/preview.gif\" width=\"800\"\u003e\u003c/p\u003e\n\n- Multiple exchanges API\n- Backtesting with historical data\n- Backtesting results visualization\n- Backtesting live preview\n- Strategy optimisation (genetic algorithms, multi thread)\n- Stretegy overfitting control (Walk-Forward)\n- Cross timeframe candles access\n- Simple working with data using callbacks e.g. [onCandle](#onCandle), [onTick](#onTick), [onDepth](#onDepth) ...\n- Written in TypeScript (JavaScript), may be executed in browser\n- Customizable with [plugins](https://github.com/debut-js/Plugins)\n- Can use community edition for free with limitations\n\n## Available brokers\n\n\u003cp\u003e\n    \u003cimg src=\"https://github.com/debut-js/Core/blob/master/.github/assets/alpaca.png\" alt=\"Alpaca API\" width=\"64\"\u003e\n    \u003cimg src=\"https://github.com/debut-js/Core/blob/master/.github/assets/binance.png\" alt=\"Binance API\" width=\"64\"\u003e\n    \u003cimg src=\"https://github.com/debut-js/Core/blob/master/.github/assets/tinkoffv2.png\" alt=\"Tinkoff API (Russia only)\" width=\"64\"\u003e\n    \u003ca href=\"https://www.patreon.com/bePatron?u=57560983\"\u003e\u003cimg src=\"https://github.com/debut-js/Core/blob/master/.github/assets/buy2.png\" alt=\"Request implementation\" width=\"64\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nDidn't see your broker? You can [donate](https://www.patreon.com/bePatron?u=57560983) for support.\n\n## Community edition\nWe believe in the power of the community! That is why we decided to publish the project. The community version is free, but it has some limitations in commercial use (income from trading startups is not commerce), as well as technical differences in testing strategies. Join the community, join the **[developer chat](https://t.me/joinchat/Acu2sbLIy_c0OWIy)**\n\n## Enterprise edition\n**(Available by [subscription](https://www.patreon.com/bePatron?u=57560983) for $20/mo)**\n\n* Cross timeframe candles access (from lower to higher candles)\n* Advanced tick emulation in backtesting (60+ ticks per candle)\n* Tinkoff and Alpaca supports all timeframes (programmaticaly solved broker issue)\n\nWe are streaming Enterprise-based deals live on our [telegram channel](https://t.me/debutjs)\n\n**Find out the price by sending a request to [debutjs.io@domainsbyproxy.com](mailto:debutjs.io@domainsbyproxy.com)**\n\n**Remember!** Starting a bot and trading in general requires careful study of the associated risks and parameters.\nIncorrect settings can cause serious financial losses.\n\nThe project has two starting trading strategies \"For example\" how to work with the system.\n\n## [CCI Dynamic](/src/strategies/cci-dynamic/) strategy report for last 100 days\n\n\u003cp align=\"center\"\u003e \u003cimg src=\"/.github/report.png\" width=\"800\"\u003e \u003c/p\u003e\n\n**Report analysis**\n\n```\nstartBalance: 500\nbalance: 1183.97\nmaxBalance: 1186.37\nminBalance: 500\nmaxMarginUsage: 1892.54\nprofit: 683.97\nlong: 273\nlongRight: 243\nshort: 282\nshortRight: 277\nabsoluteDD: 21.06\nrelativeDD: 30.31\npotentialDD: 51.9\nmaxWin: 6.21\nmaxLoose: -8.14\nprofitProb: 0.94\nlooseProb: 0.06\navgProfit: 4.54\navgLoose: 47.95\nexpectation: 1.23\nfailLine: 6\nrightLine: 20\navgFailLine: 1.93\navgRightLine: 5.36\nticksHandled: 9637\ncandlesHandled: 9636\n```\n\nStrategy statistics were collected based on the [plugin statistics](https://github.com/debut-js/Plugins/tree/master/packages/stats), follow the link to learn more about the meaning of some statistics.\n\nVisualization is done using the [Report plugin](https://github.com/debut-js/Plugins/tree/master/packages/report).\n\n## System requirements\nTo work, you need [NodeJS 16.xx/npm 7.xx](https://nodejs.org/en/) ([installation instructions](https://htmlacademy.ru/blog/boost/tools/installing-nodejs))\n\n## [Documentation](https://debutjs.io)\n\n## Project file structure\n\n```\n| - .tokens.json - custom access tokens for working with the exchange\n| - schema.json - description of the location of the startup files\n| - public/- folder for finder reports (created when finder starts)\n| - src/\n    | - strategies/\n        | - strategy1/- strategies directory\n            | - bot.ts - Strategy implementation\n            | - meta.ts - Meta data, for launching and for optimization\n            | - cfgs.ts - Configurations, for launching in tester and genetic\n        | - strategy2/\n        ...\n\n```\n\n# Installation and configuration\n\n### Obtaining API tokens\n\n### Installing tokens\n**To work, you need to create a .tokens.json file, add a token to it for work.**\n\nFor Tinkoff ([instructions](https://tinkoffcreditsystems.github.io/invest-openapi/auth)):\n\n```json\n{\n    \"tinkoff\": \"YOUR_TOKEN\",\n    \"tinkoffAccountId\": \"YOUR_ACCOUNT_ID\",\n}\n```\n\n**Get your tinkoff accounts by this hack and copy one of available account identity to `tinkoffAccountId`:**\n\nexecute command `npm run getAccountId`\n\nor\n\n```javascript\ntinkoffTransport.api.users.getAccounts({}).then(res =\u003e {\n    console.log(res);\n});\n```\n\n**For Binance ([instructions](https://www.binance.com/ru/support/faq/360002502072)):**\n```json\n{\n    \"binance\": \"YOUR_TOKEN\",\n    \"binanceSecret\": \"YOUR_SECRET\"\n}\n```\n\n**For Alpaca ([Alpaca instructions](https://alpaca.markets/docs/api-documentation/api-v2/)):**\n```json\n{\n    \"alpacaKey\": \"YOUR_TOKEN\",\n    \"alpacaSecret\": \"YOUR_SECRET\"\n}\n```\n\nAll tokens can be getted by call: `cli.getTokens()` also you can use any field name for the token.\n\n## Installing npm packages\nTo install packages, run:\n```bash\nnpm install\n```\n\n## Creating strategy\nCommand will create strategy in src/strategies direction with bot.ts, cfgs.ts and meta.ts files inside and add it to schema.json\n```bash\nnpm run plop StrategyName\n```\n\n## Build the project\n```bash\nnpm run compile\n```\n\n*It is recommended to build before each test run*\n\n` npm run compile \u0026\u0026 npm run ... `\n\n## Start testing on historical data\nHistorical data will be loaded automatically at startup All loaded data is saved in the `history` folder in the root of the project, then reused.\n\n**Before starting, make sure:**\n* The `cfgs.ts` file contains the ticker you need\n* To get history in the` .tokens.json file `a token may be required\n* The history of a stock or token exists in the requested number of days\n\nTo start, run the command:\n```bash\nnpm run testing -- --bot=FTBot --ticker=CRVUSDT --days=200 --gap=20\n```\n\nTo view the test results in a browser, execute\n```bash\nnpm run serve\n```\n\nThe results will be available for viewing on `http://localhost: 5000/`\n\nYou can read more about the test run parameters in the [documentation](https://debutjs.io/ru/#/)\n\n## Run genetic optimization\n\nRun the command:\n\n```bash\nnpm run genetic -- --bot=FTBot --ticker=CRVUSDT --days=200 --gap=30 --gen=12 --pop=2000\n```\n\nor with gap 60 days from now, and WFO enabled with type `rolling` also available `--wfo` default type is 'anchored' wfo\n\n```bash\nnpm run genetic -- --ticker=BTCUSDT --bot=FTBot --amount=500 --gen=25 --pop=10000 --days=300 --gap=60 --wfo=rolling\n```\n\nMore details about the launch parameters of the genetics can be found in the [documentation](https://debutjs.io/)\n\nAfter starting with the --log parameter, the geneticist will output data to the console\n\n```bash\nBinance history loading from Wed Nov 18 2020 03:00:00 GMT + 0300 (Moscow Standard Time) ...\n\n----- Genetic Start with 17314 candles -----\n\nGeneration: 0\nGeneration time: 5.15 s\nStats: {\n   population: 100,\n   maximum: 20.8,\n   minimum: -1.24,\n   mean: 2.5174,\n   stdev: 3.8101996325652054\n}\nGeneration: 1\n...\n```\n\n## Run genetic optimization with tickers/tokens selection\nRun the command:\n```bash\nnpm run finder -- --bot=FTBot --ticker=CRVUSDT --days=200 --gap=30 --gen=12 --pop=2000 --log\n```\nUse the `--crypt` option to take crypto pairs from the`./Crypt.json` file (By default, there are actual Binance cross-margin pairs)\n\nBy default, a set of stock tickers is used for streaming optimization from the file `stocks.json`\n\nYou can read more about the parameters for launching streaming genetics in the [documentation](https://debutjs.io/)\n\n## Starting a strategy\n\nInstall any process manager for NodeJS, for example PM2,,,\n\n```bash\nnpm install -g pm2\n```\n\nExecute the launch command, the path to the strategy launch file in the `./Out` directory.\nAn example of such a file can be found here `/src/bootstrap.ts`\n\n``` bash\npm2 start ./out/bootstrap.js\n```\n\nFurther, for operation and monitoring, you can use `pm2` command:\n\n`pm2 list` - a list of active processes\n\n`pm2 delete $ pid` - stop a process\n\n`pm2 log` - to view the logs of running processes\n\nand other commands, which can be found in the documentation of the process manager.\n\n# Debut is flexible for any tools\n\n## Buy / Sell ratio\n\nA measure of the activity rating of buyers and sellers for several pairs. This tool is based on the method of counting all purchases listed on the exchange and all sales, they are calculated for several large tokens dominating the market. Parameter `tickers` = ['ETH', 'BTC', 'ETC', 'XRP']; A fast and slow moving average (SMA) is used to smooth and track changes in activity. Further, for less voluminous tokens (altcoins), the correlation between the change in their price and the change in the buyer's index is calculated. Deals are formed for a certain coin according to the simple logic that if the buyer's activity is above 50% and the price correlation is high, or the share of buyers is less than 50% and the price correlation is high (falling).\n\n#### Start\n```bash\nnpm run compile \u0026\u0026 node ./out/tools/buysellratio/index.js\n```\n\n### Screenshot\n![preview](https://github.com/debut-js/Core/raw/master/.github/assets/workflows/bsratio.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebut-js%2FStrategies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdebut-js%2FStrategies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebut-js%2FStrategies/lists"}