Skip to content
Snippets Groups Projects
Commit 6abe6823 authored by Fabian Schuh's avatar Fabian Schuh
Browse files

[class] MarginCall -> UdpateCallOrder

parent 0122cb00
No related branches found
No related tags found
No related merge requests found
...@@ -254,4 +254,6 @@ class AccountUpdate(dict): ...@@ -254,4 +254,6 @@ class AccountUpdate(dict):
:class:`bitshares.account.Account` from this class, you can :class:`bitshares.account.Account` from this class, you can
use the ``account`` attribute. use the ``account`` attribute.
""" """
return Account(self["owner"]) account = Account(self["owner"])
account.refresh()
return account
...@@ -3,7 +3,7 @@ from events import Events ...@@ -3,7 +3,7 @@ from events import Events
from bitsharesapi.websocket import BitSharesWebsocket from bitsharesapi.websocket import BitSharesWebsocket
from bitshares.instance import shared_bitshares_instance from bitshares.instance import shared_bitshares_instance
from bitshares.market import Market from bitshares.market import Market
from bitshares.price import Order, FilledOrder, MarginCall from bitshares.price import Order, FilledOrder, UpdateCallOrder
from bitshares.account import Account, AccountUpdate from bitshares.account import Account, AccountUpdate
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# logging.basicConfig(level=logging.DEBUG) # logging.basicConfig(level=logging.DEBUG)
...@@ -81,15 +81,6 @@ class Notify(Events): ...@@ -81,15 +81,6 @@ class Notify(Events):
market["quote"]["id"], market["quote"]["id"],
]) ])
# Accounts
account_ids = []
for account_name in accounts:
account = Account(
account_name,
bitshares_instance=self.bitshares
)
account_ids.append(account["id"])
# Callbacks # Callbacks
if on_tx: if on_tx:
self.on_tx += on_tx self.on_tx += on_tx
...@@ -107,7 +98,7 @@ class Notify(Events): ...@@ -107,7 +98,7 @@ class Notify(Events):
urls=self.bitshares.rpc.urls, urls=self.bitshares.rpc.urls,
user=self.bitshares.rpc.user, user=self.bitshares.rpc.user,
password=self.bitshares.rpc.password, password=self.bitshares.rpc.password,
accounts=account_ids, accounts=accounts,
markets=market_ids, markets=market_ids,
objects=objects, objects=objects,
on_tx=on_tx, on_tx=on_tx,
...@@ -123,7 +114,7 @@ class Notify(Events): ...@@ -123,7 +114,7 @@ class Notify(Events):
* :class:`bitshares.price.Order` or * :class:`bitshares.price.Order` or
* :class:`bitshares.price.FilledOrder` or * :class:`bitshares.price.FilledOrder` or
* :class:`bitshares.price.MarginCall` * :class:`bitshares.price.UpdateCallOrder`
Also possible are limit order updates (margin calls) Also possible are limit order updates (margin calls)
...@@ -150,7 +141,7 @@ class Notify(Events): ...@@ -150,7 +141,7 @@ class Notify(Events):
elif "for_sale" in i and "sell_price" in i: elif "for_sale" in i and "sell_price" in i:
self.on_market(Order(i)) self.on_market(Order(i))
elif "collateral" in i and "call_price" in i: elif "collateral" in i and "call_price" in i:
self.on_market(MarginCall(i)) self.on_market(UpdateCallOrder(i))
else: else:
if i: if i:
log.error( log.error(
......
...@@ -466,7 +466,7 @@ class FilledOrder(Price): ...@@ -466,7 +466,7 @@ class FilledOrder(Price):
__str__ = __repr__ __str__ = __repr__
class MarginCall(Price): class UpdateCallOrder(Price):
""" This class inherits :class:`bitshares.price.Price` but has the ``base`` """ This class inherits :class:`bitshares.price.Price` but has the ``base``
and ``quote`` Amounts not only be used to represent the **call and ``quote`` Amounts not only be used to represent the **call
price** (as a ratio of base and quote). price** (as a ratio of base and quote).
...@@ -478,7 +478,7 @@ class MarginCall(Price): ...@@ -478,7 +478,7 @@ class MarginCall(Price):
self.bitshares = bitshares_instance or shared_bitshares_instance() self.bitshares = bitshares_instance or shared_bitshares_instance()
if isinstance(call, dict) and "call_price" in call: if isinstance(call, dict) and "call_price" in call:
super(MarginCall, self).__init__( super(UpdateCallOrder, self).__init__(
call.get("call_price"), call.get("call_price"),
base=call["call_price"].get("base"), base=call["call_price"].get("base"),
quote=call["call_price"].get("quote"), quote=call["call_price"].get("quote"),
......
...@@ -11,7 +11,7 @@ from .exceptions import NumRetriesReached ...@@ -11,7 +11,7 @@ from .exceptions import NumRetriesReached
from events import Events from events import Events
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# logging.basicConfig(level=logging.DEBUG) #logging.basicConfig(level=logging.DEBUG)
class BitSharesWebsocket(Events): class BitSharesWebsocket(Events):
...@@ -131,7 +131,7 @@ class BitSharesWebsocket(Events): ...@@ -131,7 +131,7 @@ class BitSharesWebsocket(Events):
self.urls = cycle([urls]) self.urls = cycle([urls])
# Instanciate Events # Instanciate Events
Events.__init__(self, *args, **kwargs) Events.__init__(self)
self.events = Events() self.events = Events()
# Store the objects we are interested in # Store the objects we are interested in
...@@ -184,9 +184,11 @@ class BitSharesWebsocket(Events): ...@@ -184,9 +184,11 @@ class BitSharesWebsocket(Events):
if self.subscription_accounts and self.on_account: if self.subscription_accounts and self.on_account:
# Unfortunately, account subscriptions don't have their own # Unfortunately, account subscriptions don't have their own
# callback number # callback number
self.accounts = self.get_full_accounts(self.subscription_accounts, True) log.debug("Subscribing to accounts %s" % str(self.subscription_accounts))
self.get_full_accounts(self.subscription_accounts, True)
if self.subscription_markets and self.on_market: if self.subscription_markets and self.on_market:
log.debug("Subscribing to markets %s" % str(self.subscription_markets))
for market in self.subscription_markets: for market in self.subscription_markets:
# Technially, every market could have it's own # Technially, every market could have it's own
# callback number # callback number
...@@ -298,7 +300,6 @@ class BitSharesWebsocket(Events): ...@@ -298,7 +300,6 @@ class BitSharesWebsocket(Events):
self.ws = websocket.WebSocketApp( self.ws = websocket.WebSocketApp(
self.url, self.url,
on_message=self.on_message, on_message=self.on_message,
# on_data=self.on_message,
on_error=self.on_error, on_error=self.on_error,
on_close=self.on_close, on_close=self.on_close,
on_open=self.on_open on_open=self.on_open
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment