def __init__(self, api_key: str, api_secret: str, passphrase: str, is_debug=False): super().__init__(api_key, api_secret, passphrase, is_debug=is_debug) self.account_api = account_api.AccountAPI(self.api_key, self.api_secret, self.passphrase, False) self.spot_api = spot_api.SpotAPI(self.api_key, self.api_secret, self.passphrase, False) self.margin_api = lever_api.LeverAPI(self.api_key, self.api_secret, self.passphrase, False) self.futures_api = futures_api.FutureAPI(self.api_key, self.api_secret, self.passphrase, False) self.swap_api = swap_api.SwapAPI(self.api_key, self.api_secret, self.passphrase, False) self.options_api = option_api.OptionAPI(self.api_key, self.api_secret, self.passphrase, False) self.information_api = information_api.InformationAPI( self.api_key, self.api_secret, self.passphrase, False) self.index_api = index_api.IndexAPI(self.api_key, self.api_secret, self.passphrase, False)
# result = optionAPI.get_trade_fee() # 公共-获取标的指数 (20次/2s) # result = optionAPI.get_index() # 公共-获取期权合约 (20次/2s) # result = optionAPI.get_instruments('') # 公共-获取期权合约详细定价 (20次/2s) # result = optionAPI.get_instruments_summary('') # 公共-获取单个期权合约详细定价 (20次/2s) # result = optionAPI.get_option_instruments_summary('', '') # 公共-获取深度数据 (20次/2s) # result = optionAPI.get_depth('') # 公共-获取成交数据 (20次/2s) # result = optionAPI.get_trades('') # 公共-获取某个Ticker信息 (20次/2s) # result = optionAPI.get_specific_ticker('') # 公共-获取K线数据 (20次/2s) # result = optionAPI.get_kline('') # index api test # 指数API indexAPI = index.IndexAPI(api_key, secret_key, passphrase, False) # 公共-获取指数成分 (20次/2s) # result = indexAPI.get_index_constituents('') # system api test # 获取系统升级状态 system = system.SystemAPI(api_key, secret_key, passphrase, False) # 公共-获取系统升级状态(1次/5s) # result = system.get_system_status('') print(time + json.dumps(result))
# 公共-获取平台总持仓量 (20次/2s) # result = swapAPI.get_holds('XRP-USD-SWAP') # 公共-获取当前限价 (20次/2s) # result = swapAPI.get_limit('XRP-USD-SWAP') # 公共-获取强平单 (20次/2s) # result = swapAPI.get_liquidation('XRP-USD-SWAP', '1') # 公共-获取合约资金费率 (20次/2s) # result = swapAPI.get_funding_time('XRP-USD-SWAP') # 公共-获取合约标记价格 (20次/2s) # result = swapAPI.get_mark_price('XRP-USD-SWAP') # 公共-获取合约历史资金费率 (能查询最近7天的数据)(20次/2s) # result = swapAPI.get_historical_funding_rate('XRP-USD-SWAP') # 指数API # index api test indexAPI = index.IndexAPI(api_key, seceret_key, passphrase, True) # 公共-获取指数成分 (20次/2s) # result = indexAPI.get_index_constituents('BTC-USD') # 期权合约API # option api test optionAPI = option.OptionAPI(api_key, seceret_key, passphrase, True) # 单个标的指数持仓信息 (20次/2s) # result = optionAPI.get_specific_position('TBTC-USD') # 单个标的物账户信息 (20次/2s) # result = optionAPI.get_underlying_account('TBTC-USD') # 下单 (40次/2s) # result = optionAPI.take_order('TBTC-USD-191213-7000-C', 'buy', '', '1', match_price='1') # 批量下单 (每个标的指数最多可批量下10个单)(20次/2s) # result = optionAPI.take_orders('TBTC-USD', [ # {"instrument_id": "TBTC-USD-191213-6000-C", "side": "buy", "price": "0.1835", "size": "1", "order_type": "0", "match_price": "0"},