def init_refreshed_stock_with_indicators(): stock = Stock(TEST_STOCK) stock.refresh(to_date = TEST_REFRESH_DATE_WITH_INDICATORS) Indicator('SMA80', partial(SMA.execute, window = 80)) Indicator('SMA150', partial(SMA.execute, window = 150)) stock.add_indicator('SMA80') stock.add_indicator('SMA150') os.rename(SAVE_FOLDER + stock.path, TEST_FOLDER + 'refreshed_stock_with_indicators.p')
def init_stock_with_indicators(): stock = Stock(TEST_STOCK) stock.refresh(to_date = TEST_REFRESH_DATE_NOT_EMPTY) indicator = Indicator('SMA80', partial(SMA.execute, window = 80)) Indicator('SMA150', partial(SMA.execute, window = 150)) stock.add_indicator('SMA80') stock.add_indicator('SMA150') os.rename(SAVE_FOLDER + stock.path, TEST_FOLDER + 'stock_with_indicators.p') os.rename(SAVE_FOLDER + indicator.path, TEST_FOLDER + 'applied_indicator.p')
def init_strategy_pass(): stock = Stock(TEST_PASS_TRADE_STOCK) stock.refresh(to_date = TEST_REFRESH_DATE_PASS) Indicator('SMA80', partial(SMA.execute, window = 80)) Indicator('SMA150', partial(SMA.execute, window = 150)) stock.add_indicator('SMA80') stock.add_indicator('SMA150') strategy = Strategy('SMA80_SMA150', test_buy_condition, test_sell_condition) strategy.refresh([stock]) os.rename(SAVE_FOLDER + strategy.path, TEST_FOLDER + 'strategy_pass.p')
def init_strategy_awaiting_sell_before(): stock = Stock(TEST_AWAITING_TRADE_STOCK) stock.refresh(to_date = TEST_REFRESH_DATE_AWAITING_SELL_1) Indicator('SMA80', partial(SMA.execute, window = 80)) Indicator('SMA150', partial(SMA.execute, window = 150)) stock.add_indicator('SMA80') stock.add_indicator('SMA150') strategy = Strategy('SMA80_SMA150', test_buy_condition, test_sell_condition) strategy.refresh([stock]) os.rename(SAVE_FOLDER + strategy.path, TEST_FOLDER + 'strategy_awaiting_sell_before.p')
def init_applied_strategy(): stock = Stock(TEST_STOCK) stock.refresh(to_date = TEST_REFRESH_DATE_WITH_INDICATORS) Indicator('SMA80', partial(SMA.execute, window = 80)) Indicator('SMA150', partial(SMA.execute, window = 150)) stock.add_indicator('SMA80') stock.add_indicator('SMA150') strategy = Strategy('SMA80_SMA150', test_buy_condition, test_sell_condition) strategy.refresh([stock]) os.rename(SAVE_FOLDER + strategy.path, TEST_FOLDER + 'applied_strategy.p') os.rename(SAVE_FOLDER + stock.path, TEST_FOLDER + 'stock_with_applied_strategy.p')
def init_strategy(): SMA = Function('SMA', SMA_) PER_K = Function('PER_K', PER_K_) Indicator('PER_K', partial(PER_K.execute, window = 10, roll = 1)) Indicator('PER_D', partial(PER_K.execute, window = 10, roll = 3)) Indicator('SMA80', partial(SMA.execute, window = 80)) Indicator('SMA150', partial(SMA.execute, window = 150)) add_indicator('SMA80') add_indicator('SMA150') add_indicator('PER_K') add_indicator('PER_D') Strategy('SMA80_SMA150_STOCHASTICS', buy_condition, sell_condition) print('Strategy SMA80_SMA150_STOCHASTICS successfully created.')
def init_empty_indicator(): indicator = Indicator('SMA80', partial(SMA.execute, window = 80)) os.rename(SAVE_FOLDER + indicator.path, TEST_FOLDER + 'empty_indicator.p')
def indicator_creation(): test = Indicator('SMA80', partial(SMA.execute, window=80)) Indicator('SMA150', partial(SMA.execute, window=150)) compare(test, EMPTY_INDICATOR, "Indicator creation")