Skip to content

Commit

Permalink
Merge pull request #5 from starsquidnodes/test
Browse files Browse the repository at this point in the history
Rework KUJI, NTRN, OSMO, STATOM, RIO
  • Loading branch information
starsquidnodes authored Jan 14, 2024
2 parents 5eda0db + 98877e1 commit 75050dc
Show file tree
Hide file tree
Showing 6 changed files with 1,661 additions and 399 deletions.
4 changes: 2 additions & 2 deletions scripts/create-feeder-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("filename", type=str)
parser.add_argument("--no-urlsets", action="store_true")
parser.add_argument("--keep-urlsets", action="store_true")
return parser.parse_args()


Expand Down Expand Up @@ -88,7 +88,7 @@ def main():
f'threshold = "{dt_value}"'
]

if not args.no_urlsets:
if args.keep_urlsets:
lines += header("url sets")

for us_name, us_urls in config.get("url_sets").items():
Expand Down
61 changes: 61 additions & 0 deletions scripts/provider-pairs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
import sys
import requests
import yaml

def get_pairs_binance(endpoint):
info_res = requests.get(f"{endpoint}/api/v3/exchangeInfo")
info_res.raise_for_status()
return [f"{s['baseAsset']}-{s['quoteAsset']}" for s in info_res.json()["symbols"]]

def get_pairs(provider):
if provider == "binance":
return get_pairs_binance("https://api.binance.com")
elif provider == "binanceus":
return get_pairs_binance("https://api.binance.us")
else:
raise RuntimeError("provider not supported")

def extend_yaml_config(provider, symbols, config_data):
config_symbols = config_data["currency_pairs"]
for symbol, data in config_symbols.items():
providers = data["providers"]
if symbol in symbols:
providers_list = [p.strip() for p in providers.split(",")]
if provider not in providers_list:
providers_list.append(provider)
config_data["currency_pairs"][symbol]["providers"] = ", ".join(providers_list)

def remove_yaml_config(provider, config_data):
config_symbols = config_data["currency_pairs"]
for symbol, data in config_symbols.items():
providers = data["providers"]
providers_list = [p.strip() for p in providers.split(",")]
if provider in providers_list:
providers_list.remove(provider)
config_data["currency_pairs"][symbol]["providers"] = ", ".join(providers_list)

if __name__ == "__main__":
if len(sys.argv) < 2:
print("usage: get-pairs.py <provider> [yaml_config]")
print("\toutputs pairs supported by provider.")
print("\tif yaml config is provided, outputs a modified config with the provider added to supported pairs.")
print("\tprefix the provider name with a dash to remove it from all pairs in the config where it exists.")
sys.exit(-1)
provider = sys.argv[1]
is_negated = provider.startswith("-")
if is_negated:
provider = provider[1:]
if len(sys.argv) == 2:
if is_negated:
raise RuntimeError("negation not supported with one argument")
print(get_pairs(provider))
elif len(sys.argv) > 2:
with open(sys.argv[2], "rb") as f:
config_data = yaml.safe_load(f)
if is_negated:
remove_yaml_config(provider, config_data)
else:
symbols = get_pairs(provider)
extend_yaml_config(provider, symbols, config_data)
print(yaml.safe_dump(config_data, width=float("inf")))
Loading

0 comments on commit 75050dc

Please sign in to comment.