mango-explorer/bin/show-funding-rates

36 lines
1023 B
Python
Executable File

#!/usr/bin/env python3
import argparse
import os
import os.path
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
import mango # nopep8
parser = argparse.ArgumentParser(
description="Shows the current funding rates for a perp market in a Mango Markets Group."
)
mango.ContextBuilder.add_command_line_parameters(parser)
parser.add_argument(
"--market",
type=str,
required=True,
help="symbol of the market to look up, e.g. 'ETH-PERP'",
)
args: argparse.Namespace = mango.parse_args(parser)
context = mango.ContextBuilder.from_command_line_parameters(args)
group = mango.Group.load(context)
market = context.market_lookup.find_by_symbol(args.market)
if market is None:
raise Exception(f"Could not find market {args.market}")
perp_market = mango.ensure_market_loaded(context, market)
if not isinstance(perp_market, mango.PerpMarket):
raise Exception(f"Market {args.market} is not a perp market.")
mango.output(perp_market.fetch_funding(context))