diff --git a/README.md b/README.md new file mode 100644 index 0000000..5028bfa --- /dev/null +++ b/README.md @@ -0,0 +1,97 @@ +# DCAv2 + +Cryptocurrency trading bot. + +## Features + +- DCA/martingale hybrid trading strategy. +- Support for Binance, Gate.io, KuCoin and OKX. +- Spot market only. +- Customizable trading parameters. +- Real-time market data updates. +- Automatic order placement and management. +- Statistics server for building real-time dashboards. +- Additional scripts for stats and analysis. + +## Getting Started + +### ATTENTION: THIS PROGRAM IS A PERSONAL PROJECT AND IS NOT INTENDED TO BE USED BY ANYONE ELSE. USE AT YOUR OWN RISK. + +### Installation + +Step-by-step installation guide: + +1. Clone the repository +```bash +git clone https://gitlab.nicosanchez.com.ar/nicolas/dcav2.git +``` + +2. Navigate to the project directory +```bash +cd DCAv2 +``` + +3. Install dependencies +```bash +pip install requirements.txt +# or +pip install -r requirements.txt +``` + +4. Configure the project +```bash +# There are configuration file examples in the config folder. +``` + +5. Generate keys +```bash +# Generate keys for the statistics server API +cd utils +python3 generate_keys.py +``` + +6. Copy keys to the credentials.py file +```bash +# Copy the generated keys to the credentials.py file in the utils folder. +python3 read_key.db.py +``` + + +## Usage + +Show how to use your project with examples: + +```bash +python3 main.py configs/exchange_config.json --first_start +``` + +If you stop the program and restart it, it will continue from where it left off by removing the --first_start option. + +```bash +python3 main.py configs/exchange_config.json +``` + +## Configuration + +You should have at least one exchange configuration file. If there are no trading pairs included in that configuration, you can add them at runtime using the commander.py script located in the utils folder. + +## Troubleshooting +### API keys +When configuring the API keys, please make sure that you have the correct permissions for the API key. If you are using a test API key, you may need to enable the test mode in the exchange's API settings. + +DO NOT ASSIGN WITHDRAWAL OR TRANSFER PERMISSIONS TO YOUR API KEYS. The only permissions required are spot trading, balance read and market data (which is public anyway) + +### API rate limits + +The program tries to be frugal with the API usage (it was tested with over 30 trading pairs with absolutely no issues), but still beware of running several instances with the same API keys/IP address. + + +## Strategy + +(WIP) + +## Contact + +If you have any questions or issues, please contact me at nicolassanchez@tutanota.com. + +Project Link: https://gitlab.nicosanchez.com.ar/nicolas/dcav2 \ No newline at end of file diff --git a/credentials.py.example b/credentials.py.example new file mode 100644 index 0000000..02f183b --- /dev/null +++ b/credentials.py.example @@ -0,0 +1,14 @@ +def get_credentials(site): + + app_API_key = "" + stats_API_key = "" + + if site=="telegram": + return {"token": "Your Telegram token", + "chatid": "Your Telegram chat-id" + } + elif site=="app_API_key": + return {"app_API_key": app_API_key} + elif site=="stats_API_key": + return {"stats_API_key": stats_API_key} + return {} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d769bc2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +ccxt==4.4.25 +Flask==2.2.2 diff --git a/todo.txt b/todo.txt index e549abc..97e3ce0 100755 --- a/todo.txt +++ b/todo.txt @@ -5,6 +5,7 @@ Mandatory: 2. Instead of giving a list of order_ids to each trader, give a list of the open orders and that's it (for easier future development, partial order fills for example) 3. Deploying script, both for testnet and for mainnet. 4. Maintain local orderbooks for each trading pair. +5. Consolidate vocabulary (trader, pair and bot; instance & trader) Would be nice to have: diff --git a/trader.py b/trader.py index dbd3785..664b56d 100755 --- a/trader.py +++ b/trader.py @@ -453,7 +453,7 @@ class trader: basefee = 0 quotefee = 0 - #Uncomment if you want to guesstimate Binance's fees. + #Uncomment if you want to guesstimate Binance's fees (Should this be a flag?). #if self.broker.get_exchange_name()=="binance": # #Fees of buy orders are charged in base currency, fees of sell orders are charged in quote currency. # try: diff --git a/utils/credentials.py.example b/utils/credentials.py.example new file mode 100644 index 0000000..2fdcc48 --- /dev/null +++ b/utils/credentials.py.example @@ -0,0 +1,26 @@ +TELEGRAM_TOKEN = "Your Telegram token" +TELEGRAM_ID = "Your Telegram chat-id" +TESTNET_API_KEY = "Your statistics server API key (if you are using the testnet)" +MAINNET_API_KEY = "Your statistics server API key" +TESTNET_URL = "Your statistics server testnet URL" +MAINNET_URL = "Your statistics server URL" + + +def get_credentials(site): + if site=="telegram": + return {"token": TELEGRAM_TOKEN, + "chatid": TELEGRAM_ID + } + elif site=="testnet_api_key": + return {"key": TESTNET_API_KEY} + elif site=="mainnet_api_key": + return {"key": MAINNET_API_KEY} + + return {} + +def get_url(site): + if site=="testnet": + return TESTNET_URL + elif site=="mainnet": + return MAINNET_URL + return "" \ No newline at end of file