Пример #1
0
def search_ema_hourly(pair, exchange):
    coin = Coin(pair, exchange)
    bullish_cross, hours_ago = coin.ema_bullish_cross(timeframe="1h",
                                                      fast_period=4,
                                                      slow_period=18)
    if bullish_cross and hours_ago <= 5:
        print(coin.pair, "({})".format(coin.exchange),
              "EMA 4-18 bullish cross {} hours ago".format(hours_ago))
Пример #2
0
 def callback(self, response):
     jsonify_coins = json.loads(response.body)
     for coin_inf in jsonify_coins:
         symbol = coin_inf['symbol'].lower()
         name = coin_inf['name'].lower()
         rank = coin_inf['rank']
         with db_session:
             coin = select(c for c in Coin if c.symbol == symbol).get()
             if not coin:
                 coin = Coin(symbol=symbol, full_name=name, rank=rank)
     self.finish()
Пример #3
0
def create_coin(string, country, link, rarity):
    reg = re.findall('<th>(?:Years|Year)<\/th>\s+<td>(.+|\n.+)<\/td>',
                     string,
                     flags=re.I)
    years = checking_regex(reg)
    years = years.replace(" ", "")
    years = years.replace("\n", "")
    print("*****************************")
    print(years)
    # reg = re.findall('<th>Value<\/th>\s+<td[\s\S]+?>([\s\S]+?)(?:\(|<)', string, flags=re.I)
    reg = re.findall('<th>Value<\/th>\s+<td>([\s\S]+?)<', string, flags=re.I)

    value = checking_regex(reg).replace("\n", "")
    value = " ".join(value.split()).replace("/", "-")
    if '<' in value or '>' in value:
        value = value.replace('>', '')
        value = value.replace('<', '')
    if '"' in value:
        value = value.replace('"', '')
    value = value.replace("&amp;nbspAFA", "")
    print(value)
    reg = re.findall('<th>Composition</th>\s+<td>(.+)</td>',
                     string,
                     flags=re.I)
    metal = checking_regex(reg)
    print(metal)
    reg = re.findall('<th>Type</th>\s+<td>(.+)</td>', string, flags=re.I)
    coin_type = checking_regex(reg)
    print(coin_type)
    reg = re.findall('<th>Weight</th>\s+<td>(.+)</td>', string, flags=re.I)
    weight = checking_regex(reg).replace(r"x\a0", "")
    print(weight)
    reg = re.findall('<th>Diameter</th>\s+<td>(.+)</td>', string, flags=re.I)
    diameter = checking_regex(reg).replace(r"x\a0", "")
    print(diameter)
    reg = re.findall('<th>Shape</th>\s+<td>(.+)</td>', string, flags=re.I)
    shape = checking_regex(reg)
    print(shape)
    reg = re.findall('<th>References</th>[\s\S]+?KM</abbr>([\s\S]+?)<',
                     string,
                     flags=re.I | re.M)
    references = checking_regex(reg).replace(",", "").replace("#", "").replace(
        "?", "").strip()

    reg = re.findall('<th>Demonetized</th>\s+<td>(.+)</td>',
                     string,
                     flags=re.I)
    demonetized = checking_regex(reg)
    print(demonetized)
    coin = Coin(country, years, value, metal, coin_type, weight, diameter,
                shape, rarity, demonetized, link, references)
    return coin
Пример #4
0
 def scrape(self, limit=None):
     soup = BeautifulSoup(self.text, 'lxml')
     table = soup.find('table', attrs={'id': TABLE_ID})
     coins = []
     for row in table.find_all('tr')[1:]:
         tds = row.find_all('td')
         props = [td.get_text().strip() for td in tds]
         icon = tds[1].find('img')
         props.append(icon['src'] if icon else '')
         coins.append(Coin(props))
         if limit and len(coins) == limit:
             break
     return Market(coins)
Пример #5
0
def search_ema_daily_mature(pair, exchange):
    """
    Finds older bullish crosses that are probably a stronger upwards trend.
    1. Bullruns that are just about to end
    2. Pumps that are slowly dying out
    3. Look for the ones that haven't increased so much since then, and are slowly rising.
    """
    coin = Coin(pair, exchange)
    bullish_cross, days_ago = coin.ema_bullish_cross(timeframe="1d",
                                                     fast_period=9,
                                                     slow_period=26)
    if bullish_cross and (8 <= days_ago <= 20):
        print(coin.pair, "({})".format(coin.exchange),
              "EMA 9-26 bullish cross, confirmed by {} days".format(days_ago))
