Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
m5l14i11 committed Apr 10, 2024
1 parent 890195d commit 5e12a31
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 289 deletions.
2 changes: 1 addition & 1 deletion core/models/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from .ohlcv import OHLCV
from .order import Order, OrderStatus
from .position_side import PositionSide
from .side import PositionSide
from .signal import Signal


Expand Down
7 changes: 7 additions & 0 deletions core/models/position_side.py → core/models/side.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ class PositionSide(Enum):

def __str__(self):
return self.value

class SignalSide(Enum):
BUY = "buy"
SELL = "sell"

def __str__(self):
return self.value.upper()
10 changes: 1 addition & 9 deletions core/models/signal.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
from dataclasses import dataclass
from enum import Enum

from .side import SignalSide
from .strategy import Strategy
from .symbol import Symbol
from .timeframe import Timeframe


class SignalSide(Enum):
BUY = "buy"
SELL = "sell"

def __str__(self):
return self.value.upper()


@dataclass(frozen=True)
class Signal:
symbol: Symbol
Expand Down
2 changes: 1 addition & 1 deletion exchange/_bybit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from core.interfaces.abstract_exchange import AbstractExchange
from core.models.broker import MarginMode, PositionMode
from core.models.lookback import TIMEFRAMES_TO_LOOKBACK, Lookback
from core.models.position_side import PositionSide
from core.models.side import PositionSide
from core.models.symbol import Symbol
from core.models.timeframe import Timeframe
from infrastructure.retry import retry
Expand Down
12 changes: 7 additions & 5 deletions executor/_paper_order_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from core.models.ohlcv import OHLCV
from core.models.order import Order, OrderStatus, OrderType
from core.models.position import Position
from core.models.position_side import PositionSide
from core.models.side import PositionSide
from core.models.symbol import Symbol
from core.models.timeframe import Timeframe

Expand Down Expand Up @@ -96,7 +96,7 @@ async def _execute_order(self, event: PositionInitialized):

current_position = current_position.add_order(order)

logger.info(f"Position to Open: {current_position}")
logger.debug(f"Position to Open: {current_position}")

if current_position.closed:
await self.tell(BrokerPositionClosed(current_position))
Expand All @@ -116,9 +116,11 @@ async def _adjust_position(self, event: RiskAdjustRequested):
fill_price = total_value / size

if (
current_position.side == PositionSide.LONG and current_position.stop_loss_price > current_position.take_profit_price
current_position.side == PositionSide.LONG
and current_position.stop_loss_price > current_position.take_profit_price
) or (
current_position.side == PositionSide.SHORT and current_position.stop_loss_price < current_position.take_profit_price
current_position.side == PositionSide.SHORT
and current_position.stop_loss_price < current_position.take_profit_price
):
logger.error(f"Wrong Adjust: {current_position}")
return
Expand Down Expand Up @@ -158,7 +160,7 @@ async def _close_position(self, event: PositionCloseRequested):

next_position = current_position.add_order(order)

logger.info(f"Closed Position: {next_position}")
logger.debug(f"Closed Position: {next_position}")

await self.tell(BrokerPositionClosed(next_position))

Expand Down
2 changes: 1 addition & 1 deletion position/_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)
from core.interfaces.abstract_config import AbstractConfig
from core.interfaces.abstract_position_factory import AbstractPositionFactory
from core.models.position_side import PositionSide
from core.models.side import PositionSide
from core.models.symbol import Symbol
from core.models.timeframe import Timeframe

Expand Down
2 changes: 1 addition & 1 deletion position/_position_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
)
from core.models.ohlcv import OHLCV
from core.models.position import Position
from core.models.position_side import PositionSide
from core.models.side import PositionSide
from core.models.signal import Signal, SignalSide


Expand Down
2 changes: 1 addition & 1 deletion position/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import List, Optional, Tuple

from core.models.position import Position
from core.models.position_side import PositionSide
from core.models.side import PositionSide
from core.models.symbol import Symbol
from core.models.timeframe import Timeframe

Expand Down
2 changes: 1 addition & 1 deletion position/risk/break_even.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from core.interfaces.abstract_config import AbstractConfig
from core.interfaces.abstract_position_risk_strategy import AbstractPositionRiskStrategy
from core.models.ohlcv import OHLCV
from core.models.position_side import PositionSide
from core.models.side import PositionSide


class PositionRiskBreakEvenStrategy(AbstractPositionRiskStrategy):
Expand Down
241 changes: 0 additions & 241 deletions position/risk/volatility.py

This file was deleted.

2 changes: 1 addition & 1 deletion position/take_profit/risk_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from core.interfaces.abstract_position_take_profit_strategy import (
AbstractPositionTakeProfitStrategy,
)
from core.models.position_side import PositionSide
from core.models.side import PositionSide


class PositionRiskRewardTakeProfitStrategy(AbstractPositionTakeProfitStrategy):
Expand Down
Loading

0 comments on commit 5e12a31

Please sign in to comment.