Skip to content

Commit

Permalink
fix position driver
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineLep committed Apr 29, 2022
1 parent 24c37c8 commit c05c3c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions core/trading/position_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _worker(self, max_open_duration: int) -> None:
"""

opened_duration = 0
position: PositionDataDict = Optional[None]
position: Optional[PositionDataDict] = None

while self._t_run:
for i in range(self._worker_sleep_time_between_loops):
Expand All @@ -180,7 +180,8 @@ def _worker(self, max_open_duration: int) -> None:
position["future"].upper() == self.market.upper()]

if len(positions) == 1:
logging.info(f"FTX API response: {str(position[0])}")
position = positions[0]
logging.info(f"FTX API response: {str(position)}")

except Exception as e:
logging.error("An error occurred when retrieving position:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
MINIMUM_AVERAGE_VOLUME = 15000 # Minimum average volume to pass validation (avoid unsellable coin)
MINIMUM_PRICE_VARIATION = 0.6 # Percentage of variation a coin must have during its last SHORT_MA_VOLUME_DEPTH candles
POSITION_LEVERAGE = 0.2 # Position leverage to apply on each position
TRAILING_STOP_PERCENTAGE = 1.8 # Trailing stop percentage
TRAILING_STOP_PERCENTAGE = 2.2 # Trailing stop percentage
STOP_LOSS_PERCENTAGE = 0.6 # Stop loss percentage

POSITION_DRIVER_WORKER_SLEEP_TIME_BETWEEN_LOOPS = 120 # When a position driver is running, check market every x sec
Expand Down

0 comments on commit c05c3c2

Please sign in to comment.