Пример #6
0
 def callback(self, response):
     jsonify_coins = json.loads(response.body)
     for coin_inf in jsonify_coins:
         symbol = coin_inf['symbol'].lower()
         name = coin_inf['name'].lower()
         rank = coin_inf['rank']
         with db_session:
             coin = select(c for c in Coin if c.symbol == symbol).get()
             if not coin:
                 coin = Coin(symbol=symbol, full_name=name, rank=rank)
                 tasks.fetch_icon.apply_async(
                     (self.coin_icon_uri.format(name.replace(' ', '-')), self.media_dir + symbol + '.png')
                 )
     self.finish()
Пример #7
0
def search_ema_daily(pair, exchange):
    """
    Find recent bullish crosses (recent being < 10 days ago)
    Remember to take the market condition and type of coin into account.
    Finds these kinds of coins:
    1. pumps that are just about to dump (look at the slope)
    2. pumps in the process of dumping
    3. gradual, weak bullish crosses that'll peter out soon
    4. gradual small bullish crosses that'll could become something big
    """
    coin = Coin(pair, exchange)
    bullish_cross, days_ago = coin.ema_bullish_cross(timeframe="1d",
                                                     fast_period=9,
                                                     slow_period=26)
    if bullish_cross and days_ago <= 10:
        print(coin.pair, "({})".format(coin.exchange),
              "EMA 9-26 bullish cross {} days ago".format(days_ago))
Пример #8
0
fh = logging.FileHandler('crypto_trading.log')
fh.setLevel(logging.DEBUG)
fh.setFormatter(formatter)
logger.addHandler(fh)

# logging to console
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setFormatter(formatter)
logger.addHandler(ch)

# Telegram bot
TELEGRAM_CHAT_ID = config.get(USER_CFG_SECTION, 'botChatID')
TELEGRAM_TOKEN = config.get(USER_CFG_SECTION, 'botToken')
BRIDGE_SYMBOL = config.get(USER_CFG_SECTION, 'bridge')
BRIDGE = Coin(BRIDGE_SYMBOL)


class RequestsHandler(Handler):
    def emit(self, record):
        log_entry = self.format(record)
        payload = {
            'chat_id': TELEGRAM_CHAT_ID,
            'text': log_entry,
            'parse_mode': 'HTML'
        }
        return requests.post("https://api.telegram.org/bot{token}/sendMessage".format(token=TELEGRAM_TOKEN),
                             data=payload).content


class LogstashFormatter(Formatter):
Пример #9
0
def search_stochrsi_oversold_all_timeframes(pair, exchange):
    coin = Coin(pair, exchange)
    is_oversold = coin.stochrsi_oversold_all_timeframes()
    if is_oversold:
        print(coin.pair, "({})".format(coin.exchange),
              "StochRSI oversold on all timeframes")
Пример #10
0
def search_rsi_increasing_all_timeframes(pair, exchange):
    coin = Coin(pair, exchange)
    is_increasing = coin.rsi_increasing_all_timeframes(period=20)
    if is_increasing:
        print(coin.pair, "({})".format(coin.exchange),
              "RSI increasing across all timeframes")
Пример #11
0
# Init config
config = configparser.ConfigParser()
config['DEFAULT'] = {
    'scout_transaction_fee': '0.001',
    'scout_multiplier': '5',
    'scout_sleep_time': '5'
}

if not os.path.exists(CFG_FL_NAME):
    print('No configuration file (user.cfg) found! See README.')
    exit()
config.read(CFG_FL_NAME)

BRIDGE_SYMBOL = config.get(USER_CFG_SECTION, 'bridge')
BRIDGE = Coin(BRIDGE_SYMBOL, False)

# Prune settings
SCOUT_HISTORY_PRUNE_TIME = float(
    config.get(USER_CFG_SECTION, 'hourToKeepScoutHistory', fallback="1"))

# Get config for scout
SCOUT_TRANSACTION_FEE = float(
    config.get(USER_CFG_SECTION, 'scout_transaction_fee'))
SCOUT_MULTIPLIER = float(config.get(USER_CFG_SECTION, 'scout_multiplier'))
SCOUT_SLEEP_TIME = int(config.get(USER_CFG_SECTION, 'scout_sleep_time'))

logger = Logger()
logger.info('Started')

supported_coin_list = []
Пример #12
0
from models import Coin
from indicators import RSI, StochasticRSI

coin = Coin("BTC-TKN")
coin.run_indicators(stochrsi=True)
coin.stochrsi_less_than_20()
Пример #13
0
from sqlalchemy.orm import sessionmaker

from database import engine
from models import Coin
import coins

Session = sessionmaker(engine.get_engine())
session = Session()

for coin in coins.__all__:
    coin = getattr(coins, coin)

    c = session.query(Coin).filter_by(name=coin.NAME).first()
    if c is not None:
        c.price = coin.MIN_PRICE
    else:
        c = Coin()
        c.name = coin.NAME
        c.price = coin.MIN_PRICE

        session.add(c)
        session.commit()