Exemplo n.º 1
0
def call_backtest (params):

    # Split params tuple to separate variables
    i = params[0]
    j = params[1]

    strategy = TS() # Instantiate trading dsystem

    # Apply srtategy paramters and needed overrides to default TS settings
    strategy.settings_ts['markets']  = markets   # Overrides initial in TS - optional
    strategy.settings_ts['lookback']  = lookback # Overrides initial in TS - optional

    strategy.params_ts['periodLong']  = i  # Apply one parameter of the trading system
    strategy.params_ts['periodShort'] = j  # Apply second parameter ....

    # Display stdout message
    # Messages written out get messed up due to concurrent execution
    print "Evaluating for long: %d and short: %d"%(i,j)

    # Backtest trading system with parameters
    # without showing graphics after the run
    results=quantiacsToolbox.runts(strategy,False)

    # Send backtest results back - must be combined in a single object - tuple in this case
    # Returning back also input parameters to link with "results" of backtesting
    # as imap_unoredered was used for multiprocessing and order of returned results is not
    # the same as order of parameters
    return (i, j, results)
Exemplo n.º 2
0
def mySettings():

    settings = {}

    settings['markets'] = ['AAPL', 'ABT', 'ABBV']
    settings['beginInSample'] = '20190101'
    settings['endInSample'] = '20200101'
    settings['lookback'] = 100
    settings['budget'] = 10**6
    settings['slippage'] = 0.05

    return settings

    if __name__ == '__main__':
        import quantiacsToolbox
        results = quantiacsToolbox.runts(__file__)
Exemplo n.º 3
0
def call_backtest(params):

    i = params[0]
    j = params[1]

    strategy = TS()  # Instantiate
    strategy.settings_ts['markets'] = markets  # Overrides initial in TS
    strategy.settings_ts['lookback'] = lookback  # Overrides initial in TS
    strategy.params_ts[
        'periodLong'] = i  # Apply long period from argument to trading system
    strategy.params_ts['periodShort'] = j  # Short period

    # Display message
    print "Evaluating for long: %d and short: %d" % (i, j)

    # Backtest trading system defined in "strategy" (TS class object)
    # without showing graphics after the run
    results = quantiacsToolbox.runts(strategy, False)

    # Send backtest results back
    return (i, j, results)
Exemplo n.º 4
0
def evalSecurities(individual):
    #print "strategy: ",individual.__str__()
    # Transform the tree expression in a callable function
    code = str(individual)
    print
    print "code: ", code
    func = toolbox.compile(expr=individual)
    #pdb.set_trace()
    # Randomly sample 400 mails in the spam database
    #spam_samp = random.sample(spam, 400)
    # Evaluate the sum of correctly identified mail as spam
    #result = sum(bool(func(*mail[:5])) is bool(mail[57]) for mail in spam_samp)

    strat = Strat()
    strat.strategy = individual
    #pdb.set_trace()
    result = quantiacsToolbox.runts(strat, plotEquity=False)

    sharpe = result['stats']['sharpe']

    if numpy.isnan(sharpe):
        sharpe = -10

    print "sharpe: ", sharpe

    #print result

    #pdb.set_trace()

    #try:
    #    print individual[0].seq
    #except:
    #    #pdb.set_trace()
    #    pass

    return sharpe,
        pos[0] = 1
    else:
        pos[0] = -1

    return pos, settings


##### Do not change this function definition #####
def mySettings():
    ''' Define your trading system settings here '''
    settings = {}

    # Futures Contracts
    settings['markets'] = ['F_US']
    settings['slippage'] = 0.05
    settings['budget'] = 1000000
    settings['lookback'] = 252
    settings['beginInSample'] = '20140101'
    settings['endInSample'] = '20170101'

    return settings


# Evaluate trading system defined in current file.
if __name__ == '__main__':
    from quantiacsToolbox import runts

    np.random.seed(98274534)

    results = runts(__file__)
