Advanced search
Quantiacs > Newbie question...related to referencing 2 elements ? View modes: 
winSton66 - 1/22/2019 2:34:02 PM
Newbie question...related to referencing 2 elements ?
OK....admittedly, a TOTAL newbie....I can do anything on ThinkorSwim ,but really want to get over the hump with Python/Quantiacs

I've asked questions here before that have gone unaswered as I see most do...I really hope you guys can come thru for me on this Q !!!  Afterall, its SIMPLE I'm sure.

I have the following example shown below.....its 2 stocks and simply looks at todays close of each stock and compares it to the previous day and goes long or short. 

QUESTION and where I'm stumped....How can I rewrite this to compare the close of stock A to the close of stock B and go long or short ?  I can't seem to understand how or where to access stock A and B in the same function...

import numpy as np
def myTradingSystem(DATE, OPEN, HIGH, LOW, CLOSE, VOL, exposure, equity, settings):  
    np_x= np.array(CLOSE[1,1])
    np_y= np.array(CLOSE[2,1]) 
    if np_x > np_y:
    if np_y> np_x:
    return pos, settings
def mySettings():
    """ Define your trading system settings here """
    settings = {}
    # Futures Contracts
    settings['markets'] = ['CASH','AMZN', 'NFLX']
    settings['endInSample'] = '20190120'
    settings['beginInSample'] = '20100101'
    settings['lookback'] = 504
    settings['budget'] = 1000000
    settings['slippage'] = 0.05
    settings['threshold'] = 0.4
    return settings
# Evaluate trading system defined in current file.
if __name__ == '__main__':
    import quantiacsToolbox
    results = quantiacsToolbox.runts(__file__)