Files
spark/src/lib_python_interop/python_interop_plugins/binance_test.py
T
John Colvin 2174162081 refactor: Consolidate all py interop into single lib
It was just too hard trying to make it work with separate libs. The
main issue was getting the python md and execution modules to
recognize PySecurityList and other types defined in the core module.
2025-06-09 06:06:50 +00:00

50 lines
1.0 KiB
Python

import json
from typing import Optional
from pathlib import Path
test_data_dir = Path("/").joinpath(
"home",
"bts",
".local",
"share",
"bts",
"sparkd",
"data",
"test_data",
"binance",
)
def load_securities() -> list:
with open(test_data_dir.joinpath("exch_info.json")) as f:
return json.load(f)["symbols"]
return []
def load_books() -> list:
with open(test_data_dir.joinpath("books.json")) as f:
return json.load(f)["books"]
return []
if __name__ == "__main__":
raw_secs = load_securities()
for s in raw_secs:
obj = {
"venue": "Binance",
"name": s["symbol"],
"asset": s["baseAsset"],
"group": s["baseAsset"],
"currency": s["quoteAsset"],
}
print(json.dumps(obj))
raw_books = load_books()
for b in raw_books:
obj = {
"name": b["name"],
"bids": b["bids"],
"asks": b["asks"],
}
print(json.dumps(obj))