Add support for different order types
This commit is contained in:
@@ -249,7 +249,7 @@ class Exchange(object):
|
||||
price = ceil(big_price) / pow(10, symbol_prec)
|
||||
return price
|
||||
|
||||
def buy(self, pair: str, rate: float, amount: float) -> Dict:
|
||||
def buy(self, pair: str, rate: float, amount: float, ordertype: str = 'limt') -> Dict:
|
||||
if self._conf['dry_run']:
|
||||
order_id = f'dry_run_buy_{randint(0, 10**6)}'
|
||||
self._dry_run_open_orders[order_id] = {
|
||||
@@ -270,7 +270,7 @@ class Exchange(object):
|
||||
amount = self.symbol_amount_prec(pair, amount)
|
||||
rate = self.symbol_price_prec(pair, rate)
|
||||
|
||||
return self._api.create_limit_buy_order(pair, amount, rate)
|
||||
return self._api.create_order(pair, ordertype, 'buy', amount, rate)
|
||||
except ccxt.InsufficientFunds as e:
|
||||
raise DependencyException(
|
||||
f'Insufficient funds to create limit buy order on market {pair}.'
|
||||
@@ -287,7 +287,7 @@ class Exchange(object):
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e)
|
||||
|
||||
def sell(self, pair: str, rate: float, amount: float) -> Dict:
|
||||
def sell(self, pair: str, rate: float, amount: float, ordertype: str = 'limt') -> Dict:
|
||||
if self._conf['dry_run']:
|
||||
order_id = f'dry_run_sell_{randint(0, 10**6)}'
|
||||
self._dry_run_open_orders[order_id] = {
|
||||
@@ -307,7 +307,7 @@ class Exchange(object):
|
||||
amount = self.symbol_amount_prec(pair, amount)
|
||||
rate = self.symbol_price_prec(pair, rate)
|
||||
|
||||
return self._api.create_limit_sell_order(pair, amount, rate)
|
||||
return self._api.create_order(pair, ordertype, 'sell', amount, rate)
|
||||
except ccxt.InsufficientFunds as e:
|
||||
raise DependencyException(
|
||||
f'Insufficient funds to create limit sell order on market {pair}.'
|
||||
|
Reference in New Issue
Block a user