Exemplo n.º 1
0
 def __init__(self, access_key, secret_key, passphrase, instrument_id, margin_mode=None, leverage=None):
     """
     okex永续合约
     :param access_key:
     :param secret_key:
     :param passphrase:
     :param instrument_id: 例如:"BTC-USDT-SWAP", "BTC-USD-SWAP"
     :param leverage:杠杆倍数,如不填则默认设置20倍杠杆
     """
     self.__access_key = access_key
     self.__secret_key = secret_key
     self.__passphrase = passphrase
     self.__instrument_id = instrument_id
     self.__okex_swap = okexswap.SwapAPI(self.__access_key, self.__secret_key, self.__passphrase)
     self.__leverage = leverage or 20
     if margin_mode == "fixed":
         try:
             self.__okex_swap.set_leverage(leverage=self.__leverage, instrument_id=self.__instrument_id, side=1)
             self.__okex_swap.set_leverage(leverage=self.__leverage, instrument_id=self.__instrument_id, side=2)
         except Exception as e:
             logger.error("OKEX永续合约设置杠杆倍数失败!请检查账户是否已设置成逐仓模式!错误:{}".format(str(e)))
     else:
         try:
             self.__okex_swap.set_leverage(leverage=self.__leverage, instrument_id=self.__instrument_id, side=3)
         except Exception as e:
             logger.error("OKEX永续合约设置杠杆倍数失败!请检查账户是否已设置成全仓模式!错误:{}".format(str(e)))
Exemplo n.º 2
0
 def __init__(self, access_key, secret_key, passphrase, instrument_id):
     self.access_key = access_key
     self.secret_key = secret_key
     self.passphrase = passphrase
     self.instrument_id = instrument_id
     self.okex_swap = okexswap.SwapAPI(self.access_key, self.secret_key, self.passphrase)