bitunix-automated-crypto-trading 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,298 @@
1
+ Metadata-Version: 2.4
2
+ Name: bitunix-automated-crypto-trading
3
+ Version: 1.0.0
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
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
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: description
33
+ Dynamic: description-content-type
34
+ Dynamic: home-page
35
+ Dynamic: requires-dist
36
+ Dynamic: requires-python
37
+ Dynamic: summary
38
+
39
+ # Bitunix Futures Auto Trading Platform
40
+
41
+ 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.
42
+
43
+ ## Features
44
+ - Real-time private account/new postion/new order data streaming via WebSocket
45
+ - Real-time public depth/kline for bid, ask and last streaming via WebSocket or thru api calls, configurable in the config file
46
+ - Automated trading strategies based on technical indicators
47
+ - Portfolio management and position tracking
48
+ - User interface is not a requirement for automated trading, all parmaeters can be configured in the config file
49
+ - login page
50
+ - main page:
51
+ - Interactive web interface with real-time updates, allows manual trading
52
+ - Real-time portfolio value
53
+ - Open positions, with signals and strength
54
+ - Active orders
55
+ - selected signals with strength
56
+ - all signals with strength
57
+ - position history
58
+ - clicking on the ticker symbol will open the current selected period chart in modal window
59
+ - notification are written to log file and can be displayed by clicking the message bar
60
+ - Config button allows to edit the confix.txt file directly from the app
61
+ - Candlestick charts for all timeframes (1m, 5m, 15m, 1h, 1d) on a single page avaible when you click the charts button
62
+ - Technical analysis including:
63
+ - Moving Averages
64
+ - MACD
65
+ - Bollinger Bands
66
+ - RSI
67
+ - Brearish or bullish candle based on the close near high or low of the current candle
68
+ - strength based on consecutive colored candles count
69
+ - ADX
70
+ - control study using the environment variables
71
+ - Secure authentication system
72
+ - Configurable trading parameters
73
+ - Real-time notifications
74
+ - Logging system with colored output
75
+ - Update environment variables without restarting the application
76
+
77
+
78
+ ## Configuration
79
+ .env file
80
+ - `API_KEY`: Bitunix API key
81
+ - `SECRET_KEY`: Bitunix secret key
82
+ - `SECRET`: JWT secret for authentication, some string like "7c4c22ef6ad145f922c72f5a18047b6bf6eff983381c975c"
83
+ - `PASSWORD`: Password for the web interface
84
+ - `HOST`: Host IP address (e.g., 0.0.0.0 for server, 127.0.0.1 for local)
85
+
86
+ The platform can be configured through the `config.py` file or `config.txt`. Key configuration parameters include:
87
+ - Trading Parameters:
88
+ - `AUTOTRADE` : True or False
89
+ - `LEVERAGE`: Trading leverage (1-100)
90
+ - `THRESHOLD`: Ticker selection based close near high or low of the day
91
+ - `MIN_VOLUME`: Ticker selection based on Minimum trading volume
92
+ - `ORDER_AMOUNT_PERCENTAGE`: Order size as percentage of portfolio
93
+ - `MAX_AUTO_TRADES`: Maximum number of automated trades
94
+ - `PROFIT_AMOUNT`: Target profit amount
95
+ - `LOSS_AMOUNT`: Maximum loss amount
96
+ - `OPTION_MOVING_AVERAGE`: Moving average period (1h, 1d, 15m, 5m, 1m)
97
+ - `BARS`: Number of bars to use for study and charting
98
+
99
+ - `Technical Indicators Parameters`:
100
+ - `MA_FAST`: Fast moving average period
101
+ - `MA_MEDIUM`: Medium moving average period
102
+ - `MA_SLOW`: Slow moving average period
103
+ - `RSI_FAST`: Fast RSI period
104
+ - `RSI_SLOW`: Slow RSI period
105
+ - `BBM_PERIOD`: Bollinger Band middle period
106
+ - `BBM_STD`: Bollinger Band standard deviation
107
+ - `MACD_PERIOD`: MACD period
108
+ - `MACD_SHORT`: MACD short period
109
+ - `MACD_LONG`: MACD long period
110
+ - `ADX_PERIOD`: ADX period
111
+
112
+ - `Study Parameters`:
113
+ - `EMA_STUDY`: Enable EMA study
114
+ - `MACD_STUDY`: Enable MACD study
115
+ - `BBM_STUDY`: Enable Bollinger Band study
116
+ - `RSI_STUDY`: Enable RSI study
117
+ - `CANDLE_TREND_STUDY`: Enable candle trend study
118
+ - `ADX_STUDY`: Enable ADX study
119
+
120
+ - `Check on Opening a Position`:
121
+ - `EMA_CHECK_ON_OPEN`: Check EMA on open
122
+ - `MACD_CHECK_ON_OPEN`: Check MACD on open
123
+ - `BBM_CHECK_ON_OPEN`: Check Bollinger Band on open
124
+ - `RSI_CHECK_ON_OPEN`: Check RSI on open
125
+ - `CANDLE_TREND_CHECK_ON_OPEN`: Check candle trend on open
126
+ - `ADX_CHECK_ON_OPEN`: Check ADX on open
127
+
128
+ - `Check on Close a Position`:
129
+ - `EMA_CHECK_ON_CLOSE`: Check EMA on close
130
+ - `MACD_CHECK_ON_CLOSE`: Check MACD on close
131
+ - `BBM_CHECK_ON_CLOSE`: Check Bollinger Band on close
132
+ - `RSI_CHECK_ON_CLOSE`: Check RSI on close
133
+ - `CANDLE_TREND_CHECK_ON_CLOSE`: Check candle trend on close
134
+ - `ADX_CHECK_ON_CLOSE`: Check ADX on close
135
+
136
+ - `intervals`:
137
+ - `SCREEN_REFRESH_INTERVAL`: Screen refresh interval
138
+ - `SIGNAL_CHECK_INTERVAL`: Signal check interval
139
+ - `PORTFOLIO_API_INTERVAL`: Portfolio API interval
140
+ - `PENDING_POSITIONS_API_INTERVAL`: Pending positions API interval
141
+ - `PENDING_ORDERS_API_INTERVAL`: Pending orders API interval
142
+ - `TRADE_HISTORY_API_INTERVAL`: Trade history API interval
143
+ - `POSITION_HISTORY_API_INTERVAL`: Position history API interval
144
+ - `TICKER_DATA_API_INTERVAL`: Ticker data API interval
145
+ - `PUBLIC_WEBSOCKET_RESTART_INTERVAL`: Public WebSocket restart interval
146
+
147
+ - Currently not using public websocket for depth and ticker data as the data is lagging or missing sometime
148
+ - `USE_PUBLIC_WEBSOCKET`: True or False
149
+
150
+ - Logging Parameters:
151
+ - `VERBOSE_LOGGING`: True or False
152
+
153
+ ## User Interface
154
+
155
+ - Access the web interface:
156
+ - Open your browser and navigate to `http://localhost:8000` or `http://your_server_ip:8000`
157
+ - Log in with your credentials (currenly user is admin and password is your_password in env file)
158
+ - display charts for all timeframes (1m, 5m, 15m, 1h, 1d) on a single page with all indicators when you click charts button
159
+ - edit the config file directly from the app
160
+ - display the log messages in amodal window by clicking the message bar
161
+
162
+ - Monitor your positions and trades:
163
+ - Real-time portfolio value
164
+ - Open positions
165
+ - Active orders
166
+ - Trading signals
167
+ - Position history
168
+ - Manual trading using buy, sell, add, reduce buttons
169
+
170
+ - Autotrade using the AutoTrade checkbox
171
+ - you can change
172
+ - Moving Average period
173
+ - Max auto trades
174
+ - Take Profit amount
175
+ - Accept Loss amount
176
+ - 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
177
+ - You can control the trading strategy using the CalculateStudy function in TickerManager.py and AutoTradeProcess function in BitunixSignal.py
178
+ - Changes are activated by unchecking and checking the AutoTrade checkbox
179
+
180
+ ## Auto Trading
181
+
182
+ - Automated Trading Algorithm is customizable:
183
+ - It allow you to select the moving average period (1h, 1d, 15m, 5m, 1m)
184
+ - It allow to select how many auto trades you want to open at a time
185
+ - CalculateStudy Function inside TickerManager.py (Interval class)
186
+ - You can setup current_signal (BUY,SELL,HOLD) and signal_strength (numeric value) based on your strategy
187
+ - current_signal can be setup based on Moving Average, MACD, Bollinger Band, RSI or close proximity to high or low of the candle
188
+ - signal_strength can be setup based on number of consecutive green or red candles or any other strategy
189
+ - AutoTradeProcess function inside BitunixSignal.py, you can setup your opening and closing trading strategy
190
+ - User interface will list the stocks in the signal window with BUY or SELL signal based on the descending value of signal_strength
191
+ - All study can be controlled thru environment variables
192
+ - Auto trade process open the trade based on following conditions:
193
+ - If the current candle is bullish
194
+ and moving average is above the medium moving average
195
+ and MACD_line > Signal_line
196
+ and RSI is above the long RSI
197
+ and current close is above bollinger band middle line
198
+ and ADX is above 25 (STRONG)
199
+ it will open long position
200
+ - If the current candle is bearish
201
+ and moving average is below the medium moving average
202
+ and MACD_line < Signal_line
203
+ and RSI is below the long RSI
204
+ and current close is belowe bollinger band middle line
205
+ and ADX is above 25 (STRONG)
206
+ it will open short position
207
+ - Auto trade process closes the trade based on following conditions:
208
+ - If the current candle is bearish, it will close the trade
209
+ - If the trade is in profit and greater than the profit_amount , it will close the trade
210
+ - If the trade is in profit and greater than the profit_amount , it will close the trade
211
+ - If the trade is in loss and greater than the loss_amount , it will close the trade
212
+ - If the order is open for more than 1 minute, it will close the open orders
213
+ - It will close long or short postions:
214
+ - If the trade is long and the fast moving average is above the medium moving average, it will close the trade
215
+ - If the trade is short and the fast moving average is below the medium moving average, it will close the trade
216
+ - If the trade is long and the MACD_line < Signal_line, it will close the trade
217
+ - If the trade is short and the MACD_line > Signal_line, it will close the trade
218
+ - If the trade is long and the short RSI < long RSI, it will close the trade
219
+ - If the trade is short and the short RSI > long RSI, it will close the trade
220
+ - if the trade is long and current close is less bollinger band middle line , it will close the trade
221
+ - if the trade is short and the current close is above bollinger band middle line , it will close the trade
222
+ - if the trade is long or short and the ADX is below 25 (WEAK), it will close the trade
223
+
224
+
225
+ ## Installation
226
+
227
+ - This uses TA-LIb
228
+ - For windows install using precompiled wheel using
229
+ - pip install https://github.com/cgohlke/talib-build/releases/download/v0.6.3/ta_lib-0.6.3-cp313-cp313-win_amd64.whl
230
+ - For linux download (ubuntu 22.04)
231
+ - sudo apt-get update
232
+ - sudo apt-get install build-essential libssl-dev libffi-dev
233
+ - wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb
234
+ - sudo dpkg -i ta-lib_0.6.4_amd64.deb
235
+
236
+ - Window install should easy (not my choice)
237
+ - wget https://github.com/tcj2001/bitunix-automated-crypto-trading/archive/refs/tags/Ver1.0.zip
238
+ - and install the package using the requirements.txt file
239
+
240
+ - Linux install (ubuntu 22.04)
241
+ - Change the Ver1.0 to the latest version in the script
242
+ - sudo su -
243
+ - bash -c "\
244
+ apt-get install -y python3-pip wget unzip dos2unix && \
245
+ python3 -m pip install --upgrade pip && \
246
+ mkdir bitunix && cd bitunix && \
247
+ wget https://github.com/tcj2001/bitunix-automated-crypto-trading/archive/refs/tags/Ver1.0.tar.gz -O bitunix.tar.gz && \
248
+ mkdir code && \
249
+ tar --strip-components=1 -xvzf bitunix.tar.gz -C code && \
250
+ cd code && \
251
+ pip3 install -r requirements.txt && \
252
+ cp sampleenv.txt .env"
253
+
254
+
255
+ - The package will be installed in the bitunix/code directory
256
+
257
+ - make sure to update the .env file with your keys
258
+ api_key=your_api_key
259
+ secret_key=your_secret_key
260
+ SECRET=your_jwt_secret
261
+ password=your_password
262
+ host=0.0.0.0 (for server) or 127.0.0.1 (for local)
263
+
264
+ - cd bitunix/code
265
+ - python3 bitunix.py
266
+
267
+ - 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
268
+
269
+ - sudo nano /etc/systemd/system/bitunix.service and enter these lines
270
+
271
+ Description=Bitunix service
272
+ After=network.target
273
+ StartLimitIntervalSec=0
274
+ [Service]
275
+ User=root
276
+ Restart=always
277
+ RestartSec=15
278
+ ExecStart=/usr/bin/python3 /home/tcj2001/bitunix/code/bitunix.py
279
+ WorkingDirectory=/home/tcj2001/bitunix/code
280
+
281
+ [Install]
282
+ WantedBy=multi-user.target
283
+
284
+ - systemctl daemon-reload
285
+ - systemctl enable bitunix.service
286
+ - systemctl start bitunix.service or just reboot the server
287
+
288
+ ## License
289
+
290
+ https://opensource.org/licenses/MIT
291
+
292
+ ## Support
293
+
294
+ thomsonmathews@hotmail.com
295
+
296
+ If you like this project buy me a lunch or coffee
297
+ - 35ocu1V25Zw9tgXyrcWudUqpj8rHbT2CdE (bitcoin)
298
+ - DEXXvZbTbxeaYCh3EMf7MsdptbAU2kujDc (dogecoin)
@@ -0,0 +1,5 @@
1
+ bitunix_automated_crypto_trading-1.0.0.dist-info/METADATA,sha256=vJguPDZqQ5Uww_3rN9_2BuCSTQKWaOaATTlb-Iiz9Co,13013
2
+ bitunix_automated_crypto_trading-1.0.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
3
+ bitunix_automated_crypto_trading-1.0.0.dist-info/entry_points.txt,sha256=h3mo-V8kaikc2r8IumkA9pGoGhwfjmzbcorsI0nEuC4,41
4
+ bitunix_automated_crypto_trading-1.0.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ bitunix_automated_crypto_trading-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bitunix = bitunix:main