Created
April 21, 2017 09:56
-
-
Save xeroc/475742e6e3f3ce660959bbc9dc845a42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
from numpy import linspace | |
from uptick.decorators import unlock, online | |
from uptick.main import main | |
from bitshares.market import Market | |
from bitshares.account import Account | |
import click | |
@main.command() | |
@click.option( | |
"--account", | |
default=None | |
) | |
@click.argument( | |
"market" | |
) | |
@click.argument( | |
"side", | |
type=click.Choice(['buy', 'sell']) | |
) | |
@click.argument( | |
"min", | |
type=float | |
) | |
@click.argument( | |
"max", | |
type=float | |
) | |
@click.argument( | |
"num", | |
type=float | |
) | |
@click.argument( | |
"amount", | |
type=float | |
) | |
@click.pass_context | |
@online | |
@unlock | |
def spread(ctx, market, side, min, max, num, amount, account): | |
market = Market(market) | |
ctx.bitshares.bundle = True | |
if min < max: | |
space = linspace(min, max, num) | |
else: | |
space = linspace(max, min, num) | |
func = getattr(market, side) | |
for p in space: | |
func(p, amount, account=account) | |
# ctx.bitshares.txbuffer.constructTx() | |
# pprint(ctx.bitshares.txbuffer.json()) | |
pprint(ctx.bitshares.txbuffer.broadcast()) | |
@main.command() | |
@click.option( | |
"--account", | |
default=None | |
) | |
@click.argument( | |
"market" | |
) | |
@click.pass_context | |
@online | |
@unlock | |
def cancelall(ctx, market, account): | |
market = Market(market) | |
ctx.bitshares.bundle = True | |
market.cancel([ | |
x["id"] for x in market.accountopenorders(account) | |
], account=account) | |
# ctx.bitshares.txbuffer.constructTx() | |
# pprint(ctx.bitshares.txbuffer.json()) | |
pprint(ctx.bitshares.txbuffer.broadcast()) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment