Skip to content

Commit

Permalink
[GrapheneExchange] _get_txorder_price
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Jan 13, 2016
1 parent 3b1bdbe commit ae3b8c0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions grapheneexchange/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,25 @@ def _get_price_filled(self, f, m):
r["quote"] = f["op"]["receives"]
return self._get_price(r)

def _get_txorder_price(self, f, m):
""" A newly place limit order has `amount_to_sell` and
`min_to_receive` which serve as `base` and `quote` depending
on sell or buy
"""
r = {}
if f["op"]["min_to_receive"]["asset_id"] == m["base"] :
# If the seller received "base" in a quote_base market, than
# it has been a sell order of quote
r["base"] = f["op"]["min_to_receive"]
r["quote"] = f["op"]["amount_to_sell"]
elif["op"]["min_to_receive"]["asset_id"] == m["quote"]:
# buy order
r["base"] = f["op"]["amount_to_sell"]
r["quote"] = f["op"]["min_to_receive"]
else :
return None
return self._get_price(r)

def returnCurrencies(self):
""" In contrast to poloniex, this call returns the assets of the
watched markets only.
Expand Down

0 comments on commit ae3b8c0

Please sign in to comment.