Skip to content

Instantly share code, notes, and snippets.

@xeroc
Created May 4, 2017 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeroc/1f9a296447fd63f8b3ee446afc10bf14 to your computer and use it in GitHub Desktop.
Save xeroc/1f9a296447fd63f8b3ee446afc10bf14 to your computer and use it in GitHub Desktop.
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