luxorasap 0.1.26__py3-none-any.whl → 0.1.27__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.
luxorasap/__init__.py CHANGED
@@ -13,7 +13,7 @@ from types import ModuleType
13
13
  try:
14
14
  __version__: str = metadata.version(__name__)
15
15
  except metadata.PackageNotFoundError: # editable install
16
- __version__ = "0.1.26"
16
+ __version__ = "0.1.27"
17
17
 
18
18
  # ─── Lazy loader ─────────────────────────────────────────────────
19
19
  def __getattr__(name: str) -> ModuleType:
@@ -637,7 +637,6 @@ class LuxorQuery:
637
637
  tickers = [t.lower() for t in tickers] # padronizando tickers para lowercase
638
638
 
639
639
  prices = self.hist_prices_table.copy()
640
-
641
640
 
642
641
  surrogate_previous_date = previous_date - dt.timedelta(days=30)
643
642
  surrogate_recent_date = recent_date + dt.timedelta(days=30)
@@ -658,7 +657,7 @@ class LuxorQuery:
658
657
 
659
658
  if get_intraday_prices:
660
659
  prices = self.__hist_prices_intraday_extensor(prices)
661
-
660
+
662
661
  if currency != "local":
663
662
 
664
663
  # TODO: Resolver problema de consistencia com ticker e ticker_bbg
@@ -667,25 +666,29 @@ class LuxorQuery:
667
666
 
668
667
  ticker_map = assets.query("~Ticker_BBG.isna() and Ticker_BBG != Ticker")[["Ticker", "Ticker_BBG"]].set_index("Ticker").to_dict("index")
669
668
  assets["Ticker"] = assets["Ticker"].apply(lambda x: ticker_map[x]["Ticker_BBG"] if x in ticker_map.keys() else x)
670
-
671
- prices = pd.merge(assets[["Ticker", "Location"]], prices, left_on="Ticker", right_on="Asset")[["Date", "Asset", "Last_Price", "Location"]]
669
+ ticker_to_location = assets[["Ticker", "Location"]].drop_duplicates()
670
+ prices = pd.merge(prices, ticker_to_location, left_on="Asset", right_on="Ticker", how='left')[["Date", "Asset", "Last_Price", "Location"]]
671
+
672
672
  currency_map = {"bz":"brl","br":"brl", "us":"usd", "cn":"cad", "eur":"eur"}
673
673
  prices["Location"] = prices["Location"].apply(lambda x: currency_map.get(x, 'not found'))
674
674
 
675
675
  prices_by_location = []
676
676
  iter_prices = prices.groupby("Location")
677
-
677
+
678
678
  for p in iter_prices:
679
+
679
680
  if p[0] == 'not found':
680
681
  assets_not_found = list(p[1]["Asset"].unique())
681
682
  logger.warning(f"currency_map nao suporta Location dos ativos {assets_not_found}.")
682
683
  continue
683
684
  price_currency = p[0]
685
+
684
686
  converted_prices = self.convert_currency(p[1][list(set(p[1].columns) - {"Location"})],
685
687
  price_currency=price_currency, dest_currency=currency,
686
688
  usdbrl_ticker=usdbrl_ticker, force_continuous_date_range=force_continuous_date_range,
687
689
  holiday_location=holiday_location, get_intraday_prices=get_intraday_prices,
688
690
  force_month_end=force_month_end)
691
+
689
692
  if not converted_prices.empty:
690
693
  prices_by_location.append(converted_prices)
691
694
 
@@ -697,7 +700,7 @@ class LuxorQuery:
697
700
 
698
701
  # Finalmente, vamos seguir filtrando pelo periodo desejado.
699
702
  prices = prices.query("Date <= @recent_date and Date >= @previous_date and Asset.isin(@tickers)")
700
-
703
+
701
704
  #if adjust_bmfxlcoc and ('bmfxclco curncy' in tickers) and (recent_date == dt.date.today()):
702
705
  # max_date = prices.query("Asset == 'bmfxclco curncy'")["Date"].max()
703
706
  # if max_date < dt.date.today(): # vamos colocar mais um dia usando usdbrl curncy
@@ -1558,6 +1561,7 @@ class LuxorQuery:
1558
1561
  period=period, holiday_location=holiday_location,
1559
1562
  currency=currency, agregate_by_name=False, usdbrl_ticker=usdbrl_ticker
1560
1563
  )
1564
+
1561
1565
  # Vamos obter os precos de fechamento em cada dia
1562
1566
  # Preenchendo primeiro todo o historico
1563
1567
  prices_previous_date = (df["Date"].min() - dt.timedelta(days=100)).date()
@@ -1566,8 +1570,9 @@ class LuxorQuery:
1566
1570
  tickers=price_keys, previous_date=prices_previous_date, currency=currency,
1567
1571
  get_intraday_prices=True, usdbrl_ticker=usdbrl_ticker
1568
1572
  ).rename(columns={"Asset":"Price_Key"})
1569
-
1570
- df = df.merge(prices, on=["Date", "Price_Key"], how="left")
1573
+
1574
+ #df = df.merge(prices, on=["Date", "Price_Key"], how="left")
1575
+ df = df.merge(prices, on=["Date", "Price_Key"]) #, how="left")
1571
1576
  # Finalmente, vamos atualizar com o preco mais recente do ativo na data de hoje
1572
1577
  #df_prev = df.query("Date < @dt.date.today()").copy()
1573
1578
  #df_today = df.query("Date == @dt.date.today()").copy()
