init
This commit is contained in:
20
Bithumb.py
20
Bithumb.py
@@ -18,7 +18,6 @@ class Bithumb(HTS):
|
|||||||
RESOURCE_PATH = None
|
RESOURCE_PATH = None
|
||||||
buySellChecker = None
|
buySellChecker = None
|
||||||
analyzerSqlite = None
|
analyzerSqlite = None
|
||||||
log_filename = None
|
|
||||||
|
|
||||||
def __init__(self, RESOURCE_PATH):
|
def __init__(self, RESOURCE_PATH):
|
||||||
super().__init__(RESOURCE_PATH)
|
super().__init__(RESOURCE_PATH)
|
||||||
@@ -33,8 +32,6 @@ class Bithumb(HTS):
|
|||||||
self.buySellChecker = BuySellChecker()
|
self.buySellChecker = BuySellChecker()
|
||||||
self.analyzerSqlite = AnalyzerSqlite()
|
self.analyzerSqlite = AnalyzerSqlite()
|
||||||
|
|
||||||
self.log_filename = os.path.join(RESOURCE_PATH, 'analysis', 'bithumb', 'transaction.json')
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def bull_market(self, df, ticker):
|
def bull_market(self, df, ticker):
|
||||||
@@ -413,6 +410,17 @@ class Bithumb(HTS):
|
|||||||
def getBalance(self, ticker):
|
def getBalance(self, ticker):
|
||||||
tmp = self.bithumb.get_balance(ticker)
|
tmp = self.bithumb.get_balance(ticker)
|
||||||
return tmp[2]
|
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):
|
def buyRealTime(self, ticker, isRealTime=False):
|
||||||
|
|
||||||
stock = {"CODE": ticker, "NAME": ticker, "PRICE": []}
|
stock = {"CODE": ticker, "NAME": ticker, "PRICE": []}
|
||||||
@@ -436,14 +444,16 @@ class Bithumb(HTS):
|
|||||||
|
|
||||||
# 그래프를 그린다.
|
# 그래프를 그린다.
|
||||||
if len(data.index) > 10:
|
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:
|
if max(bsLine['buy'][len(bsLine['buy']) - 2:]) > 100:
|
||||||
balance = self.getBalance(ticker)
|
balance = self.getBalance(ticker)
|
||||||
count = int(balance * (bsLine['buy_weight'][len(bsLine['buy_weight'])-1]/100))
|
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 = self.bithumb.buy_limit_order(ticker, bsLine['buy'][len(bsLine['buy'])-1], count)
|
||||||
# order: ('bid', 'BTC', 'C0101000000322993432', 'KRW')
|
# 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 = csv.writer(log_file)
|
||||||
wr.writerow([datetime.now().strftime('%Y-%m-%d %H:%M:%S'), order[0], order[1], order[2], order[3]])
|
wr.writerow([datetime.now().strftime('%Y-%m-%d %H:%M:%S'), order[0], order[1], order[2], order[3]])
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
,stock_code,type,orderNum,count,price,datetime
|
|
||||||
0,122630,2,2,20,14555,2022-07-08 12:07:04.174773
|
|
||||||
1,122630,2,2,20,14585,2022-07-08 13:01:04.328865
|
|
||||||
2,122630,2,2,20,14570,2022-07-08 13:24:03.429791
|
|
||||||
3,122630,2,2,20,14625,2022-07-08 14:27:03.920891
|
|
||||||
4,122630,2,2,20,14615,2022-07-08 14:33:03.578675
|
|
||||||
5,122630,2,2,20,14585,2022-07-08 14:47:04.028914
|
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
,stock_code,type,orderNum,count,price,datetime
|
|
||||||
0,252670,2,2,40,2570,2022-04-22 13:51:03.587620
|
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
,stock_code,type,orderNum,count,price,datetime
|
|
||||||
0,252670,2,2,300,2665,2022-05-26 11:38:06.850113
|
|
||||||
1,252670,2,2,300,2665,2022-05-26 11:39:03.672531
|
|
||||||
2,252670,2,2,300,2680,2022-05-26 13:09:03.891335
|
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
,stock_code,type,orderNum,count,price,datetime
|
|
||||||
0,252670,2,2,500,2640,2022-05-27 10:55:04.113265
|
|
||||||
|
Reference in New Issue
Block a user