grouped contract methods
This commit is contained in:
parent
3e4912979a
commit
14ae327459
@ -397,6 +397,28 @@ class Exchange:
|
|||||||
order[prop] = order[prop] * contract_size
|
order[prop] = order[prop] * contract_size
|
||||||
return order
|
return order
|
||||||
|
|
||||||
|
def _amount_to_contracts(self, pair: str, amount: float):
|
||||||
|
|
||||||
|
contract_size = None
|
||||||
|
if ('contractSize' in self.markets[pair]):
|
||||||
|
contract_size = self.markets[pair]['contractSize']
|
||||||
|
|
||||||
|
if (contract_size and self.trading_mode == TradingMode.FUTURES):
|
||||||
|
return amount / contract_size
|
||||||
|
else:
|
||||||
|
return amount
|
||||||
|
|
||||||
|
def _contracts_to_amount(self, pair: str, num_contracts: float):
|
||||||
|
|
||||||
|
contract_size = None
|
||||||
|
if ('contractSize' in self.markets[pair]):
|
||||||
|
contract_size = self.markets[pair]['contractSize']
|
||||||
|
|
||||||
|
if (contract_size and self.trading_mode == TradingMode.FUTURES):
|
||||||
|
return num_contracts * contract_size
|
||||||
|
else:
|
||||||
|
return num_contracts
|
||||||
|
|
||||||
def set_sandbox(self, api: ccxt.Exchange, exchange_config: dict, name: str) -> None:
|
def set_sandbox(self, api: ccxt.Exchange, exchange_config: dict, name: str) -> None:
|
||||||
if exchange_config.get('sandbox'):
|
if exchange_config.get('sandbox'):
|
||||||
if api.urls.get('test'):
|
if api.urls.get('test'):
|
||||||
@ -873,28 +895,6 @@ class Exchange:
|
|||||||
params.update({param: time_in_force})
|
params.update({param: time_in_force})
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def _amount_to_contracts(self, pair: str, amount: float):
|
|
||||||
|
|
||||||
contract_size = None
|
|
||||||
if ('contractSize' in self.markets[pair]):
|
|
||||||
contract_size = self.markets[pair]['contractSize']
|
|
||||||
|
|
||||||
if (contract_size and self.trading_mode == TradingMode.FUTURES):
|
|
||||||
return amount / contract_size
|
|
||||||
else:
|
|
||||||
return amount
|
|
||||||
|
|
||||||
def _contracts_to_amount(self, pair: str, num_contracts: float):
|
|
||||||
|
|
||||||
contract_size = None
|
|
||||||
if ('contractSize' in self.markets[pair]):
|
|
||||||
contract_size = self.markets[pair]['contractSize']
|
|
||||||
|
|
||||||
if (contract_size and self.trading_mode == TradingMode.FUTURES):
|
|
||||||
return num_contracts * contract_size
|
|
||||||
else:
|
|
||||||
return num_contracts
|
|
||||||
|
|
||||||
def create_order(self, pair: str, ordertype: str, side: str, amount: float,
|
def create_order(self, pair: str, ordertype: str, side: str, amount: float,
|
||||||
rate: float, leverage: float = 1.0, time_in_force: str = 'gtc') -> Dict:
|
rate: float, leverage: float = 1.0, time_in_force: str = 'gtc') -> Dict:
|
||||||
# TODO-lev: remove default for leverage
|
# TODO-lev: remove default for leverage
|
||||||
|
Loading…
Reference in New Issue
Block a user