Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

596 bitshares attributes #619

Merged
merged 1 commit into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions dexbot/orderengines/bitshares_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self,
config=None,
account=None,
market=None,
worker_market=None,
fee_asset_symbol=None,
bitshares_instance=None,
bitshares_bundle=None,
Expand Down Expand Up @@ -71,9 +72,11 @@ def __init__(self,
self.config = Config.get_worker_config_file(name)

# Get Bitshares account and market for this worker
self._account = account
self.account = account

self._market = market
self.market = market

self.worker_market = worker_market

# Recheck flag - Tell the strategy to check for updated orders
self.recheck_orders = False
Expand Down Expand Up @@ -183,7 +186,7 @@ def balance(self, asset, fee_reservation=0):
:param float | fee_reservation: How much is saved in reserve for the fees
:return: Balance of specific asset
"""
balance = self._account.balance(asset)
balance = self.account.balance(asset)

if fee_reservation > 0:
balance['amount'] = balance['amount'] - fee_reservation
Expand Down Expand Up @@ -686,15 +689,15 @@ def account(self):

:return: object | Account
"""
return self._account
return self.account

@property
def balances(self):
""" Returns all the balances of the account assigned for the worker.

:return: Balances in list where each asset is in their own Amount object
"""
return self._account.balances
return self.account.balances

def get_own_orders(self, refresh=True):
""" Return the account's open orders in the current market
Expand All @@ -709,7 +712,7 @@ def get_own_orders(self, refresh=True):
self.account.refresh()

for order in self.account.openorders:
if self.worker["market"] == order.market and self.account.openorders:
if self.worker_market == order.market and self.account.openorders:
orders.append(order)

return orders
Expand Down Expand Up @@ -747,7 +750,7 @@ def market(self):
# TODO: property, also in price feed, need to consider inheritance priority
""" Return the market object as :class:`bitshares.market.Market`
"""
return self._market
return self.market

@staticmethod
def get_updated_limit_order(limit_order):
Expand Down
4 changes: 2 additions & 2 deletions dexbot/pricefeeds/bitshares_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self,
market,
bitshares_instance=None):

self._market = market
self.market = market
self.ticker = self.market.ticker
self.disabled = False # flag for suppress errors

Expand Down Expand Up @@ -339,7 +339,7 @@ def get_market_spread(self, quote_amount=0, base_amount=0):
def market(self):
""" Return the market object as :class:`bitshares.market.Market`
"""
return self._market
return self.market

@staticmethod
def sort_orders_by_price(orders, sort='DESC'):
Expand Down
2 changes: 2 additions & 0 deletions dexbot/strategies/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def __init__(self,
}
)

self.worker_market = self.worker["market"]

self.orders_log = logging.LoggerAdapter(logging.getLogger('dexbot.orders_log'), {})

def pause(self):
Expand Down