Esempio n. 1
0
    def decideVolatilityTrade(self, trade_flag, current_price, base_time):
        if trade_flag == "pass":
            hour = base_time.hour
            seconds = base_time.second
            common_stoploss = 0.2

            if (hour >= 15 or hour < 4) and seconds < 10:
                self.setVolatilityIndicator(base_time)
                up_flag, down_flag = decideVolatility(
                    volatility_value=0.3,
                    start_price=self.start_price_1m,
                    end_price=self.end_price_1m)

                if up_flag:
                    trade_flag = "buy"
                    self.buy_count = 0
                    self.sell_count = 0
                    self.original_stoploss_rate = common_stoploss
                    self.algorithm = "volatility"
                elif down_flag:
                    trade_flag = "sell"
                    self.buy_count = 0
                    self.sell_count = 0
                    self.original_stoploss_rate = common_stoploss
                    self.algorithm = "volatility"

        return trade_flag
Esempio n. 2
0
    def decideVolatilityTrade(self, trade_flag, current_price, base_time):
        if trade_flag == "pass":
            hour = base_time.hour
            seconds = base_time.second

            if (hour >= 15 or hour < 4) and seconds >= 50:
                self.setVolatilityIndicator(base_time)
                up_flag, down_flag = decideVolatility(
                    current_price=current_price,
                    volatility_value=0.3,
                    volatility_buy_price=self.volatility_buy_price,
                    volatility_bid_price=self.volatility_bid_price)

                if up_flag:
                    trade_flag = "buy"
                    self.buy_count = 0
                    self.sell_count = 0
                    self.original_stoploss_rate = 0.2
                    self.writeVolatilityLog(current_price, mode="trade")
                elif down_flag:
                    trade_flag = "sell"
                    self.buy_count = 0
                    self.sell_count = 0
                    self.original_stoploss_rate = 0.2
                    self.writeVolatilityLog(current_price, mode="trade")

                if trade_flag != "pass":
                    self.algorithm = "volatility"

        return trade_flag
    def decideVolatilityTrade(self, trade_flag, current_price, base_time):
        if trade_flag == "pass":
            hour = base_time.hour
            seconds = base_time.second
            common_stoploss = 0.2

            if (hour >= 15 or hour < 4) and seconds >= 50:
                self.setVolatilityIndicator(base_time)
                up_flag, down_flag = decideVolatility(
                    current_price=current_price,
                    volatility_value=0.3,
                    volatility_buy_price=self.volatility_buy_price,
                    volatility_bid_price=self.volatility_bid_price)

                if up_flag:
                    trade_flag = "buy"
                    self.buy_count = 0
                    self.sell_count = 0
                    self.original_stoploss_rate = common_stoploss
                    self.algorithm = "volatility"
                    self.writeResultLog()
                elif down_flag:
                    trade_flag = "sell"
                    self.buy_count = 0
                    self.sell_count = 0
                    self.original_stoploss_rate = common_stoploss
                    self.algorithm = "volatility"
                    self.writeResultLog()

                if trade_flag != "pass":
                    self.first_take_profit = 0.5
                    self.second_take_profit = 1.0
                    self.first_trail_threshold = 0.3
                    self.second_trail_threshold = 0.3

        return trade_flag
Esempio n. 4
0
    def decideVolatilityStopLoss(self, stl_flag, current_price, base_time):
        if self.algorithm == "expantion" or self.algorithm == "volatility":
            mode = "stl"
            seconds = base_time.second
            if seconds >= 50:
                self.setVolatilityIndicator(base_time)
                up_flag, down_flag = decideVolatility(
                    current_price=current_price,
                    volatility_value=0.3,
                    volatility_buy_price=self.volatility_buy_price,
                    volatility_bid_price=self.volatility_bid_price)

                if up_flag and self.order_kind == "sell":
                    stl_flag = True
                    self.buy_count = 0
                    self.sell_count = 0
                    self.writeVolatilityLog(current_price, mode=mode)
                elif down_flag and self.order_kind == "buy":
                    stl_flag = True
                    self.buy_count = 0
                    self.sell_count = 0
                    self.writeVolatilityLog(current_price, mode=mode)

        return stl_flag