@@ -1591,7 +1596,7 @@ class LuxorQuery:
1591
1596
 
1592
1597
  # preenchendo Last_Price nulos com o do dia anterior para os mesmos asset_id
1593
1598
  df["Last_Price"] = df.groupby("Asset_ID")["Last_Price"].ffill()
1594
-
1599
+
1595
1600
  return df
1596
1601
 
1597
1602
 
@@ -1764,7 +1769,7 @@ class LuxorQuery:
1764
1769
  usdbrl_ticker=usdbrl_ticker).rename(columns={"Asset":"Price_Key"})
1765
1770
 
1766
1771
  positions_and_movements = positions_and_movements.merge(prices[["Date", "Price_Key", "Last_Price"]], on=["Date","Price_Key"])
1767
-
1772
+
1768
1773
  positions_and_movements["Period"] = period
1769
1774
  positions_and_movements["Currency"] = currency
1770
1775
  # Consideramos como ativos atuais aqueles que possuem posicao aberta ou que foram encerradas no dia
@@ -1798,7 +1803,7 @@ class LuxorQuery:
1798
1803
  positions_and_movements = positions_and_movements.merge(spx_prices, on="Date", how="left")
1799
1804
 
1800
1805
  #positions_and_movements["spx_index"] = (positions_and_movements["spx_index"].pct_change().fillna(0)+1).cumprod()-1
1801
-
1806
+
1802
1807
  return positions_and_movements.rename(columns={"Price_Key":"Ticker"})
1803
1808
 
1804
1809
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luxorasap
3
- Version: 0.1.26
3
+ Version: 0.1.27
4
4
  Summary: Toolbox da Luxor para ingestão, análise e automação de dados financeiros.
5
5
  Author-email: Luxor Group <backoffice@luxor.com.br>
6
6
  License: Proprietary – All rights reserved
@@ -1,10 +1,10 @@
1
- luxorasap/__init__.py,sha256=0CdN0DYQg1fsYpGr_uL9pWLMvXJc8uoMmv-7n_qY1gg,1356
1
+ luxorasap/__init__.py,sha256=Lap_a2YVeAI84i3uDJettMmJb6Er5EKKvYcw9i4Fcuc,1356
2
2
  luxorasap/btgapi/__init__.py,sha256=QUlfb5oiBY6K1Q5x4-a-x2wECe1At5wc2962I5odOJk,620
3
3
  luxorasap/btgapi/auth.py,sha256=PvyCtbEyBO2B1CIeAlNXWugKW1OgiKfPcVzS6K5FBnQ,1872
4
4
  luxorasap/btgapi/reports.py,sha256=ZVEMLoJPXc0r3XjPJPMsKQN0zZd1Npd7umNpAj1bncs,8040
5
5
  luxorasap/btgapi/trades.py,sha256=956HZ9BvN9C_VQvKTyBLN0x6ZygwVqBZN11F7OnNbDI,5985
6
6
  luxorasap/datareader/__init__.py,sha256=41RAvbrQ4R6oj67S32CrKqolx0CJ2W8cbOF6g5Cqm2g,120
7
- luxorasap/datareader/core.py,sha256=uBO8XxFxm5103OwFZgKm20KHqjbni-JTN_A8G5vhp0U,155775
7
+ luxorasap/datareader/core.py,sha256=mNXCHYTK-e-8cyfwwVAkHjgchqIg1WJa4rY1zXPCSR4,156040
8
8
  luxorasap/ingest/__init__.py,sha256=XhxDTN2ar-u6UCPhnxNU_to-nWiit-SpQ6cA_N9eMSs,795
9
9
  luxorasap/ingest/cloud/__init__.py,sha256=azo4zLS-kmV2ZZjePFB4CsibL4obbzHChC-Rn3Jp2Bc,2168
10
10
  luxorasap/ingest/legacy_local/dataloader.py,sha256=zKPhuiBSFwkuWN6d8g2s60KkbVk1R_1cGMCtQM9j-0c,11908
@@ -14,8 +14,8 @@ luxorasap/utils/dataframe/reader.py,sha256=Vzjdw-AeS1lnWEHQ8RZNh0kK93NWTp0NWVi_B
14
14
  luxorasap/utils/dataframe/transforms.py,sha256=OIvlTTcjFX6bUhuQp_syEp7ssm4sLzwvgsag6n2Wl3k,2438
15
15
  luxorasap/utils/storage/__init__.py,sha256=U3XRq94yzRp3kgBSUcRzs2tQgJ4o8h8a1ZzwiscA5XM,67
16
16
  luxorasap/utils/storage/blob.py,sha256=0QnwrUP-9vWYK8ffa6NqE7rV_t6RdScRM8GQnMxY_4w,3184
17
- luxorasap-0.1.26.dist-info/METADATA,sha256=SvMgaLYEOkv8EDmoqaAJ5_YY5ZcepzxrLDw5XDoilJk,3804
18
- luxorasap-0.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- luxorasap-0.1.26.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
20
- luxorasap-0.1.26.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
21
- luxorasap-0.1.26.dist-info/RECORD,,
17
+ luxorasap-0.1.27.dist-info/METADATA,sha256=okMLILpjx_OJjBP3R2Sf4MFE1wZofKmi230l2yG5__0,3804
18
+ luxorasap-0.1.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ luxorasap-0.1.27.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
20
+ luxorasap-0.1.27.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
21
+ luxorasap-0.1.27.dist-info/RECORD,,