-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_test.py
executable file
·139 lines (111 loc) · 3.19 KB
/
api_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! /usr/bin/env python
# XCoin API-call sample script (for Python 3.X)
#
# @author btckorea
# @date 2017-04-11
#
#
# First, Build and install pycurl with the following commands::
# (if necessary, become root)
#
# https://pypi.python.org/pypi/pycurl/7.43.0#downloads
#
# tar xvfz pycurl-7.43.0.tar.gz
# cd pycurl-7.43.0
# python setup.py --libcurl-dll=libcurl.so install
# python setup.py --with-openssl install
# python setup.py install
import sys
from xcoin_api_client import *
import pprint
import os
b_api_key = os.environ["BITHUMB_API_KEY"]
b_api_secret = os.environ["BITHUMB_API_SECRET"]
p_api_key = os.environ["POLONIEX_API_KEY"]
p_api_secret = os.environ["POLONIEX_API_SECRET"]
api = XCoinAPI(b_api_key, b_api_secret);
rgParams = {
"order_currency" : "BTC",
"payment_currency" : "KRW",
};
#
# public api
#
# /public/ticker
# /public/recent_ticker
# /public/orderbook
# /public/recent_transactions
#result = api.xcoinApiCall("/public/ticker", rgParams);
##print(result)
#print("status: " + result["status"]);
#print("last: " + result["data"]["closing_price"]);
#print("sell: " + result["data"]["sell_price"]);
#print("buy: " + result["data"]["buy_price"]);
#
# private api
#
# endpoint => parameters
# /info/current
# /info/account
# /info/balance
# /info/wallet_address
#rgParams = {
# "currency" : "LTC"
# };
#result = api.xcoinApiCall("/info/account", rgParams);
#print(result)
#print("status: " + result["status"]);
#print("created: " + result["data"]["created"]);
#print("account id: " + result["data"]["account_id"]);
#print("trade fee: " + result["data"]["trade_fee"]);
#print("balance: " + result["data"]["balance"]);
#
#
### Wallet address
#rgParams = {
# "currency" : "BTC"
# };
#result = api.xcoinApiCall("/info/wallet_address", rgParams);
##print(result)
## BALANCE
print("==== Bith Balance ==== ")
bith_balance = {}
coins = ["BTC", "ETH", "ETC", "LTC", "XRP"]
for c in coins:
rgParams = {
"currency" : c};
result = api.xcoinApiCall("/info/balance", rgParams);
#print(result)
bith_balance[c] = result['data']['available_'+c.lower()]
#print("{} :\t {}".format(c, result['data']['available_'+c.lower()]))
bith_balance['KRW'] = result['data']['available_krw']
for c in bith_balance:
if float(bith_balance[c]) > 0:
print(c, bith_balance[c])
print("==== Coinone Balance ==== ")
from secret import ACCESS_TOKEN, SECRET_KEY
from coinone.account import Account
from pprint import pprint
my = Account(ACCESS_TOKEN, SECRET_KEY)
mybal = my.balance()
coinone_balance = {}
coinone_balance['BTC'] = mybal['btc']['balance']
coinone_balance['ETC']= mybal['etc']['balance']
coinone_balance['ETH']= mybal['eth']['balance']
coinone_balance['KRW']= mybal['krw']['balance']
for c in coinone_balance:
if float(coinone_balance[c]) > 0:
print(c, coinone_balance[c])
print("==== Polo Balance ==== ")
import poloniex
polo = poloniex.Poloniex(p_api_key, p_api_secret)
polo_balance = polo.returnBalances()
for c in polo_balance:
if float(polo_balance[c]) > 0:
print(c, polo_balance[c])
#print(balance)
# or
#balance = polo('returnBalances')
#print("I have %s BTC!" % balance['BTC'])
sys.exit(0);
print("==== Polo Balance ==== ")