Skip to content

Instantly share code, notes, and snippets.

@berkorbay
Created January 4, 2024 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berkorbay/00085f222feca38b434d4de96df19cf6 to your computer and use it in GitHub Desktop.
Save berkorbay/00085f222feca38b434d4de96df19cf6 to your computer and use it in GitHub Desktop.
İlk 3 Gün GİP Hacimleri Karşılaştırması
## GİP Hacim Karşılaştırma
from eptr2 import EPTR2
import re
import pandas as pd
eptr = EPTR2()
idm_qty_24 = eptr.call("idm-qty", start_date="2024-01-01", end_date="2024-01-03")
idm_qty_23 = eptr.call("idm-qty", start_date="2023-01-01", end_date="2023-01-03")
idm_vol_24 = eptr.call("idm-volume", start_date="2024-01-01", end_date="2024-01-03")
idm_vol_23 = eptr.call("idm-volume", start_date="2023-01-01", end_date="2023-01-03")
idm_qty_23["actual_qty"] = idm_qty_23.apply(
lambda row: (
int(re.sub(".*\-", "", row["kontratAdi"]))
if str(row["kontratAdi"]).startswith("PB")
else 1
)
* row["clearingQuantity"],
axis=1,
)
tot_qty_23 = idm_qty_23["actual_qty"].sum()
tot_qty_23_breakdown = (
idm_qty_23[["kontratTuru", "actual_qty"]].groupby("kontratTuru").sum().to_dict()
)
tot_qty_24 = idm_qty_24["clearingQuantity"].sum()
tot_vol_23 = idm_vol_23["tradingVolume"].sum()
vol_23_breakdown = idm_vol_23.groupby("kontratTuru").sum("tradingVolume").to_dict()
tot_vol_24 = idm_vol_24["tradingVolume"].sum()
results = {
"miktar": {
"2023": {"toplam": tot_qty_23, **tot_qty_23_breakdown["actual_qty"]},
"2024": {"toplam": tot_qty_24, "Saatlik": tot_qty_24, "Blok": 0},
},
"hacim": {
"2023": {"toplam": tot_vol_23, **vol_23_breakdown["tradingVolume"]},
"2024": {"toplam": tot_vol_24, "Saatlik": tot_vol_24, "Blok": 0},
},
}
print(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment