Exemplo n.º 1
0
#let's check that we have enough USD to place this order
auth = gcl.AuthClient()
usd_acct = auth.getAccounts()['USD']

usd_cost = nu.interp_float_str(args.volume, usd_acct.available)

if (usd_acct.available < usd_cost):
    print("Insufficient USD in account.")
    print("Balance: $%.2f" % usd_acct.balance)
    print("Available: $%.2f" % usd_acct.available)
    sys.exit(1)

size = usd_cost / args.price

size = nu.floor_size(size)

print("Total cost: $%.2f" % usd_cost)
print("Total value if all bought: %f ETH" % size)

params = gpr.LimitOrderParams(args.price, size, side='buy')

print("Placing order: %s" % params)

order = auth.buy(params)

if (order.isError):
    print("... error placing order: %s" % order)
else:
    print("... order placed: %s" % order)
    print("Order ID: %s" % order.id)
Exemplo n.º 2
0
    weights = np.arange(1, args.n_orders)
elif(args.vol_dist == "exp"):
    weights = np.exp(np.linspace(1, 3, args.n_orders))
else:
    print("Invalid volume distribution type.")
    sys.exit(4)

weights = weights / float(np.sum(weights))

if(args.price_hilo == "low"):
    weights = np.fliplr([weights])[0]

volumes = weights*args.total_amount

prices = np.asarray([np.round(x,2) for x in prices])
volumes = np.asarray([nu.floor_size(x) for x in volumes])

print("Total value if all sold: $%.2f" % np.sum(prices*volumes))

orders = []

for price,size in zip(prices, volumes):
    params = gpr.LimitOrderParams(price, size, side='sell')

    print("Placing order: %s" % params)
    order =  auth.sell(params)

    if(order.isError):
        #error placing order
        #cancel all previous orders
        print("... error placing order: %s" % order)