Rewrite, edit and organize examples/rest demos.

This commit is contained in:
Davide Casale
2023-02-20 18:11:10 +01:00
parent e3eb3d6a56
commit cec9d6ba68
33 changed files with 353 additions and 589 deletions

View File

@@ -0,0 +1,28 @@
# python -c "import examples.rest.public.rest_calculation_endpoints"
from bfxapi import Client, PUB_REST_HOST
from bfxapi.rest.types import TradingMarketAveragePrice, FundingMarketAveragePrice, FxRate
bfx = Client(REST_HOST=PUB_REST_HOST)
trading_market_average_price: TradingMarketAveragePrice = bfx.rest.public.get_trading_market_average_price(
symbol="tBTCUSD",
amount=-100,
price_limit=20000.5
)
print("Average execution price for tBTCUSD:", trading_market_average_price.price_avg)
funding_market_average_price: FundingMarketAveragePrice = bfx.rest.public.get_funding_market_average_price(
symbol="fUSD",
amount=100,
period=2,
rate_limit=0.00015
)
print("Average execution rate for fUSD:", funding_market_average_price.rate_avg)
fx_rate: FxRate = bfx.rest.public.get_fx_rate(ccy1="USD", ccy2="EUR")
print("Exchange rate between USD and EUR:", fx_rate.current_rate)