Exemplo n.º 6
0
    settings['n_sharpe'] = 252  # This many timesteps to compute Sharpes.
    settings['horizon'] = settings['n_time'] - settings['n_sharpe'] + 1
    settings['num_epochs'] = 100  # Number of epochs each day.
    settings['batch_size'] = 32
    settings['val_period'] = 16
    settings['lr'] = 1e-2  # Learning rate.
    settings['iter'] = 0
    settings['lookback'] = 1000
    settings['budget'] = 10**6
    settings['slippage'] = 0.05
    settings['beginInSample'] = '20010104'
    settings['endInSample'] = '20131231'
    settings['retrain_interval'] = 1000
    settings['allow_shorting'] = True
    settings['lr_mult_base'] = 1.
    settings['restart_variables'] = True
    settings['nn'] = None
    settings['data_types'] = [1, 4]
    settings['markets'] = ['AAPL', 'GOOG', 'MMM', 'CASH']
    settings['past_data'] = training.make_empty_datadict(settings['markets'])
    return settings


if __name__ == '__main__':
    import quantiacsToolbox
    RESULTS = quantiacsToolbox.runts(__file__)

    print RESULTS['stats']
    RESULTS['nn'] = None
    joblib.dump(RESULTS, 'saved_data/results_of_this_run.pkl')
Exemplo n.º 7
0
            'F_RR', 'F_RU', 'F_RY', 'F_S', 'F_SB', 'F_SF', 'F_SH', 'F_SI',
            'F_SM', 'F_SS', 'F_SX', 'F_TR', 'F_TU', 'F_TY', 'F_UB', 'F_US',
            'F_UZ', 'F_VF', 'F_VT', 'F_VW', 'F_VX', 'F_W', 'F_XX', 'F_YM',
            'F_ZQ'
        ]

    settings['beginInSample'] = '2011101'
    settings['endInSample'] = '20200101'
    settings['lookback'] = 200
    settings['budget'] = 10**6
    settings['slippage'] = 0.05
    settings['participation'] = 0.1

    settings['days_passed'] = 0
    settings['spy_under_short_sma'] = 0
    settings['spy_over_short_sma'] = 0
    settings['logUrl'] = True

    return settings


# Evaluate trading system defined in current file.
if __name__ == '__main__':
    import quantiacsToolbox

    parser = argparse.ArgumentParser(description='Run strategy backtrace.')

    args = parser.parse_args()

    results = quantiacsToolbox.runts(__file__)
Exemplo n.º 8
0
    settings = {}

    # Futures Contracts
    settings['markets'] = [
        'CASH', 'F_AD', 'F_AE', 'F_AH', 'F_AX', 'F_BC', 'F_BG', 'F_BO', 'F_BP',
        'F_C', 'F_CA', 'F_CC', 'F_CD', 'F_CF', 'F_CL', 'F_CT', 'F_DL', 'F_DM',
        'F_DT', 'F_DX', 'F_DZ', 'F_EB', 'F_EC', 'F_ED', 'F_ES', 'F_F', 'F_FB',
        'F_FC', 'F_FL', 'F_FM', 'F_FP', 'F_FV', 'F_FY', 'F_GC', 'F_GD', 'F_GS',
        'F_GX', 'F_HG', 'F_HO', 'F_HP', 'F_JY', 'F_KC', 'F_LB', 'F_LC', 'F_LN',
        'F_LQ', 'F_LR', 'F_LU', 'F_LX', 'F_MD', 'F_MP', 'F_ND', 'F_NG', 'F_NQ',
        'F_NR', 'F_NY', 'F_O', 'F_OJ', 'F_PA', 'F_PL', 'F_PQ', 'F_RB', 'F_RF',
        'F_RP', 'F_RR', 'F_RU', 'F_RY', 'F_S', 'F_SB', 'F_SF', 'F_SH', 'F_SI',
        'F_SM', 'F_SS', 'F_SX', 'F_TR', 'F_TU', 'F_TY', 'F_UB', 'F_US', 'F_UZ',
        'F_VF', 'F_VT', 'F_VW', 'F_VX', 'F_W', 'F_XX', 'F_YM', 'F_ZQ'
    ]

    settings['lookback'] = 252
    settings['budget'] = 10**6
    settings['slippage'] = 0.05

    settings['gap'] = 20
    settings['dimension'] = 5

    return settings


if __name__ == '__main__':
    import quantiacsToolbox

    quantiacsToolbox.runts(__file__)
