Exemplo n.º 1
0
 def _get_limit_price_from_risk(self, eval_note):
     if eval_note > 0:
         if self.USE_CLOSE_TO_CURRENT_PRICE:
             return 1 + self.CLOSE_TO_CURRENT_PRICE_DEFAULT_RATIO
         factor = self.SELL_LIMIT_ORDER_MIN_PERCENT + \
                  ((1 - abs(eval_note) + 1 - self.trader.risk) * self.LIMIT_ORDER_ATTENUATION)
         return trading_modes.check_factor(self.SELL_LIMIT_ORDER_MIN_PERCENT,
                                           self.SELL_LIMIT_ORDER_MAX_PERCENT, factor)
     else:
         if self.USE_CLOSE_TO_CURRENT_PRICE:
             return 1 - self.CLOSE_TO_CURRENT_PRICE_DEFAULT_RATIO
         factor = self.BUY_LIMIT_ORDER_MAX_PERCENT - \
                  ((1 - abs(eval_note) + 1 - self.trader.risk) * self.LIMIT_ORDER_ATTENUATION)
         return trading_modes.check_factor(self.BUY_LIMIT_ORDER_MIN_PERCENT,
                                           self.BUY_LIMIT_ORDER_MAX_PERCENT, factor)
Exemplo n.º 2
0
    def _get_market_quantity_from_risk(self, eval_note, quantity, quote, selling=False):
        weighted_risk = self.trader.risk * self.QUANTITY_RISK_WEIGHT
        ref_market = self.exchange_manager.exchange_personal_data.portfolio_manager.reference_market
        if (selling and quote != ref_market) or (not selling and quote == ref_market):
            weighted_risk *= self.SELL_MULTIPLIER
        factor = self.QUANTITY_MARKET_MIN_PERCENT + (
                (abs(eval_note) + weighted_risk) * self.QUANTITY_MARKET_ATTENUATION)

        checked_factor = trading_modes.check_factor(self.QUANTITY_MARKET_MIN_PERCENT,
                                                    self.QUANTITY_MARKET_MAX_PERCENT, factor)
        return checked_factor * quantity
Exemplo n.º 3
0
 def _get_buy_limit_quantity_from_risk(self, eval_note, quantity, quote):
     if self.BUY_WITH_MAXIMUM_SIZE_ORDERS:
         return quantity
     weighted_risk = self.trader.risk * self.QUANTITY_RISK_WEIGHT
     # consider buy quantity like a sell if quote is the reference market
     if quote == self.exchange_manager.exchange_personal_data.portfolio_manager.reference_market:
         weighted_risk *= self.SELL_MULTIPLIER
     factor = self.QUANTITY_MIN_PERCENT + ((abs(eval_note) + weighted_risk) * self.QUANTITY_ATTENUATION)
     checked_factor = trading_modes.check_factor(self.QUANTITY_MIN_PERCENT, self.QUANTITY_MAX_PERCENT,
                                                 factor)
     return checked_factor * quantity
Exemplo n.º 4
0
 async def _get_sell_limit_quantity_from_risk(self, eval_note, quantity, quote):
     if self.SELL_WITH_MAXIMUM_SIZE_ORDERS:
         return quantity
     weighted_risk = self.trader.risk * self.QUANTITY_RISK_WEIGHT
     # consider sell quantity like a buy if base is the reference market
     if quote != self.exchange_manager.exchange_personal_data.portfolio_manager.reference_market:
         weighted_risk *= self.SELL_MULTIPLIER
     if await self._get_ratio(quote) < self.FULL_SELL_MIN_RATIO:
         return quantity
     factor = self.QUANTITY_MIN_PERCENT + ((abs(eval_note) + weighted_risk) * self.QUANTITY_ATTENUATION)
     checked_factor = trading_modes.check_factor(self.QUANTITY_MIN_PERCENT, self.QUANTITY_MAX_PERCENT,
                                                 factor)
     return checked_factor * quantity
 def _get_stop_price_from_risk(self):
     factor = self.STOP_LOSS_ORDER_MAX_PERCENT - (
         self.trader.risk * self.STOP_LOSS_ORDER_ATTENUATION)
     return trading_modes.check_factor(self.STOP_LOSS_ORDER_MIN_PERCENT,
                                       self.STOP_LOSS_ORDER_MAX_PERCENT,
                                       factor)