pdmt5 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pdmt5/dataframe.py CHANGED
@@ -29,7 +29,6 @@ class Mt5Config(BaseModel):
29
29
  timeout: int | None = Field(
30
30
  default=None, description="Connection timeout in milliseconds"
31
31
  )
32
- portable: bool | None = Field(default=None, description="Use portable mode")
33
32
 
34
33
 
35
34
  class Mt5DataClient(Mt5Client):
@@ -51,14 +50,13 @@ class Mt5DataClient(Mt5Client):
51
50
  description="Number of retry attempts for connection initialization",
52
51
  )
53
52
 
54
- def initialize_mt5(
53
+ def initialize_and_login_mt5(
55
54
  self,
56
55
  path: str | None = None,
57
56
  login: int | None = None,
58
57
  password: str | None = None,
59
58
  server: str | None = None,
60
59
  timeout: int | None = None,
61
- portable: bool | None = None,
62
60
  ) -> None:
63
61
  """Initialize MetaTrader5 connection with retry logic.
64
62
 
@@ -70,18 +68,16 @@ class Mt5DataClient(Mt5Client):
70
68
  password: Account password (overrides config).
71
69
  server: Server name (overrides config).
72
70
  timeout: Connection timeout (overrides config).
73
- portable: Use portable mode (overrides config).
74
71
 
75
72
  Raises:
76
73
  Mt5RuntimeError: If initialization fails after retries.
77
74
  """
78
- initialize_kwargs = {
79
- "path": path or self.config.path,
75
+ path = path or self.config.path
76
+ login_kwargs = {
80
77
  "login": login or self.config.login,
81
78
  "password": password or self.config.password,
82
79
  "server": server or self.config.server,
83
80
  "timeout": timeout or self.config.timeout,
84
- "portable": portable if portable is not None else self.config.portable,
85
81
  }
86
82
  for i in range(1 + max(0, self.retry_count)):
87
83
  if i:
@@ -91,11 +87,12 @@ class Mt5DataClient(Mt5Client):
91
87
  self.retry_count,
92
88
  )
93
89
  time.sleep(i)
94
- if self.initialize(**initialize_kwargs): # type: ignore[reportArgumentType]
95
- self.logger.info("MT5 initialization successful.")
90
+ if self.initialize(path=path, **login_kwargs) and (
91
+ (not login_kwargs["login"]) or self.login(**login_kwargs)
92
+ ):
96
93
  return
97
94
  error_message = (
98
- f"MT5 initialization failed after {self.retry_count} retries:"
95
+ f"MT5 initialize and login failed after {self.retry_count} retries:"
99
96
  f" {self.last_error()}"
100
97
  )
101
98
  raise Mt5RuntimeError(error_message)
pdmt5/mt5.py CHANGED
@@ -106,7 +106,6 @@ class Mt5Client(BaseModel):
106
106
  password: str | None = None,
107
107
  server: str | None = None,
108
108
  timeout: int | None = None,
109
- portable: bool | None = None,
110
109
  ) -> bool:
111
110
  """Establish a connection with the MetaTrader 5 terminal.
112
111
 
@@ -116,7 +115,6 @@ class Mt5Client(BaseModel):
116
115
  password: Trading account password.
117
116
  server: Trade server address.
118
117
  timeout: Connection timeout in milliseconds.
119
- portable: Use portable mode.
120
118
 
121
119
  Returns:
122
120
  True if successful, False otherwise.
@@ -135,7 +133,6 @@ class Mt5Client(BaseModel):
135
133
  "password": password,
136
134
  "server": server,
137
135
  "timeout": timeout,
138
- "portable": portable,
139
136
  }.items()
140
137
  if v is not None
141
138
  },
pdmt5/trading.py CHANGED
@@ -32,6 +32,7 @@ class Mt5TradingClient(Mt5DataClient):
32
32
  def close_open_positions(
33
33
  self,
34
34
  symbols: str | list[str] | tuple[str, ...] | None = None,
35
+ dry_run: bool | None = None,
35
36
  **kwargs: Any, # noqa: ANN401
36
37
  ) -> dict[str, list[dict[str, Any]]]:
37
38
  """Close all open positions for specified symbols.
@@ -39,6 +40,8 @@ class Mt5TradingClient(Mt5DataClient):
39
40
  Args:
40
41
  symbols: Optional symbol or list of symbols to filter positions.
41
42
  If None, all symbols will be considered.
