This commit is contained in:
dsyoon
2023-01-21 19:46:24 +09:00
parent fb61512b82
commit d18629ec8e
5 changed files with 15 additions and 20 deletions

View File

@@ -18,7 +18,6 @@ class Bithumb(HTS):
RESOURCE_PATH = None
buySellChecker = None
analyzerSqlite = None
log_filename = None
def __init__(self, RESOURCE_PATH):
super().__init__(RESOURCE_PATH)
@@ -33,8 +32,6 @@ class Bithumb(HTS):
self.buySellChecker = BuySellChecker()
self.analyzerSqlite = AnalyzerSqlite()
self.log_filename = os.path.join(RESOURCE_PATH, 'analysis', 'bithumb', 'transaction.json')
return
def bull_market(self, df, ticker):
@@ -413,6 +410,17 @@ class Bithumb(HTS):
def getBalance(self, ticker):
tmp = self.bithumb.get_balance(ticker)
return tmp[2]
def exist_buy(self, ticker, log_filename):
log_file = open('data.csv', '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 buyRealTime(self, ticker, isRealTime=False):
stock = {"CODE": ticker, "NAME": ticker, "PRICE": []}
@@ -436,14 +444,16 @@ class Bithumb(HTS):
# 그래프를 그린다.
if len(data.index) > 10:
if not isRealTime:
today = datetime.today().strftime('%Y%m%d')
log_filename = os.path.join(RESOURCE_PATH, 'analysis', 'bithumb', today + '.log')
if not isRealTime and self.exist_buy(ticker, log_filename):
if max(bsLine['buy'][len(bsLine['buy']) - 2:]) > 100:
balance = self.getBalance(ticker)
count = int(balance * (bsLine['buy_weight'][len(bsLine['buy_weight'])-1]/100))
order = self.bithumb.buy_limit_order(ticker, bsLine['buy'][len(bsLine['buy'])-1], count)
# order: ('bid', 'BTC', 'C0101000000322993432', 'KRW')
with open(self.log_filename, 'a', newline='') as log_file:
with open(log_filename, 'a', newline='', encoding='utf-8') as log_file:
wr = csv.writer(log_file)
wr.writerow([datetime.now().strftime('%Y-%m-%d %H:%M:%S'), order[0], order[1], order[2], order[3]])
else: