forked from veox/python3-krakenex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print-open-positions.py
executable file
·41 lines (31 loc) · 1.05 KB
/
print-open-positions.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
#!/usr/bin/env python
# This file is part of krakenex.
# Licensed under the Simplified BSD license. See `examples/LICENSE.txt`.
# FIXME: Prints the sum of _some_ open positions?..
# Maintainer: [email protected] (@AustinDeric on github)
import krakenex
# configure api
k = krakenex.API()
k.load_key('kraken.key')
# prepare request
req_data = {'docalcs': 'true'}
# querry servers
start = k.query_public('Time')
open_positions = k.query_private('OpenPositions', req_data)
end = k.query_public('Time')
latency = end['result']['unixtime']-start['result']['unixtime']
# parse result
dict(open_positions)
b = 0
c = 0
for i in open_positions['result']:
order = open_positions['result'][i]
if(order['pair']=='XETHZUSD'):
b += (float(order['vol']))
if (order['pair'] == 'XXBTZUSD'):
c += (float(order['vol']))
print('error count: ' + str(len(open_positions['error'])))
print('latency: ' + str(latency))
print('total open eth: ' + str(b))
print('total open btc: ' + str(c))
print('total open positions: ' + str(len(open_positions['result'])))