Created
May 4, 2017 08:16
-
-
Save xeroc/1f9a296447fd63f8b3ee446afc10bf14 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 / float(num), 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