|
| 1 | +import os |
| 2 | +import logging |
| 3 | +from datamaxi import Datamaxi |
| 4 | + |
| 5 | + |
| 6 | +logging.basicConfig(level=logging.INFO) |
| 7 | + |
| 8 | +api_key = os.getenv("API_KEY") |
| 9 | +base_url = os.getenv("BASE_URL") or "https://api.datamaxiplus.com" |
| 10 | + |
| 11 | +datamaxi = Datamaxi(api_key=api_key, base_url=base_url) |
| 12 | + |
| 13 | + |
| 14 | +def testcall(func, **kwargs): |
| 15 | + name = f"{func.__module__}.{func.__qualname__}" |
| 16 | + logging.info(name) |
| 17 | + func(**kwargs) |
| 18 | + logging.info(f"{name} ok") |
| 19 | + |
| 20 | + |
| 21 | +logging.info("cex candle") |
| 22 | +testcall( |
| 23 | + datamaxi.cex.candle, |
| 24 | + exchange="binance", |
| 25 | + symbol="BTC-USDT", |
| 26 | + interval="1m", |
| 27 | + market="spot", |
| 28 | +) |
| 29 | +testcall(datamaxi.cex.candle.exchanges, market="spot") |
| 30 | +testcall(datamaxi.cex.candle.symbols, exchange="binance", market="spot") |
| 31 | +testcall(datamaxi.cex.candle.intervals) |
| 32 | + |
| 33 | +logging.info("cex ticker") |
| 34 | +testcall(datamaxi.cex.ticker.exchanges, market="spot") |
| 35 | +testcall(datamaxi.cex.ticker.symbols, exchange="binance", market="spot") |
| 36 | + |
| 37 | +logging.info("cex token updates") |
| 38 | +testcall(datamaxi.cex.token.updates) |
| 39 | + |
| 40 | +logging.info("cex fees") |
| 41 | +testcall(datamaxi.cex.fee.get, exchange="binance", symbol="BTC-USDT") |
| 42 | +testcall(datamaxi.cex.fee.exchanges) |
| 43 | +testcall(datamaxi.cex.fee.symbols, exchange="binance") |
| 44 | + |
| 45 | +logging.info("cex announcement") |
| 46 | +testcall(datamaxi.cex.announcement.get) |
| 47 | + |
| 48 | +logging.info("cex transfer") |
| 49 | +testcall(datamaxi.cex.wallet_status.get, exchange="binance", asset="BTC") |
| 50 | +testcall(datamaxi.cex.wallet_status.exchanges) |
| 51 | +testcall(datamaxi.cex.wallet_status.assets, exchange="binance") |
| 52 | + |
| 53 | +logging.info("funding rate") |
| 54 | +testcall(datamaxi.funding_rate.history, exchange="binance", symbol="BTC-USDT") |
| 55 | +testcall(datamaxi.funding_rate.latest, exchange="binance", symbol="BTC-USDT") |
| 56 | +testcall(datamaxi.funding_rate.exchanges) |
| 57 | +testcall(datamaxi.funding_rate.symbols, exchange="binance") |
| 58 | + |
| 59 | + |
| 60 | +logging.info("dex") |
| 61 | +testcall(datamaxi.dex.chains) |
| 62 | +testcall(datamaxi.dex.exchanges) |
| 63 | +testcall(datamaxi.dex.pools, exchange="klayswap", chain="kaia_mainnet") |
| 64 | +testcall(datamaxi.dex.intervals) |
| 65 | +testcall( |
| 66 | + datamaxi.dex.trade, |
| 67 | + exchange="pancakeswap", |
| 68 | + chain="bsc_mainnet", |
| 69 | + pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423", |
| 70 | +) |
| 71 | +testcall( |
| 72 | + datamaxi.dex.liquidity, |
| 73 | + exchange="pancakeswap", |
| 74 | + chain="bsc_mainnet", |
| 75 | + pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423", |
| 76 | +) |
| 77 | +testcall( |
| 78 | + datamaxi.dex.trade, |
| 79 | + exchange="pancakeswap", |
| 80 | + chain="bsc_mainnet", |
| 81 | + pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423", |
| 82 | +) |
| 83 | + |
| 84 | +logging.info("forex") |
| 85 | +testcall(datamaxi.forex.symbols) |
| 86 | +testcall(datamaxi.forex, symbol="USD-KRW", pandas=True) |
| 87 | + |
| 88 | +logging.info("premium") |
| 89 | +testcall(datamaxi.premium) |
| 90 | +testcall(datamaxi.premium.exchanges) |
0 commit comments