Exemplo n.º 9
0
def sim(plan):
  returnDict = quantiacsToolbox.runts(sys.argv[1], plotEquity=False, plan=plan)
  return returnDict['stats']['sharpe']
Exemplo n.º 10
0
import numpy as np
from scipy.signal import lfilter

def mySettings():
    settings = {}
    settings['markets'] = ['CASH', 'F_AD', 'F_BO', 'F_BP', 'F_C', 'F_CC', 'F_CD',
                           'F_CL', 'F_CT', 'F_DX', 'F_EC', 'F_ED', 'F_ES', 'F_FC', 'F_FV', 'F_GC',
                           'F_HG', 'F_HO', 'F_JY', 'F_KC', 'F_LB', 'F_LC', 'F_LN', 'F_MD', 'F_MP',
                           'F_NG', 'F_NQ', 'F_NR', 'F_O', 'F_OJ', 'F_PA', 'F_PL', 'F_RB', 'F_RU',
                           'F_S', 'F_SB', 'F_SF', 'F_SI', 'F_SM', 'F_TU', 'F_TY', 'F_US', 'F_W',
                           'F_XX', 'F_YM']
    settings['slippage'] = 0.05
    settings['budget'] = 1000000
    settings['beginInSample'] = '20050101'
    settings['endInSample'] = '20121231'
    settings['lookback'] = 504
    return settings

def myTradingSystem(DATE, OPEN, HIGH, LOW, CLOSE, settings):
    period1 = 504
    rsi1 = RSI(CLOSE, period1)
    p = rsi1 - 50
    return p, settings

def RSI(CLOSE,period):
    closeMom = CLOSE[1:, :] - CLOSE[:-1, :]
    upPosition = np.where(closeMom >= 0)
    downPosition = np.where(closeMom < 0)
    upMoves = closeMom.copy()
    upMoves[downPosition] = 0
Exemplo n.º 11
0
import quantiacsToolbox

returnDict = quantiacsToolbox.runts("strats/s102.py")
Exemplo n.º 12
0
    '''
    a_new = a_old - lr * grad(F(a_old))
    
    {\displaystyle \mathbf {a} _{n+1}=\mathbf {a} _{n}-\gamma \nabla F(\mathbf {a} _{n})}
    '''
    i = 0
    j_org = 2 * w_1 + 4 * (w_2 * w_2 * w_2)
    while (True):
        w_1_new = w_1 - lr * (2 * w_1)
        w_2_new = w_2 - lr * (w_2 * w_2 * w_2)
        delta = (w_1_new - w_1) * (w_1_new - w_1) + (w_2_new -
                                                     w_2) * (w_2_new - w_2)
        delta = math.sqrt(delta)
        i += 1
        print('iteration: ' + str(i) + ' delta: ' + str(delta))

        if delta < success:
            break

        if i > 1000000:
            break

        w_1 = w_1_new
        w_2 = w_2_new

    sys.exit(0)

    from quantiacsToolbox import runts

    runts()
Exemplo n.º 13
0
        return overall_pos, settings

    def mySettings(self):
        return settings


    
if __name__ == '__main__':
    settings = mainSettings()
    nMarkets = len(settings['markets'])
    macd_indicator = np.zeros(nMarkets)
    rsi_indicator = np.zeros(nMarkets)
    bb_indicator = np.zeros(nMarkets)

    res_MACD = quantiacsToolbox.runts(MACD_strat, plotEquity = False)
    mktEquity_MACD = np.array(res_MACD['marketEquity'])

    res_RSI = quantiacsToolbox.runts(RSI_strat, plotEquity = False)
    mktEquity_RSI = np.array(res_RSI['marketEquity'])

    res_BB = quantiacsToolbox.runts(BB_strat, plotEquity = False)
    mktEquity_BB = np.array(res_BB['marketEquity'])

    for i in range(1, nMarkets):
        try:
            stat_MACD = quantiacsToolbox.stats(mktEquity_MACD[-56:, i])
            if stat_MACD['sharpe'] > 0:
                macd_indicator[i] = 1

            stat_RSI = quantiacsToolbox.stats(mktEquity_RSI[-56:, i])
