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

openorders does not reflect partial fills #18

Open
pramirez92 opened this issue Jul 23, 2019 · 3 comments
Open

openorders does not reflect partial fills #18

pramirez92 opened this issue Jul 23, 2019 · 3 comments

Comments

@pramirez92
Copy link

"uptick openorders some_account" reflects the original order amounts, rather than the current order amounts. In other words, when there is a partial fill the amounts do not update to reflect the amount remaining on the order.

I have looked at the code, but I am not quite knowledgeable enough to suggest the fix. Page 13 of this document may reference a related item (search for "for_sale" in that doc):

https://buildmedia.readthedocs.org/media/pdf/python-bitshares/develop/python-bitshares.pdf

@pramirez92
Copy link
Author

pramirez92 commented Jul 23, 2019

Update:

I changed one line of code in markets.py as shown below (see the "for_sale" shown in bold). As expected, without any partial fill on an open order, this gives me the same output as before the change. When a partial fill has occurred, this change corrects the base asset, but not the quote asset. To fix the quote asset, it's simply a matter of dividing the "for_sale" amount (formerly the base asset) by the price on the order. Simple as that.

This is probably dead simple for a python programmer to implement. Not so simple for me ;-) , but I'm going to give it a shot. I'll post an update when I'm done (unless someone beats me to it!)

===

@main.command()
@click.pass_context
@onlinechain
@click.argument("account", type=str)
def openorders(ctx, account):
""" List open orders of an account
"""
account = Account(
account or config["default_account"], bitshares_instance=ctx.bitshares
)
t = [["Price", "Quote", "Base", "ID"]]
for o in account.openorders:
t.append(
[
"{:f} {}/{}".format(
o["price"],
o["base"]["asset"]["symbol"],
o["quote"]["asset"]["symbol"],
),
str(o["quote"]),
str(o["for_sale"]),
o["id"],
]
)
print_table(t)

@pramirez92
Copy link
Author

pramirez92 commented Jul 23, 2019

This is close:

I changed this:
str(o["quote"]),
str(o["base"]),

To this:
str(o["for_sale"]/o["price"]),
str(o["for_sale"]),

On a partial fill, the numbers are correct now, but the currency symbols on the quote side are backwards on the output (strange).

So not quite there yet ...

It would be nice if they had also implemented "to_buy" when they implemented "for_sale":
bitshares/python-bitshares#85

Anyway, I'm almost there. The math works in my above change, but there is some symbol formatting thing that I'm not understanding.

Can you finish this off?

@xeroc
Copy link
Member

xeroc commented Aug 5, 2019

Can you send a pull request please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants