pdmt5 0.2.1__py3-none-any.whl → 0.2.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/trading.py CHANGED
@@ -589,30 +589,31 @@ class Mt5TradingClient(Mt5DataClient):
589
589
  price=symbol_info_tick["bid"],
590
590
  )
591
591
  result = (
592
- positions_df.assign(
592
+ positions_df
593
+ .assign(
593
594
  elapsed_seconds=lambda d: (
594
595
  symbol_info_tick["time"] - d["time"]
595
596
  ).dt.total_seconds(),
596
597
  underlier_increase_ratio=lambda d: (
597
598
  d["price_current"] / d["price_open"] - 1
598
599
  ),
599
- buy=lambda d: (d["type"] == self.mt5.POSITION_TYPE_BUY),
600
- sell=lambda d: (d["type"] == self.mt5.POSITION_TYPE_SELL),
600
+ buy=lambda d: d["type"] == self.mt5.POSITION_TYPE_BUY,
601
+ sell=lambda d: d["type"] == self.mt5.POSITION_TYPE_SELL,
601
602
  )
602
603
  .assign(
603
604
  buy_i=lambda d: d["buy"].astype(int),
604
605
  sell_i=lambda d: d["sell"].astype(int),
605
606
  )
606
607
  .assign(
607
- sign=lambda d: (d["buy_i"] - d["sell_i"]),
608
+ sign=lambda d: d["buy_i"] - d["sell_i"],
608
609
  margin=lambda d: (
609
610
  (d["buy_i"] * ask_margin + d["sell_i"] * bid_margin)
610
611
  * d["volume"]
611
612
  ),
612
613
  )
613
614
  .assign(
614
- signed_volume=lambda d: (d["volume"] * d["sign"]),
615
- signed_margin=lambda d: (d["margin"] * d["sign"]),
615
+ signed_volume=lambda d: d["volume"] * d["sign"],
616
+ signed_margin=lambda d: d["margin"] * d["sign"],
616
617
  underlier_profit_ratio=lambda d: (
617
618
  d["underlier_increase_ratio"] * d["sign"]
618
619
  ),
pdmt5/utils.py CHANGED
@@ -87,9 +87,9 @@ def _convert_time_columns_in_df(df: pd.DataFrame) -> pd.DataFrame:
87
87
  new_df = df.copy()
88
88
  for c in new_df.columns:
89
89
  if c.startswith("time_") and c.endswith("_msc"):
90
- new_df[c] = pd.to_datetime(new_df[c], unit="ms")
90
+ new_df[c] = pd.to_datetime(new_df[c], unit="ms").astype("datetime64[ns]")
91
91
  elif c == "time" or c.startswith("time_"):
92
- new_df[c] = pd.to_datetime(new_df[c], unit="s")
92
+ new_df[c] = pd.to_datetime(new_df[c], unit="s").astype("datetime64[ns]")
93
93
  return new_df
94
94
 
95
95
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdmt5
3
- Version: 0.2.1
3
+ Version: 0.2.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>
@@ -339,7 +339,7 @@ with Mt5TradingClient(config=config) as trader:
339
339
  sell_margin = trader.calculate_minimum_order_margin("EURUSD", "SELL")
340
340
  print(f"Minimum BUY margin: {buy_margin['margin']} (volume: {buy_margin['volume']})")
341
341
  print(f"Minimum SELL margin: {sell_margin['margin']} (volume: {sell_margin['volume']})")
342
-
342
+
343
343
  # Calculate volume by margin
344
344
  available_margin = 1000.0
345
345
  max_buy_volume = trader.calculate_volume_by_margin("EURUSD", available_margin, "BUY")
@@ -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=OFBkONLTrut9aWPvi0-JJMVdoaZBFEsVIC8ZrErqfY8,25576
5
+ pdmt5/utils.py,sha256=1-NDVVLSkwgPWfGhwWMeYphnFwi8vCLo_UCL5KAO-uQ,3963
6
+ pdmt5-0.2.2.dist-info/METADATA,sha256=VO8I_fkEFjpzo_TL8sQVHqgGhm9le3cA9KHcDyPwHxM,16096
7
+ pdmt5-0.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
8
+ pdmt5-0.2.2.dist-info/licenses/LICENSE,sha256=iABrdaUGOBWLYotFupB_PGe8arV5o7rVhn-_vK6P704,1073
9
+ pdmt5-0.2.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,9 +0,0 @@
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=Qd4RhZprDcWTzT3JmKl8XGVq8i9hExNdPSJbCRdUx-s,25569
5
- pdmt5/utils.py,sha256=Ll5Q3OE5h1A_sZ_qVEnOPGniFlT6_MmHfuu0zqeLdeU,3913
6
- pdmt5-0.2.1.dist-info/METADATA,sha256=OjDjumI_5kGHyEjpIg-xgZyGJSULRUJM_LQnv2IeJ-4,16100
7
- pdmt5-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- pdmt5-0.2.1.dist-info/licenses/LICENSE,sha256=iABrdaUGOBWLYotFupB_PGe8arV5o7rVhn-_vK6P704,1073
9
- pdmt5-0.2.1.dist-info/RECORD,,