diff --git a/Bithumb_minute.py b/Bithumb_minute.py index 0003c69..8108317 100644 --- a/Bithumb_minute.py +++ b/Bithumb_minute.py @@ -432,17 +432,6 @@ class Bithumb_minute(HTS): return - def exist_buy(self, ticker, log_filename): - if os.path.exists(log_filename): - log_file = open(log_filename, 'r', ) - reader = csv.reader(log_file) - for line in reader: - if line[2] == ticker: - log_file.close() - return True - log_file.close() - return False - def notBuy(self, data, i): if i > 5: check = True @@ -717,20 +706,19 @@ class Bithumb_minute(HTS): # 10분이 지난 미체결은 취소한다. self.cancel_order(log_filename, 10) if isRealTime: - if not self.exist_buy(ticker, log_filename): - if max(bsLine['buy'][len(bsLine['buy']) - 2:]) > 100: - tmp = self.bithumb.get_balance(ticker) - balance = tmp[2] - count = round((balance * (bsLine['buy_weight'][len(bsLine['buy_weight']) - 1] / 100)) / bsLine['buy'][len(bsLine['buy']) - 1], 2) - order = self.bithumb.buy_limit_order(ticker, bsLine['buy'][len(bsLine['buy']) - 1], count) - # order: ('bid', 'BTC', 'C0101000000322993432', 'KRW') + if max(bsLine['buy'][len(bsLine['buy']) - 2:]) > 100: + tmp = self.bithumb.get_balance(ticker) + balance = tmp[2] + count = round((balance * (bsLine['buy_weight'][len(bsLine['buy_weight']) - 1] / 100)) / bsLine['buy'][len(bsLine['buy']) - 1], 2) + order = self.bithumb.buy_limit_order(ticker, bsLine['buy'][len(bsLine['buy']) - 1], count) + # order: ('bid', 'BTC', 'C0101000000322993432', 'KRW') - with open(log_filename, 'a', newline='', encoding='utf-8') as log_file: - wr = csv.writer(log_file) - wr.writerow(["buy", datetime.now().strftime('%Y-%m-%d %H:%M:%S'), order[0], order[1], order[2], order[3]]) + with open(log_filename, 'a', newline='', encoding='utf-8') as log_file: + wr = csv.writer(log_file) + wr.writerow(["buy", datetime.now().strftime('%Y-%m-%d %H:%M:%S'), order[0], order[1], order[2], order[3]]) - dirName = os.path.join(RESOURCE_PATH, 'analysis', 'bithumb') - self.writeFile(dirName, ticker, data, bsLine, datetime.now().strftime('%Y%m%d %H%M%S'), 'buy') + dirName = os.path.join(RESOURCE_PATH, 'analysis', 'bithumb') + self.writeFile(dirName, ticker, data, bsLine, datetime.now().strftime('%Y%m%d %H%M%S'), 'buy') if max(bsLine['sell'][len(bsLine['sell']) - 2:]) > 100: tmp = self.bithumb.get_balance(ticker) @@ -760,7 +748,7 @@ if __name__ == "__main__": bithumb = Bithumb_minute(RESOURCE_PATH) tickers = ['XRP'] - isRealTime = False + isRealTime = True if isRealTime: while True: for ticker in tickers: