59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
from xcoin_api_client import *
|
|
import sched
|
|
import time
|
|
import data_manager
|
|
|
|
|
|
api_key = "api_connect_key"
|
|
api_secret = "api_secret_key"
|
|
api = XCoinAPI(api_key, api_secret)
|
|
|
|
# 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
|
|
|
|
|
|
rgParams = {
|
|
"order_currency": "xrp",
|
|
"payment_currency": "KRW"
|
|
}
|
|
|
|
scheduler = sched.scheduler(time.time, time.sleep)
|
|
timer_delay = 0.1
|
|
|
|
def printTicker(result):
|
|
print("["+time.strftime("%H:%M:%S")+"]" + " status: " + result["status"] + " last: " + result["data"]["closing_price"])
|
|
|
|
def printTransaction(result):
|
|
print("["+time.strftime("%H:%M:%S")+"]" + " status: " + result["status"])
|
|
for item in result['data']:
|
|
print('\t[' + item['transaction_date']+']' + item['type'] + ' ' + item['price']);
|
|
|
|
|
|
datamgr = data_manager.DataMgr()
|
|
def main(arg):
|
|
#result = api.xcoinApiCall("/public/ticker/" + rgParams["order_currency"], rgParams)
|
|
#if result is not None:
|
|
# printTicker(result)
|
|
|
|
result = api.xcoinApiCall("/public/recent_transactions/" + rgParams["order_currency"], rgParams)
|
|
if result is not None:
|
|
for item in reversed(result['data']):
|
|
datamgr.insert(item)
|
|
|
|
scheduler.enter(timer_delay, 1, main, (arg, ))
|
|
|
|
scheduler.enter(timer_delay, 1, main, (scheduler, ))
|
|
scheduler.run()
|