Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Various problems

.

5 responses

Maybe you should look into how you can debug your python code on Quantopian, like using log.info('foo') or log.debug('bar'), maybe in combination with type(some_var) etc. Sorry for the vague answer but I believe its better to learn how to fish! :)

takuo takuo.

Try this:

#  TEMA-DEMA ???

import talib  
import numpy as np  
import pandas as pd  

def initialize(context): 

    schedule_function(trade, date_rules.every_day(), time_rules.market_close(minutes=30)) 

def trade(context, data):  
    stk = symbol('QQQ')  
    period = 100  
    O = data.history(stk, 'open',  period, '1m')  
    H = data.history(stk, 'high',  period, '1m')  
    L = data.history(stk, 'low',   period, '1m')  
    C = data.history(stk, 'close', period, '1m')      

    AvgP = (O[-1] + H[-1] + L[-1] + C[-1])/4  
    np_AvgP = np.ndarray(AvgP)  
    t = talib.TEMA(np_AvgP, timeperiod = 2)[-1]  
    d = talib.DEMA(np_AvgP, timeperiod = 14)[-1]  
    if t > d:  
        order_target_percent(stk, 1.0)  
    elif  t < d:  
        order_target(stk, 0)  

@Peter Aa
Been doing that and will keep doing that

@Vladimir Yevtushenko
Tried that and...

ValueError: cannot convert float NaN to integer ... USER ALGORITHM:18,
in trade np_AvgP = np.ndarray(AvgP)

No idea why it spits that out.

TEMA-DEMA
Strange, it is working for me.

I tried again and it works 20% of the time. How can it work only sometimes lol ??