Example #1
0
def sell():
    """sell a given trade"""

    global TEST
    print("SELL", file=sys.stderr)
    pair = request.args.get('pair')
    name = config.main.name
    current_price = request.args.get('price')
    print(pair, name, file=sys.stderr)

    test_trade = bool(os.environ['HOST'] in ["test", "stag"])
    trade = Trade(interval='4h', test_data=TEST, test_trade=test_trade)

    current_time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
    sells = [(pair, current_time, current_price)]

    # Sell, then update page
    trade.sell(sells, name=name)
    sleep(1)
    dbase = Mysql(interval='4h', test=test_trade)
    dbase.get_active_trades()
    del dbase
    get_open(SCHED)
    get_closed(SCHED)
    return redirect("/api", code=302)
Example #2
0
def buy():
    """Buy a given pair"""
    global TEST
    pair = request.args.get('pair')
    LOGGER.info("Buying pair %s" % pair)
    trade = Trade(interval='4h', test_data=TEST, test_trade=TEST_TRADE)
    current_time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
    current_price = get_current_price(pair)
    buys = [(pair, current_time, current_price)]
    trade.open_trade(buys)
    sleep(1)
    dbase = Mysql()
    dbase.get_active_trades()
    del dbase
    return redirect("/api", code=302)
Example #3
0
def buy():
    """Buy a given pair"""
    global TEST
    print("BUY", file=sys.stderr)
    pair = request.args.get('pair')
    test_trade = bool(os.environ['HOST'] in ["test", "stag"])
    trade = Trade(interval='4h', test_data=TEST, test_trade=test_trade)
    current_time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
    current_price = get_current_price(pair)
    buys = [(pair, current_time, current_price)]
    trade.buy(buys)
    sleep(1)
    dbase = Mysql()
    dbase.get_active_trades()
    del dbase
    get_open(SCHED)
    get_closed(SCHED)
    return redirect("/api", code=302)
Example #4
0
def sell():
    """sell a given trade"""

    global TEST
    pair = request.args.get('pair')
    LOGGER.info("Selling pair %s" % pair)

    current_price = request.args.get('price')

    interval = DATA[pair]['interval']
    trade = Trade(interval=interval, test_data=TEST, test_trade=TEST_TRADE)

    current_time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
    sells = [(pair, current_time, current_price)]

    # Sell, then update page
    trade.close_trade(sells)
    sleep(1)
    dbase = Mysql(interval='4h', test=TEST_TRADE)
    dbase.get_active_trades()
    del dbase
    return redirect("/api", code=302)