Commit 6d823536 authored by wenwen.tang's avatar wenwen.tang 😕

npe bugfix

parent e96fb03c
...@@ -4,12 +4,13 @@ from py_jftech import autowired ...@@ -4,12 +4,13 @@ from py_jftech import autowired
from ai.data_access import DataAccess from ai.data_access import DataAccess
from ai.model_trainer import ModelTrainer from ai.model_trainer import ModelTrainer
from ai.noticer import upload_predict
from ai.training_data_builder import TrainingDataBuilder from ai.training_data_builder import TrainingDataBuilder
from api import DataSync from api import DataSync
# 截止日期 # 截止日期
# max_date = None max_date = None
max_date = '2023-11-24' # max_date = '2023-12-01'
# 待预测指数 # 待预测指数
# PREDICT_LIST = [67] # PREDICT_LIST = [67]
...@@ -33,7 +34,8 @@ def predictionFromMoel(the_model, scaledX_forecast, predict_item): ...@@ -33,7 +34,8 @@ def predictionFromMoel(the_model, scaledX_forecast, predict_item):
predictionStr = 'UP' predictionStr = 'UP'
content = f"""\n On day {forecastDay.strftime("%m/%d/%Y")}, the model predicts {predict_item} to be {predictionStr} in {str(numForecastDays)} business days. \n""" content = f"""\n On day {forecastDay.strftime("%m/%d/%Y")}, the model predicts {predict_item} to be {predictionStr} in {str(numForecastDays)} business days. \n"""
print(content) print(content)
# upload_predict(predict_item, forecastDay, predictionStr) # if predict_item == 'SPX':
# upload_predict(f'{predict_item} Index', forecastDay, predictionStr)
# send(content) # send(content)
return prediction return prediction
...@@ -41,7 +43,7 @@ def predictionFromMoel(the_model, scaledX_forecast, predict_item): ...@@ -41,7 +43,7 @@ def predictionFromMoel(the_model, scaledX_forecast, predict_item):
######################################## ########################################
if __name__ == '__main__': if __name__ == '__main__':
sync() sync()
toForecast = True # False means test, True means forecast toForecast = False # False means test, True means forecast
# define some parameters # define some parameters
win1W = 5 # 1 week win1W = 5 # 1 week
win1M = 21 # 1 Month win1M = 21 # 1 Month
......
...@@ -122,6 +122,7 @@ class TrainingDataBuilder(ABC): ...@@ -122,6 +122,7 @@ class TrainingDataBuilder(ABC):
def build_train_test(self, pid, indexData, vixData, indexOtherData, cpiData, FDTRData, NAPMPMIData): def build_train_test(self, pid, indexData, vixData, indexOtherData, cpiData, FDTRData, NAPMPMIData):
###### Merge Data to one table ###### Merge Data to one table
predictData = self.build_predict_data(indexData, pid) predictData = self.build_predict_data(indexData, pid)
forecastDay = None
if (self._toForecast): if (self._toForecast):
forecastDay = predictData['date'].iloc[-1] forecastDay = predictData['date'].iloc[-1]
DataAll = pd.merge(predictData, vixData, how='outer', on='date') DataAll = pd.merge(predictData, vixData, how='outer', on='date')
...@@ -177,7 +178,7 @@ class TrainingDataBuilder(ABC): ...@@ -177,7 +178,7 @@ class TrainingDataBuilder(ABC):
# scaledX = scaler.fit_transform(X) # scaledX = scaler.fit_transform(X)
DataScaler = scaler.fit(X) DataScaler = scaler.fit(X)
scaledX = DataScaler.transform(X) scaledX = DataScaler.transform(X)
scaledX_forecast = None
if (self._toForecast): if (self._toForecast):
scaledX_forecast = DataScaler.transform(X_forecast) scaledX_forecast = DataScaler.transform(X_forecast)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment