forked from PyWaves/PyWaves
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.py
32 lines (27 loc) · 1.22 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
32
import pywaves
class Order(object):
def __init__(self, orderId, assetPair, address = '', pywaves=pywaves):
self.pywaves = pywaves
self.orderId = orderId
self.assetPair = assetPair
self.address = address
self.matcher = self.pywaves.MATCHER
self.matcherPublicKey = self.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 = self.pywaves.wrapper('/matcher/orderbook/%s/%s/%s' % (pywaves.DEFAULT_CURRENCY if self.assetPair.asset1.assetId=='' else self.assetPair.asset1.assetId, pywaves.DEFAULT_CURRENCY 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__