def percent_sell_strat(self):
        ignored = utils.file_to_json("ignored_coins.json")
        held_markets = [market for market in self.held_coins]
        for coin_market in held_markets:
            current_high = self.history_coins[coin_market]
            coin_price = float(self.bittrex_coins[coin_market]['Last'])
            percent_change_24h = utils.get_percent_change_24h(
                self.bittrex_coins[coin_market])

            if coin_price < current_high * 0.80 \
                    or percent_change_24h >= 110:

                coin_to_sell = utils.get_second_market_coin(coin_market)

                balance = self.api.get_balance(coin_to_sell)

                if balance['success']:
                    amount = float(balance['result']['Available'])
                    if amount > 0:
                        utils.sell(self.api, amount, coin_market,
                                   self.bittrex_coins)
                        ignored[coin_market] = 1
                        utils.json_to_file(ignored, "ignored_coins.json")
                else:
                    utils.print_and_write_to_logfile(
                        "Could not retrieve balance: " + balance['message'])
Example #2
0
    def percent_sell_strat(self):
        """
        If a coin drops more than 10% of its highest price then sell
        """

        held_markets = [market for market in self.held_coins]
        for coin_market in held_markets:
            current_high = self.history_coins[coin_market]
            coin_price = float(self.bittrex_coins[coin_market]['Last'])
            """
            if cur_24h_change > highest_24h_change:
                self.held_coins[coin_market]['highest_24h_change'] = cur_24h_change
                highest_24h_change = cur_24h_change
                utils.json_to_file(self.held_coins, "held_coins.json")

                self.held_coins[coin_market]['sell_threshold'] = self.updated_threshold(coin_market, self.held_coins)
                utils.json_to_file(self.held_coins, "held_coins.json")
            """

            if coin_price < current_high * 0.97:

                coin_to_sell = utils.get_second_market_coin(coin_market)

                balance = self.api.get_balance(coin_to_sell)

                if balance['success']:
                    amount = float(balance['result']['Available'])
                    if amount > 0:
                        utils.sell(self.api, amount, coin_market,
                                   self.bittrex_coins)
                else:
                    utils.print_and_write_to_logfile(
                        "Could not retrieve balance: " + balance['message'])
Example #3
0
    def hodl_sell_strat(self):

        for market in self.held_coins:
            cur_price = float(self.bittrex_coins[market]['Last'])
            bought_price = self.held_coins[market]['price_bought']
            change = utils.percent_change(bought_price, cur_price)

            desired_gain = self.held_coins[market]['desired_gain']

            if change >= desired_gain:
                coin_to_sell = utils.get_second_market_coin(market)
                balance = self.api.get_balance(coin_to_sell)
                if balance['success']:
                    amount = float(balance['result']['Available'])
                    utils.sell(self.api, amount, market, self.bittrex_coins)
                else:
                    utils.print_and_write_to_logfile(
                        "Could not retrieve balance: " + balance['message'])
Example #4
0
    def keltner_sell_strat(self):
        if len(self.keltner_coins['BTC-ETH']
               ['upper_band_data']) > self.keltner_period:
            for coin in self.keltner_coins:
                market = self.bittrex_coins[coin]['MarketName']
                lower_band_data = self.keltner_coins[market]['lower_band_data']

                if len(lower_band_data) == self.keltner_period:
                    market = self.bittrex_coins[coin]['MarketName']
                    coins_pending_buy = [
                        market for market in self.pending_orders['Buying']
                    ]
                    coins_pending_sell = [
                        market for market in self.pending_orders['Selling']
                    ]

                    highest_price_history = utils.file_to_json(
                        'coin_highest_price_history.json')
                    if market not in coins_pending_buy and market not in coins_pending_sell and market in self.held_coins:

                        cur_price = price_data_seconds[-1]
                        price_data_seconds = self.keltner_coins[market][
                            'price_data_seconds']

                        deviation = self.get_deviation_of_last_x(
                            5, price_data_seconds)

                        highest_coin_price = highest_price_history[market]

                        if self.downward_cross(
                                market, 'upper_band_data'
                        ) or cur_price <= highest_coin_price - 2 * deviation:
                            coin_to_sell = utils.get_second_market_coin(market)
                            balance = self.api.get_balance(coin_to_sell)
                            if balance['success']:
                                amount = float(balance['result']['Available'])
                                utils.sell(self.api, amount, market,
                                           self.bittrex_coins)
                            else:
                                utils.print_and_write_to_logfile(
                                    "Could not retrieve balance: " +
                                    balance['message'])
Example #5
0
    def low_high_sell_strat(self):
        for market in self.held_coins:
            cur_price = float(self.bittrex_coins[market]['Last'])
            bought_price = self.held_coins[market]['price_bought']
            change = utils.percent_change(bought_price, cur_price)

            desired_gain = self.held_coins[market]['desired_gain']
            high_bar = self.held_coins[market]['high_bar']

            if change >= desired_gain and change >= high_bar:
                self.held_coins[market]['high_bar'] = high_bar + 10
                utils.json_to_file(self.held_coins, 'held_coins.json')
            elif high_bar != desired_gain and change < high_bar - 10:
                coin_to_sell = utils.get_second_market_coin(market)
                balance = self.api.get_balance(coin_to_sell)
                if balance['success']:
                    amount = float(balance['result']['Available'])
                    self.update_bittrex_coins()
                    utils.sell(self.api, amount, market, self.bittrex_coins)
                else:
                    utils.print_and_write_to_logfile("Could not retrieve balance: " + balance['message'])