Abbreviations replacement project

From BPAX Lab
import re


# 定义替换规则
patterns = [
    (r'\bBRB\b', 'bear body'),
    (r'\bTTR\b', 'tight trading range'),
    (r'\bOB\b', 'outside bar'),
    (r'\bIB\b', 'inside bar'),
    (r'\bFBO\b', 'failed breakout'),
    (r'\bMTR\b', 'major trend reversal'),
    (r'\bPW\b', 'parabolic wedge'),
    (r'\bL2\b', 'low 2'),
    (r'\bHOD\b', 'high of today'),
    (r'\bLOD\b', 'low of today'),
    (r'\bHPW\b', 'wait for higher probability'),
    (r'\bBRE2\b', 'bear exit above'),
    (r'\bBRE4\b', 'bear exit above'),
    (r'\bBOP\b', 'breakout point'),
    (r'\bSPBR\b', 'surprise bear bar'),
    (r'\bPP\b', "60% or higher probability"),
    (r'\bS\b', 'bear bar'),
    (r'\bSB\b', 'seller below'),
    (r'\bPS\b', 'lower than 50% probability'),
    (r'\bMGB\b', 'magnet below'),
    (r'\bMMD\b', 'measured move down'),
    (r'\bY\b', 'yesterday'),
    (r'\bBO\b', 'breakout'),
    (r'\bLOY\b', 'low of yesterday'),
    (r'\bREV\b', 'reversal'),
    (r'\bBR\b', 'bears'),
    (r'\bCH\b', 'channel'),
    (r'\bDD\b', 'doji'),
    (r'\bBL\b', 'bulls'),
    (r'\bBRN\b', 'big round number'),
    (r'\bSS\b', 'sell signal'),
    (r'\bBL\b', 'bulls'),
    (r'\bSBDM\b', 'surprise bears dominant major trend'),
    (r'\bSBU\b', 'Surprisingly big bulls'),
    (r'\bPL\b', "50% or lower probability"),
    (r'\bS2\b', "Weak Trader's Equation wait for higher probability sell"),
    (r'\bBL\b', "bulls"),
    (r'\bSC\b', 'spike and channel'),
    (r'\bPTG\b', 'profit taking'),
    (r'\bBRTP\b', 'bear trap, failed bear breakout'),
    (r'\bSTC\b', 'sell the close'),
    (r'\bMRV\b', 'minor reversal '),
    (r'\bBUDC\b', 'BUDC 60% probability of trading range'),
    (r'\bNS\b', 'Not high enough probability for stop entry traders to scalp'),
    (r'\bMBO\b', 'Minor Breakout, 60% will last 1-5 bars'),
    (r'\bNWS\b', "need wide stop"),
    (r'\bBBRBC\b', "big bear bar Closing near its low"),
    (r'\bBRCH\b', "bear channel"),
    (r'\bNWS\b', "need wide stop"),
    (r'\bBB\b', "buyer below"),
 #   (r'\b\b', ""),
    (r'\bTGT\b', "target"),
    (r'\bBR\b', "bears"),
    (r'\bSP\b', "support"),
    (r'\bTR\b', "trading range"),
    (r'\bSCBR\b', "Spike and Channel Bear Trend, at least 2 legs down, often in a wedge bottom"),
    (r'\bSPBR\b', "Small PullBack Bear trend. Most pullbacks are small and only last 1 or 2 bars. 60% or higher probability sellers above prior bar."),
    (r'\bW\b', "wedge,or anything similar, like any 3 push pattern"),
    (r'\bREVU\b', "reversal up"),
    (r'\bBLD\b', "bull doji"),
    (r'\bMW\b', "micro Wedge, a wedge formed by only 3 - 4 bars"),
    (r'\bMDRU\b', "Midday reversal up is a bull trend reversal in the middle of the day, sometimes exactly at bar 40 or 41, and sometimes leads to bull trend for rest of day"),



]

# 打开文件A.txt并读取内容
with open('A.txt', 'r') as file:
    data = file.read()

# 替换指定字符串
for pattern, replacement in patterns:
    data = re.sub(pattern, replacement, data)

# 将结果写入文件B.txt
with open('B.txt', 'w') as file:
    file.write(data)