Spaces:
Sleeping
Sleeping
Update models/suggestion.py
Browse files- models/suggestion.py +18 -11
models/suggestion.py
CHANGED
@@ -14,9 +14,9 @@ class RecommendationType(str, Enum):
|
|
14 |
|
15 |
|
16 |
class TakeProfitPoints(BaseModel):
|
17 |
-
first: float
|
18 |
-
second: float
|
19 |
-
third: float
|
20 |
|
21 |
|
22 |
class TradeSuggestion(BaseModel):
|
@@ -30,21 +30,28 @@ class TradeSuggestion(BaseModel):
|
|
30 |
trade_amount: float
|
31 |
|
32 |
@property
|
33 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
if self.direction == TradeDirection.LONG:
|
35 |
return (
|
36 |
((self.take_profit.third - self.entry_price) / self.entry_price)
|
37 |
* 100
|
38 |
* self.recommended_leverage
|
39 |
)
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
)
|
46 |
|
47 |
-
def to_prompt_dict(self):
|
48 |
return {
|
49 |
"symbol": self.symbol,
|
50 |
"direction": self.direction.value,
|
|
|
14 |
|
15 |
|
16 |
class TakeProfitPoints(BaseModel):
|
17 |
+
first: float = Field(..., description="First take profit")
|
18 |
+
second: float = Field(..., description="Second take profit")
|
19 |
+
third: float = Field(..., description="Third take profit")
|
20 |
|
21 |
|
22 |
class TradeSuggestion(BaseModel):
|
|
|
30 |
trade_amount: float
|
31 |
|
32 |
@property
|
33 |
+
def is_entry_better_than_current(self) -> bool:
|
34 |
+
return (
|
35 |
+
self.entry_price <= self.current_price
|
36 |
+
if self.direction == TradeDirection.LONG
|
37 |
+
else self.entry_price >= self.current_price
|
38 |
+
)
|
39 |
+
|
40 |
+
@property
|
41 |
+
def potential_profit_percentage(self) -> float:
|
42 |
if self.direction == TradeDirection.LONG:
|
43 |
return (
|
44 |
((self.take_profit.third - self.entry_price) / self.entry_price)
|
45 |
* 100
|
46 |
* self.recommended_leverage
|
47 |
)
|
48 |
+
return (
|
49 |
+
((self.entry_price - self.take_profit.third) / self.entry_price)
|
50 |
+
* 100
|
51 |
+
* self.recommended_leverage
|
52 |
+
)
|
|
|
53 |
|
54 |
+
def to_prompt_dict(self) -> dict:
|
55 |
return {
|
56 |
"symbol": self.symbol,
|
57 |
"direction": self.direction.value,
|