Spaces:
Sleeping
Sleeping
Create suggestion.py
Browse files- suggestion.py +60 -0
suggestion.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from enum import Enum
|
2 |
+
from pydantic import BaseModel, Field
|
3 |
+
|
4 |
+
|
5 |
+
class TradeDirection(str, Enum):
|
6 |
+
LONG = "long"
|
7 |
+
SHORT = "short"
|
8 |
+
|
9 |
+
|
10 |
+
class RecommendationType(str, Enum):
|
11 |
+
RECOMMENDED = "It is recommended to enter the transaction."
|
12 |
+
NOT_RECOMMENDED = "It is not recommended to enter into a transaction."
|
13 |
+
CAUTIOUS = "Entering the trade with caution"
|
14 |
+
|
15 |
+
|
16 |
+
class TakeProfitPoints(BaseModel):
|
17 |
+
first: float
|
18 |
+
second: float
|
19 |
+
third: float
|
20 |
+
|
21 |
+
|
22 |
+
class TradeSuggestion(BaseModel):
|
23 |
+
symbol: str
|
24 |
+
direction: TradeDirection
|
25 |
+
entry_price: float
|
26 |
+
recommended_leverage: int
|
27 |
+
take_profit: TakeProfitPoints
|
28 |
+
recommendation: RecommendationType
|
29 |
+
current_price: float
|
30 |
+
trade_amount: float
|
31 |
+
|
32 |
+
@property
|
33 |
+
def potential_profit_percentage(self):
|
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 |
+
else:
|
41 |
+
return (
|
42 |
+
((self.entry_price - self.take_profit.third) / self.entry_price)
|
43 |
+
* 100
|
44 |
+
* self.recommended_leverage
|
45 |
+
)
|
46 |
+
|
47 |
+
def to_prompt_dict(self):
|
48 |
+
return {
|
49 |
+
"symbol": self.symbol,
|
50 |
+
"direction": self.direction.value,
|
51 |
+
"entry_price": f"${self.entry_price:.2f}",
|
52 |
+
"leverage": f"{self.recommended_leverage}x",
|
53 |
+
"take_profit_1": f"${self.take_profit.first:.2f}",
|
54 |
+
"take_profit_2": f"${self.take_profit.second:.2f}",
|
55 |
+
"take_profit_3": f"${self.take_profit.third:.2f}",
|
56 |
+
"recommendation": self.recommendation.value,
|
57 |
+
"current_price": f"${self.current_price:.2f}",
|
58 |
+
"trade_amount": f"${self.trade_amount:.2f}",
|
59 |
+
"potential_profit": f"{self.potential_profit_percentage:.2f}%",
|
60 |
+
}
|