{"id":28634789,"url":"https://github.com/seungwoo321/cats","last_synced_at":"2026-04-12T10:40:25.636Z","repository":{"id":39947664,"uuid":"469343546","full_name":"Seungwoo321/cats","owner":"Seungwoo321","description":"Crypto Automated Trading System","archived":false,"fork":false,"pushed_at":"2022-07-18T09:13:41.000Z","size":3688,"stargazers_count":7,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"v2","last_synced_at":"2026-04-12T10:39:53.909Z","etag":null,"topics":["bitcoin","bot","graphql","trading","trading-bot"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Seungwoo321.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}},"created_at":"2022-03-13T10:55:14.000Z","updated_at":"2025-10-18T10:43:05.000Z","dependencies_parsed_at":"2022-09-21T13:00:53.267Z","dependency_job_id":null,"html_url":"https://github.com/Seungwoo321/cats","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Seungwoo321/cats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seungwoo321%2Fcats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seungwoo321%2Fcats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seungwoo321%2Fcats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seungwoo321%2Fcats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seungwoo321","download_url":"https://codeload.github.com/Seungwoo321/cats/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seungwoo321%2Fcats/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31712292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T06:22:27.080Z","status":"ssl_error","status_checked_at":"2026-04-12T06:21:52.710Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["bitcoin","bot","graphql","trading","trading-bot"],"created_at":"2025-06-12T16:30:30.765Z","updated_at":"2026-04-12T10:40:25.620Z","avatar_url":"https://github.com/Seungwoo321.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crypto Automated Trading System (CATS)\n\nAlgorithmic trading bot based on [`grademark's backtest.ts`](https://github.com/Grademark/grademark/blob/master/src/lib/backtest.ts)\n\n\u003e Still in __development__.\n\u003e\n\u003e Currently, only BitMEX exchanges are supported.\n\u003e\n\u003e Added new feature @cats/cli .\n\n## Development environment\n\n- InfluxDB 2.2\n- MariaDB 10.5\n- Node.js 16.15.0\n\n## Prerequirements\n\n- Infrastructure\n  - InfluxDB 2.2 must be installed and [run collector](#run-collector)\n  - MariaDB 10.5 must be installed and [run apollo-server](#run-apollo-server).\n- Define your trading strategy\n\n### Infrastructure\n\nmariadb and influxdb setup automatically.\n\n```bash\ndocker compose up -d\n```\n\n## Getting Started\n\n### Add CLI 'cats'\n\n```bash\ngit clone https://github.com/Seungwoo321/cats.git\ncd cats/packages/cats-cli\nnpm link \n\ncats --version\n```\n\n### Installation\n\n```bash\nnpm install\n```\n\n### build\n\n```bash\nnpm run build \n```\n\n### Lint\n\n```bash\nnpm run lint:fix\n```\n\n## Usage\n\n### run apollo server\n\n```bash\n# dev\nnpm run dev:apollo -w @cats/apollo-server\n\n# production\nnpm run serve:apollo -w @cats/apollo-server\n\n```\n\n### run collector\n\n - Usage 1. one line:\n```bash\ncats collector \\\n    --exchange-id bitmex \\\n    --exchange-mode production \\\n    --symbol BTC/USD:BTC \\\n    --timeframe 1h \\\n    --startDate \"2022-01-01 00:00:00\" \\\n    --endDate \"2022-07-13 00:00:00\" \\\n    --token cats\n```\n\n- Usage 2. interactive:\n```bash\ncats collector\n? Enter a token to access Influx2 (http://localhost:8086) 2QR9pFvw6sNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n? Please select the exchange to collect Bitmex\n? exchangeMode: test\n? Please select an symbol BTC/USD:BTC\n? Please select a time unit 5 min\n? Select a start date:  2022-06-01 12:00:00\n? Select a end date:  2022-06-07 08:38:00\nColleting data... |████████████████████████████████████████| 100% || 20/20 Requsts\n```\n\n### run create bot\n\n- Usage 1. one line:\n\n```bash\n## command\ncats create test-bot \\\n    --symbol BTC/USD:BTC \\\n    --strategy a \\\n    --timeframe 1d \\\n    --exchange-id bitmex\n    --exchange-access-key \u003capi-key\u003e \\\n    --exchagne-secret-key \u003csecret-key\u003e \\\n    --exchange-mode test \n\n## ouptut\nSuccessfully registered. \nrun command: cats list test-bot\n```\n\n- Usage 2. interactive:\n\n```bash\n## command\n$ cats create test-bot\n\n? Please select the exchange to be used by ccxt Bitmex\n? exchangeMode: test\n? Enter the exchange API KEY to be used by ccxt \u003capi-key\u003e\n? Enter the exchange SECRET KEY to be used by ccxt \u003csecret-key\u003e\n? Please select an symbol BTC/USD:BTC\n? Please select a time unit 1 day\n? Please select a strategy name a\n\n## ouptut\nSuccessfully registered. \nrun command: cats list test-bot\n\n```\n\nBoth methods work the __same__\n\n### run bot\n\n```bash\nDEBUG=trading:bitmex,execution-trading:bitmex cats run test-bot\n```\n\n## Define trading strategy\n\n[See here](https://github.com/Grademark/grademark-first-example/blob/master/index.js#L37-L53)\n\nFor example, write the strategy name a as:\n\n```js\n// strategy/a.js \nrequire('data-forge-indicators')\n\nmodule.exports = {\n    // required\n    entryRule: async (enterPostion, args) =\u003e {\n        if (/** If you want to enter a long position */) {\n            await enterPosition({ symbol: args.parameters.symbol, direction: 'long', entryPrice: args.parameters.entryPrice })\n\n        } else if (/** If you want to enter a short position */) {\n            await enterPosition({ symbol: args.parameters.symbol, direction: 'short', entryPrice: args.parameters.entryPrice })\n\n        }\n    },\n    // required\n    exitRule: async (exitPosition, args) =\u003e {\n        if (args.position.direction === 'long') {\n            if (/** If you want to exit long position */) {\n                await exitPosition(args.parameters.symbol)\n            }\n\n        } else {\n            if (/** If you want to exit short position */) {\n                await exitPosition(args.parameters.symbol)\n            }\n        }\n    },\n\n    // option\n    stopLoss: args =\u003e {\n        return args.entryPrice * (5 / 100)\n    },\n\n    // option\n    trailingStopLoss: args =\u003e {\n        return args.entryPrice * (5 / 100)\n    },\n\n    // option\n    prepIndicators: ({ inputSeries }) =\u003e {\n        if (!inputSeries.toArray().length) {\n            return inputSeries\n        }\n        // If you want to add \"Moving Average\"\n        const sma20 = inputSeries\n            .deflate(bar =\u003e bar.close)\n            .sma(20)\n        inputSeries = inputSeries.withSeries('sma20', movingAverage)\n            .skip(20)\n        const sma60 = inputSeries\n            .deflate(bar =\u003e bar.close)\n            .sma(60)\n        inputSeries = inputSeries.withSeries('sma60', movingAverage)\n            .skip(60)\n        const sma60 = inputSeries\n            .deflate(bar =\u003e bar.close)\n            .sma(120)\n        inputSeries = inputSeries.withSeries('sma60', movingAverage)\n            .skip(120)\n        return inputSeries\n    }\n}\n\n// strategy/index.js \nconst a = require('./a')\n\nmodule.exports = {\n    a\n}\n\n```\n\n\n## @cats/cli\n\n```bash\n$ cats --help\n\nUsage: cats \u003ccommand\u003e [options]\n\nOptions:\n  -V, --version                output the version number\n  -h, --help                   display help for command\n\nCommands:\n  create [options] \u003cbot-name\u003e  Configure variables to run the bot application.\n  list [options] [bot-name]    List the bot application configured. Require --all flags or [bot name].\n  delete [options] [bot-name]  Delete the bot application configured. Require --all flags or [bot name].\n  run [options] \u003cbot-name\u003e     run bot created app\n  serve \u003cbot-name\u003e             pm2 start \u003cbot-name\u003e\n  pm2                          pm2 installed in devDependencies\n  collector [options]          Collect candles from exchanges into influxdb.\n  help [command]               display help for command\n\n  Run cats \u003ccommand\u003e --help for detailed usage of given command.\n```\n\n```bash\n$ cats create --help\n\nUsage: cats create [options] \u003cbot-name\u003e\n\nConfigure variables to run the bot application.\n\nOptions:\n  --symbol \u003csymbol\u003e                          currency symbol to apply automatic trading\n  --strategy \u003cstrategy\u003e                      trading strategy e.g ...\n  --timeframe \u003ctimeframe\u003e                    trading cycle. e.g 30m,1h,4h,1d\n  --exchange-id \u003cexchangeId\u003e                 ccxt for EXCHANGE_ID - https://docs.ccxt.com/en/latest/manual.html#instantiation\n  --exchange-api-key \u003cexchangeApiKey\u003e        ccxt for EXCHANGE_API_KEY - https://docs.ccxt.com/en/latest/manual.html#instantiation\n  --exchange-secret-key \u003cexchangeSecretKey\u003e  ccxt for EXCHANGE_SECRET_KEY - https://docs.ccxt.com/en/latest/manual.html#instantiation\n  --exchange-mode \u003cexchangeMode\u003e             ccxt for enable exchange’s sandbox - https://docs.ccxt.com/en/latest/manual.html#testnets-and-sandbox-environments\n  -h, --help                                 display help for command\n\n```\n\n```bash\n$ cats list --help\n\nUsage: cats list [options] [bot-name]\n\nList the bot application configured. Require --all flags or [bot name].\n\nOptions:\n  -a, --all   List all settings.\n  -h, --help  display help for command\n\n```\n\n```bash\n$ cats delete --help\n\nUsage: cats delete [options] [bot-name]\n\nDelete the bot application configured. Require --all flags or [bot name].\n\nOptions:\n  -a, --all   Delete all settings.\n  -h, --help  display help for command\n\n```\n\n```bash\n$ cats run --help\n\nUsage: cats run [options] \u003cbot-name\u003e\n\nrun bot created app\n\nOptions:\n  --symbol \u003csymbol\u003e         currency symbol to apply automatic trading\n  --strategy \u003cstrategy\u003e     trading strategy e.g ...\n  --timeframe \u003ctimeframe\u003e   trading cycle. e.g 30m,1h,4h,1d\n  -c, --capital \u003ccapital\u003e   starting capital. currency is XBt (Satoshi)\n  -f, --force               force to apply capital\n  --skip                    first only skip\n  -h, --help                display help for command\n\n```\n\n```bash\n$ cats serve --help\n\nUsage: cats serve [options] \u003cbot-name\u003e\n\npm2 start \u003cbot-name\u003e\n\nOptions:\n  -c, --capital \u003ccapital\u003e  starting capital. currency is XBt (Satoshi)\n  -f, --force              force to apply capital\n  -h, --help               display help for command\n\n```\n\n```bash\n$ cats collector --help\n\nUsage: cats collector [options]\n\nCollect candles from exchanges into influxdb.\n\nOptions:\n  --exchange-id \u003cexchangeId\u003e      exchange Name to collect data. eg. bitmex\n  --exchange-mode \u003cexchangeMode\u003e  ccxt for enable exchange’s sandbox - https://docs.ccxt.com/en/latest/manual.html#testnets-and-sandbox-environments\n  --symbol \u003csymbol\u003e               currency symbol\n  --timeframe \u003ctimeframe\u003e         trading cycle\n  --startDate \u003cstartDate\u003e         data collection start date\n  --endDate \u003cendDate\u003e             data collection end date\n  --token \u003cinfluxdb-token\u003e        Token for access Influxdb (localhost:8086)\n  -h, --help                      display help for command\n\n```\n\n```bash\n$ cats backtest --help\n\nUsage: cats backtest [options]\n\nbacktesting grademark - https://github.com/Grademark/grademark\n\nOptions:\n  --exchange-id \u003cexchangeId\u003e      exchange Name to collect data. eg. bitmex\n  --exchange-mode \u003cexchangeMode\u003e  ccxt for enable exchange’s sandbox - https://docs.ccxt.com/en/latest/manual.html#testnets-and-sandbox-environments\n  --symbol \u003csymbol\u003e               currency symbol\n  --strategy \u003cstrategy\u003e           trading strategy e.g ...\n  --timeframe \u003ctimeframe\u003e         trading cycle\n  --startDate \u003cstartDate\u003e         backtest start date\n  --endDate \u003cendDate\u003e             backtest end date\n  --token \u003ctoken\u003e                 Token for access Influxdb (localhost:8086)\n  -c, --capital \u003ccapital\u003e         starting capital. currency is XBt (Satoshi)\n  -h, --help                      display help for command\n\n```\n\n\n## License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseungwoo321%2Fcats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseungwoo321%2Fcats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseungwoo321%2Fcats/lists"}