-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusde.py
37 lines (31 loc) · 1.18 KB
/
usde.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from src.utils.llama import StableLlamaAPI
import polars as pl
def get_usde_circulating_supply():
stable_llama = StableLlamaAPI()
df_usde = stable_llama.get_a_stablecoin(id=146)
df_eth = pl.DataFrame(df_usde["chainBalances"]["Ethereum"]["tokens"])
df_eth = df_eth.with_columns(
(pl.col("date") * 1000).cast(pl.Datetime("ms")).alias("date"),
pl.col("circulating")
.struct.field("peggedUSD")
.cast(pl.Int64)
.alias("circulating"),
pl.col("minted").struct.field("peggedUSD").cast(pl.Int64).alias("minted"),
)
dfs = {}
for key in list(df_usde["chainBalances"].keys())[:1]:
df = pl.DataFrame(df_usde["chainBalances"][key]["tokens"])
print(df.schema)
print(df.head())
df = df.with_columns(
(pl.col("date") * 1000).cast(pl.Datetime("ms")).alias("date"),
pl.col("circulating")
.struct.field("peggedUSD")
.cast(pl.Int64)
.alias("circulating"),
pl.col("minted").struct.field("peggedUSD").cast(pl.Int64).alias("minted"),
)
dfs[key] = df
return dfs
if __name__ == "__main__":
get_usde_circulating_supply()