{"id":22488576,"url":"https://github.com/pirate/crypto-trader","last_synced_at":"2025-08-02T21:31:16.157Z","repository":{"id":37742941,"uuid":"45860798","full_name":"pirate/crypto-trader","owner":"pirate","description":":moneybag: Cryptocurrency trading bot library with a simple example strategy (trading via Gemini).","archived":true,"fork":false,"pushed_at":"2019-04-03T07:23:40.000Z","size":52,"stargazers_count":616,"open_issues_count":2,"forks_count":138,"subscribers_count":62,"default_branch":"master","last_synced_at":"2024-12-06T17:20:25.804Z","etag":null,"topics":["algorithm","bitcoin","bot","coinbase","exchange-api","gemini","market","money","python","strategy","trading"],"latest_commit_sha":null,"homepage":"","language":"Python","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/pirate.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":"2015-11-09T19:17:19.000Z","updated_at":"2024-12-03T14:46:55.000Z","dependencies_parsed_at":"2022-08-24T16:21:34.021Z","dependency_job_id":null,"html_url":"https://github.com/pirate/crypto-trader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pirate/crypto-trader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fcrypto-trader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fcrypto-trader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fcrypto-trader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fcrypto-trader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pirate","download_url":"https://codeload.github.com/pirate/crypto-trader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fcrypto-trader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268456442,"owners_count":24253228,"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-02T02:00:12.353Z","response_time":74,"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":["algorithm","bitcoin","bot","coinbase","exchange-api","gemini","market","money","python","strategy","trading"],"created_at":"2024-12-06T17:18:03.771Z","updated_at":"2025-08-02T21:31:15.791Z","avatar_url":"https://github.com/pirate.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Crypto Trading Bot Framework using the Gemini Exchange\n:moneybag: Python bindings for trading Bitcoin, Ethereum, \u0026 USD on the Gemini.com Exchange API.\n\n---\n## ARCHIVED: Use https://github.com/ccxt/ccxt\n\n## Quickstart\n\n1. **Download \u0026 install**\n```bash\ngit clone https://github.com/pirate/cryto-trader.git\ncd crypto-trader\npip3 install -r requirements.txt\n```\n\n2. **Open https://exchange.gemini.com/settings/api and get an API key \u0026 secret**\n```bash\ncp secrets_default.py secrets.py\nnano secrets.py  # add key \u0026 secret here\n```\n\n3. **Start hacking!**\n```python\nimport gemini_api as api\nfrom symbols import Order, ETH, USD\n\ncurrent_price = USD(api.ticker('ethusd')['last'])\nif current_price \u003e USD(950.00):\n    buy_order = Order(api.new_order('buy', 'ethusd', ETH(0.001), current_price))\n\n    for event in order_events(buy_order.id):\n        print(event)\n```\n\n4. **(Optional) run the example bot**\n```bash\nnano settings.py                   # Confirm your bot parameters\npython3 ./example.py ethusd        # Run the example theshold bot\n```\n\n## Configuration\n\n - **API Key Secrets:** `secrets.py`\n - **Bot Settings:** `settings.py`\n\n## API Documentation\n\n```python\nimport gemini_api as api\nfrom symbols import Order, USD, BTC, ETH\n```\n\n### Data Types\n\n**Currencies:**\n \n - `symbols.USD`: US Dollar `USD(1.25)`\n - `symbols.BTC`: Bitcoin   `BTC(0.000001)`\n - `symbols.ETH`: Ethereum  `ETH(0.0001)`\n\nAll currency symbols are based on the base type `symbols.Currency`.\n\n**Order:**\nAll API functions that deal with order data like `new_order` or `order_status` return a raw json dict from Gemini with the schema below.  It can be converted to a type-checked python object by using `Order(order_json)`.\n```python\norder_json = {\n    \"order_id\": \"44375901\",\n    \"id\": \"44375901\",\n    \"symbol\": \"btcusd\",\n    \"exchange\": \"gemini\",\n    \"avg_execution_price\": \"400.00\",\n    \"side\": \"buy\",\n    \"type\": \"exchange limit\",\n    \"timestamp\": \"1494870642\",\n    \"timestampms\": 1494870642156,\n    \"is_live\": False,\n    \"is_cancelled\": False,\n    \"is_hidden\": False,\n    \"was_forced\": False,\n    \"executed_amount\": \"3\",\n    \"remaining_amount\": \"0\",\n    \"options\": [],\n    \"price\": \"400.00\",\n    \"original_amount\": \"3\",\n}\nbuy_order = Order(order_json)\norder_id = buy_order.id       # values can be accessed as properties\n```\n\n### REST API Functions\nThe Gemini REST API functions documentation can be found here:  \nhttps://docs.gemini.com/rest-api/#requests\n\n**`api.ticker(symbol: str) -\u003e dict`:**  \nGet the ticker price info for a given symbol, e.g.:\n```python\nticker_info = api.ticker('ethusd')\n# {'bid': '914.00', 'ask': '914.44', 'volume': {'ETH': '94530.56656129', 'USD': '83955829.9730076926', 'timestamp': 1515014100000}, 'last': '915.39'}\nlast_price = USD(ticker_info['last'])\n```\n\n**`api.new_order(side: str, symbol: str, amt: Currency, price: Currency) -\u003e dict`:**  \nSubmit a new order to Gemini, e.g:\n```python\nbuy_order = Order(api.new_order('buy', 'ethusd', ETH(0.01), USD(965)))\nsell_order = Order(api.new_order('sell', 'ethusd', ETH(0.01), USD(965)))\n```\n\n**`api.order_status(order_id: str) -\u003e dict`:**  \nGet the updated order info json from Gemini for a given order_id, e.g.:\n```python\nbuy_order = Order(api.order_status('44375901'))\nprint(buy_order.filled_amt)\n```\n\n### WebSocket API Functions\nThe Gemini WebSocket API functions documentation can be found here:  \nhttps://docs.gemini.com/websocket-api/#websocket-request\n\n**`api.order_events(order_id: str) -\u003e Generator[dict]`:**  \nGet a live-updating stream of order events via WebSocket e.g.:\n```python\nfor event in api.order_events('44375901'):\n    print(event)\n```\n\n## Example Bot\n\n\u003cimg src=\"https://i.imgur.com/Hi3EYym.png\" width=\"500px\"/\u003e\n\n`example.py` is a simple example bot that randomly creates some initial buys, then sells the moment it makes a certain threshold percentage of profit.\n\nIt might profit if the market is trending upwards, but generally this strategy [doesn't work](https://gist.github.com/pirate/eac582480aa34b5adda9e6adc1878190) if you want to make any real money.  This code serves as a boilerplate example upon which to build other, more advanced bots.\n\nThis type of tight, risk-averse bot will only make small profits because it never waits for big upward trends to max out, it sells as soon as it goes in the green.  The days where it starts in the red and stays there also end up sucking much of the profit away.\n\n## Roadmap\n\n* Write a meta-trader that spawns multiple traders with tweaked parameters to see which ones make the most money\n* Add GDAX/Coinbase Exchange API bindings\n* Add Bitfinex Exchange API bindings\n\n## Developer Info\n\nThis library is built on Python 3.6 and uses MyPy for type checking.\n\n**Check MyPy types:**\n```bash\nenv MYPYPATH=./stubs mypy example.py\n```\n\n## Disclaimer\n\nI'm not responsible for any money you lose from this code.  The code is MIT Licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirate%2Fcrypto-trader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpirate%2Fcrypto-trader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirate%2Fcrypto-trader/lists"}