-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_test.py
More file actions
117 lines (92 loc) · 2.81 KB
/
api_test.py
File metadata and controls
117 lines (92 loc) · 2.81 KB
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
#! /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 price import *
from bithumb_api import *
from polonix_api import *
from bitrex_api import *
import pprint
#
# public api
#
# /public/ticker
# /public/recent_ticker
# /public/orderbook
# /public/recent_transactions
#
# private api
#
# endpoint => parameters
# /info/current
# /info/account
# /info/balance
# /info/wallet_address
#result = api.xcoinApiCall("/info/account", rgParams);
#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"]);
#bithumb
api_key = "api_connect_key";
api_secret = "api_secret_key";
"""
api = BithumbAPI(api_key, api_secret);
rgParams = {
#"group_orders" : "1",
#"count" : "30"
};
result = api.BithumbAPICall("/public/ticker/BTC", rgParams);
print("BTC_Opening: " + result["data"]["opening_price"]);
print("BTC_Closing: " + result["data"]["closing_price"]);
print("BTC_Min: " + result["data"]["min_price"]);
print("BTC_Max: " + result["data"]["max_price"]);
print("BTC_Avg: " + result["data"]["average_price"]);
print("BTC_units_traded: " + result["data"]["units_traded"]);
print("BTC_volume_1day: " + result["data"]["volume_1day"]);
print("BTC_volume_7day: " + result["data"]["volume_7day"]);
print("BTC_Buy: " + result["data"]["buy_price"]);
print("BTC_Sell: " + result["data"]["sell_price"]);
"""
#poloniex
"""
api = poloniex(api_key, api_secret);
rgParams = {
#"group_orders" : "1",
#"count" : "30"
};
result=api.api_query("returnTicker",rgParams);
print("last: " + result["BTC_ETH"]["last"]);
print("lowestAsk: " + result["BTC_ETH"]["lowestAsk"]);
print("highestBid: " + result["BTC_ETH"]["highestBid"]);
print("percentChange: " + result["BTC_ETH"]["percentChange"]);
print("baseVolume: " + result["BTC_ETH"]["baseVolume"]);
print("quoteVolume: " + result["BTC_ETH"]["quoteVolume"]);
print("USDT_BTC: " + result["USDT_BTC"]["last"]);
"""
api = Bittrex(api_key, api_secret);
rgParams = {
"market" : "BTC-ETH",
#"count" : "30"
};
result=api.api_query("getmarketsummary",rgParams);
#print("last: " + result["result"]["Last"]);
for i in range(len(result['result'])):
if result['result'][i]['MarketName'] == 'BTC-ETH':
print (result['result'][i]);
sys.exit(0);