bitunix-automated-crypto-trading 3.3.6__tar.gz → 3.3.7__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.
Files changed (25) hide show
  1. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/PKG-INFO +1 -1
  2. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/README.md +1 -0
  3. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/BitunixSignal.py +23 -11
  4. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/TickerManager.py +2 -2
  5. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/config.py +1 -0
  6. bitunix_automated_crypto_trading-3.3.7/bitunix_automated_crypto_trading/version.py +1 -0
  7. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading.egg-info/PKG-INFO +1 -1
  8. bitunix_automated_crypto_trading-3.3.6/bitunix_automated_crypto_trading/version.py +0 -1
  9. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/AsyncThreadRunner.py +0 -0
  10. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/BitunixApi.py +0 -0
  11. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/BitunixWebSocket.py +0 -0
  12. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/DataFrameHtmlRenderer.py +0 -0
  13. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/NotificationManager.py +0 -0
  14. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/SupportResistance.py +0 -0
  15. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/ThreadManager.py +0 -0
  16. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/__init__.py +0 -0
  17. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/bitunix.py +0 -0
  18. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading/logger.py +0 -0
  19. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading.egg-info/SOURCES.txt +0 -0
  20. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading.egg-info/dependency_links.txt +0 -0
  21. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading.egg-info/entry_points.txt +0 -0
  22. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading.egg-info/requires.txt +0 -0
  23. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/bitunix_automated_crypto_trading.egg-info/top_level.txt +0 -0
  24. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/setup.cfg +0 -0
  25. {bitunix_automated_crypto_trading-3.3.6 → bitunix_automated_crypto_trading-3.3.7}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitunix_automated_crypto_trading
3
- Version: 3.3.6
3
+ Version: 3.3.7
4
4
  Summary: Bitunix Futures Auto Trading Platform
5
5
  Home-page: https://github.com/tcj2001/bitunix-automated-crypto-trading
6
6
  Author: tcj2001
@@ -85,6 +85,7 @@ The platform can be configured through the `config.py` file or `config.txt`. Key
85
85
  - `MACD_SHORT`: MACD short period
86
86
  - `MACD_LONG`: MACD long period
87
87
  - `ADX_PERIOD`: ADX period
88
+ - `MINIMUM_CONSECUTIVE_CANDLES`: Minimum number of consecutive candles to consider for a signal.
88
89
 
89
90
  - `Study Parameters`:
90
91
  - `EMA_STUDY`: Enable EMA study
@@ -650,14 +650,14 @@ class BitunixSignal:
650
650
  trade_time = datetime.strptime(datetime_str, "%Y-%m-%d %H:%M:%S")
651
651
  # Convert datetime object to Unix timestamp)
652
652
  trade_time_unix = int(trade_time.timestamp())
653
- print(f"trade_time_unix: {trade_time_unix}, trade_time: {trade_time}")
653
+ #print(f"trade_time_unix: {trade_time_unix}, trade_time: {trade_time}")
654
654
  # Get current Unix timestamp
655
655
  current_time_unix = int(time.time())