Exemplo n.º 14
0
    import numpy as np

    Long = np.transpose(mktExposure)
    Long[Long < 0] = 0

    Long = Long[:-1]  # Market Exposure lagged by one day
    Long = Long.sum(axis=0)
    return Long


def CalcShortExposure(mktExposure, lookBack):
    import numpy as np

    Short = -np.transpose(mktExposure)
    Short[Short < 0] = 0

    Short = Short[:-1]  # Market Exposure lagged by one day
    Short = Short.sum(axis=0)
    return Short


# Evaluate trading system defined in current file.
if __name__ == '__main__':
    from quantiacsToolbox import runts, optimize

    #optimize()
    res = runts(reloadData=False)
    l1 = CalcLongExposure(res['marketExposure'], 0)
    s1 = CalcShortExposure(res['marketExposure'], 0)

    sys.exit(0)
    closeRange = np.ptp(CLOSE[-4:,1])
    atr = ATR(HIGH, LOW, CLOSE, 4)

    LongRule1 = CLOSE[-1,1] < CLOSE[-2,1] and  closeRange < atr[1]
    ShortRule1 = CLOSE[-1,1] > CLOSE[-2,1] and  closeRange < atr[1]

    if LongRule1:
        p[0], p[1] = 0, 1

    if ShortRule1:
        p[0], p[1] = 0, -1

    return p, settings


def mySettings():
    settings = {}
    settings['markets']     = ['CASH','F_CL']
    settings['slippage']    = 0.0
    settings['budget']      = 1000000
    settings['beginInSample'] = '20040101'
    settings['endInSample']   = '20140101'
    settings['lookback']    = 504

    return settings

if __name__=='__main__':
    import quantiacsToolbox
    results = quantiacsToolbox.runts(__file__)
Exemplo n.º 16
0
        longEquity = smaRecent > smaLong
        shortEquity = ~longEquity

        pos = numpy.zeros((1, nMarkets))

        pos[0, longEquity] = 1
        pos[0, shortEquity] = -1

        weights = pos / numpy.nansum(abs(pos))

        return weights, settings

    def mySettings(self):
        """
        Return settings dictionary
        """
        return self.settings_ts


# For testing this strategy as standalone, and when testing best parameters
# resulted from optimisation
if __name__ == '__main__':

    import quantiacsToolbox

    # Instantiate trading system
    strategy = TS()

    # Run backtest
    results = quantiacsToolbox.runts(strategy)
def mySettings():
    """ Define your trading system settings here """

    settings = {}

    # Futures Contracts
    settings['markets'] = ['CASH', 'F_AD', 'F_AE', 'F_AH', 'F_AX', 'F_BC', 'F_BG', 'F_BO', 'F_BP', 'F_C',  'F_CA',
                           'F_CC', 'F_CD', 'F_CF', 'F_CL', 'F_CT', 'F_DL', 'F_DM', 'F_DT', 'F_DX', 'F_DZ', 'F_EB',
                           'F_EC', 'F_ED', 'F_ES', 'F_F',  'F_FB', 'F_FC', 'F_FL', 'F_FM', 'F_FP', 'F_FV', 'F_FY',
                           'F_GC', 'F_GD', 'F_GS', 'F_GX', 'F_HG', 'F_HO', 'F_HP', 'F_JY', 'F_KC', 'F_LB', 'F_LC',
                           'F_LN', 'F_LQ', 'F_LR', 'F_LU', 'F_LX', 'F_MD', 'F_MP', 'F_ND', 'F_NG', 'F_NQ', 'F_NR',
                           'F_NY', 'F_O',  'F_OJ', 'F_PA', 'F_PL', 'F_PQ', 'F_RB', 'F_RF', 'F_RP', 'F_RR', 'F_RU',
                           'F_RY', 'F_S',  'F_SB', 'F_SF', 'F_SH', 'F_SI', 'F_SM', 'F_SS', 'F_SX', 'F_TR', 'F_TU',
                           'F_TY', 'F_UB', 'F_US', 'F_UZ', 'F_VF', 'F_VT', 'F_VW', 'F_VX',  'F_W', 'F_XX', 'F_YM',
                           'F_ZQ']

    settings['lookback'] = 252
    settings['budget'] = 10 ** 6
    settings['slippage'] = 0.05

    settings['gap'] = 20
    settings['dimension'] = 5

    return settings


