-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
ยท80 lines (68 loc) ยท 2.65 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import time
import pyupbit as p
access =
secret =
login = p.Upbit(access, secret)
def get_balance(ticker):
"""์๊ณ ์กฐํ"""
balances = login.get_balances()
for b in balances:
if b['currency'] == ticker:
if b['balance'] is not None:
return float(b['balance'])
else:
return 0
return 0
first_percent = 0.01 # ์์ํ ๋ ๋ชํผ์ผํธ ์ด์ ์ฆ๊ฐํ ์
target_percent = 0.05 # ๋ชํผ์ผํธ ์ด์ ์ด์ต๋ ์
money = 5500 # ๋ฐ๊ฒฌํ๋ฉด ๋ฃ์ ์๋
print("======== ๊ฒฝ์ฃผ๋ง ํ์๊ธฐ ์์ =========")
coin_list = ["KRW-BTT", "KRW-AHT", "KRW-TT", "KRW-CRE", 'KRW-MFT', 'KRW-RFR', 'KRW-TSHP', 'KRW-OBSR', 'KRW-MVL',
'KRW-IQ',
'KRW-QKC', 'KRW-STMX', 'KRW-IOST', 'KRW-QTCON', 'KRW-EDR', 'KRW-LAMB', 'KRW-STPT', 'KRW-PXL', 'KRW-SSX',
'KRW-JST',
'KRW-IGNIS', 'KRW-ORBS', 'KRW-HUM', 'KRW-LOOM', 'KRW-UPP', 'KRW-META', 'KRW-MOC', 'KRW-TRX', 'KRW-FCT2',
'KRW-LBC',
'KRW-ANKR', 'KRW-CRO', 'KRW-SNT', 'KRW-WAXP', 'KRW-TON', 'KRW-OMG', 'KRW-EOS', 'KRW-SRM', 'KRW-THETA',
'KRW-GAS',
'KRW-QTUM', 'KRW-FLOW']
flag = 0
count = 1
while True:
try:
if flag == 0:
print("ํ์์์!",count,"๋ฒ์งธ ์๋ ์ค")
first_price = p.get_current_price(coin_list)
for k in first_price:
first_price[k] = first_price[k] + first_price[k] * first_percent
time.sleep(1.5)
check_price = p.get_current_price(coin_list)
flag = 1
count += 1
if flag == 1:
print("ํ์ฌ์ํ : ", flag)
for c in check_price:
if check_price[c] >= first_price[c]:
login.buy_market_order(c, money * 0.9995)
flag = 2
print(c, ":", check_price[c], "์ ๋งค์")
target_price = check_price[c] + check_price[c] * target_percent
break
if flag == 2:
print("ํ์ฌ์ํ : ", flag)
while True:
sell_price = p.get_current_price(c)
time.sleep(0.3)
if sell_price > target_price:
login.sell_market_order(c, get_balance(c[4:]))
print(c, "ํ์์")
flag = 3
break
if flag == 3:
print("์ข
๋ฃํฉ๋๋ค")
break
print("=== ๋ฐ๊ฒฌ ๋ชปํจ ===")
time.sleep(0.1)
except Exception as e:
print("๋๊ธฐ")
time.sleep(1)