def plotPriceAndBeLong(issue, modelStartDate, modelEndDate, valData): from Code.lib.plot_utils import PlotUtility plotIt = PlotUtility() plotTitle = "Close " + str(modelStartDate) + " to " + str(modelEndDate) plotIt.plot_v2x(valData, plotTitle) plt.show(block=False) plotIt.histogram(valData['beLong'], x_label="beLong signal", y_label="Frequency", title = "beLong distribution for " + issue) plt.show(block=False)
@author: kruegkj time_test_modelling.py Goal: Test and verify in sample and out of sample time splits for dataset """ from Code.lib.plot_utils import PlotUtility from Code.lib.time_utils import TimeUtility from Code.lib.retrieve_data import DataRetrieve, ComputeTarget from Code.utilities.stat_tests import stationarity_tests, mean_and_variance import datetime from dateutil.relativedelta import relativedelta from pandas.tseries.offsets import BDay if __name__ == "__main__": plotIt = PlotUtility() timeUtil = TimeUtility() dSet = DataRetrieve() ct = ComputeTarget() doPlot = False issue = "tlt" pivotDate = datetime.date(2018, 4, 2) is_oos_ratio = 2 oos_months = 3 segments = 3 # get segmented dates isOosDates = timeUtil.is_oos_data_split(issue, pivotDate, is_oos_ratio, oos_months, segments) dataLoadStartDate = isOosDates[0]
# Import custom libraries from Code.lib.plot_utils import PlotUtility from Code.lib.time_utils import TimeUtility from Code.lib.retrieve_data import DataRetrieve, ComputeTarget from Code.lib.retrieve_system_info import TradingSystemUtility from Code.lib.candle_indicators import CandleIndicators from Code.lib.transformers import Transformers from Code.lib.ta_momentum_studies import TALibMomentumStudies from Code.lib.model_utils import ModelUtility, TimeSeriesSplitImproved from Code.lib.feature_generator import FeatureGenerator from Code.lib.config import current_feature, feature_dict from Code.models import models_utils from Code.lib.model_algos import AlgoUtility from Code.lib.tms_utils import TradeRisk plotIt = PlotUtility() timeUtil = TimeUtility() ct = ComputeTarget() candle_ind = CandleIndicators() dSet = DataRetrieve() taLibMomSt = TALibMomentumStudies() transf = Transformers() modelUtil = ModelUtility() featureGen = FeatureGenerator() dSet = DataRetrieve() modelAlgo = AlgoUtility() sysUtil = TradingSystemUtility() tradeRisk = TradeRisk() if __name__ == '__main__':
UO signal feature_dict """ col_name = 'ROC_' + str(period) current_feature['Latest'] = col_name feature_dict[col_name] = 'Keep' df[col_name] = ta.ROC(df.Close, period) return df if __name__ == "__main__": from Code.lib.plot_utils import PlotUtility from Code.lib.retrieve_data import DataRetrieve plotIt = PlotUtility() taLibMomSt = TALibMomentumStudies() dSet = DataRetrieve() issue = "TLT" df = dSet.read_issue_data(issue) lastRow = df.shape[0] dataLoadEndDate = df.Date[lastRow - 100] pprint(dataLoadEndDate) dataLoadStartDate = df.Date[lastRow - 3000] pprint(dataLoadStartDate) dataSet = dSet.set_date_range(df, dataLoadStartDate, dataLoadEndDate) pprint(dataSet.tail(10))
from sklearn.model_selection import TimeSeriesSplit import matplotlib.pylab as plt from pandas.tseries.offsets import BDay import os.path import pickle #from pandas.tseries.holiday import USFederalHolidayCalendar #from pandas.tseries.offsets import CustomBusinessDay #us_cal = CustomBusinessDay(calendar=USFederalHolidayCalendar()) from sklearn.model_selection import StratifiedShuffleSplit from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier from sklearn.neighbors import KNeighborsClassifier from sklearn import svm if __name__ == "__main__": plotIt = PlotUtility() timeUtil = TimeUtility() ct = ComputeTarget() candle_ind = CandleIndicators() dSet = DataRetrieve() taLibMomSt = TALibMomentumStudies() transf = Transformers() modelUtil = ModelUtility() featureGen = FeatureGenerator() issue = "TLT" # Set IS-OOS parameters pivotDate = datetime.date(2019, 1, 3) is_oos_ratio = 2 oos_months = 4 segments = 4
from Code.lib.plot_utils import PlotUtility #from Code.lib.time_utils import TimeUtility from Code.lib.retrieve_data import DataRetrieve from Code.lib.retrieve_system_info import TradingSystemUtility #from Code.lib.candle_indicators import CandleIndicators #from Code.lib.transformers import Transformers #from Code.lib.ta_momentum_studies import TALibMomentumStudies #from Code.lib.model_utils import ModelUtility, TimeSeriesSplitImproved #from Code.lib.feature_generator import FeatureGenerator #from Code.utilities.stat_tests import stationarity_tests #from Code.lib.config import current_feature, feature_dict #from Code.models import models_utils #from Code.lib.model_algos import AlgoUtility from Code.lib.tms_utils import TradeRisk plotIt = PlotUtility() #timeUtil = TimeUtility() #ct = ComputeTarget() #taLibMomSt = TALibMomentumStudies() #transf = Transformers() #modelUtil = ModelUtility() #featureGen = FeatureGenerator() dSet = DataRetrieve() #modelAlgo = AlgoUtility() sysUtil = TradingSystemUtility() tradeRisk = TradeRisk() if __name__ == '__main__': # set to existing system name OR set to blank if creating new if len(sys.argv) < 2:
indices[test_start:test_start + test_size]) else: for test_start in test_starts: yield (indices[:test_start], indices[test_start:test_start + test_size]) if __name__ == "__main__": from Code.lib.plot_utils import PlotUtility from Code.lib.retrieve_data import DataRetrieve, ComputeTarget from Code.lib.time_utils import TimeUtility from Code.lib.feature_generator import FeatureGenerator from Code.utilities.stat_tests import stationarity_tests # from Code.lib.config import current_feature, feature_dict plotIt = PlotUtility() ct = ComputeTarget() dSet = DataRetrieve() featureGen = FeatureGenerator() timeUtil = TimeUtility() modelUtil = ModelUtility() #timeSeriesImp = TimeSeriesSplitImproved() dataLoadStartDate = "2014-09-26" dataLoadEndDate = "2018-04-05" issue = "TLT" # Set IS-OOS parameters pivotDate = datetime.date(2018, 4, 2) is_oos_ratio = 2 oos_months = 4 segments = 4