if __name__ == '__main__':
    import quantiacsToolbox

    quantiacsToolbox.runts(__file__)
import numpy as np
from scipy.signal import lfilter

def mySettings():
    settings = {}
    settings['markets'] = ['CASH', 'AAPL', 'AMZN', 'GOOGL', 'GS', 'JPM', 'MS', \
                           'MSFT', 'T']
    #settings['markets']     = ['CASH', 'F_AD', 'F_BO', 'F_BP', 'F_C', 'F_CC', 'F_CD', 'F_CL', 'F_CT', 'F_DX', 'F_EC', 'F_ED', 'F_ES', 'F_FC', 'F_FV', 'F_GC', 'F_HG', 'F_HO', 'F_JY', 'F_KC', 'F_LB', 'F_LC', 'F_LN', 'F_MD', 'F_MP', 'F_NG', 'F_NQ', 'F_NR', 'F_O', 'F_OJ', 'F_PA', 'F_PL', 'F_RB', 'F_RU', 'F_S', 'F_SB', 'F_SF', 'F_SI', 'F_SM', 'F_TU', 'F_TY', 'F_US', 'F_W', 'F_XX', 'F_YM']
    settings['slippage'] = 0.15
    settings['budget'] = 3000000
    settings['beginInSample'] = '20150102'
    settings['endInSample'] = '20170531'
    settings['lookback'] = 504
    return settings

def myTradingSystem(DATE, OPEN, HIGH, LOW, CLOSE, settings):
    period1 = 504
    rsi1 = RSI(CLOSE, period1)
    p = rsi1 - 50
    return p, settings

def RSI(CLOSE, period):
    closeMom = CLOSE[1:, :] - CLOSE[:-1, :]
    upPosition = np.where(closeMom >= 0)
    downPosition = np.where(closeMom < 0)
    upMoves = closeMom.copy()
    upMoves[downPosition] = 0
    #print upMoves[upPosition] + "\n"
    downMoves = np.abs(closeMom.copy())
    downMoves[upPosition] = 0
Exemplo n.º 19
0
def mySettings():

    settings['markets'] = [
        'CASH', 'AAPL', 'ABBV', 'ABT', 'ACN', 'AEP', 'AIG', 'ALL', 'AMGN',
        'AMZN', 'APA', 'APC', 'AXP', 'BA', 'BAC', 'BAX', 'BK', 'BMY', 'BRKB',
        'C', 'CAT', 'CL', 'CMCSA', 'COF', 'COP', 'COST', 'CSCO', 'CVS', 'CVX',
        'DD', 'DIS', 'DOW', 'DVN', 'EBAY', 'EMC', 'EMR', 'EXC', 'F', 'FB',
        'FCX', 'FDX', 'FOXA', 'GD', 'GE', 'GILD', 'GM', 'GOOGL', 'GS', 'HAL',
        'HD', 'HON', 'HPQ', 'IBM', 'INTC', 'JNJ', 'JPM', 'KO', 'LLY', 'LMT',
        'LOW', 'MA', 'MCD', 'MDLZ', 'MDT', 'MET', 'MMM', 'MO', 'MON', 'MRK',
        'MS', 'MSFT', 'NKE', 'NOV', 'NSC', 'ORCL', 'OXY', 'PEP', 'PFE', 'PG',
        'PM', 'QCOM', 'RTN', 'SBUX', 'SLB', 'SO', 'SPG', 'T', 'TGT', 'TWX',
        'TXN', 'UNH', 'UNP', 'UPS', 'USB', 'UTX', 'V', 'VZ', 'WAG', 'WFC',
        'WMT', 'XOM'
    ]

    settings['beginInSample'] = '20170101'
    settings['endInSample'] = '20200101'
    settings['lookback'] = 300
    settings['budget'] = 10**6
    settings['slippage'] = 0.05

    return settings


if __name__ == "__main__":
    import quantiacsToolbox
    results = quantiacsToolbox.runts(
        '/Users/rostammahabadi/Documents/Projects/TrendfollowingQuantiacs.py')
