align dry_run_orders

This commit is contained in:
iuvbio 2019-02-20 02:38:16 +01:00
parent 686949b258
commit e495ffec78

View File

@ -283,11 +283,11 @@ class Exchange(object):
price = ceil(big_price) / pow(10, symbol_prec) price = ceil(big_price) / pow(10, symbol_prec)
return price return price
def buy(self, pair: str, ordertype: str, amount: float, def dry_run_order(self, pair: str, ordertype: str, side: str, amount: float,
rate: float, time_in_force) -> Dict: rate: float, params: Dict = {}) -> Dict:
if self._conf['dry_run']:
order_id = f'dry_run_buy_{randint(0, 10**6)}' order_id = f'dry_run_buy_{randint(0, 10**6)}'
self._dry_run_open_orders[order_id] = { dry_order = {
"id": order_id,
'pair': pair, 'pair': pair,
'price': rate, 'price': rate,
'amount': amount, 'amount': amount,
@ -296,8 +296,19 @@ class Exchange(object):
'remaining': 0.0, 'remaining': 0.0,
'datetime': arrow.utcnow().isoformat(), 'datetime': arrow.utcnow().isoformat(),
'status': 'closed', 'status': 'closed',
'fee': None 'fee': None # should this be None or skipped?
} }
return order_id, dry_order
def create_order(self, pair: str, ordertype: str, side: str, amount: float,
rate: float, params: Dict = {}) -> Dict:
pass # TODO: finish this
def buy(self, pair: str, ordertype: str, amount: float,
rate: float, time_in_force) -> Dict:
if self._conf['dry_run']:
order_id, dry_order = self.dry_run_order(pair, ordertype, "buy", amount, rate)
self._dry_run_open_orders[order_id] = dry_order
return {'id': order_id} return {'id': order_id}
try: try:
@ -331,17 +342,8 @@ class Exchange(object):
def sell(self, pair: str, ordertype: str, amount: float, def sell(self, pair: str, ordertype: str, amount: float,
rate: float, time_in_force='gtc') -> Dict: rate: float, time_in_force='gtc') -> Dict:
if self._conf['dry_run']: if self._conf['dry_run']:
order_id = f'dry_run_sell_{randint(0, 10**6)}' order_id, dry_order = self.dry_run_order(pair, ordertype, "sell", amount, rate)
self._dry_run_open_orders[order_id] = { self._dry_run_open_orders[order_id] = dry_order
'pair': pair,
'price': rate,
'amount': amount,
'type': ordertype,
'side': 'sell',
'remaining': 0.0,
'datetime': arrow.utcnow().isoformat(),
'status': 'closed'
}
return {'id': order_id} return {'id': order_id}
try: try:
@ -389,21 +391,11 @@ class Exchange(object):
'In stoploss limit order, stop price should be more than limit price') 'In stoploss limit order, stop price should be more than limit price')
if self._conf['dry_run']: if self._conf['dry_run']:
order_id = f'dry_run_buy_{randint(0, 10**6)}' order_id, dry_order = self.dry_run_order(
self._dry_run_open_orders[order_id] = { pair, "stop_loss_limit", "sell", amount, stop_price, rate)
'info': {}, dry_order.update({"info": {}, "remaining": amount, "status": "open"})
'id': order_id, self._dry_run_open_orders[order_id] = dry_order
'pair': pair, return dry_order
'price': stop_price,
'amount': amount,
'type': 'stop_loss_limit',
'side': 'sell',
'remaining': amount,
'datetime': arrow.utcnow().isoformat(),
'status': 'open',
'fee': None
}
return self._dry_run_open_orders[order_id]
try: try: