コード例 #1
0
def write_log(action, name=file_name):
    global last_close, last_price, order_id, holding, current_price
    log = ''
    current_price = get_price(token, last_price)
    if action == 'BUY' or action == 'SELL':
        simulator.place_order(action, token_mappings[token], 1000)
        slack_msg = action + " : " + str(
            token_mappings[token]) + " @ " + str(current_price)
        if order_id == '':
            datetime_obj = getDateTime()
            order_id = str(datetime_obj.hour) + str(datetime_obj.minute) + str(
                datetime_obj.second)
            holding = 'up' if action == 'BUY' else 'down'
            last_price = current_price
            log = create_log(action)
        else:
            holding = ''
            slack_msg = slack_msg + ' for Order Id : ' + str(
                order_id) + ' in : ' + str(flag) + " : Bollinger bands"
            log = create_log(action)
            order_id = ''
        sendMessage(slack_msg)
    name = token + "/" + name
    f = open(name, 'a')
    if log == '':
        log = create_log(action)
    f.write(log)
    f.close()
コード例 #2
0
def write_log(action, name=file_name):
    global profit, stop_loss, historical_data, supertrend, rsi, rsi_slope, wma20, wma5, wma14, last_close, last_price, order_id, holding, current_price, price_status
    log = ''
    current_price = get_price(token, last_close)
    if action == 'BUY' or action == 'SELL':
        slack_msg = action + " : " + str(
            token_mappings[token]) + " @ " + str(current_price)
        if order_id == '':
            datetime_obj = getDateTime()
            order_id = str(datetime_obj.hour) + str(datetime_obj.minute) + str(
                datetime_obj.second)
            holding = 'up' if action == 'BUY' else 'down'
            last_price = current_price
            log = create_log(action)
        else:
            holding = ''
            slack_msg = slack_msg + ' for Order Id : ' + str(
                order_id) + ' in : ' + str(flag)
            sendTrades(slack_msg)
            log = create_log(action)
            order_id = ''
        sendMessage(slack_msg)
    name = token + "/" + name
    f = open(name, 'a')
    if log == '':
        log = create_log(action)
    f.write(log)
    f.close()
コード例 #3
0
def place_order(signal):
    if supertrend == 'up' and 60 <= rsi <= 80 and rsi_slope > 0.5 and wma5 >= wma20 and holding == '' and order_id == '' and signal == '':
        write_log('BUY')
    elif supertrend == 'down' and 20 <= rsi <= 40 and rsi_slope < -0.5 and wma5 <= wma20 and holding == '' and order_id == '' and signal == '':
        write_log('SELL')
    elif holding != '' and order_id != '' and signal == '':
        write_log('HOLD')
    elif holding != '' and order_id != '' and signal != '':
        write_log(signal)
    else:
        write_log('NONE')
    if holding != '' and order_id != '' and signal == '' and swing:
        action = 'SELL' if holding == 'up' else 'BUY'
        slack_msg = action + " : " + str(token_mappings[token]) + " @ " + str(current_price) + " for Order : "+str(order_id)+" : Swing"
        sendMessage(slack_msg)