Exemplo n.º 20
0
import quantiacsToolbox
returnDict = quantiacsToolbox.runts('strats/s100.py')
Exemplo n.º 21
0
    # 'DVN','EBAY','EMC','EMR','EXC','F','FB','FCX','FDX','FOXA','GD','GE',
    # 'GILD','GM','GOOGL','GS','HAL','HD','HON','HPQ','IBM','INTC','JNJ','JPM',
    # 'KO','LLY','LMT','LOW','MA','MCD','MDLZ','MDT','MET','MMM','MO','MON',
    # 'MRK','MS','MSFT','NKE','NOV','NSC','ORCL','OXY','PEP','PFE','PG','PM',
    # 'QCOM','RTN','SBUX','SLB','SO','SPG','T','TGT','TWX','TXN','UNH','UNP',
    # 'UPS','USB','UTX','V','VZ','WAG','WFC','WMT','XOM']

    # Futures Contracts

    settings['markets'] = [
        'CASH', 'F_AD', 'F_BO', 'F_BP', 'F_C', 'F_CC', 'F_CD', 'F_CL', 'F_CT',
        'F_DX', 'F_EC', 'F_ED', 'F_ES', 'F_FC', 'F_FV', 'F_GC', 'F_HG', 'F_HO',
        'F_JY', 'F_KC', 'F_LB', 'F_LC', 'F_LN', 'F_MD', 'F_MP', 'F_NG', 'F_NQ',
        'F_NR', 'F_O', 'F_OJ', 'F_PA', 'F_PL', 'F_RB', 'F_RU', 'F_S', 'F_SB',
        'F_SF', 'F_SI', 'F_SM', 'F_TU', 'F_TY', 'F_US', 'F_W', 'F_XX', 'F_YM'
    ]
    settings['beginInSample'] = '20120506'  #start date
    settings['endInSample'] = '20190410'  #end date
    settings['lookback'] = 504  #how many data points prior to last n days
    settings['budget'] = 10**6  #$1M budget
    settings[
        'slippage'] = 0.05  #brokerage commisions, market slippage, inflation, etc.

    return settings


# Evaluate trading system defined in current file.
if __name__ == '__main__':
    import quantiacsToolbox
    results = quantiacsToolbox.runts('trendFollowing.py')
import numpy as np
from scipy.signal import lfilter

def mySettings():
    settings={}
    settings['markets']     = ['CASH', 'F_AD', 'F_BO', 'F_BP', 'F_C', 'F_CC', 'F_CD', 'F_CL', 'F_CT', 'F_DX', 'F_EC', 'F_ED', 'F_ES', 'F_FC', 'F_FV', 'F_GC', 'F_HG', 'F_HO', 'F_JY', 'F_KC', 'F_LB', 'F_LC', 'F_LN', 'F_MD', 'F_MP', 'F_NG', 'F_NQ', 'F_NR', 'F_O', 'F_OJ', 'F_PA', 'F_PL', 'F_RB', 'F_RU', 'F_S', 'F_SB', 'F_SF', 'F_SI', 'F_SM', 'F_TU', 'F_TY', 'F_US', 'F_W', 'F_XX', 'F_YM']
    settings['slippage']    = 0.05
    settings['budget']      = 1000000
    # settings['beginInSample'] = '20050101'
    settings['endInSample']   = '20121231'
    settings['lookback']    = 504
    return settings

def myTradingSystem(DATE, OPEN, HIGH, LOW, CLOSE, settings):
    period1 = 504
    rsi1 = RSI(CLOSE,period1)
    p = rsi1 -50

    return p, settings

def RSI(CLOSE,period):
    closeMom = CLOSE[1:,:] - CLOSE[:-1,:]
    upPosition   = np.where(closeMom >= 0)
    downPosition  = np.where(closeMom < 0)
    upMoves = closeMom.copy()
    upMoves[downPosition]  = 0
    downMoves = np.abs(closeMom.copy())
    downMoves[upPosition] = 0
    out = 100 - 100 / (1 + (np.mean(upMoves[-(period+1):,:],axis=0) / np.mean(downMoves[-(period+1):,:],axis=0)))
    return out
