bitunix-automated-crypto-trading 2.6.6__tar.gz → 2.6.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading.egg-info → bitunix_automated_crypto_trading-2.6.8}/PKG-INFO +36 -36
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/README.md +273 -273
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/AsyncThreadRunner.py +81 -81
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/BitunixApi.py +278 -278
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/BitunixSignal.py +1099 -1099
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/BitunixWebSocket.py +254 -254
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/DataFrameHtmlRenderer.py +74 -74
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/NotificationManager.py +23 -23
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/ThreadManager.py +68 -68
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/TickerManager.py +635 -635
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/bitunix.py +597 -593
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/config.py +90 -90
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/logger.py +84 -84
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8/bitunix_automated_crypto_trading.egg-info}/PKG-INFO +36 -36
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading.egg-info/SOURCES.txt +1 -18
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/setup.cfg +4 -4
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/setup.py +115 -115
- bitunix_automated_crypto_trading-2.6.6/MANIFEST.in +0 -7
- bitunix_automated_crypto_trading-2.6.6/RUNNING.md +0 -52
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/config.txt +0 -60
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/sampleenv.txt +0 -5
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/static/chart.css +0 -28
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/static/chart.js +0 -362
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/static/modal.css +0 -68
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/static/modal.js +0 -147
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/static/script.js +0 -166
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/static/styles.css +0 -118
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/templates/charts.html +0 -98
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/templates/login.html +0 -19
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/templates/main.html +0 -551
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/templates/modal-chart.html +0 -26
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/templates/modal-config.html +0 -34
- bitunix_automated_crypto_trading-2.6.6/bitunix_automated_crypto_trading/templates/modal-logs.html +0 -15
- bitunix_automated_crypto_trading-2.6.6/requirements.txt +0 -33
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading/__init__.py +0 -0
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading.egg-info/dependency_links.txt +0 -0
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading.egg-info/entry_points.txt +0 -0
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading.egg-info/requires.txt +0 -0
- {bitunix_automated_crypto_trading-2.6.6 → bitunix_automated_crypto_trading-2.6.8}/bitunix_automated_crypto_trading.egg-info/top_level.txt +0 -0
@@ -1,36 +1,36 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: bitunix_automated_crypto_trading
|
3
|
-
Version: 2.6.
|
4
|
-
Summary: Bitunix Futures Auto Trading Platform
|
5
|
-
Home-page: https://github.com/tcj2001/bitunix-automated-crypto-trading
|
6
|
-
Author: tcj2001
|
7
|
-
Author-email: thomsonmathews@hotmail.com
|
8
|
-
License: MIT
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
11
|
-
Classifier: Operating System :: OS Independent
|
12
|
-
Requires-Python: >=3.13
|
13
|
-
Requires-Dist: fastapi
|
14
|
-
Requires-Dist: uvicorn
|
15
|
-
Requires-Dist: fastapi-login
|
16
|
-
Requires-Dist: python-multipart
|
17
|
-
Requires-Dist: jinja2
|
18
|
-
Requires-Dist: python-dotenv
|
19
|
-
Requires-Dist: pydantic
|
20
|
-
Requires-Dist: pydantic-settings
|
21
|
-
Requires-Dist: websockets
|
22
|
-
Requires-Dist: requests
|
23
|
-
Requires-Dist: aiohttp
|
24
|
-
Requires-Dist: pytz
|
25
|
-
Requires-Dist: cryptography
|
26
|
-
Requires-Dist: colorama
|
27
|
-
Requires-Dist: pandas
|
28
|
-
Requires-Dist: numpy
|
29
|
-
Dynamic: author
|
30
|
-
Dynamic: author-email
|
31
|
-
Dynamic: classifier
|
32
|
-
Dynamic: home-page
|
33
|
-
Dynamic: license
|
34
|
-
Dynamic: requires-dist
|
35
|
-
Dynamic: requires-python
|
36
|
-
Dynamic: summary
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: bitunix_automated_crypto_trading
|
3
|
+
Version: 2.6.8
|
4
|
+
Summary: Bitunix Futures Auto Trading Platform
|
5
|
+
Home-page: https://github.com/tcj2001/bitunix-automated-crypto-trading
|
6
|
+
Author: tcj2001
|
7
|
+
Author-email: thomsonmathews@hotmail.com
|
8
|
+
License: MIT
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Operating System :: OS Independent
|
12
|
+
Requires-Python: >=3.13
|
13
|
+
Requires-Dist: fastapi
|
14
|
+
Requires-Dist: uvicorn
|
15
|
+
Requires-Dist: fastapi-login
|
16
|
+
Requires-Dist: python-multipart
|
17
|
+
Requires-Dist: jinja2
|
18
|
+
Requires-Dist: python-dotenv
|
19
|
+
Requires-Dist: pydantic
|
20
|
+
Requires-Dist: pydantic-settings
|
21
|
+
Requires-Dist: websockets
|
22
|
+
Requires-Dist: requests
|
23
|
+
Requires-Dist: aiohttp
|
24
|
+
Requires-Dist: pytz
|
25
|
+
Requires-Dist: cryptography
|
26
|
+
Requires-Dist: colorama
|
27
|
+
Requires-Dist: pandas
|
28
|
+
Requires-Dist: numpy
|
29
|
+
Dynamic: author
|
30
|
+
Dynamic: author-email
|
31
|
+
Dynamic: classifier
|
32
|
+
Dynamic: home-page
|
33
|
+
Dynamic: license
|
34
|
+
Dynamic: requires-dist
|
35
|
+
Dynamic: requires-python
|
36
|
+
Dynamic: summary
|
@@ -1,273 +1,273 @@
|
|
1
|
-
# Bitunix Futures Auto Trading Platform
|
2
|
-
|
3
|
-
A real-time cryptocurrency trading platform built with FastAPI and WebSocket technology using Bitunix API and websockets for Futures. The platform provides automated trading capabilities, real-time market data visualization, and portfolio management features.
|
4
|
-
|
5
|
-
## Features
|
6
|
-
- Real-time private account/new postion/new order data streaming via WebSocket
|
7
|
-
- Real-time public depth/kline for bid, ask and last streaming via WebSocket or thru api calls, configurable in the config file
|
8
|
-
- Automated trading strategies based on technical indicators
|
9
|
-
- Portfolio management and position tracking
|
10
|
-
- User interface is not a requirement for automated trading, all parmaeters can be configured in the config file
|
11
|
-
- login page
|
12
|
-
- main page:
|
13
|
-
- Interactive web interface with real-time updates, allows manual trading
|
14
|
-
- Real-time portfolio value
|
15
|
-
- Open positions, with signals and strength
|
16
|
-
- Active orders
|
17
|
-
- selected signals with strength
|
18
|
-
- all signals with strength
|
19
|
-
- position history
|
20
|
-
- clicking on the ticker symbol will open the current selected period chart in modal window
|
21
|
-
- notification are written to log file and can be displayed by clicking the message bar
|
22
|
-
- Config button allows to edit the confix.txt file directly from the app
|
23
|
-
- Candlestick charts for all timeframes (1m, 5m, 15m, 1h, 1d) on a single page avaible when you click the charts button
|
24
|
-
- Technical analysis including:
|
25
|
-
- Moving Averages
|
26
|
-
- MACD
|
27
|
-
- Bollinger Bands
|
28
|
-
- RSI
|
29
|
-
- Brearish or bullish candle based on the close near high or low of the current candle
|
30
|
-
- strength based on consecutive colored candles count
|
31
|
-
- ADX
|
32
|
-
- control study using the environment variables
|
33
|
-
- Secure authentication system
|
34
|
-
- Configurable trading parameters
|
35
|
-
- Real-time notifications
|
36
|
-
- Logging system with colored output
|
37
|
-
- Update environment variables without restarting the application
|
38
|
-
|
39
|
-
|
40
|
-
## Configuration
|
41
|
-
.env file
|
42
|
-
- `API_KEY`: Bitunix API key
|
43
|
-
- `SECRET_KEY`: Bitunix secret key
|
44
|
-
- `SECRET`: JWT secret for authentication, some string like "7c4c22ef6ad145f922c72f5a18047b6bf6eff983381c975c"
|
45
|
-
- `PASSWORD`: Password for the web interface
|
46
|
-
- `HOST`: Host IP address (e.g., 0.0.0.0 for server, 127.0.0.1 for local)
|
47
|
-
|
48
|
-
The platform can be configured through the `config.py` file or `config.txt`. Key configuration parameters include:
|
49
|
-
- Trading Parameters:
|
50
|
-
- `AUTOTRADE` : True or False
|
51
|
-
- `LEVERAGE`: Trading leverage (1-100)
|
52
|
-
- `THRESHOLD`: Ticker selection based close near high or low of the day
|
53
|
-
- `MIN_VOLUME`: Ticker selection based on Minimum trading volume
|
54
|
-
- `ORDER_AMOUNT_PERCENTAGE`: Order size as percentage of portfolio
|
55
|
-
- `MAX_AUTO_TRADES`: Maximum number of automated trades
|
56
|
-
- `PROFIT_AMOUNT`: Target profit amount
|
57
|
-
- `LOSS_AMOUNT`: Maximum loss amount
|
58
|
-
- `OPTION_MOVING_AVERAGE`: Moving average period (1h, 1d, 15m, 5m, 1m)
|
59
|
-
- `BARS`: Number of bars to use for study and charting
|
60
|
-
|
61
|
-
- `Technical Indicators Parameters`:
|
62
|
-
- `MA_FAST`: Fast moving average period
|
63
|
-
- `MA_MEDIUM`: Medium moving average period
|
64
|
-
- `MA_SLOW`: Slow moving average period
|
65
|
-
- `RSI_FAST`: Fast RSI period
|
66
|
-
- `RSI_SLOW`: Slow RSI period
|
67
|
-
- `BBM_PERIOD`: Bollinger Band middle period
|
68
|
-
- `BBM_STD`: Bollinger Band standard deviation
|
69
|
-
- `MACD_PERIOD`: MACD period
|
70
|
-
- `MACD_SHORT`: MACD short period
|
71
|
-
- `MACD_LONG`: MACD long period
|
72
|
-
- `ADX_PERIOD`: ADX period
|
73
|
-
|
74
|
-
- `Study Parameters`:
|
75
|
-
- `EMA_STUDY`: Enable EMA study
|
76
|
-
- `EMA_CROSSING`: Check EMA crossing or crossed, COMPARING FAST AND MEDIUM MOVING AVERAGE
|
77
|
-
- `EMA_CHECK_ON_OPEN`: Check EMA on open
|
78
|
-
- `EMA_CHECK_ON_CLOSE`: Check EMA on close
|
79
|
-
|
80
|
-
- `MACD_STUDY`: Enable MACD study
|
81
|
-
- `MACD_CROSSING`: Check MACD crossing or crossed, comparing MACD line and signal line
|
82
|
-
- `MACD_CHECK_ON_OPEN`: Check MACD on open
|
83
|
-
- `MACD_CHECK_ON_CLOSE`: Check MACD on close
|
84
|
-
|
85
|
-
- `BBM_STUDY`: Enable Bollinger Band study
|
86
|
-
- `BBM_CROSSING`: Check Bollinger Band crossing or crossed, comparing close and middle line
|
87
|
-
- `BBM_CHECK_ON_OPEN`: Check Bollinger Band on open
|
88
|
-
- `BBM_CHECK_ON_CLOSE`: Check Bollinger Band on close
|
89
|
-
|
90
|
-
- `RSI_STUDY`: Enable RSI study
|
91
|
-
- `RSI_CROSSING`: Check RSI crossing or crossed, comparing fast and slow RSI
|
92
|
-
- `RSI_CHECK_ON_OPEN`: Check RSI on open
|
93
|
-
- `RSI_CHECK_ON_CLOSE`: Check RSI on close
|
94
|
-
|
95
|
-
- `ADX_STUDY`: Enable ADX study
|
96
|
-
- `ADX_CHECK_ON_OPEN`: Check ADX on open
|
97
|
-
- `ADX_CHECK_ON_CLOSE`: Check ADX on close
|
98
|
-
|
99
|
-
- `CANDLE_TREND_STUDY`: Enable candle trend study
|
100
|
-
- `CANDLE_TREND_CHECK_ON_OPEN`: Check candle trend on open
|
101
|
-
- `CANDLE_TREND_CHECK_ON_CLOSE`: Check candle trend on close
|
102
|
-
|
103
|
-
- `intervals`:
|
104
|
-
- `SCREEN_REFRESH_INTERVAL`: Screen refresh interval
|
105
|
-
- `SIGNAL_CHECK_INTERVAL`: Signal check interval
|
106
|
-
- `PORTFOLIO_API_INTERVAL`: Portfolio API interval
|
107
|
-
- `PENDING_POSITIONS_API_INTERVAL`: Pending positions API interval
|
108
|
-
- `PENDING_ORDERS_API_INTERVAL`: Pending orders API interval
|
109
|
-
- `TRADE_HISTORY_API_INTERVAL`: Trade history API interval
|
110
|
-
- `POSITION_HISTORY_API_INTERVAL`: Position history API interval
|
111
|
-
- `TICKER_DATA_API_INTERVAL`: Ticker data API interval
|
112
|
-
- `PUBLIC_WEBSOCKET_RESTART_INTERVAL`: Public WebSocket restart interval
|
113
|
-
|
114
|
-
- Currently not using public websocket for depth and ticker data as the data is lagging or missing sometime
|
115
|
-
- `USE_PUBLIC_WEBSOCKET`: True or False
|
116
|
-
|
117
|
-
- Logging Parameters:
|
118
|
-
- `VERBOSE_LOGGING`: True or False
|
119
|
-
|
120
|
-
## User Interface
|
121
|
-
|
122
|
-
- Access the web interface:
|
123
|
-
- Open your browser and navigate to `http://localhost:8000` or `http://your_server_ip:8000`
|
124
|
-
- Log in with your credentials (currenly user is admin and password is your_password in env file)
|
125
|
-
- display charts for all timeframes (1m, 5m, 15m, 1h, 1d) on a single page with all indicators when you click charts button
|
126
|
-
- edit the config file directly from the app
|
127
|
-
- display the log messages in amodal window by clicking the message bar
|
128
|
-
|
129
|
-
- Monitor your positions and trades:
|
130
|
-
- Real-time portfolio value
|
131
|
-
- Open positions
|
132
|
-
- Active orders
|
133
|
-
- Trading signals
|
134
|
-
- Position history
|
135
|
-
- Manual trading using buy, sell, add, reduce buttons
|
136
|
-
|
137
|
-
- Autotrade using the AutoTrade checkbox
|
138
|
-
- you can change
|
139
|
-
- Moving Average period
|
140
|
-
- Max auto trades
|
141
|
-
- Take Profit amount
|
142
|
-
- Accept Loss amount
|
143
|
-
- You can control the study like Moving Average, MACD, Bollinger Band, RSI or close proximity to high or low of the candle using the env file
|
144
|
-
- You can control the trading strategy using the CalculateStudy function in TickerManager.py and AutoTradeProcess function in BitunixSignal.py
|
145
|
-
- Changes are activated by unchecking and checking the AutoTrade checkbox
|
146
|
-
|
147
|
-
## Auto Trading
|
148
|
-
|
149
|
-
- Automated Trading Algorithm is customizable:
|
150
|
-
- It allow you to select the moving average period (1h, 1d, 15m, 5m, 1m)
|
151
|
-
- It allow to select how many auto trades you want to open at a time
|
152
|
-
- CalculateStudy Function inside TickerManager.py (Interval class)
|
153
|
-
- You can setup current_signal (BUY,SELL,HOLD) and signal_strength (numeric value) based on your strategy
|
154
|
-
- current_signal can be setup based on Moving Average, MACD, Bollinger Band, RSI or close proximity to high or low of the candle
|
155
|
-
- signal_strength can be setup based on number of consecutive green or red candles or any other strategy
|
156
|
-
- AutoTradeProcess function inside BitunixSignal.py, you can setup your opening and closing trading strategy
|
157
|
-
- User interface will list the stocks in the signal window with BUY or SELL signal based on the descending value of signal_strength
|
158
|
-
- All study can be controlled thru environment variables
|
159
|
-
- Auto trade process open the trade based on following conditions:
|
160
|
-
- If the current candle is bullish
|
161
|
-
and moving average is above the medium moving average
|
162
|
-
and MACD_line > Signal_line
|
163
|
-
and RSI is above the long RSI
|
164
|
-
and current close is above bollinger band middle line
|
165
|
-
and ADX is above 25 (STRONG)
|
166
|
-
it will open long position
|
167
|
-
- If the current candle is bearish
|
168
|
-
and moving average is below the medium moving average
|
169
|
-
and MACD_line < Signal_line
|
170
|
-
and RSI is below the long RSI
|
171
|
-
and current close is belowe bollinger band middle line
|
172
|
-
and ADX is above 25 (STRONG)
|
173
|
-
it will open short position
|
174
|
-
- Auto trade process closes the trade based on following conditions:
|
175
|
-
- If the current candle is bearish, it will close the trade
|
176
|
-
- If the trade is in profit and greater than the profit_amount , it will close the trade
|
177
|
-
- If the trade is in profit and greater than the profit_amount , it will close the trade
|
178
|
-
- If the trade is in loss and greater than the loss_amount , it will close the trade
|
179
|
-
- If the order is open for more than 1 minute, it will close the open orders
|
180
|
-
- It will close long or short postions:
|
181
|
-
- If the trade is long and the fast moving average is above the medium moving average, it will close the trade
|
182
|
-
- If the trade is short and the fast moving average is below the medium moving average, it will close the trade
|
183
|
-
- If the trade is long and the MACD_line < Signal_line, it will close the trade
|
184
|
-
- If the trade is short and the MACD_line > Signal_line, it will close the trade
|
185
|
-
- If the trade is long and the short RSI < long RSI, it will close the trade
|
186
|
-
- If the trade is short and the short RSI > long RSI, it will close the trade
|
187
|
-
- if the trade is long and current close is less bollinger band middle line , it will close the trade
|
188
|
-
- if the trade is short and the current close is above bollinger band middle line , it will close the trade
|
189
|
-
- if the trade is long or short and the ADX is below 25 (WEAK), it will close the trade
|
190
|
-
|
191
|
-
|
192
|
-
## Installation
|
193
|
-
|
194
|
-
- Linux install (ubuntu 22.04)
|
195
|
-
- sudo su -
|
196
|
-
- # required for TA-Lib
|
197
|
-
- wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb
|
198
|
-
- sudo dpkg -i ta-lib_0.6.4_amd64.deb
|
199
|
-
- # change the tags/2.0 to the latest version in the script below and run it
|
200
|
-
- bash -c "\
|
201
|
-
apt-get install -y python3-pip wget unzip dos2unix && \
|
202
|
-
python3 -m pip install --upgrade pip && \
|
203
|
-
mkdir bitunix && cd bitunix && \
|
204
|
-
wget https://github.com/tcj2001/bitunix-automated-crypto-trading/archive/refs/tags/2.0.tar.gz -O bitunix.tar.gz && \
|
205
|
-
mkdir code && \
|
206
|
-
tar --strip-components=1 -xvzf bitunix.tar.gz -C code && \
|
207
|
-
cd code && \
|
208
|
-
pip3 install -r requirements.txt && \
|
209
|
-
cp sampleenv.txt .env"
|
210
|
-
- The package will be installed in the bitunix/code directory
|
211
|
-
- cd bitunix/code
|
212
|
-
- python3 bitunix.py
|
213
|
-
|
214
|
-
- Windows
|
215
|
-
- mkdir c:\bitunix
|
216
|
-
- cd c:\bitunix
|
217
|
-
- python -m venv env
|
218
|
-
- .\env\Scripts\activate
|
219
|
-
- # check python version should be 3.13 or above
|
220
|
-
- python3 --version
|
221
|
-
- python -m pip install --upgrade pip
|
222
|
-
- pip install https://github.com/cgohlke/talib-build/releases/download/v0.6.3/ta_lib-0.6.3-cp313-cp313-win_amd64.whl
|
223
|
-
- # change the tags/2.0 to the latest version in the script below and run it
|
224
|
-
- wget https://github.com/tcj2001/bitunix-automated-crypto-trading/archive/refs/tags/2.0.zip
|
225
|
-
- unzip zip file and copy the content inside C:\bitunix\Ver1.0.zip\bitunix-automated-crypto-trading-Ver1.0 to c:\bitunix
|
226
|
-
- pip install -r requirements.txt
|
227
|
-
- # Make sure ta-lib is installed
|
228
|
-
- python -c "import talib; print(talib.get_functions());"
|
229
|
-
- copy sampleenv.txt to .env and update the keys accordingly
|
230
|
-
- python bitunix.py
|
231
|
-
|
232
|
-
- make sure to update the .env file with your keys
|
233
|
-
api_key=your_api_key
|
234
|
-
secret_key=your_secret_key
|
235
|
-
SECRET=your_jwt_secret
|
236
|
-
password=your_password
|
237
|
-
host=0.0.0.0 (for server) or 127.0.0.1 (for local)
|
238
|
-
|
239
|
-
- cd bitunix/code
|
240
|
-
- python3 bitunix.py
|
241
|
-
|
242
|
-
- This app will exit if there is any error detected on a the periodic async threads. create a systemd service to run the app in the background and restart it if it exits. The app will
|
243
|
-
|
244
|
-
- sudo nano /etc/systemd/system/bitunix.service and enter these lines
|
245
|
-
|
246
|
-
Description=Bitunix service
|
247
|
-
After=network.target
|
248
|
-
StartLimitIntervalSec=0
|
249
|
-
[Service]
|
250
|
-
User=root
|
251
|
-
Restart=always
|
252
|
-
RestartSec=15
|
253
|
-
ExecStart=/usr/bin/python3 /home/tcj2001/bitunix/code/bitunix.py
|
254
|
-
WorkingDirectory=/home/tcj2001/bitunix/code
|
255
|
-
|
256
|
-
[Install]
|
257
|
-
WantedBy=multi-user.target
|
258
|
-
|
259
|
-
- systemctl daemon-reload
|
260
|
-
- systemctl enable bitunix.service
|
261
|
-
- systemctl start bitunix.service or just reboot the server
|
262
|
-
|
263
|
-
## License
|
264
|
-
|
265
|
-
https://opensource.org/licenses/MIT
|
266
|
-
|
267
|
-
## Support
|
268
|
-
|
269
|
-
thomsonmathews@hotmail.com
|
270
|
-
|
271
|
-
If you like this project buy me a lunch or coffee
|
272
|
-
- 35ocu1V25Zw9tgXyrcWudUqpj8rHbT2CdE (bitcoin)
|
273
|
-
- DEXXvZbTbxeaYCh3EMf7MsdptbAU2kujDc (dogecoin)
|
1
|
+
# Bitunix Futures Auto Trading Platform
|
2
|
+
|
3
|
+
A real-time cryptocurrency trading platform built with FastAPI and WebSocket technology using Bitunix API and websockets for Futures. The platform provides automated trading capabilities, real-time market data visualization, and portfolio management features.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
- Real-time private account/new postion/new order data streaming via WebSocket
|
7
|
+
- Real-time public depth/kline for bid, ask and last streaming via WebSocket or thru api calls, configurable in the config file
|
8
|
+
- Automated trading strategies based on technical indicators
|
9
|
+
- Portfolio management and position tracking
|
10
|
+
- User interface is not a requirement for automated trading, all parmaeters can be configured in the config file
|
11
|
+
- login page
|
12
|
+
- main page:
|
13
|
+
- Interactive web interface with real-time updates, allows manual trading
|
14
|
+
- Real-time portfolio value
|
15
|
+
- Open positions, with signals and strength
|
16
|
+
- Active orders
|
17
|
+
- selected signals with strength
|
18
|
+
- all signals with strength
|
19
|
+
- position history
|
20
|
+
- clicking on the ticker symbol will open the current selected period chart in modal window
|
21
|
+
- notification are written to log file and can be displayed by clicking the message bar
|
22
|
+
- Config button allows to edit the confix.txt file directly from the app
|
23
|
+
- Candlestick charts for all timeframes (1m, 5m, 15m, 1h, 1d) on a single page avaible when you click the charts button
|
24
|
+
- Technical analysis including:
|
25
|
+
- Moving Averages
|
26
|
+
- MACD
|
27
|
+
- Bollinger Bands
|
28
|
+
- RSI
|
29
|
+
- Brearish or bullish candle based on the close near high or low of the current candle
|
30
|
+
- strength based on consecutive colored candles count
|
31
|
+
- ADX
|
32
|
+
- control study using the environment variables
|
33
|
+
- Secure authentication system
|
34
|
+
- Configurable trading parameters
|
35
|
+
- Real-time notifications
|
36
|
+
- Logging system with colored output
|
37
|
+
- Update environment variables without restarting the application
|
38
|
+
|
39
|
+
|
40
|
+
## Configuration
|
41
|
+
.env file
|
42
|
+
- `API_KEY`: Bitunix API key
|
43
|
+
- `SECRET_KEY`: Bitunix secret key
|
44
|
+
- `SECRET`: JWT secret for authentication, some string like "7c4c22ef6ad145f922c72f5a18047b6bf6eff983381c975c"
|
45
|
+
- `PASSWORD`: Password for the web interface
|
46
|
+
- `HOST`: Host IP address (e.g., 0.0.0.0 for server, 127.0.0.1 for local)
|
47
|
+
|
48
|
+
The platform can be configured through the `config.py` file or `config.txt`. Key configuration parameters include:
|
49
|
+
- Trading Parameters:
|
50
|
+
- `AUTOTRADE` : True or False
|
51
|
+
- `LEVERAGE`: Trading leverage (1-100)
|
52
|
+
- `THRESHOLD`: Ticker selection based close near high or low of the day
|
53
|
+
- `MIN_VOLUME`: Ticker selection based on Minimum trading volume
|
54
|
+
- `ORDER_AMOUNT_PERCENTAGE`: Order size as percentage of portfolio
|
55
|
+
- `MAX_AUTO_TRADES`: Maximum number of automated trades
|
56
|
+
- `PROFIT_AMOUNT`: Target profit amount
|
57
|
+
- `LOSS_AMOUNT`: Maximum loss amount
|
58
|
+
- `OPTION_MOVING_AVERAGE`: Moving average period (1h, 1d, 15m, 5m, 1m)
|
59
|
+
- `BARS`: Number of bars to use for study and charting
|
60
|
+
|
61
|
+
- `Technical Indicators Parameters`:
|
62
|
+
- `MA_FAST`: Fast moving average period
|
63
|
+
- `MA_MEDIUM`: Medium moving average period
|
64
|
+
- `MA_SLOW`: Slow moving average period
|
65
|
+
- `RSI_FAST`: Fast RSI period
|
66
|
+
- `RSI_SLOW`: Slow RSI period
|
67
|
+
- `BBM_PERIOD`: Bollinger Band middle period
|
68
|
+
- `BBM_STD`: Bollinger Band standard deviation
|
69
|
+
- `MACD_PERIOD`: MACD period
|
70
|
+
- `MACD_SHORT`: MACD short period
|
71
|
+
- `MACD_LONG`: MACD long period
|
72
|
+
- `ADX_PERIOD`: ADX period
|
73
|
+
|
74
|
+
- `Study Parameters`:
|
75
|
+
- `EMA_STUDY`: Enable EMA study
|
76
|
+
- `EMA_CROSSING`: Check EMA crossing or crossed, COMPARING FAST AND MEDIUM MOVING AVERAGE
|
77
|
+
- `EMA_CHECK_ON_OPEN`: Check EMA on open
|
78
|
+
- `EMA_CHECK_ON_CLOSE`: Check EMA on close
|
79
|
+
|
80
|
+
- `MACD_STUDY`: Enable MACD study
|
81
|
+
- `MACD_CROSSING`: Check MACD crossing or crossed, comparing MACD line and signal line
|
82
|
+
- `MACD_CHECK_ON_OPEN`: Check MACD on open
|
83
|
+
- `MACD_CHECK_ON_CLOSE`: Check MACD on close
|
84
|
+
|
85
|
+
- `BBM_STUDY`: Enable Bollinger Band study
|
86
|
+
- `BBM_CROSSING`: Check Bollinger Band crossing or crossed, comparing close and middle line
|
87
|
+
- `BBM_CHECK_ON_OPEN`: Check Bollinger Band on open
|
88
|
+
- `BBM_CHECK_ON_CLOSE`: Check Bollinger Band on close
|
89
|
+
|
90
|
+
- `RSI_STUDY`: Enable RSI study
|
91
|
+
- `RSI_CROSSING`: Check RSI crossing or crossed, comparing fast and slow RSI
|
92
|
+
- `RSI_CHECK_ON_OPEN`: Check RSI on open
|
93
|
+
- `RSI_CHECK_ON_CLOSE`: Check RSI on close
|
94
|
+
|
95
|
+
- `ADX_STUDY`: Enable ADX study
|
96
|
+
- `ADX_CHECK_ON_OPEN`: Check ADX on open
|
97
|
+
- `ADX_CHECK_ON_CLOSE`: Check ADX on close
|
98
|
+
|
99
|
+
- `CANDLE_TREND_STUDY`: Enable candle trend study
|
100
|
+
- `CANDLE_TREND_CHECK_ON_OPEN`: Check candle trend on open
|
101
|
+
- `CANDLE_TREND_CHECK_ON_CLOSE`: Check candle trend on close
|
102
|
+
|
103
|
+
- `intervals`:
|
104
|
+
- `SCREEN_REFRESH_INTERVAL`: Screen refresh interval
|
105
|
+
- `SIGNAL_CHECK_INTERVAL`: Signal check interval
|
106
|
+
- `PORTFOLIO_API_INTERVAL`: Portfolio API interval
|
107
|
+
- `PENDING_POSITIONS_API_INTERVAL`: Pending positions API interval
|
108
|
+
- `PENDING_ORDERS_API_INTERVAL`: Pending orders API interval
|
109
|
+
- `TRADE_HISTORY_API_INTERVAL`: Trade history API interval
|
110
|
+
- `POSITION_HISTORY_API_INTERVAL`: Position history API interval
|
111
|
+
- `TICKER_DATA_API_INTERVAL`: Ticker data API interval
|
112
|
+
- `PUBLIC_WEBSOCKET_RESTART_INTERVAL`: Public WebSocket restart interval
|
113
|
+
|
114
|
+
- Currently not using public websocket for depth and ticker data as the data is lagging or missing sometime
|
115
|
+
- `USE_PUBLIC_WEBSOCKET`: True or False
|
116
|
+
|
117
|
+
- Logging Parameters:
|
118
|
+
- `VERBOSE_LOGGING`: True or False
|
119
|
+
|
120
|
+
## User Interface
|
121
|
+
|
122
|
+
- Access the web interface:
|
123
|
+
- Open your browser and navigate to `http://localhost:8000` or `http://your_server_ip:8000`
|
124
|
+
- Log in with your credentials (currenly user is admin and password is your_password in env file)
|
125
|
+
- display charts for all timeframes (1m, 5m, 15m, 1h, 1d) on a single page with all indicators when you click charts button
|
126
|
+
- edit the config file directly from the app
|
127
|
+
- display the log messages in amodal window by clicking the message bar
|
128
|
+
|
129
|
+
- Monitor your positions and trades:
|
130
|
+
- Real-time portfolio value
|
131
|
+
- Open positions
|
132
|
+
- Active orders
|
133
|
+
- Trading signals
|
134
|
+
- Position history
|
135
|
+
- Manual trading using buy, sell, add, reduce buttons
|
136
|
+
|
137
|
+
- Autotrade using the AutoTrade checkbox
|
138
|
+
- you can change
|
139
|
+
- Moving Average period
|
140
|
+
- Max auto trades
|
141
|
+
- Take Profit amount
|
142
|
+
- Accept Loss amount
|
143
|
+
- You can control the study like Moving Average, MACD, Bollinger Band, RSI or close proximity to high or low of the candle using the env file
|
144
|
+
- You can control the trading strategy using the CalculateStudy function in TickerManager.py and AutoTradeProcess function in BitunixSignal.py
|
145
|
+
- Changes are activated by unchecking and checking the AutoTrade checkbox
|
146
|
+
|
147
|
+
## Auto Trading
|
148
|
+
|
149
|
+
- Automated Trading Algorithm is customizable:
|
150
|
+
- It allow you to select the moving average period (1h, 1d, 15m, 5m, 1m)
|
151
|
+
- It allow to select how many auto trades you want to open at a time
|
152
|
+
- CalculateStudy Function inside TickerManager.py (Interval class)
|
153
|
+
- You can setup current_signal (BUY,SELL,HOLD) and signal_strength (numeric value) based on your strategy
|
154
|
+
- current_signal can be setup based on Moving Average, MACD, Bollinger Band, RSI or close proximity to high or low of the candle
|
155
|
+
- signal_strength can be setup based on number of consecutive green or red candles or any other strategy
|
156
|
+
- AutoTradeProcess function inside BitunixSignal.py, you can setup your opening and closing trading strategy
|
157
|
+
- User interface will list the stocks in the signal window with BUY or SELL signal based on the descending value of signal_strength
|
158
|
+
- All study can be controlled thru environment variables
|
159
|
+
- Auto trade process open the trade based on following conditions:
|
160
|
+
- If the current candle is bullish
|
161
|
+
and moving average is above the medium moving average
|
162
|
+
and MACD_line > Signal_line
|
163
|
+
and RSI is above the long RSI
|
164
|
+
and current close is above bollinger band middle line
|
165
|
+
and ADX is above 25 (STRONG)
|
166
|
+
it will open long position
|
167
|
+
- If the current candle is bearish
|
168
|
+
and moving average is below the medium moving average
|
169
|
+
and MACD_line < Signal_line
|
170
|
+
and RSI is below the long RSI
|
171
|
+
and current close is belowe bollinger band middle line
|
172
|
+
and ADX is above 25 (STRONG)
|
173
|
+
it will open short position
|
174
|
+
- Auto trade process closes the trade based on following conditions:
|
175
|
+
- If the current candle is bearish, it will close the trade
|
176
|
+
- If the trade is in profit and greater than the profit_amount , it will close the trade
|
177
|
+
- If the trade is in profit and greater than the profit_amount , it will close the trade
|
178
|
+
- If the trade is in loss and greater than the loss_amount , it will close the trade
|
179
|
+
- If the order is open for more than 1 minute, it will close the open orders
|
180
|
+
- It will close long or short postions:
|
181
|
+
- If the trade is long and the fast moving average is above the medium moving average, it will close the trade
|
182
|
+
- If the trade is short and the fast moving average is below the medium moving average, it will close the trade
|
183
|
+
- If the trade is long and the MACD_line < Signal_line, it will close the trade
|
184
|
+
- If the trade is short and the MACD_line > Signal_line, it will close the trade
|
185
|
+
- If the trade is long and the short RSI < long RSI, it will close the trade
|
186
|
+
- If the trade is short and the short RSI > long RSI, it will close the trade
|
187
|
+
- if the trade is long and current close is less bollinger band middle line , it will close the trade
|
188
|
+
- if the trade is short and the current close is above bollinger band middle line , it will close the trade
|
189
|
+
- if the trade is long or short and the ADX is below 25 (WEAK), it will close the trade
|
190
|
+
|
191
|
+
|
192
|
+
## Installation
|
193
|
+
|
194
|
+
- Linux install (ubuntu 22.04)
|
195
|
+
- sudo su -
|
196
|
+
- # required for TA-Lib
|
197
|
+
- wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb
|
198
|
+
- sudo dpkg -i ta-lib_0.6.4_amd64.deb
|
199
|
+
- # change the tags/2.0 to the latest version in the script below and run it
|
200
|
+
- bash -c "\
|
201
|
+
apt-get install -y python3-pip wget unzip dos2unix && \
|
202
|
+
python3 -m pip install --upgrade pip && \
|
203
|
+
mkdir bitunix && cd bitunix && \
|
204
|
+
wget https://github.com/tcj2001/bitunix-automated-crypto-trading/archive/refs/tags/2.0.tar.gz -O bitunix.tar.gz && \
|
205
|
+
mkdir code && \
|
206
|
+
tar --strip-components=1 -xvzf bitunix.tar.gz -C code && \
|
207
|
+
cd code && \
|
208
|
+
pip3 install -r requirements.txt && \
|
209
|
+
cp sampleenv.txt .env"
|
210
|
+
- The package will be installed in the bitunix/code directory
|
211
|
+
- cd bitunix/code
|
212
|
+
- python3 bitunix.py
|
213
|
+
|
214
|
+
- Windows
|
215
|
+
- mkdir c:\bitunix
|
216
|
+
- cd c:\bitunix
|
217
|
+
- python -m venv env
|
218
|
+
- .\env\Scripts\activate
|
219
|
+
- # check python version should be 3.13 or above
|
220
|
+
- python3 --version
|
221
|
+
- python -m pip install --upgrade pip
|
222
|
+
- pip install https://github.com/cgohlke/talib-build/releases/download/v0.6.3/ta_lib-0.6.3-cp313-cp313-win_amd64.whl
|
223
|
+
- # change the tags/2.0 to the latest version in the script below and run it
|
224
|
+
- wget https://github.com/tcj2001/bitunix-automated-crypto-trading/archive/refs/tags/2.0.zip
|
225
|
+
- unzip zip file and copy the content inside C:\bitunix\Ver1.0.zip\bitunix-automated-crypto-trading-Ver1.0 to c:\bitunix
|
226
|
+
- pip install -r requirements.txt
|
227
|
+
- # Make sure ta-lib is installed
|
228
|
+
- python -c "import talib; print(talib.get_functions());"
|
229
|
+
- copy sampleenv.txt to .env and update the keys accordingly
|
230
|
+
- python bitunix.py
|
231
|
+
|
232
|
+
- make sure to update the .env file with your keys
|
233
|
+
api_key=your_api_key
|
234
|
+
secret_key=your_secret_key
|
235
|
+
SECRET=your_jwt_secret
|
236
|
+
password=your_password
|
237
|
+
host=0.0.0.0 (for server) or 127.0.0.1 (for local)
|
238
|
+
|
239
|
+
- cd bitunix/code
|
240
|
+
- python3 bitunix.py
|
241
|
+
|
242
|
+
- This app will exit if there is any error detected on a the periodic async threads. create a systemd service to run the app in the background and restart it if it exits. The app will
|
243
|
+
|
244
|
+
- sudo nano /etc/systemd/system/bitunix.service and enter these lines
|
245
|
+
|
246
|
+
Description=Bitunix service
|
247
|
+
After=network.target
|
248
|
+
StartLimitIntervalSec=0
|
249
|
+
[Service]
|
250
|
+
User=root
|
251
|
+
Restart=always
|
252
|
+
RestartSec=15
|
253
|
+
ExecStart=/usr/bin/python3 /home/tcj2001/bitunix/code/bitunix.py
|
254
|
+
WorkingDirectory=/home/tcj2001/bitunix/code
|
255
|
+
|
256
|
+
[Install]
|
257
|
+
WantedBy=multi-user.target
|
258
|
+
|
259
|
+
- systemctl daemon-reload
|
260
|
+
- systemctl enable bitunix.service
|
261
|
+
- systemctl start bitunix.service or just reboot the server
|
262
|
+
|
263
|
+
## License
|
264
|
+
|
265
|
+
https://opensource.org/licenses/MIT
|
266
|
+
|
267
|
+
## Support
|
268
|
+
|
269
|
+
thomsonmathews@hotmail.com
|
270
|
+
|
271
|
+
If you like this project buy me a lunch or coffee
|
272
|
+
- 35ocu1V25Zw9tgXyrcWudUqpj8rHbT2CdE (bitcoin)
|
273
|
+
- DEXXvZbTbxeaYCh3EMf7MsdptbAU2kujDc (dogecoin)
|