Skip to content

Commit

Permalink
fix position opening direction
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineLep committed May 10, 2022
1 parent 6e5c5ef commit fdd93c8
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions strategies/cryptofeed_strategy/cryptofeed_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

SLEEP_TIME_BETWEEN_LOOPS = 10
LIQUIDATION_HISTORY_RETENTION_TIME = 60 * 60 # 1 hour retention
STOP_LOSS_PERCENTAGE = 1
TAKE_PROFIT_PERCENTAGE_1 = 0.5
TAKE_PROFIT_PERCENTAGE_1 = 1
TIMEFRAMES = [60] # 1 min
EXCHANGES = ["FTX", "BINANCE_FUTURES"]
TRIGGER_LIQUIDATION_VALUE = 10000
Expand Down Expand Up @@ -154,12 +153,10 @@ def perform_data_analysis(self, timeframe: int):
logging.info(f'oi_sum_usd for {pair} - ${oi_sum_usd:_}')

# Open position logic
if sell_liquidation_sum * LIQUIDATIONS_OI_RATIO_THRESHOLD < oi_sum_usd < \
buy_liquidation_sum * LIQUIDATIONS_OI_RATIO_THRESHOLD:
self.open_position(pair, SideEnum.BUY)
elif buy_liquidation_sum * LIQUIDATIONS_OI_RATIO_THRESHOLD < oi_sum_usd < \
sell_liquidation_sum * LIQUIDATIONS_OI_RATIO_THRESHOLD:
if buy_liquidation_sum * LIQUIDATIONS_OI_RATIO_THRESHOLD > oi_sum_usd:
self.open_position(pair, SideEnum.SELL)
elif sell_liquidation_sum * LIQUIDATIONS_OI_RATIO_THRESHOLD > oi_sum_usd:
self.open_position(pair, SideEnum.BUY)

def open_position(self, pair: str, side: SideEnum) -> None:
# Don't reopen a position if there is a position driver already opened
Expand All @@ -173,7 +170,7 @@ def open_position(self, pair: str, side: SideEnum) -> None:
current_price = StockUtils.get_market_price(self.ftx_rest_api, pair + '-PERP')

available_balance_without_borrow = StockUtils.get_available_balance_without_borrow(self.ftx_rest_api,)
percent_balance_per_trade = (available_balance_without_borrow * 20) * 0.01
percent_balance_per_trade = (available_balance_without_borrow * 20) * 0.001
logging.info(f'available without borrow: ${available_balance_without_borrow}')
position_size = percent_balance_per_trade / current_price

Expand Down

0 comments on commit fdd93c8

Please sign in to comment.