This Python script serves as the main component of a trading bot designed to automate cryptocurrency trading on the KuCoin exchange platform. The bot utilizes various signals and market data to make trading decisions, with the primary objective of generating profits.
The script relies on the following Python libraries and modules:
signals_model
: Contains thesignal_class
used for analyzing market signals.predictions
: Includes functions for generating predictions and creating CSV files.time
: Provides functionality for time-related operations.datetime
: Enables date and time manipulation.kucoin.client
: Imports the Trade and Market classes for interacting with the KuCoin API.sys
: Offers access to system-specific parameters and functions.logging
: Facilitates logging for monitoring the bot's activities.gspread
: Allows interaction with Google Sheets.tkinter.messagebox
: Provides message box functionality for displaying warnings.
The script requires API credentials to authenticate with the KuCoin exchange. Ensure that the following variables are correctly configured with your API key, API secret, and API passphrase:
api_key
api_secret
api_passphrase
To enable recording of trading results in a Google Sheets document, the script utilizes Google Sheets API. Make sure to set up a service account and provide the path to the service account JSON file in the following line:
creds = ServiceAccountCredentials.from_json_keyfile_name('tradingbot-388122-bf66d2bf966b.json', scope)
Ensure that the specified Google Sheets document ('TRADINGRESULTS' in this case) exists and is accessible by the service account.
The script performs the following main functions:
-
Market Data Retrieval: Fetches market data for the specified cryptocurrency pair (e.g., BTC-USDT) from the KuCoin exchange.
-
Signal Analysis: Analyzes market signals using the
signal_class
fromsignals_model
and generates trading signals. -
Trading Execution: Executes buy or sell orders based on the generated signals, considering parameters such as trading value, profit percentage, and prevent loss percentage.
-
Logging: Logs trading activities, errors, and other relevant information to a log file ('trading_bot.log' in this case).
-
Google Sheets Recording: Records trading results, including timestamps, prices, percentage moves, and trading values, in a Google Sheets document.
-
Continuous Execution: The script runs indefinitely, periodically fetching market data, analyzing signals, and executing trades at specified intervals (e.g., every 3 minutes).
Ensure that all necessary dependencies are installed and the configuration variables are properly set before running the script. Execute the script in a Python environment to start the trading bot.