wiki/examples/py/apex-watch.md
import os
import sys
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
import asyncio
import ccxt.pro as ccxt # noqa: E402
# AUTO-TRANSPILE #
'use strict'
print('CCXT Version:', ccxt.version) # eslint-disable-line import/no-named-as-default-member
async def loop(exchange, symbol):
while True:
try:
ticker = await exchange.watch_ticker(symbol)
print(Date(), exchange.id, symbol)
print(ticker)
await exchange.sleep(1000)
except Exception as e:
print(e)
async def main():
exchange = ccxt.apex({
'apiKey': 'your api Key',
'secret': 'your api secret',
'walletAddress': 'your eth address',
'options': {
'accountId': 'your account id',
'passphrase': 'your api passphrase',
'seeds': 'your zklink omni seed',
'brokerId': '',
},
})
exchange.set_sandbox_mode(True)
if exchange.has['watchTicker']:
await exchange.load_markets()
target_symbols = ['BTC-USDT', 'ETH-USDT']
for i in range(0, len(target_symbols)):
symbol = target_symbols[i]
await exchange.close()
asyncio.run(loop(exchange, symbol))
else:
print(exchange.id, 'does not support watchTicker yet')
main()