forked from jansenmarc/PyWaves
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.py
31 lines (26 loc) · 1.12 KB
/
order.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
import pywaves
class Order(object):
def __init__(self, orderId, assetPair, address = ''):
self.orderId = orderId
self.assetPair = assetPair
self.address = address
self.matcher = pywaves.MATCHER
self.matcherPublicKey = pywaves.MATCHER_PUBLICKEY
self.status()
def __str__(self):
return 'status = %s\n' \
'id = %s\n' \
'%s\n' \
'sender.address = %s\n' \
'sender.publicKey = %s\n' \
'matcher = %s' % (self.status(), self.orderId, self.assetPair, self.address.address, self.address.publicKey, self.matcherPublicKey)
def status(self):
try:
req = pywaves.wrapper('/matcher/orderbook/%s/%s/%s' % ('WAVES' if self.assetPair.asset1.assetId=='' else self.assetPair.asset1.assetId, 'WAVES' if self.assetPair.asset2.assetId=='' else self.assetPair.asset2.assetId, self.orderId), host=self.matcher)
return req['status']
except:
pass
def cancel(self):
if self.address:
self.address.cancelOrder(self.assetPair, self)
__repr__ = __str__