Esempio n. 1
0
def watch_outcomes_long():
    most_recent_transaction = get_most_recent_transaction()
    while True:
        try:
            log_ping('Pinging outcomes long.')
            transactions = get_transactions_range(most_recent_transaction)
            for each in transactions['transactions']:
                log_outcomes_long(each)
            most_recent_transaction = int(transactions['lastTransactionID'])
        except Exception as e:
            log_ping('Can not establish long connection.' + str(e))

        env = yaml.safe_load(open('/seq/seq3/configs/env.yaml', 'r'))
        time.sleep(env['ping_oanda_outcomes_interval'])
Esempio n. 2
0
def watch_candles():
    while True:
        # Compare latest fetched candle with last logged candle.
        env = yaml.safe_load(open('/seq/seq3/configs/env.yaml','r'))
        most_recent_candle = get_placement_candles('EUR_USD', 
                                                   env['granularity'], 2)
        # If candle is larger, call placements.  Otherwise, slee & try again.
        if most_recent_candle.iloc[-1,0] <= \
                                   pd.to_datetime(env['latest_timestamp']):
           msg = 'Waiting on new candle.\t{}'
           log_ping(msg.format(most_recent_candle.iloc[-1,0]))
        else:     
            msg = 'New Candle Found.\t{}\t\n< < < '
            log_ping(msg.format(most_recent_candle.iloc[-1,0]))
            log_eval(msg.format(most_recent_candle.iloc[-1,0]))
            evaluate_positions(most_recent_candle.iloc[-1, 0])
            env['latest_timestamp'] = str(most_recent_candle.iloc[-1, 0])
            yaml.safe_dump(env, open('/seq/seq3/configs/env.yaml', 'w'), 
                           default_flow_style=False)
        time.sleep(env['ping_oanda_candles_interval'])
Esempio n. 3
0
                                                                    timestamp))

            
def watch_candles():
    while True:
        # Compare latest fetched candle with last logged candle.
        env = yaml.safe_load(open('/seq/seq3/configs/env.yaml','r'))
        most_recent_candle = get_placement_candles('EUR_USD', 
                                                   env['granularity'], 2)
        # If candle is larger, call placements.  Otherwise, slee & try again.
        if most_recent_candle.iloc[-1,0] <= \
                                   pd.to_datetime(env['latest_timestamp']):
           msg = 'Waiting on new candle.\t{}'
           log_ping(msg.format(most_recent_candle.iloc[-1,0]))
        else:     
            msg = 'New Candle Found.\t{}\t\n< < < '
            log_ping(msg.format(most_recent_candle.iloc[-1,0]))
            log_eval(msg.format(most_recent_candle.iloc[-1,0]))
            evaluate_positions(most_recent_candle.iloc[-1, 0])
            env['latest_timestamp'] = str(most_recent_candle.iloc[-1, 0])
            yaml.safe_dump(env, open('/seq/seq3/configs/env.yaml', 'w'), 
                           default_flow_style=False)
        time.sleep(env['ping_oanda_candles_interval'])



if __name__ == '__main__':
    log_ping('\n\n')
    log_eval('\n\n')
    watch_candles()