656
- print(f"current_time_unix: {current_time_unix}, time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
656
+ #print(f"current_time_unix: {current_time_unix}, time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
657
657
  # Calculate duration in minutes
658
658
  duration_minutes = (current_time_unix - trade_time_unix) / 60
659
- print(f"diff: {current_time_unix - trade_time_unix}")
660
- print(f"duration_minutes: {duration_minutes}")
659
+ #print(f"diff: {current_time_unix - trade_time_unix}")
660
+ #print(f"duration_minutes: {duration_minutes}")
661
661
 
662
662
  return round(duration_minutes)
663
663
 
@@ -729,6 +729,7 @@ class BitunixSignal:
729
729
  self.logger.info(f"row.symbol: {row.symbol} , duration_minutes: {duration_minutes}, last trade time: {mtime if duration_minutes is not None else 'N/A'}")
730
730
  if duration_minutes is None or duration_minutes > self.settings.DELAY_IN_MINUTES_FOR_SAME_TICKER_TRADES:
731
731
  side = "BUY" if row[f'{period}_barcolor'] == self.green and row[f'{period}_trend'] == "BUY" else "SELL" if row[f'{period}_barcolor'] == self.red and row[f'{period}_trend'] == "SELL" else ""
732
+ #self.logger.info(f"row.symbol: {row.symbol} , ok to {side}, {row[f'{period}_barcolor']} , {row[f'{period}_trend']} ")
732
733
  if side != "":
733
734
  select = True
734
735
  self.pendingPositions = await self.bitunixApi.GetPendingPositionData({'symbol': row.symbol})
@@ -792,6 +793,7 @@ class BitunixSignal:
792
793
  count=count+1
793
794
  else:
794
795
  self.logger.info(f"Skipping {row.symbol} as it has been opened for less than {self.settings.DELAY_IN_MINUTES_FOR_SAME_TICKER_TRADES} minutes")
796
+
795
797
  if count >= int(self.settings.MAX_AUTO_TRADES):
796
798
  break
797
799
  await asyncio.sleep(0)
@@ -898,17 +900,22 @@ class BitunixSignal:
898
900
 
899
901
  if self.settings.BOT_TRAIL_SL:
900
902
  if old_slPrice is not None:
901
- sl_midpoint = old_slPrice / (1 - self.settings.LOSS_PERCENTAGE/100/self.settings.LEVERAGE) if side == "BUY" else old_slPrice / (1 + self.settings.LOSS_PERCENTAGE/100/self.settings.LEVERAGE) if tpPrice is not None else None
903
+ sl_midpoint = old_slPrice / (1 - self.settings.LOSS_PERCENTAGE/100/self.settings.LEVERAGE) if side == "BUY" else old_slPrice / (1 + self.settings.LOSS_PERCENTAGE/100/self.settings.LEVERAGE) if tpPrice is not None else None
904
+ if roi > self.settings.PROFIT_PERCENTAGE:
905
+ sl_midpoint = tp_midpoint
906
+
902
907
  if sl_midpoint is not None and (price > sl_midpoint and side == "BUY" or price < sl_midpoint and side == "SELL"):
903
-
904
- slPrice = price * (1 - float(self.settings.LOSS_PERCENTAGE) / 100 / self.settings.LEVERAGE) if side == "BUY" else price * (1 + float(self.settings.LOSS_PERCENTAGE) / 100 / self.settings.LEVERAGE)
908
+ if roi > self.settings.PROFIT_PERCENTAGE and self.settings.PROFIT_PERCENTAGE < self.settings.LOSS_PERCENTAGE:
909
+ slPrice = price * (1 - float(self.settings.PROFIT_PERCENTAGE) / 100 / self.settings.LEVERAGE) if side == "BUY" else price * (1 + float(self.settings.PROFIT_PERCENTAGE) / 100 / self.settings.LEVERAGE)
910
+ else:
911
+ slPrice = price * (1 - float(self.settings.LOSS_PERCENTAGE) / 100 / self.settings.LEVERAGE) if side == "BUY" else price * (1 + float(self.settings.LOSS_PERCENTAGE) / 100 / self.settings.LEVERAGE)
905
912
  slPrice = Decimal(await self.str_precision(slPrice))
906
913
  slPrice = float(str(slPrice.quantize(Decimal(f'1e-{decimal_places}'))))
907
914
  slOrderPrice = await self.increment_by_last_decimal(await self.str_precision(slPrice))
908
915
 
909
916
  if (self.settings.BOT_TRAIL_TP and tpOrderPrice is not None) or (self.settings.BOT_TRAIL_SL and slOrderPrice is not None):
910
917
  self.notifications.add_notification(
911
- f'{colors.CYAN} {row.symbol} price: {price}, ROI: {roi}%, TP: {old_tpPrice}, TP midpoint: {tp_midpoint}, new TP: {tpPrice}, SL: {old_slPrice}, SL midpoint: {sl_midpoint}, new SL: {slPrice}'
918
+ f'{colors.CYAN} {row.symbol} avgOpenPrice: {avgOpenPrice}, current price: {price}, ROI: {roi}%, TP: {old_tpPrice}, TP midpoint: {tp_midpoint}, new TP: {tpPrice}, SL: {old_slPrice}, SL midpoint: {sl_midpoint}, new SL: {slPrice}'
912
919
  )
913
920
 
914
921
 
@@ -922,9 +929,14 @@ class BitunixSignal:
922
929
  if self.settings.BOT_TRAIL_SL and slPrice is not None and slOrderPrice is not None:
923
930
  datajs3 = await self.bitunixApi.ModifyTpSlOrder({'orderId':slorderId,'slPrice':str(slPrice),'slQty':str(qty),'slStopType':slStopType,'slOrderType':slOrderType})
924
931
  if datajs3 is not None:
925
- self.notifications.add_notification(
926
- f'{colors.CYAN} Stop Loss order for {row.symbol} moved from {old_slPrice} to {slPrice}'
927
- )
932
+ if roi > self.settings.PROFIT_PERCENTAGE and self.settings.PROFIT_PERCENTAGE < self.settings.LOSS_PERCENTAGE:
933
+ self.notifications.add_notification(
934
+ f'{colors.CYAN} Stop Loss order for {row.symbol} moved from {old_slPrice} to breakeven {slPrice}'
935
+ )
936
+ else:
937
+ self.notifications.add_notification(
938
+ f'{colors.CYAN} Stop Loss order for {row.symbol} moved from {old_slPrice} to {slPrice}'
939
+ )
928
940
 
929
941
 
930
942
 
@@ -750,13 +750,13 @@ class Tickers:
750
750
  trending_conditions = [
751
751
  (
752
752
  (df[f'{period}_trend']=='BUY') &
753
- (df[f'{period}_cb']>1)
753
+ (df[f'{period}_cb']>= self.settings.MINIMUM_CONSECUTIVE_CANDLES)
754
754
  #&
755
755
  #(df[f'{period}_barcolor']==self.green)
756
756
  ),
757
757
  (
758
758
  (df[f'{period}_trend']=='SELL') &
759
- (df[f'{period}_cb']>1)
759
+ (df[f'{period}_cb']>= self.settings.MINIMUM_CONSECUTIVE_CANDLES)
760
760
  #&
761
761
  #(df[f'{period}_barcolor']==self.red)
762
762
  )
@@ -44,6 +44,7 @@ class Settings(BaseSettings):
44
44
  MACD_SHORT: int = Field(default=12, ge=1)
45
45
  MACD_LONG: int = Field(default=26, ge=1)
46
46
  ADX_PERIOD: int = Field(default=14, ge=1)
47
+ MINIMUM_CONSECUTIVE_CANDLES: int = Field(default=2, ge=1)
47
48
 
48
49
  # Technical Indicators
49
50
  OPEN_ON_ANY_SIGNAL: bool = Field(default=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitunix_automated_crypto_trading
3
- Version: 3.3.6
3
+ Version: 3.3.7
4
4
  Summary: Bitunix Futures Auto Trading Platform
5
5
  Home-page: https://github.com/tcj2001/bitunix-automated-crypto-trading
6
6
  Author: tcj2001