def nDayEMA(field, period):
    # 'AMGN','AMZN','APA','APC','AXP','BA','BAC','BAX','BK','BMY','BRKB','C',
    # 'CAT','CL','CMCSA','COF','COP','COST','CSCO','CVS','CVX','DD','DIS','DOW',
    # 'DVN','EBAY','EMC','EMR','EXC','F','FB','FCX','FDX','FOXA','GD','GE',
    # 'GILD','GM','GOOGL','GS','HAL','HD','HON','HPQ','IBM','INTC','JNJ','JPM',
    # 'KO','LLY','LMT','LOW','MA','MCD','MDLZ','MDT','MET','MMM','MO','MON',
    # 'MRK','MS','MSFT','NKE','NOV','NSC','ORCL','OXY','PEP','PFE','PG','PM',
    # 'QCOM','RTN','SBUX','SLB','SO','SPG','T','TGT','TWX','TXN','UNH','UNP',
    # 'UPS','USB','UTX','V','VZ','WAG','WFC','WMT','XOM']

    # Futures Contracts
    settings['markets'] = ['CASH', 'F_AD', 'F_AE', 'F_AH', 'F_AX', 'F_BC', 'F_BG', 'F_BO', 'F_BP', 'F_C',  'F_CA',
                           'F_CC', 'F_CD', 'F_CF', 'F_CL', 'F_CT', 'F_DL', 'F_DM', 'F_DT', 'F_DX', 'F_DZ', 'F_EB',
                           'F_EC', 'F_ED', 'F_ES', 'F_F',  'F_FB', 'F_FC', 'F_FL', 'F_FM', 'F_FP', 'F_FV', 'F_FY',
                           'F_GC', 'F_GD', 'F_GS', 'F_GX', 'F_HG', 'F_HO', 'F_HP', 'F_JY', 'F_KC', 'F_LB', 'F_LC',
                           'F_LN', 'F_LQ', 'F_LR', 'F_LU', 'F_LX', 'F_MD', 'F_MP', 'F_ND', 'F_NG', 'F_NQ', 'F_NR',
                           'F_NY', 'F_O',  'F_OJ', 'F_PA', 'F_PL', 'F_PQ', 'F_RB', 'F_RF', 'F_RP', 'F_RR', 'F_RU',
                           'F_RY', 'F_S',  'F_SB', 'F_SF', 'F_SH', 'F_SI', 'F_SM', 'F_SS', 'F_SX', 'F_TR', 'F_TU',
                           'F_TY', 'F_UB', 'F_US', 'F_UZ', 'F_VF', 'F_VT', 'F_VW', 'F_VX',  'F_W', 'F_XX', 'F_YM',
                           'F_ZQ']

    settings['lookback'] = 504
    settings['budget'] = 10**6
    settings['slippage'] = 0.05

    return settings

# Evaluate trading system defined in current file.
if __name__ == '__main__':
    from quantiacsToolbox import runts
    results = runts(__file__)
Exemplo n.º 24
0
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 28 17:56:04 2015

@author: yuy
"""

import quantiacsToolbox

returnDict = quantiacsToolbox.runts('H:\training materials\QuantiacsPythonToolbox_v222\pythonToolbox\sampleTradingSystems\meanReversion.py')

quantiacsToolbox.runts 


returnDict['tsName']	#a string that contains the name of your trading system
returnDict['fundDate']	#a list of the dates available to your trading system
returnDict['fundTradeDates']	#a list of the  dates traded by your trading system
returnDict['fundEquity']	#a list defining the equity of your portfolio
returnDict['marketEquity']	#a list containing the equity made from each market in settings[‘markets’]
returnDict['marketExposure']	#a list containing the allocation of capital to each market in settings[‘markets’]
returnDict['errorLog']	#a list describing any errors made in evaluation
returnDict['runtime']	#a float containing the time required to evaluate your system.
returnDict['evalDate']	#an int that describes the last date of evaluation for your system (in YYYYMMDD format)
returnDict['stats']	#a dict containing the performance statistics of your system 
returnDict['settings']	#a dict containting the settings defined in mySettings