Ejemplo n.º 1
0
def test(year, stock):
    filename = "../Historical Data/%s/%s-%s.csv" % (year, stock, year)
    prices = pd.read_csv(filename)["Close"]
    dates = pd.read_csv(filename)["Date"]

    agent = CCI_Agent(25, 0.015, 0.015)

    test = Backtest(agent, 10000)

    output = test.run(prices)

    # class Evaluation takes for initialization - prices, output, name of algorithm, name of security
    evaluator = Evaluation(prices, dates, output, "CCI", stock)
    evaluator.complete_evaluation()
Ejemplo n.º 2
0
def test(year, stock, window=150, up=0.05, down=0.05):
    filename = "../Historical Data/%s/%s-%s.csv" % (year, stock, year)
    prices = pd.read_csv(filename)["Close"]
    dates = pd.read_csv(filename)["Date"]
    '''
	Parameters for the Moving Momentum algorithm:
	1. Small SMA (default 20)
	2. Large SMA (default 150)
	3. Stochastic oscillator sensitivity (default 14)
	4. Stochastic oscillator oversold threshold (default below 20)
	5. Stochastic oscillator overbought threshold (default above 80)
	6. Small EMA (default 12)
	7. Large EMA (default 26)
	8. Signal Line (default 9)
	'''

    agent = Momentum_Agent(150, 20, 150, 14, 20, 80, 12, 26, 9)

    test = Backtest(agent, 10000)

    output = test.run(prices)

    # class Evaluation takes for initialization - prices, output, name of algorithm, name of security
    evaluator = Evaluation(prices, dates, output, "Moving Momentum", stock)
    return evaluator.complete_evaluation()
Ejemplo n.º 3
0
def test(year, stock, window, up, down, get_plots=True, verbose=True):
	filename = "../Historical Data/%s/%s-%s.csv" %(year, stock, year)
	prices = pd.read_csv(filename)["Close"]
	dates = pd.read_csv(filename)["Date"]

	agent = SMA_Agent(window, up, down)

	test = Backtest(agent, 10000)

	output = test.run(prices)

	# class Evaluation takes for initialization - prices, output, name of algorithm, name of security
	evaluator = Evaluation(prices, dates, output, "SMA", stock)
	return evaluator.complete_evaluation(get_plots, verbose)
Ejemplo n.º 4
0
def test(year, stock, window=10, up=0.05, down = 0.05):
	filename = "../Historical Data/%s/%s-%s.csv" %(year, stock, year)
	prices = pd.read_csv(filename)["Close"]
	dates = pd.read_csv(filename)["Date"]

	'''
	Parameters for the Six month cycle MACD:
	1. Small EMA (default 12)
	2. Large EMA (default 26)
	3. Signal Line (default 9)
	'''

	agent = SixMonthCycle_Agent(26, 12, 26, 9, 0.015, 0.015)

	test = Backtest(agent, 10000)

	output = test.run(prices, dates)

	# class Evaluation takes for initialization - prices, output, name of algorithm, name of security
	evaluator = Evaluation(prices, dates, output, "Six Month Cycle MACD", stock)
	return evaluator.complete_evaluation()
Ejemplo n.º 5
0
def test(year,
         stock,
         window=10,
         up=0.05,
         down=0.05,
         get_plots=True,
         verbose=True):
    quandl.ApiConfig.api_key = "FDEDsMbK1E2t_PMf7X3M"
    df = quandl.get('NSE/ZEEL', start_date='2017-01-01', end_date='2017-12-31')
    prices = df["Close"]
    dates = df["Date"]

    agent = EMA_Agent(window, up, down)

    test = Backtest(agent, 10000)

    output = test.run(prices)

    # class Evaluation takes for initialization - prices, output, name of algorithm, name of security

    evaluator = Evaluation(prices, dates, output, "EMA", stock)
    return evaluator.complete_evaluation(get_plots, verbose)