43
+ dry_run: Optional flag to enable dry run mode. If None, uses the instance's
44
+ `dry_run` attribute.
42
45
  **kwargs: Additional keyword arguments for request parameters.
43
46
 
44
47
  Returns:
@@ -53,18 +56,22 @@ class Mt5TradingClient(Mt5DataClient):
53
56
  symbol_list = self.symbols_get()
54
57
  self.logger.info("Fetching and closing positions for symbols: %s", symbol_list)
55
58
  return {
56
- s: self._fetch_and_close_position(symbol=s, **kwargs) for s in symbol_list
59
+ s: self._fetch_and_close_position(symbol=s, dry_run=dry_run, **kwargs)
60
+ for s in symbol_list
57
61
  }
58
62
 
59
63
  def _fetch_and_close_position(
60
64
  self,
61
65
  symbol: str | None = None,
66
+ dry_run: bool | None = None,
62
67
  **kwargs: Any, # noqa: ANN401
63
68
  ) -> list[dict[str, Any]]:
64
69
  """Close all open positions for a specific symbol.
65
70
 
66
71
  Args:
67
72
  symbol: Optional symbol filter.
73
+ dry_run: Optional flag to enable dry run mode. If None, uses the instance's
74
+ `dry_run` attribute.
68
75
  **kwargs: Additional keyword arguments for request parameters.
69
76
 
70
77
  Returns:
@@ -96,6 +103,7 @@ class Mt5TradingClient(Mt5DataClient):
96
103
  "position": p["ticket"],
97
104
  **kwargs,
98
105
  },
106
+ dry_run=dry_run,
99
107
  )
100
108
  for p in positions_dict
101
109
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdmt5
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Pandas-based data handler for MetaTrader 5
5
5
  Project-URL: Repository, https://github.com/dceoy/pdmt5.git
6
6
  Author-email: dceoy <dceoy@users.noreply.github.com>
@@ -0,0 +1,9 @@
1
+ pdmt5/__init__.py,sha256=QbSFrsi7_bgFzb-ma4DmmUjR90UvrqKMnRZq1wPRmoI,446
2
+ pdmt5/dataframe.py,sha256=rUWtR23hrXBdBqzJhbOlIemNy73RrjSTZZJUhwoL6io,38084
3
+ pdmt5/mt5.py,sha256=KgxHapIrh5b4L0wIOAQIjfXNZafalihbFrh9fhYHmrI,32254
4
+ pdmt5/trading.py,sha256=aa4eqRl-xrYqMTdgKgdLJuvg2GIoziE5wA3SRPn0jMs,7377
5
+ pdmt5/utils.py,sha256=Ll5Q3OE5h1A_sZ_qVEnOPGniFlT6_MmHfuu0zqeLdeU,3913
6
+ pdmt5-0.1.2.dist-info/METADATA,sha256=0PTSBNZFHetz9WJZLndgNGUSoxFNXFy18rpNJZK05s4,9029
7
+ pdmt5-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ pdmt5-0.1.2.dist-info/licenses/LICENSE,sha256=iABrdaUGOBWLYotFupB_PGe8arV5o7rVhn-_vK6P704,1073
9
+ pdmt5-0.1.2.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- pdmt5/__init__.py,sha256=QbSFrsi7_bgFzb-ma4DmmUjR90UvrqKMnRZq1wPRmoI,446
2
- pdmt5/dataframe.py,sha256=MumdFp72ZN_394X_viMkovfyb1c8C-LxLFTdymLEMYM,38345
3
- pdmt5/mt5.py,sha256=rAY7MQalobUWZtMfC_xyTFCDTuU3EkFAyY_geBl6cyg,32379
4
- pdmt5/trading.py,sha256=4rT0WgK0JyLMv8XatXur8-NWqG6gh_8XQ-g5sVX9xq0,6987
5
- pdmt5/utils.py,sha256=Ll5Q3OE5h1A_sZ_qVEnOPGniFlT6_MmHfuu0zqeLdeU,3913
6
- pdmt5-0.1.0.dist-info/METADATA,sha256=MJKmvQctS6kaU_OhqtXOYJNNa1uUutr2smvmUfnUD5g,9029
7
- pdmt5-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- pdmt5-0.1.0.dist-info/licenses/LICENSE,sha256=iABrdaUGOBWLYotFupB_PGe8arV5o7rVhn-_vK6P704,1073
9
- pdmt5-0.1.0.dist-info/RECORD,,
File without changes