SHL github project: uat_shl

  • training module: shl_tm

  • prediction module: shl_pm

  • simulation module: shl_sm

  • misc module: shl_mm

data feeds:

  • historical bidding price, per second, time series

  • live bidding price, per second, time series

parameter lookup table: python dictionary

  • parm_si (seasonality index per second)

  • parm_month (parameter like alpha, beta, gamma, etc. per month)

[1] Import useful reference packages


In [1]:
import pandas as pd

Initialization


In [2]:
# function to fetch Seasonality-Index
def shl_intra_fetch_si(ccyy_mm, time, shl_data_parm_si):
#     return shl_data_parm_si[(shl_data_parm_si['ccyy-mm'] == '2017-09') & (shl_data_parm_si['time'] == '11:29:00')]
    return shl_data_parm_si[(shl_data_parm_si['ccyy-mm'] == ccyy_mm) & (shl_data_parm_si['time'] == time)].iloc[0]['si']

In [3]:
# function to fetch Dynamic-Increment
def shl_intra_fetch_di(ccyy_mm, shl_data_parm_month):
    return shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == ccyy_mm].iloc[0]['di']

In [4]:
def shl_intra_fetch_previous_n_sec_time_as_str(shl_data_time_field, n):
    return str((pd.to_datetime(shl_data_time_field, format='%H:%M:%S') - pd.Timedelta(seconds=n)).time())

def shl_intra_fetch_future_n_sec_time_as_str(shl_data_time_field, n):
    return str((pd.to_datetime(shl_data_time_field, format='%H:%M:%S') - pd.Timedelta(seconds=-n)).time())

In [5]:
def shl_initialize(in_ccyy_mm='2017-07'):
    print()
    print('+-----------------------------------------------+')
    print('| shl_initialize()                              |')
    print('+-----------------------------------------------+')
    print()
    global shl_data_parm_si
    global shl_data_parm_month
    shl_data_parm_si = pd.read_csv('data/parm_si.csv') 
    shl_data_parm_month = pd.read_csv('data/parm_month.csv') 

    global shl_global_parm_ccyy_mm 
    shl_global_parm_ccyy_mm = in_ccyy_mm
    
    # create default global base price
    global shl_global_parm_base_price
    shl_global_parm_base_price = 10000000

    global shl_global_parm_dynamic_increment
    shl_global_parm_dynamic_increment = shl_intra_fetch_di(shl_global_parm_ccyy_mm, shl_data_parm_month)

    global shl_global_parm_alpha
    shl_global_parm_alpha = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['alpha']
    global shl_global_parm_beta
    shl_global_parm_beta  = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['beta']
    global shl_global_parm_gamma
    shl_global_parm_gamma = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['gamma']
    global shl_global_parm_sec57_weight
    shl_global_parm_sec57_weight = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['sec57-weight']
    global shl_global_parm_month_weight
    shl_global_parm_month_weight = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['month-weight']
    global shl_global_parm_short_weight
    shl_global_parm_short_weight = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['short-weight']

    # default = 0
    global shl_global_parm_short_weight_ratio
    shl_global_parm_short_weight_ratio = 0
    
    # create default average error between 46~50 seconds:
    global shl_global_parm_short_weight_misc
    shl_global_parm_short_weight_misc = 0

    
    print('shl_global_parm_ccyy_mm           : %s' % shl_global_parm_ccyy_mm)
    print('-------------------------------------------------')
    print('shl_global_parm_alpha             : %0.15f' % shl_global_parm_alpha) # used in forecasting
    print('shl_global_parm_beta              : %0.15f' % shl_global_parm_beta)  # used in forecasting
    print('shl_global_parm_gamma             : %0.15f' % shl_global_parm_gamma) # used in forecasting
    print('shl_global_parm_short_weight      : %f' % shl_global_parm_short_weight) # used in forecasting
    print('shl_global_parm_short_weight_ratio: %f' % shl_global_parm_short_weight) # used in forecasting
    print('shl_global_parm_sec57_weight      : %f' % shl_global_parm_sec57_weight) # used in training a model
    print('shl_global_parm_month_weight      : %f' % shl_global_parm_month_weight) # used in training a model
    print('shl_global_parm_dynamic_increment : %d' % shl_global_parm_dynamic_increment)
    print('-------------------------------------------------')

#     plt.figure(figsize=(6,3)) # plot seasonality index
#     plt.plot(shl_data_parm_si[(shl_data_parm_si['ccyy-mm'] == shl_global_parm_ccyy_mm)]['si'])
    
    global shl_data_pm_1_step
    shl_data_pm_1_step = pd.DataFrame() # initialize dataframe of prediction results
    print()
    print('prediction results dataframe: shl_data_pm_1_step')
    print(shl_data_pm_1_step)

    global shl_data_pm_k_step
    shl_data_pm_k_step = pd.DataFrame() # initialize dataframe of prediction results
    print()
    print('prediction results dataframe: shl_data_pm_k_step')
    print(shl_data_pm_k_step)

In [6]:
shl_initialize()


+-----------------------------------------------+
| shl_initialize()                              |
+-----------------------------------------------+

shl_global_parm_ccyy_mm           : 2017-07
-------------------------------------------------
shl_global_parm_alpha             : 0.636279780099081
shl_global_parm_beta              : 0.237518711616408
shl_global_parm_gamma             : 0.223562510966253
shl_global_parm_short_weight      : 0.125000
shl_global_parm_short_weight_ratio: 0.125000
shl_global_parm_sec57_weight      : 0.500000
shl_global_parm_month_weight      : 0.900000
shl_global_parm_dynamic_increment : 300
-------------------------------------------------

prediction results dataframe: shl_data_pm_1_step
Empty DataFrame
Columns: []
Index: []

prediction results dataframe: shl_data_pm_k_step
Empty DataFrame
Columns: []
Index: []

shl_predict_price(in_current_time, in_current_price, in_k_sec) # return k-seconrds Predicted Prices, in a list format

shl_predict_set_price(in_current_time, in_current_price, in_k_sec) # return k-second Predicted Price + Dynamic Increment, in a list format

call k times of shl_predict_price()

shl_data_pm_1_step_itr = pd.DataFrame() # initialize prediction dataframe at 11:29:00


In [28]:
(shl_data_pm_1_step['f_1_step_pred_price_inc'].shift(1)[46:50] - shl_data_pm_1_step['f_actual_price4pm'][46:50]).sum()


Out[28]:
-163.55250082102714

In [29]:
(shl_data_pm_k_step['f_1_step_pred_price_inc'].shift(1)[46:50] - shl_data_pm_k_step['f_actual_price4pm'][46:50]).sum()


Out[29]:
-163.55250082102714

In [ ]:


In [48]:
def shl_predict_price_1_step(in_current_time, in_current_price):
# 11:29:00~11:29:50

    global shl_data_pm_k_step
    
    global shl_global_parm_short_weight_misc
    if in_current_time < '11:29:50': shl_global_parm_short_weight_misc = 0
    
    global shl_global_parm_short_weight_ratio
    
    global shl_global_parm_base_price 


    print()
    print('+-----------------------------------------------+')
    print('| shl_predict_price()                           |')
    print('+-----------------------------------------------+')
    print()
    print('current_ccyy_mm   : %s' % shl_global_parm_ccyy_mm) # str, format: ccyy-mm
    print('in_current_time   : %s' % in_current_time) # str, format: hh:mm:ss
    print('in_current_price  : %d' % in_current_price) # number, format: integer
    print('-------------------------------------------------')

    
    # capture & calculate 11:29:00 bid price - 1 as base price
    if in_current_time == '11:29:00':
        shl_global_parm_base_price = in_current_price -1 
        print('*INFO* At time [ %s ] Set shl_global_parm_base_price : %d ' % (in_current_time, shl_global_parm_base_price)) # Debug
        
#     f_actual_datetime = shl_global_parm_ccyy_mm + ' ' + in_current_time
#     print('*INFO* f_actual_datetime   : %s ' %  f_actual_datetime)

    # get Seasonality-Index, for current second
    f_actual_si = shl_intra_fetch_si(shl_global_parm_ccyy_mm, in_current_time, shl_data_parm_si)
    print('*INFO* f_actual_si         : %0.10f ' %  f_actual_si) # Debug
    
    # get Seasonality-Index, for current second + 1
    f_1_step_time = shl_intra_fetch_future_n_sec_time_as_str(in_current_time, 1)
    f_1_step_si = shl_intra_fetch_si(shl_global_parm_ccyy_mm, f_1_step_time, shl_data_parm_si)
    print('*INFO* f_1_step_si         : %0.10f ' %  f_1_step_si) # Debug
    
    # calculate price increment: f_actual_price4pm
    f_actual_price4pm = in_current_price -  shl_global_parm_base_price
    print('*INFO* f_actual_price4pm   : %d ' % f_actual_price4pm) # Debug
    
    # calculate seasonality adjusted price increment: f_actual_price4pmsi
    f_actual_price4pmsi = f_actual_price4pm / f_actual_si
    print('*INFO* f_actual_price4pmsi : %0.10f ' % f_actual_price4pmsi) # Debug
    

    if in_current_time == '11:29:00':
#         shl_data_pm_k_step_itr = pd.DataFrame() # initialize prediction dataframe at 11:29:00
        print('---- call prediction function shl_pm ---- %s' % in_current_time)
        f_1_step_pred_les_level = f_actual_price4pmsi # special handling for 11:29:00
        f_1_step_pred_les_trend = 0 # special handling for 11:29:00
        f_1_step_pred_les = f_1_step_pred_les_level + f_1_step_pred_les_trend
        f_1_step_pred_adj_misc = 0
        f_1_step_pred_price_inc = (f_1_step_pred_les + f_1_step_pred_adj_misc) * f_1_step_si
        f_1_step_pred_price = f_1_step_pred_price_inc + shl_global_parm_base_price
        f_1_step_pred_price_rounded = round(f_1_step_pred_price/100, 0) * 100
        f_1_step_pred_set_price_rounded = f_1_step_pred_price_rounded + shl_global_parm_dynamic_increment
        
    else:
        print('---- call prediction function shl_pm ---- %s' % in_current_time)
        
#       function to get average forecast error between 46~50 seconds: mean(f_current_step_error)
        if in_current_time == '11:29:50':
            sec50_pred_price_inc = shl_data_pm_k_step[(shl_data_pm_k_step['ccyy-mm'] == shl_global_parm_ccyy_mm) \
                                                & (shl_data_pm_k_step['time'] ==in_current_time)].iloc[0]['f_1_step_pred_price_inc']
            sec50_error    = sec50_pred_price_inc - f_actual_price4pm
            sec46_49_error = (shl_data_pm_k_step['f_1_step_pred_price_inc'].shift(1)[46:50] - shl_data_pm_k_step['f_actual_price4pm'][46:50]).sum()
            print('*INFO* sec50_error    : %f' % sec50_error)
            print('*INFO* sec46_49_error : %f' % sec46_49_error)
            
            shl_global_parm_short_weight_misc = (sec50_error + sec46_49_error) / 5
            print('*INFO* shl_global_parm_short_weight_misc  : %f' % shl_global_parm_short_weight_misc)
            
#       ----------------------------------------------------------------------------------------------------        
#       if in_current_time == '11:29:50':
            shl_global_parm_short_weight_ratio = 1
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)
        if in_current_time == '11:29:51':
            shl_global_parm_short_weight_ratio = 2
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:52':
            shl_global_parm_short_weight_ratio = 3
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:53':
            shl_global_parm_short_weight_ratio = 4
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:54':
            shl_global_parm_short_weight_ratio = 5
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:55':
            shl_global_parm_short_weight_ratio = 6
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:56':
            shl_global_parm_short_weight_ratio = 7
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:57':
            shl_global_parm_short_weight_ratio = 8
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:58':
            shl_global_parm_short_weight_ratio = 9
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:59':
            shl_global_parm_short_weight_ratio = 10
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
        if in_current_time == '11:29:60':
            shl_global_parm_short_weight_ratio = 11
            print('*INFO* shl_global_parm_short_weight_ratio : %d' % shl_global_parm_short_weight_ratio)        
#       ----------------------------------------------------------------------------------------------------        
        
        previous_pred_les_level = shl_data_pm_k_step[(shl_data_pm_k_step['ccyy-mm'] == shl_global_parm_ccyy_mm) \
                                            & (shl_data_pm_k_step['time'] ==in_current_time)].iloc[0]['f_1_step_pred_les_level']
        print('     previous_pred_les_level : %f' % previous_pred_les_level)
        
        previous_pred_les_trend = shl_data_pm_k_step[(shl_data_pm_k_step['ccyy-mm'] == shl_global_parm_ccyy_mm) \
                                            & (shl_data_pm_k_step['time'] ==in_current_time)].iloc[0]['f_1_step_pred_les_trend']
        print('     previous_pred_les_trend : %f' % previous_pred_les_trend)

            
        f_1_step_pred_les_level = shl_global_parm_alpha * f_actual_price4pmsi \
                                    + (1 - shl_global_parm_alpha) * (previous_pred_les_level + previous_pred_les_trend)
        print('     f_1_step_pred_les_level  : %f' % f_1_step_pred_les_level)
        f_1_step_pred_les_trend = shl_global_parm_beta * (f_1_step_pred_les_level - previous_pred_les_level) \
                                    + (1 - shl_global_parm_beta) * previous_pred_les_trend
        print('     f_1_step_pred_les_trend  : %f' % f_1_step_pred_les_trend)
        
        f_1_step_pred_les = f_1_step_pred_les_level + f_1_step_pred_les_trend
        f_1_step_pred_adj_misc = shl_global_parm_short_weight_misc * shl_global_parm_short_weight * shl_global_parm_short_weight_ratio * shl_global_parm_gamma
        print('     les + misc               : %f' % (f_1_step_pred_adj_misc+f_1_step_pred_les))
        f_1_step_pred_price_inc = (f_1_step_pred_les + f_1_step_pred_adj_misc) * f_1_step_si
        print('     f_1_step_pred_price_inc  : %f' % f_1_step_pred_price_inc)
        print('     f_1_step_si              : %f' % f_1_step_si)
        f_1_step_pred_price = f_1_step_pred_price_inc + shl_global_parm_base_price
        f_1_step_pred_price_rounded = round(f_1_step_pred_price/100, 0) * 100
        f_1_step_pred_set_price_rounded = f_1_step_pred_price_rounded + shl_global_parm_dynamic_increment
   
        
    # write results to shl_pm dataframe
            
    shl_data_pm_k_step_itr_dict = {
                         'ccyy-mm' : shl_global_parm_ccyy_mm
                        ,'time' : f_1_step_time # in_current_time + 1 second
                        ,'bid' : in_current_price
                        ,'f_actual_si' : f_actual_si
                        ,'f_1_step_si' : f_1_step_si
                        ,'f_actual_price4pm' : f_actual_price4pm
                        ,'f_actual_price4pmsi' :  f_actual_price4pmsi
                        ,'f_1_step_pred_les_level' : f_1_step_pred_les_level
                        ,'f_1_step_pred_les_trend' : f_1_step_pred_les_trend
                        ,'f_1_step_pred_les' : f_1_step_pred_les
                        ,'f_1_step_pred_adj_misc' : f_1_step_pred_adj_misc
                        ,'f_1_step_pred_price_inc' : f_1_step_pred_price_inc
                        ,'f_1_step_pred_price' : f_1_step_pred_price
                        ,'f_1_step_pred_price_rounded' : f_1_step_pred_price_rounded
                        ,'f_1_step_pred_set_price_rounded' : f_1_step_pred_set_price_rounded
                        }
#     shl_data_pm_k_step_itr =  shl_data_pm_k_step_itr.append(shl_data_pm_k_step_itr_dict, ignore_index=True)
#     shl_data_pm_k_step     =  shl_data_pm_k_step.append(shl_data_pm_k_step_itr_dict, ignore_index=True)
    return shl_data_pm_k_step_itr_dict

In [15]:
def shl_predict_price_k_step(in_current_time, in_current_price, in_k_seconds=1):
    global shl_data_pm_1_step
    
    global shl_data_pm_k_step
    shl_data_pm_k_step = shl_data_pm_1_step.copy() 
    
    shl_data_pm_itr_dict = {}
    
    for k in range(1,in_k_seconds+1):
        print()
        print('==>> Forecasting next %3d second/step... ' % k)
        if k == 1:
            print('k = ', k)
            input_price = in_current_price
            input_time  = in_current_time
            shl_data_pm_itr_dict = shl_predict_price_1_step(input_time, input_price)
            shl_data_pm_1_step     =  shl_data_pm_1_step.append(shl_data_pm_itr_dict, ignore_index=True)
        else:
            print('k = ', k)
            input_price = shl_data_pm_itr_dict['f_1_step_pred_price']
            input_time  = shl_data_pm_itr_dict['time']
            shl_data_pm_itr_dict = shl_predict_price_1_step(input_time, input_price)

        shl_data_pm_k_step     =  shl_data_pm_k_step.append(shl_data_pm_itr_dict, ignore_index=True)

In [16]:
shl_data_pm_1_step


Out[16]:

In [17]:
shl_data_pm_k_step


Out[17]:

In [ ]:


In [ ]:
# shl_data_pm_1_step['f_actual_price4pm'][46:50]

In [ ]:
# shl_data_pm_1_step['f_1_step_pred_price_inc'].shift(1)[46:50]

In [ ]:
# shl_data_pm_1_step['f_1_step_pred_price_inc'].shift(1)[46:50] - shl_data_pm_1_step['f_actual_price4pm'][46:50]

In [ ]:


In [ ]:

shl_sm


In [19]:
shl_data_history_ts_process = pd.read_csv('data/history_ts.csv') 
shl_data_history_ts_process.tail()


Out[19]:
ccyy-mm time bid-price ref-price
1886 2017-07 11:29:56 92100 89800
1887 2017-07 11:29:57 92100 89800
1888 2017-07 11:29:58 92100 89800
1889 2017-07 11:29:59 92200 89800
1890 2017-07 11:30:00 92200 89800

shl_sm Simulation Module Parm:


In [104]:
# which month to predict?
# shl_global_parm_ccyy_mm = '2017-04'
# shl_global_parm_ccyy_mm_offset = 1647

# shl_global_parm_ccyy_mm = '2017-05'
# shl_global_parm_ccyy_mm_offset = 1708

shl_global_parm_ccyy_mm = '2017-06'
shl_global_parm_ccyy_mm_offset = 1769

# shl_global_parm_ccyy_mm = '2017-07'
# shl_global_parm_ccyy_mm_offset = 1830

In [105]:
shl_data_pm_1_step = pd.DataFrame() # initialize dataframe of prediction results
shl_data_pm_k_step = pd.DataFrame()

In [106]:
# Upon receiving 11:29:00 second price, to predict till 11:29:49 <- one-step forward price forecasting

shl_data_pm_1_step = pd.DataFrame() # initialize dataframe of prediction results

for i in range(shl_global_parm_ccyy_mm_offset, shl_global_parm_ccyy_mm_offset+50): # use July 2015 data as simulatino
    print('\n<<<< Record No.: %5d >>>>' % i)
    print(shl_data_history_ts_process['ccyy-mm'][i]) # format: ccyy-mm
    print(shl_data_history_ts_process['time'][i]) # format: hh:mm:ss
    print(shl_data_history_ts_process['bid-price'][i]) # format: integer
    shl_predict_price_k_step(shl_data_history_ts_process['time'][i], shl_data_history_ts_process['bid-price'][i],1) # <- one-step forward price forecasting


<<<< Record No.:  1769 >>>>
2017-06
11:29:00
88400

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:00
in_current_price  : 88400
-------------------------------------------------
*INFO* At time [ 11:29:00 ] Set shl_global_parm_base_price : 88399 
*INFO* f_actual_si         : 0.0023822130 
*INFO* f_1_step_si         : 0.0148610890 
*INFO* f_actual_price4pm   : 1 
*INFO* f_actual_price4pmsi : 419.7777444754 
---- call prediction function shl_pm ---- 11:29:00

<<<< Record No.:  1770 >>>>
2017-06
11:29:01
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:01
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.0148610890 
*INFO* f_1_step_si         : 0.0237690550 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 6796.2717940792 
---- call prediction function shl_pm ---- 11:29:01
     previous_pred_les_level : 419.777744
     previous_pred_les_trend : 0.000000
     f_1_step_pred_les_level  : 4477.011976
     f_1_step_pred_les_trend  : 963.669047
     les + misc               : 5440.681024
     f_1_step_pred_price_inc  : 129.319846
     f_1_step_si              : 0.023769

<<<< Record No.:  1771 >>>>
2017-06
11:29:02
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:02
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.0237690550 
*INFO* f_1_step_si         : 0.0309433440 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 4249.2223607544 
---- call prediction function shl_pm ---- 11:29:02
     previous_pred_les_level : 4477.011976
     previous_pred_les_trend : 963.669047
     f_1_step_pred_les_level  : 4682.579968
     f_1_step_pred_les_trend  : 783.605861
     les + misc               : 5466.185829
     f_1_step_pred_price_inc  : 169.142068
     f_1_step_si              : 0.030943

<<<< Record No.:  1772 >>>>
2017-06
11:29:03
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:03
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.0309433440 
*INFO* f_1_step_si         : 0.0392121080 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 3264.0298992895 
---- call prediction function shl_pm ---- 11:29:03
     previous_pred_les_level : 4682.579968
     previous_pred_les_trend : 783.605861
     f_1_step_pred_les_level  : 4064.998538
     f_1_step_pred_les_trend  : 450.797661
     les + misc               : 4515.796200
     f_1_step_pred_price_inc  : 177.073888
     f_1_step_si              : 0.039212

<<<< Record No.:  1773 >>>>
2017-06
11:29:04
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:04
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.0392121080 
*INFO* f_1_step_si         : 0.0387689300 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 2575.7350255181 
---- call prediction function shl_pm ---- 11:29:04
     previous_pred_les_level : 4064.998538
     previous_pred_les_trend : 450.797661
     f_1_step_pred_les_level  : 3281.374502
     f_1_step_pred_les_trend  : 157.599410
     les + misc               : 3438.973913
     f_1_step_pred_price_inc  : 133.325339
     f_1_step_si              : 0.038769

<<<< Record No.:  1774 >>>>
2017-06
11:29:05
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:05
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.0387689300 
*INFO* f_1_step_si         : 0.0757339540 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 2605.1789409715 
---- call prediction function shl_pm ---- 11:29:05
     previous_pred_les_level : 3281.374502
     previous_pred_les_trend : 157.599410
     f_1_step_pred_les_level  : 2908.447031
     f_1_step_pred_les_trend  : 31.589349
     les + misc               : 2940.036380
     f_1_step_pred_price_inc  : 222.660580
     f_1_step_si              : 0.075734

<<<< Record No.:  1775 >>>>
2017-06
11:29:06
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:06
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.0757339540 
*INFO* f_1_step_si         : 0.0941974490 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 1333.6158310181 
---- call prediction function shl_pm ---- 11:29:06
     previous_pred_les_level : 2908.447031
     previous_pred_les_trend : 31.589349
     f_1_step_pred_les_level  : 1917.903466
     f_1_step_pred_les_trend  : -211.186344
     les + misc               : 1706.717123
     f_1_step_pred_price_inc  : 160.768399
     f_1_step_si              : 0.094197

<<<< Record No.:  1776 >>>>
2017-06
11:29:07
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:07
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.0941974490 
*INFO* f_1_step_si         : 0.1333751000 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 1072.2158728524 
---- call prediction function shl_pm ---- 11:29:07
     previous_pred_les_level : 1917.903466
     previous_pred_les_trend : -211.186344
     f_1_step_pred_les_level  : 1302.996807
     f_1_step_pred_les_trend  : -307.077473
     les + misc               : 995.919334
     f_1_step_pred_price_inc  : 132.830841
     f_1_step_si              : 0.133375

<<<< Record No.:  1777 >>>>
2017-06
11:29:08
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:08
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.1333751000 
*INFO* f_1_step_si         : 0.2041837360 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 757.2627874318 
---- call prediction function shl_pm ---- 11:29:08
     previous_pred_les_level : 1302.996807
     previous_pred_les_trend : -307.077473
     f_1_step_pred_les_level  : 844.066999
     f_1_step_pred_les_trend  : -343.145244
     les + misc               : 500.921755
     f_1_step_pred_price_inc  : 102.280075
     f_1_step_si              : 0.204184

<<<< Record No.:  1778 >>>>
2017-06
11:29:09
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:09
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.2041837360 
*INFO* f_1_step_si         : 0.2321693820 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 494.6525221774 
---- call prediction function shl_pm ---- 11:29:09
     previous_pred_les_level : 844.066999
     previous_pred_les_trend : -343.145244
     f_1_step_pred_les_level  : 496.932769
     f_1_step_pred_les_trend  : -344.092703
     les + misc               : 152.840066
     f_1_step_pred_price_inc  : 35.484784
     f_1_step_si              : 0.232169

<<<< Record No.:  1779 >>>>
2017-06
11:29:10
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:10
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.2321693820 
*INFO* f_1_step_si         : 0.2946054880 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 435.0272164656 
---- call prediction function shl_pm ---- 11:29:10
     previous_pred_les_level : 496.932769
     previous_pred_les_trend : -344.092703
     f_1_step_pred_les_level  : 332.390044
     f_1_step_pred_les_trend  : -301.446223
     les + misc               : 30.943821
     f_1_step_pred_price_inc  : 9.116219
     f_1_step_si              : 0.294605

<<<< Record No.:  1780 >>>>
2017-06
11:29:11
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:11
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.2946054880 
*INFO* f_1_step_si         : 0.3488655530 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 342.8313596113 
---- call prediction function shl_pm ---- 11:29:11
     previous_pred_les_level : 332.390044
     previous_pred_les_trend : -301.446223
     f_1_step_pred_les_level  : 229.391555
     f_1_step_pred_les_trend  : -254.311173
     les + misc               : -24.919618
     f_1_step_pred_price_inc  : -8.693596
     f_1_step_si              : 0.348866

<<<< Record No.:  1781 >>>>
2017-06
11:29:12
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:12
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.3488655530 
*INFO* f_1_step_si         : 0.3571459030 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 289.5098101015 
---- call prediction function shl_pm ---- 11:29:12
     previous_pred_les_level : 229.391555
     previous_pred_les_trend : -254.311173
     f_1_step_pred_les_level  : 175.145469
     f_1_step_pred_les_trend  : -206.791971
     les + misc               : -31.646502
     f_1_step_pred_price_inc  : -11.302419
     f_1_step_si              : 0.357146

<<<< Record No.:  1782 >>>>
2017-06
11:29:13
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:13
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.3571459030 
*INFO* f_1_step_si         : 0.3775201620 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 282.7975881890 
---- call prediction function shl_pm ---- 11:29:13
     previous_pred_les_level : 175.145469
     previous_pred_les_trend : -206.791971
     f_1_step_pred_les_level  : 168.427915
     f_1_step_pred_les_trend  : -159.270554
     les + misc               : 9.157361
     f_1_step_pred_price_inc  : 3.457088
     f_1_step_si              : 0.377520

<<<< Record No.:  1783 >>>>
2017-06
11:29:14
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:14
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.3775201620 
*INFO* f_1_step_si         : 0.4092913790 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 267.5353800044 
---- call prediction function shl_pm ---- 11:29:14
     previous_pred_les_level : 168.427915
     previous_pred_les_trend : -159.270554
     f_1_step_pred_les_level  : 173.558070
     f_1_step_pred_les_trend  : -120.222309
     les + misc               : 53.335761
     f_1_step_pred_price_inc  : 21.829867
     f_1_step_si              : 0.409291

<<<< Record No.:  1784 >>>>
2017-06
11:29:15
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:15
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.4092913790 
*INFO* f_1_step_si         : 0.4206648770 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 246.7679633194 
---- call prediction function shl_pm ---- 11:29:15
     previous_pred_les_level : 173.558070
     previous_pred_les_trend : -120.222309
     f_1_step_pred_les_level  : 176.412760
     f_1_step_pred_les_trend  : -90.989219
     les + misc               : 85.423541
     f_1_step_pred_price_inc  : 35.934684
     f_1_step_si              : 0.420665

<<<< Record No.:  1785 >>>>
2017-06
11:29:16
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:16
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.4206648770 
*INFO* f_1_step_si         : 0.4638547580 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 240.0961086181 
---- call prediction function shl_pm ---- 11:29:16
     previous_pred_les_level : 176.412760
     previous_pred_les_trend : -90.989219
     f_1_step_pred_les_level  : 183.838568
     f_1_step_pred_les_trend  : -67.613808
     les + misc               : 116.224760
     f_1_step_pred_price_inc  : 53.911408
     f_1_step_si              : 0.463855

<<<< Record No.:  1786 >>>>
2017-06
11:29:17
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:17
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.4638547580 
*INFO* f_1_step_si         : 0.4951657820 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 217.7405712846 
---- call prediction function shl_pm ---- 11:29:17
     previous_pred_les_level : 183.838568
     previous_pred_les_trend : -67.613808
     f_1_step_pred_les_level  : 180.817218
     f_1_step_pred_les_trend  : -52.271891
     les + misc               : 128.545327
     f_1_step_pred_price_inc  : 63.651247
     f_1_step_si              : 0.495166

<<<< Record No.:  1787 >>>>
2017-06
11:29:18
88500

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:18
in_current_price  : 88500
-------------------------------------------------
*INFO* f_actual_si         : 0.4951657820 
*INFO* f_1_step_si         : 0.5080609120 
*INFO* f_actual_price4pm   : 101 
*INFO* f_actual_price4pmsi : 203.9720911087 
---- call prediction function shl_pm ---- 11:29:18
     previous_pred_les_level : 180.817218
     previous_pred_les_trend : -52.271891
     f_1_step_pred_les_level  : 176.537852
     f_1_step_pred_les_trend  : -40.872768
     les + misc               : 135.665084
     f_1_step_pred_price_inc  : 68.926126
     f_1_step_si              : 0.508061

<<<< Record No.:  1788 >>>>
2017-06
11:29:19
88600

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:19
in_current_price  : 88600
-------------------------------------------------
*INFO* f_actual_si         : 0.5080609120 
*INFO* f_1_step_si         : 0.5316053510 
*INFO* f_actual_price4pm   : 201 
*INFO* f_actual_price4pmsi : 395.6218540977 
---- call prediction function shl_pm ---- 11:29:19
     previous_pred_les_level : 176.537852
     previous_pred_les_trend : -40.872768
     f_1_step_pred_les_level  : 301.070320
     f_1_step_pred_les_trend  : -1.585930
     les + misc               : 299.484391
     f_1_step_pred_price_inc  : 159.207505
     f_1_step_si              : 0.531605

<<<< Record No.:  1789 >>>>
2017-06
11:29:20
88600

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:20
in_current_price  : 88600
-------------------------------------------------
*INFO* f_actual_si         : 0.5316053510 
*INFO* f_1_step_si         : 0.5724520020 
*INFO* f_actual_price4pm   : 201 
*INFO* f_actual_price4pmsi : 378.1000315777 
---- call prediction function shl_pm ---- 11:29:20
     previous_pred_les_level : 301.070320
     previous_pred_les_trend : -1.585930
     f_1_step_pred_les_level  : 349.505933
     f_1_step_pred_les_trend  : 10.295123
     les + misc               : 359.801056
     f_1_step_pred_price_inc  : 205.968835
     f_1_step_si              : 0.572452

<<<< Record No.:  1790 >>>>
2017-06
11:29:21
88600

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:21
in_current_price  : 88600
-------------------------------------------------
*INFO* f_actual_si         : 0.5724520020 
*INFO* f_1_step_si         : 0.5843722490 
*INFO* f_actual_price4pm   : 201 
*INFO* f_actual_price4pmsi : 351.1211408079 
---- call prediction function shl_pm ---- 11:29:21
     previous_pred_les_level : 349.505933
     previous_pred_les_trend : 10.295123
     f_1_step_pred_les_level  : 354.278202
     f_1_step_pred_les_trend  : 8.983341
     les + misc               : 363.261543
     f_1_step_pred_price_inc  : 212.279965
     f_1_step_si              : 0.584372

<<<< Record No.:  1791 >>>>
2017-06
11:29:22
88600

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:22
in_current_price  : 88600
-------------------------------------------------
*INFO* f_actual_si         : 0.5843722490 
*INFO* f_1_step_si         : 0.5966521600 
*INFO* f_actual_price4pm   : 201 
*INFO* f_actual_price4pmsi : 343.9588384698 
---- call prediction function shl_pm ---- 11:29:22
     previous_pred_les_level : 354.278202
     previous_pred_les_trend : 8.983341
     f_1_step_pred_les_level  : 350.979622
     f_1_step_pred_les_trend  : 6.066156
     les + misc               : 357.045778
     f_1_step_pred_price_inc  : 213.032135
     f_1_step_si              : 0.596652

<<<< Record No.:  1792 >>>>
2017-06
11:29:23
88600

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:23
in_current_price  : 88600
-------------------------------------------------
*INFO* f_actual_si         : 0.5966521600 
*INFO* f_1_step_si         : 0.6276205910 
*INFO* f_actual_price4pm   : 201 
*INFO* f_actual_price4pmsi : 336.8796988852 
---- call prediction function shl_pm ---- 11:29:23
     previous_pred_les_level : 350.979622
     previous_pred_les_trend : 6.066156
     f_1_step_pred_les_level  : 344.214510
     f_1_step_pred_les_trend  : 3.018489
     les + misc               : 347.232999
     f_1_step_pred_price_inc  : 217.930580
     f_1_step_si              : 0.627621

<<<< Record No.:  1793 >>>>
2017-06
11:29:24
88600

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:24
in_current_price  : 88600
-------------------------------------------------
*INFO* f_actual_si         : 0.6276205910 
*INFO* f_1_step_si         : 0.6615943850 
*INFO* f_actual_price4pm   : 201 
*INFO* f_actual_price4pmsi : 320.2571790701 
---- call prediction function shl_pm ---- 11:29:24
     previous_pred_les_level : 344.214510
     previous_pred_les_trend : 3.018489
     f_1_step_pred_les_level  : 330.068830
     f_1_step_pred_les_trend  : -1.058322
     les + misc               : 329.010508
     f_1_step_pred_price_inc  : 217.671505
     f_1_step_si              : 0.661594

<<<< Record No.:  1794 >>>>
2017-06
11:29:25
88700

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:25
in_current_price  : 88700
-------------------------------------------------
*INFO* f_actual_si         : 0.6615943850 
*INFO* f_1_step_si         : 0.6796086800 
*INFO* f_actual_price4pm   : 301 
*INFO* f_actual_price4pmsi : 454.9615396146 
---- call prediction function shl_pm ---- 11:29:25
     previous_pred_les_level : 330.068830
     previous_pred_les_trend : -1.058322
     f_1_step_pred_les_level  : 409.150603
     f_1_step_pred_les_trend  : 17.976450
     les + misc               : 427.127053
     f_1_step_pred_price_inc  : 290.279252
     f_1_step_si              : 0.679609

<<<< Record No.:  1795 >>>>
2017-06
11:29:26
88700

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:26
in_current_price  : 88700
-------------------------------------------------
*INFO* f_actual_si         : 0.6796086800 
*INFO* f_1_step_si         : 0.7008853550 
*INFO* f_actual_price4pm   : 301 
*INFO* f_actual_price4pmsi : 442.9019358611 
---- call prediction function shl_pm ---- 11:29:26
     previous_pred_les_level : 409.150603
     previous_pred_les_trend : 17.976450
     f_1_step_pred_les_level  : 437.164292
     f_1_step_pred_les_trend  : 20.360482
     les + misc               : 457.524774
     f_1_step_pred_price_inc  : 320.672414
     f_1_step_si              : 0.700885

<<<< Record No.:  1796 >>>>
2017-06
11:29:27
88700

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:27
in_current_price  : 88700
-------------------------------------------------
*INFO* f_actual_si         : 0.7008853550 
*INFO* f_1_step_si         : 0.7258007710 
*INFO* f_actual_price4pm   : 301 
*INFO* f_actual_price4pmsi : 429.4568260739 
---- call prediction function shl_pm ---- 11:29:27
     previous_pred_les_level : 437.164292
     previous_pred_les_trend : 20.360482
     f_1_step_pred_les_level  : 439.665706
     f_1_step_pred_les_trend  : 16.118619
     les + misc               : 455.784326
     f_1_step_pred_price_inc  : 330.808615
     f_1_step_si              : 0.725801

<<<< Record No.:  1797 >>>>
2017-06
11:29:28
88700

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:28
in_current_price  : 88700
-------------------------------------------------
*INFO* f_actual_si         : 0.7258007710 
*INFO* f_1_step_si         : 0.7406630210 
*INFO* f_actual_price4pm   : 301 
*INFO* f_actual_price4pmsi : 414.7143569237 
---- call prediction function shl_pm ---- 11:29:28
     previous_pred_les_level : 439.665706
     previous_pred_les_trend : 16.118619
     f_1_step_pred_les_level  : 429.652335
     f_1_step_pred_les_trend  : 9.911783
     les + misc               : 439.564118
     f_1_step_pred_price_inc  : 325.568887
     f_1_step_si              : 0.740663

<<<< Record No.:  1798 >>>>
2017-06
11:29:29
88700

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:29
in_current_price  : 88700
-------------------------------------------------
*INFO* f_actual_si         : 0.7406630210 
*INFO* f_1_step_si         : 0.7749686950 
*INFO* f_actual_price4pm   : 301 
*INFO* f_actual_price4pmsi : 406.3926393863 
---- call prediction function shl_pm ---- 11:29:29
     previous_pred_les_level : 429.652335
     previous_pred_les_trend : 9.911783
     f_1_step_pred_les_level  : 418.457777
     f_1_step_pred_les_trend  : 4.898632
     les + misc               : 423.356408
     f_1_step_pred_price_inc  : 328.087963
     f_1_step_si              : 0.774969

<<<< Record No.:  1799 >>>>
2017-06
11:29:30
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:30
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.7749686950 
*INFO* f_1_step_si         : 0.7967683450 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 517.4402560867 
---- call prediction function shl_pm ---- 11:29:30
     previous_pred_les_level : 418.457777
     previous_pred_les_trend : 4.898632
     f_1_step_pred_les_level  : 483.220058
     f_1_step_pred_les_trend  : 19.117369
     les + misc               : 502.337427
     f_1_step_pred_price_inc  : 400.246560
     f_1_step_si              : 0.796768

<<<< Record No.:  1800 >>>>
2017-06
11:29:31
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:31
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.7967683450 
*INFO* f_1_step_si         : 0.8239920950 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 503.2830464669 
---- call prediction function shl_pm ---- 11:29:31
     previous_pred_les_level : 483.220058
     previous_pred_les_trend : 19.117369
     f_1_step_pred_les_level  : 502.939106
     f_1_step_pred_les_trend  : 19.260279
     les + misc               : 522.199384
     f_1_step_pred_price_inc  : 430.288165
     f_1_step_si              : 0.823992

<<<< Record No.:  1801 >>>>
2017-06
11:29:32
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:32
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.8239920950 
*INFO* f_1_step_si         : 0.8456485560 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 486.6551541371 
---- call prediction function shl_pm ---- 11:29:32
     previous_pred_les_level : 502.939106
     previous_pred_les_trend : 19.260279
     f_1_step_pred_les_level  : 499.583309
     f_1_step_pred_les_trend  : 13.888538
     les + misc               : 513.471847
     f_1_step_pred_price_inc  : 434.216726
     f_1_step_si              : 0.845649

<<<< Record No.:  1802 >>>>
2017-06
11:29:33
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:33
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.8456485560 
*INFO* f_1_step_si         : 0.8708946860 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 474.1922600764 
---- call prediction function shl_pm ---- 11:29:33
     previous_pred_les_level : 499.583309
     previous_pred_les_trend : 13.888538
     f_1_step_pred_les_level  : 488.479040
     f_1_step_pred_les_trend  : 7.952278
     les + misc               : 496.431318
     f_1_step_pred_price_inc  : 432.339397
     f_1_step_si              : 0.870895

<<<< Record No.:  1803 >>>>
2017-06
11:29:34
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:34
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.8708946860 
*INFO* f_1_step_si         : 0.9278569940 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 460.4460291769 
---- call prediction function shl_pm ---- 11:29:34
     previous_pred_les_level : 488.479040
     previous_pred_les_trend : 7.952278
     f_1_step_pred_les_level  : 473.534606
     f_1_step_pred_les_trend  : 2.513881
     les + misc               : 476.048487
     f_1_step_pred_price_inc  : 441.704918
     f_1_step_si              : 0.927857

<<<< Record No.:  1804 >>>>
2017-06
11:29:35
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:35
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.9278569940 
*INFO* f_1_step_si         : 0.9616321100 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 432.1786682571 
---- call prediction function shl_pm ---- 11:29:35
     previous_pred_les_level : 473.534606
     previous_pred_les_trend : 2.513881
     f_1_step_pred_les_level  : 448.135008
     f_1_step_pred_les_trend  : -4.116093
     les + misc               : 444.018916
     f_1_step_pred_price_inc  : 426.982847
     f_1_step_si              : 0.961632

<<<< Record No.:  1805 >>>>
2017-06
11:29:36
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:36
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.9616321100 
*INFO* f_1_step_si         : 0.9787400280 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 416.9993865949 
---- call prediction function shl_pm ---- 11:29:36
     previous_pred_les_level : 448.135008
     previous_pred_les_trend : -4.116093
     f_1_step_pred_les_level  : 426.826936
     f_1_step_pred_les_trend  : -8.199510
     les + misc               : 418.627426
     f_1_step_pred_price_inc  : 409.727419
     f_1_step_si              : 0.978740

<<<< Record No.:  1806 >>>>
2017-06
11:29:37
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:37
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.9787400280 
*INFO* f_1_step_si         : 0.9870518520 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 409.7104323192 
---- call prediction function shl_pm ---- 11:29:37
     previous_pred_les_level : 426.826936
     previous_pred_les_trend : -8.199510
     f_1_step_pred_les_level  : 412.953723
     f_1_step_pred_les_trend  : -9.547120
     les + misc               : 403.406603
     f_1_step_pred_price_inc  : 398.183235
     f_1_step_si              : 0.987052

<<<< Record No.:  1807 >>>>
2017-06
11:29:38
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:38
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 0.9870518520 
*INFO* f_1_step_si         : 1.0277287330 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 406.2603187335 
---- call prediction function shl_pm ---- 11:29:38
     previous_pred_les_level : 412.953723
     previous_pred_les_trend : -9.547120
     f_1_step_pred_les_level  : 405.222365
     f_1_step_pred_les_trend  : -9.115843
     les + misc               : 396.106522
     f_1_step_pred_price_inc  : 407.090054
     f_1_step_si              : 1.027729

<<<< Record No.:  1808 >>>>
2017-06
11:29:39
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:39
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 1.0277287330 
*INFO* f_1_step_si         : 1.0732818240 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 390.1807812938 
---- call prediction function shl_pm ---- 11:29:39
     previous_pred_les_level : 405.222365
     previous_pred_les_trend : -9.115843
     f_1_step_pred_les_level  : 392.336093
     f_1_step_pred_les_trend  : -10.011390
     les + misc               : 382.324703
     f_1_step_pred_price_inc  : 410.342154
     f_1_step_si              : 1.073282

<<<< Record No.:  1809 >>>>
2017-06
11:29:40
88800

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:40
in_current_price  : 88800
-------------------------------------------------
*INFO* f_actual_si         : 1.0732818240 
*INFO* f_1_step_si         : 1.1014312080 
*INFO* f_actual_price4pm   : 401 
*INFO* f_actual_price4pmsi : 373.6204145389 
---- call prediction function shl_pm ---- 11:29:40
     previous_pred_les_level : 392.336093
     previous_pred_les_trend : -10.011390
     f_1_step_pred_les_level  : 376.786340
     f_1_step_pred_les_trend  : -11.326855
     les + misc               : 365.459485
     f_1_step_pred_price_inc  : 402.528482
     f_1_step_si              : 1.101431

<<<< Record No.:  1810 >>>>
2017-06
11:29:41
88900

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:41
in_current_price  : 88900
-------------------------------------------------
*INFO* f_actual_si         : 1.1014312080 
*INFO* f_1_step_si         : 1.1636423890 
*INFO* f_actual_price4pm   : 501 
*INFO* f_actual_price4pmsi : 454.8627243909 
---- call prediction function shl_pm ---- 11:29:41
     previous_pred_les_level : 376.786340
     previous_pred_les_trend : -11.326855
     f_1_step_pred_les_level  : 422.344959
     f_1_step_pred_les_trend  : 2.184509
     les + misc               : 424.529468
     f_1_step_pred_price_inc  : 494.000484
     f_1_step_si              : 1.163642

<<<< Record No.:  1811 >>>>
2017-06
11:29:42
88900

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:42
in_current_price  : 88900
-------------------------------------------------
*INFO* f_actual_si         : 1.1636423890 
*INFO* f_1_step_si         : 1.2770115610 
*INFO* f_actual_price4pm   : 501 
*INFO* f_actual_price4pmsi : 430.5446456196 
---- call prediction function shl_pm ---- 11:29:42
     previous_pred_les_level : 422.344959
     previous_pred_les_trend : 2.184509
     f_1_step_pred_les_level  : 428.356804
     f_1_step_pred_les_trend  : 3.093573
     les + misc               : 431.450377
     f_1_step_pred_price_inc  : 550.967120
     f_1_step_si              : 1.277012

<<<< Record No.:  1812 >>>>
2017-06
11:29:43
89000

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:43
in_current_price  : 89000
-------------------------------------------------
*INFO* f_actual_si         : 1.2770115610 
*INFO* f_1_step_si         : 1.3885120710 
*INFO* f_actual_price4pm   : 601 
*INFO* f_actual_price4pmsi : 470.6300384073 
---- call prediction function shl_pm ---- 11:29:43
     previous_pred_les_level : 428.356804
     previous_pred_les_trend : 3.093573
     f_1_step_pred_les_level  : 456.379603
     f_1_step_pred_les_trend  : 9.014731
     les + misc               : 465.394334
     f_1_step_pred_price_inc  : 646.205651
     f_1_step_si              : 1.388512

<<<< Record No.:  1813 >>>>
2017-06
11:29:44
89000

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:44
in_current_price  : 89000
-------------------------------------------------
*INFO* f_actual_si         : 1.3885120710 
*INFO* f_1_step_si         : 1.4408790780 
*INFO* f_actual_price4pm   : 601 
*INFO* f_actual_price4pmsi : 432.8374326391 
---- call prediction function shl_pm ---- 11:29:44
     previous_pred_les_level : 456.379603
     previous_pred_les_trend : 9.014731
     f_1_step_pred_les_level  : 444.679036
     f_1_step_pred_les_trend  : 4.094460
     les + misc               : 448.773496
     f_1_step_pred_price_inc  : 646.628341
     f_1_step_si              : 1.440879

<<<< Record No.:  1814 >>>>
2017-06
11:29:45
89100

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:45
in_current_price  : 89100
-------------------------------------------------
*INFO* f_actual_si         : 1.4408790780 
*INFO* f_1_step_si         : 1.5694557710 
*INFO* f_actual_price4pm   : 701 
*INFO* f_actual_price4pmsi : 486.5085562718 
---- call prediction function shl_pm ---- 11:29:45
     previous_pred_les_level : 444.679036
     previous_pred_les_trend : 4.094460
     f_1_step_pred_les_level  : 472.783552
     f_1_step_pred_les_trend  : 9.797298
     les + misc               : 482.580849
     f_1_step_pred_price_inc  : 757.389299
     f_1_step_si              : 1.569456

<<<< Record No.:  1815 >>>>
2017-06
11:29:46
89100

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:46
in_current_price  : 89100
-------------------------------------------------
*INFO* f_actual_si         : 1.5694557710 
*INFO* f_1_step_si         : 1.6448651010 
*INFO* f_actual_price4pm   : 701 
*INFO* f_actual_price4pmsi : 446.6516438073 
---- call prediction function shl_pm ---- 11:29:46
     previous_pred_les_level : 472.783552
     previous_pred_les_trend : 9.797298
     f_1_step_pred_les_level  : 459.719822
     f_1_step_pred_les_trend  : 4.367376
     les + misc               : 464.087198
     f_1_step_pred_price_inc  : 763.360836
     f_1_step_si              : 1.644865

<<<< Record No.:  1816 >>>>
2017-06
11:29:47
89100

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:47
in_current_price  : 89100
-------------------------------------------------
*INFO* f_actual_si         : 1.6448651010 
*INFO* f_1_step_si         : 1.7484231600 
*INFO* f_actual_price4pm   : 701 
*INFO* f_actual_price4pmsi : 426.1747662917 
---- call prediction function shl_pm ---- 11:29:47
     previous_pred_les_level : 459.719822
     previous_pred_les_trend : 4.367376
     f_1_step_pred_les_level  : 439.964284
     f_1_step_pred_les_trend  : -1.362268
     les + misc               : 438.602017
     f_1_step_pred_price_inc  : 766.861924
     f_1_step_si              : 1.748423

<<<< Record No.:  1817 >>>>
2017-06
11:29:48
89100

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:48
in_current_price  : 89100
-------------------------------------------------
*INFO* f_actual_si         : 1.7484231600 
*INFO* f_1_step_si         : 1.7903136450 
*INFO* f_actual_price4pm   : 701 
*INFO* f_actual_price4pmsi : 400.9326895441 
---- call prediction function shl_pm ---- 11:29:48
     previous_pred_les_level : 439.964284
     previous_pred_les_trend : -1.362268
     f_1_step_pred_les_level  : 414.633786
     f_1_step_pred_les_trend  : -7.055171
     les + misc               : 407.578615
     f_1_step_pred_price_inc  : 729.693555
     f_1_step_si              : 1.790314

<<<< Record No.:  1818 >>>>
2017-06
11:29:49
89100

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:49
in_current_price  : 89100
-------------------------------------------------
*INFO* f_actual_si         : 1.7903136450 
*INFO* f_1_step_si         : 1.9309782790 
*INFO* f_actual_price4pm   : 701 
*INFO* f_actual_price4pmsi : 391.5515038149 
---- call prediction function shl_pm ---- 11:29:49
     previous_pred_les_level : 414.633786
     previous_pred_les_trend : -7.055171
     f_1_step_pred_les_level  : 397.380888
     f_1_step_pred_les_trend  : -9.477322
     les + misc               : 387.903566
     f_1_step_pred_price_inc  : 749.033361
     f_1_step_si              : 1.930978

In [107]:
# Upon receiving 11:29:50 second price, to predict till 11:30:00 <- ten-step forward price forecasting

for i in range(shl_global_parm_ccyy_mm_offset+50, shl_global_parm_ccyy_mm_offset+51): # use July 2015 data as simulatino
    print('\n<<<< Record No.: %5d >>>>' % i)
    print(shl_data_history_ts_process['ccyy-mm'][i]) # format: ccyy-mm
    print(shl_data_history_ts_process['time'][i]) # format: hh:mm:ss
    print(shl_data_history_ts_process['bid-price'][i]) # format: integer
    shl_predict_price_k_step(shl_data_history_ts_process['time'][i], shl_data_history_ts_process['bid-price'][i],10) # <- ten-step forward price forecasting


<<<< Record No.:  1819 >>>>
2017-06
11:29:50
89100

==>> Forecasting next   1 second/step... 
k =  1

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:50
in_current_price  : 89100
-------------------------------------------------
*INFO* f_actual_si         : 1.9309782790 
*INFO* f_1_step_si         : 2.0018259430 
*INFO* f_actual_price4pm   : 701 
*INFO* f_actual_price4pmsi : 363.0284232731 
---- call prediction function shl_pm ---- 11:29:50
*INFO* sec50_error    : 48.033361
*INFO* sec46_49_error : 213.305614
*INFO* shl_global_parm_short_weight_misc  : 52.267795
*INFO* shl_global_parm_short_weight_ratio : 1
     previous_pred_les_level : 397.380888
     previous_pred_les_trend : -9.477322
     f_1_step_pred_les_level  : 372.076016
     f_1_step_pred_les_trend  : -13.236661
     les + misc               : 360.299994
     f_1_step_pred_price_inc  : 721.257876
     f_1_step_si              : 2.001826

==>> Forecasting next   2 second/step... 
k =  2

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:51
in_current_price  : 89120
-------------------------------------------------
*INFO* f_actual_si         : 2.0018259430 
*INFO* f_1_step_si         : 2.0608409580 
*INFO* f_actual_price4pm   : 721 
*INFO* f_actual_price4pmsi : 360.2999944285 
---- call prediction function shl_pm ---- 11:29:51
*INFO* shl_global_parm_short_weight_ratio : 2
     previous_pred_les_level : 372.076016
     previous_pred_les_trend : -13.236661
     f_1_step_pred_les_level  : 359.768730
     f_1_step_pred_les_trend  : -13.015917
     les + misc               : 349.674093
     f_1_step_pred_price_inc  : 720.622693
     f_1_step_si              : 2.060841

==>> Forecasting next   3 second/step... 
k =  3

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:52
in_current_price  : 89119
-------------------------------------------------
*INFO* f_actual_si         : 2.0608409580 
*INFO* f_1_step_si         : 2.1669312840 
*INFO* f_actual_price4pm   : 720 
*INFO* f_actual_price4pmsi : 349.6740928917 
---- call prediction function shl_pm ---- 11:29:52
*INFO* shl_global_parm_short_weight_ratio : 3
     previous_pred_les_level : 359.768730
     previous_pred_les_trend : -13.015917
     f_1_step_pred_les_level  : 348.611564
     f_1_step_pred_les_trend  : -12.574429
     les + misc               : 340.419055
     f_1_step_pred_price_inc  : 737.664700
     f_1_step_si              : 2.166931

==>> Forecasting next   4 second/step... 
k =  4

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:53
in_current_price  : 89136
-------------------------------------------------
*INFO* f_actual_si         : 2.1669312840 
*INFO* f_1_step_si         : 2.2854831720 
*INFO* f_actual_price4pm   : 737 
*INFO* f_actual_price4pmsi : 340.4190552310 
---- call prediction function shl_pm ---- 11:29:53
*INFO* shl_global_parm_short_weight_ratio : 4
     previous_pred_les_level : 348.611564
     previous_pred_les_trend : -12.574429
     f_1_step_pred_les_level  : 338.825262
     f_1_step_pred_les_trend  : -11.912197
     les + misc               : 332.755626
     f_1_step_pred_price_inc  : 760.507383
     f_1_step_si              : 2.285483

==>> Forecasting next   5 second/step... 
k =  5

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:54
in_current_price  : 89159
-------------------------------------------------
*INFO* f_actual_si         : 2.2854831720 
*INFO* f_1_step_si         : 2.4051380830 
*INFO* f_actual_price4pm   : 760 
*INFO* f_actual_price4pmsi : 332.7556255554 
---- call prediction function shl_pm ---- 11:29:54
*INFO* shl_global_parm_short_weight_ratio : 5
     previous_pred_les_level : 338.825262
     previous_pred_les_trend : -11.912197
     f_1_step_pred_les_level  : 330.630568
     f_1_step_pred_les_trend  : -11.029220
     les + misc               : 326.904548
     f_1_step_pred_price_inc  : 786.250578
     f_1_step_si              : 2.405138

==>> Forecasting next   6 second/step... 
k =  6

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:55
in_current_price  : 89185
-------------------------------------------------
*INFO* f_actual_si         : 2.4051380830 
*INFO* f_1_step_si         : 2.5395496220 
*INFO* f_actual_price4pm   : 786 
*INFO* f_actual_price4pmsi : 326.9045479737 
---- call prediction function shl_pm ---- 11:29:55
*INFO* shl_global_parm_short_weight_ratio : 6
     previous_pred_les_level : 330.630568
     previous_pred_les_trend : -11.029220
     f_1_step_pred_les_level  : 324.248227
     f_1_step_pred_les_trend  : -9.925500
     les + misc               : 323.086567
     f_1_step_pred_price_inc  : 820.494368
     f_1_step_si              : 2.539550

==>> Forecasting next   7 second/step... 
k =  7

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:56
in_current_price  : 89219
-------------------------------------------------
*INFO* f_actual_si         : 2.5395496220 
*INFO* f_1_step_si         : 2.6922988440 
*INFO* f_actual_price4pm   : 820 
*INFO* f_actual_price4pmsi : 323.0865665951 
---- call prediction function shl_pm ---- 11:29:56
*INFO* shl_global_parm_short_weight_ratio : 7
     previous_pred_les_level : 324.248227
     previous_pred_les_trend : -9.925500
     f_1_step_pred_les_level  : 319.898981
     f_1_step_pred_les_trend  : -8.601035
     les + misc               : 321.522426
     f_1_step_pred_price_inc  : 865.634455
     f_1_step_si              : 2.692299

==>> Forecasting next   8 second/step... 
k =  8

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:57
in_current_price  : 89264
-------------------------------------------------
*INFO* f_actual_si         : 2.6922988440 
*INFO* f_1_step_si         : 2.7559213250 
*INFO* f_actual_price4pm   : 865 
*INFO* f_actual_price4pmsi : 321.5224255283 
---- call prediction function shl_pm ---- 11:29:57
*INFO* shl_global_parm_short_weight_ratio : 8
     previous_pred_les_level : 319.898981
     previous_pred_les_trend : -8.601035
     f_1_step_pred_les_level  : 317.803576
     f_1_step_pred_les_trend  : -7.055826
     les + misc               : 322.432869
     f_1_step_pred_price_inc  : 888.599619
     f_1_step_si              : 2.755921

==>> Forecasting next   9 second/step... 
k =  9

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:58
in_current_price  : 89287
-------------------------------------------------
*INFO* f_actual_si         : 2.7559213250 
*INFO* f_1_step_si         : 2.9170470950 
*INFO* f_actual_price4pm   : 888 
*INFO* f_actual_price4pmsi : 322.4328688824 
---- call prediction function shl_pm ---- 11:29:58
*INFO* shl_global_parm_short_weight_ratio : 9
     previous_pred_les_level : 317.803576
     previous_pred_les_trend : -7.055826
     f_1_step_pred_les_level  : 318.182755
     f_1_step_pred_les_trend  : -5.289873
     les + misc               : 326.038641
     f_1_step_pred_price_inc  : 951.070070
     f_1_step_si              : 2.917047

==>> Forecasting next  10 second/step... 
k =  10

+-----------------------------------------------+
| shl_predict_price()                           |
+-----------------------------------------------+

current_ccyy_mm   : 2017-06
in_current_time   : 11:29:59
in_current_price  : 89350
-------------------------------------------------
*INFO* f_actual_si         : 2.9170470950 
*INFO* f_1_step_si         : 3.0648617500 
*INFO* f_actual_price4pm   : 951 
*INFO* f_actual_price4pmsi : 326.0386407663 
---- call prediction function shl_pm ---- 11:29:59
*INFO* shl_global_parm_short_weight_ratio : 10
     previous_pred_les_level : 318.182755
     previous_pred_les_trend : -5.289873
     f_1_step_pred_les_level  : 321.257262
     f_1_step_pred_les_trend  : -3.303176
     les + misc               : 332.560485
     f_1_step_pred_price_inc  : 1019.251911
     f_1_step_si              : 3.064862

In [108]:
# shl_data_pm_1_step.tail(11)

In [109]:
# shl_data_pm_k_step.tail(11)

In [ ]:

MISC - Validation


In [44]:
%matplotlib inline
import matplotlib.pyplot as plt

In [110]:
shl_data_pm_k_step_test = shl_data_pm_k_step.copy()

shl_data_pm_k_step_test.index = shl_data_pm_k_step_test.index + 1

shl_data_pm_k_step_test


Out[110]:
bid ccyy-mm f_1_step_pred_adj_misc f_1_step_pred_les f_1_step_pred_les_level f_1_step_pred_les_trend f_1_step_pred_price f_1_step_pred_price_inc f_1_step_pred_price_rounded f_1_step_pred_set_price_rounded f_1_step_si f_actual_price4pm f_actual_price4pmsi f_actual_si time
1 88400.000000 2017-06 0.000000 419.777744 419.777744 0.000000 88405.238354 6.238354 88400.0 88700.0 0.014861 1.000000 419.777744 0.002382 11:29:01
2 88500.000000 2017-06 0.000000 5440.681024 4477.011976 963.669047 88528.319846 129.319846 88500.0 88800.0 0.023769 101.000000 6796.271794 0.014861 11:29:02
3 88500.000000 2017-06 0.000000 5466.185829 4682.579968 783.605861 88568.142068 169.142068 88600.0 88900.0 0.030943 101.000000 4249.222361 0.023769 11:29:03
4 88500.000000 2017-06 0.000000 4515.796200 4064.998538 450.797661 88576.073888 177.073888 88600.0 88900.0 0.039212 101.000000 3264.029899 0.030943 11:29:04
5 88500.000000 2017-06 0.000000 3438.973913 3281.374502 157.599410 88532.325339 133.325339 88500.0 88800.0 0.038769 101.000000 2575.735026 0.039212 11:29:05
6 88500.000000 2017-06 0.000000 2940.036380 2908.447031 31.589349 88621.660580 222.660580 88600.0 88900.0 0.075734 101.000000 2605.178941 0.038769 11:29:06
7 88500.000000 2017-06 0.000000 1706.717123 1917.903466 -211.186344 88559.768399 160.768399 88600.0 88900.0 0.094197 101.000000 1333.615831 0.075734 11:29:07
8 88500.000000 2017-06 0.000000 995.919334 1302.996807 -307.077473 88531.830841 132.830841 88500.0 88800.0 0.133375 101.000000 1072.215873 0.094197 11:29:08
9 88500.000000 2017-06 0.000000 500.921755 844.066999 -343.145244 88501.280075 102.280075 88500.0 88800.0 0.204184 101.000000 757.262787 0.133375 11:29:09
10 88500.000000 2017-06 0.000000 152.840066 496.932769 -344.092703 88434.484784 35.484784 88400.0 88700.0 0.232169 101.000000 494.652522 0.204184 11:29:10
11 88500.000000 2017-06 0.000000 30.943821 332.390044 -301.446223 88408.116219 9.116219 88400.0 88700.0 0.294605 101.000000 435.027216 0.232169 11:29:11
12 88500.000000 2017-06 0.000000 -24.919618 229.391555 -254.311173 88390.306404 -8.693596 88400.0 88700.0 0.348866 101.000000 342.831360 0.294605 11:29:12
13 88500.000000 2017-06 0.000000 -31.646502 175.145469 -206.791971 88387.697581 -11.302419 88400.0 88700.0 0.357146 101.000000 289.509810 0.348866 11:29:13
14 88500.000000 2017-06 0.000000 9.157361 168.427915 -159.270554 88402.457088 3.457088 88400.0 88700.0 0.377520 101.000000 282.797588 0.357146 11:29:14
15 88500.000000 2017-06 0.000000 53.335761 173.558070 -120.222309 88420.829867 21.829867 88400.0 88700.0 0.409291 101.000000 267.535380 0.377520 11:29:15
16 88500.000000 2017-06 0.000000 85.423541 176.412760 -90.989219 88434.934684 35.934684 88400.0 88700.0 0.420665 101.000000 246.767963 0.409291 11:29:16
17 88500.000000 2017-06 0.000000 116.224760 183.838568 -67.613808 88452.911408 53.911408 88500.0 88800.0 0.463855 101.000000 240.096109 0.420665 11:29:17
18 88500.000000 2017-06 0.000000 128.545327 180.817218 -52.271891 88462.651247 63.651247 88500.0 88800.0 0.495166 101.000000 217.740571 0.463855 11:29:18
19 88500.000000 2017-06 0.000000 135.665084 176.537852 -40.872768 88467.926126 68.926126 88500.0 88800.0 0.508061 101.000000 203.972091 0.495166 11:29:19
20 88600.000000 2017-06 0.000000 299.484391 301.070320 -1.585930 88558.207505 159.207505 88600.0 88900.0 0.531605 201.000000 395.621854 0.508061 11:29:20
21 88600.000000 2017-06 0.000000 359.801056 349.505933 10.295123 88604.968835 205.968835 88600.0 88900.0 0.572452 201.000000 378.100032 0.531605 11:29:21
22 88600.000000 2017-06 0.000000 363.261543 354.278202 8.983341 88611.279965 212.279965 88600.0 88900.0 0.584372 201.000000 351.121141 0.572452 11:29:22
23 88600.000000 2017-06 0.000000 357.045778 350.979622 6.066156 88612.032135 213.032135 88600.0 88900.0 0.596652 201.000000 343.958838 0.584372 11:29:23
24 88600.000000 2017-06 0.000000 347.232999 344.214510 3.018489 88616.930580 217.930580 88600.0 88900.0 0.627621 201.000000 336.879699 0.596652 11:29:24
25 88600.000000 2017-06 0.000000 329.010508 330.068830 -1.058322 88616.671505 217.671505 88600.0 88900.0 0.661594 201.000000 320.257179 0.627621 11:29:25
26 88700.000000 2017-06 0.000000 427.127053 409.150603 17.976450 88689.279252 290.279252 88700.0 89000.0 0.679609 301.000000 454.961540 0.661594 11:29:26
27 88700.000000 2017-06 0.000000 457.524774 437.164292 20.360482 88719.672414 320.672414 88700.0 89000.0 0.700885 301.000000 442.901936 0.679609 11:29:27
28 88700.000000 2017-06 0.000000 455.784326 439.665706 16.118619 88729.808615 330.808615 88700.0 89000.0 0.725801 301.000000 429.456826 0.700885 11:29:28
29 88700.000000 2017-06 0.000000 439.564118 429.652335 9.911783 88724.568887 325.568887 88700.0 89000.0 0.740663 301.000000 414.714357 0.725801 11:29:29
30 88700.000000 2017-06 0.000000 423.356408 418.457777 4.898632 88727.087963 328.087963 88700.0 89000.0 0.774969 301.000000 406.392639 0.740663 11:29:30
31 88800.000000 2017-06 0.000000 502.337427 483.220058 19.117369 88799.246560 400.246560 88800.0 89100.0 0.796768 401.000000 517.440256 0.774969 11:29:31
32 88800.000000 2017-06 0.000000 522.199384 502.939106 19.260279 88829.288165 430.288165 88800.0 89100.0 0.823992 401.000000 503.283046 0.796768 11:29:32
33 88800.000000 2017-06 0.000000 513.471847 499.583309 13.888538 88833.216726 434.216726 88800.0 89100.0 0.845649 401.000000 486.655154 0.823992 11:29:33
34 88800.000000 2017-06 0.000000 496.431318 488.479040 7.952278 88831.339397 432.339397 88800.0 89100.0 0.870895 401.000000 474.192260 0.845649 11:29:34
35 88800.000000 2017-06 0.000000 476.048487 473.534606 2.513881 88840.704918 441.704918 88800.0 89100.0 0.927857 401.000000 460.446029 0.870895 11:29:35
36 88800.000000 2017-06 0.000000 444.018916 448.135008 -4.116093 88825.982847 426.982847 88800.0 89100.0 0.961632 401.000000 432.178668 0.927857 11:29:36
37 88800.000000 2017-06 0.000000 418.627426 426.826936 -8.199510 88808.727419 409.727419 88800.0 89100.0 0.978740 401.000000 416.999387 0.961632 11:29:37
38 88800.000000 2017-06 0.000000 403.406603 412.953723 -9.547120 88797.183235 398.183235 88800.0 89100.0 0.987052 401.000000 409.710432 0.978740 11:29:38
39 88800.000000 2017-06 0.000000 396.106522 405.222365 -9.115843 88806.090054 407.090054 88800.0 89100.0 1.027729 401.000000 406.260319 0.987052 11:29:39
40 88800.000000 2017-06 0.000000 382.324703 392.336093 -10.011390 88809.342154 410.342154 88800.0 89100.0 1.073282 401.000000 390.180781 1.027729 11:29:40
41 88800.000000 2017-06 0.000000 365.459485 376.786340 -11.326855 88801.528482 402.528482 88800.0 89100.0 1.101431 401.000000 373.620415 1.073282 11:29:41
42 88900.000000 2017-06 0.000000 424.529468 422.344959 2.184509 88893.000484 494.000484 88900.0 89200.0 1.163642 501.000000 454.862724 1.101431 11:29:42
43 88900.000000 2017-06 0.000000 431.450377 428.356804 3.093573 88949.967120 550.967120 88900.0 89200.0 1.277012 501.000000 430.544646 1.163642 11:29:43
44 89000.000000 2017-06 0.000000 465.394334 456.379603 9.014731 89045.205651 646.205651 89000.0 89300.0 1.388512 601.000000 470.630038 1.277012 11:29:44
45 89000.000000 2017-06 0.000000 448.773496 444.679036 4.094460 89045.628341 646.628341 89000.0 89300.0 1.440879 601.000000 432.837433 1.388512 11:29:45
46 89100.000000 2017-06 0.000000 482.580849 472.783552 9.797298 89156.389299 757.389299 89200.0 89500.0 1.569456 701.000000 486.508556 1.440879 11:29:46
47 89100.000000 2017-06 0.000000 464.087198 459.719822 4.367376 89162.360836 763.360836 89200.0 89500.0 1.644865 701.000000 446.651644 1.569456 11:29:47
48 89100.000000 2017-06 0.000000 438.602017 439.964284 -1.362268 89165.861924 766.861924 89200.0 89500.0 1.748423 701.000000 426.174766 1.644865 11:29:48
49 89100.000000 2017-06 0.000000 407.578615 414.633786 -7.055171 89128.693555 729.693555 89100.0 89400.0 1.790314 701.000000 400.932690 1.748423 11:29:49
50 89100.000000 2017-06 0.000000 387.903566 397.380888 -9.477322 89148.033361 749.033361 89100.0 89400.0 1.930978 701.000000 391.551504 1.790314 11:29:50
51 89100.000000 2017-06 1.460640 358.839354 372.076016 -13.236661 89120.257876 721.257876 89100.0 89400.0 2.001826 701.000000 363.028423 1.930978 11:29:51
52 89120.257876 2017-06 2.921280 346.752813 359.768730 -13.015917 89119.622693 720.622693 89100.0 89400.0 2.060841 721.257876 360.299994 2.001826 11:29:52
53 89119.622693 2017-06 4.381920 336.037135 348.611564 -12.574429 89136.664700 737.664700 89100.0 89400.0 2.166931 720.622693 349.674093 2.060841 11:29:53
54 89136.664700 2017-06 5.842560 326.913066 338.825262 -11.912197 89159.507383 760.507383 89200.0 89500.0 2.285483 737.664700 340.419055 2.166931 11:29:54
55 89159.507383 2017-06 7.303200 319.601348 330.630568 -11.029220 89185.250578 786.250578 89200.0 89500.0 2.405138 760.507383 332.755626 2.285483 11:29:55
56 89185.250578 2017-06 8.763840 314.322727 324.248227 -9.925500 89219.494368 820.494368 89200.0 89500.0 2.539550 786.250578 326.904548 2.405138 11:29:56
57 89219.494368 2017-06 10.224480 311.297946 319.898981 -8.601035 89264.634455 865.634455 89300.0 89600.0 2.692299 820.494368 323.086567 2.539550 11:29:57
58 89264.634455 2017-06 11.685119 310.747749 317.803576 -7.055826 89287.599619 888.599619 89300.0 89600.0 2.755921 865.634455 321.522426 2.692299 11:29:58
59 89287.599619 2017-06 13.145759 312.892881 318.182755 -5.289873 89350.070070 951.070070 89400.0 89700.0 2.917047 888.599619 322.432869 2.755921 11:29:59
60 89350.070070 2017-06 14.606399 317.954086 321.257262 -3.303176 89418.251911 1019.251911 89400.0 89700.0 3.064862 951.070070 326.038641 2.917047 11:30:00

In [111]:
# bid is predicted bid-price from shl_pm
plt.figure(figsize=(12,6))
plt.plot(shl_data_pm_k_step['bid'])
# plt.plot(shl_data_pm_1_step_k_step['f_1_step_pred_price'].shift(1))
plt.plot(shl_data_pm_k_step_test['f_1_step_pred_price'])

# bid is actual bid-price from raw dataset
shl_data_actual_bid = shl_data_history_ts_process[shl_global_parm_ccyy_mm_offset:shl_global_parm_ccyy_mm_offset+61].copy()
shl_data_actual_bid.reset_index(inplace=True)
plt.figure(figsize=(12,6))
plt.plot(shl_data_actual_bid['bid-price'])
plt.plot(shl_data_pm_k_step_test['f_1_step_pred_price'])


Out[111]:
[<matplotlib.lines.Line2D at 0x7f1aeb01d5c0>]

In [ ]:


In [112]:
# pd.concat([shl_data_actual_bid['bid-price'], shl_data_pm_k_step_test['f_1_step_pred_price'], shl_data_pm_k_step_test['f_1_step_pred_price'] - shl_data_actual_bid['bid-price']], axis=1, join='inner')
pd.concat([shl_data_actual_bid['bid-price'].tail(11), shl_data_pm_k_step_test['f_1_step_pred_price'].tail(11), shl_data_pm_k_step_test['f_1_step_pred_price'].tail(11) - shl_data_actual_bid['bid-price'].tail(11)], axis=1, join='inner')


Out[112]:
bid-price f_1_step_pred_price 0
50 89100 89148.033361 48.033361
51 89100 89120.257876 20.257876
52 89100 89119.622693 19.622693
53 89200 89136.664700 -63.335300
54 89200 89159.507383 -40.492617
55 89200 89185.250578 -14.749422
56 89200 89219.494368 19.494368
57 89300 89264.634455 -35.365545
58 89300 89287.599619 -12.400381
59 89300 89350.070070 50.070070
60 89400 89418.251911 18.251911

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

shl_pm Prediction Module Parm:


In [ ]:
# create default global base price
shl_global_parm_base_price = 10000000

shl_global_parm_dynamic_increment = shl_intra_fetch_di(shl_global_parm_ccyy_mm, shl_data_parm_month)

shl_global_parm_alpha = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['alpha']
shl_global_parm_beta  = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['beta']
shl_global_parm_gamma = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['gamma']
shl_global_parm_sec57_weight = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['sec57-weight']
shl_global_parm_month_weight = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['month-weight']
shl_global_parm_short_weight = shl_data_parm_month[shl_data_parm_month['ccyy-mm'] == shl_global_parm_ccyy_mm].iloc[0]['short-weight']

# create default average error between 46~50 seconds:
shl_global_parm_short_weight_misc = 0

print('=================================================')
print('  Global Parameters for Month : %s' % shl_global_parm_ccyy_mm)
print('-------------------------------------------------')

print('shl_global_parm_dynamic_increment : %d' % shl_global_parm_dynamic_increment)

print('shl_global_parm_alpha             : %0.15f' % shl_global_parm_alpha) # used in forecasting
print('shl_global_parm_beta              : %0.15f' % shl_global_parm_beta)  # used in forecasting
print('shl_global_parm_gamma             : %0.15f' % shl_global_parm_gamma) # used in forecasting
print('shl_global_parm_sec57_weight      : %f' % shl_global_parm_sec57_weight) # used in training a model
print('shl_global_parm_month_weight      : %f' % shl_global_parm_month_weight) # used in training a model
print('shl_global_parm_short_weight      : %f' % shl_global_parm_short_weight) # used in training a model
print('=================================================')

# plot seasonality index
plt.figure(figsize=(6,3))
plt.plot(shl_data_parm_si[(shl_data_parm_si['ccyy-mm'] == shl_global_parm_ccyy_mm)]['si'])

In [ ]:

Start of shl_sm


In [ ]:
# 11:29:00~11:29:50

shl_global_parm_short_weight_misc = 0

# for i in range(1830, 1830+51): # use July 2015 data as simulatino
for i in range(shl_global_parm_ccyy_mm_offset, shl_global_parm_ccyy_mm_offset+51): # use July 2015 data as simulatino
    print('\n<<<< Record No.: %5d >>>>' % i)
    print(shl_data_history_ts_process['ccyy-mm'][i]) # format: ccyy-mm
    print(shl_data_history_ts_process['time'][i]) # format: hh:mm:ss
    print(shl_data_history_ts_process['bid-price'][i]) # format: integer
#     print(shl_data_history_ts_process['ref-price'][i])
    
    # capture & calculate 11:29:00 bid price - 1 = base price
    if shl_data_history_ts_process['time'][i] == '11:29:00':
        shl_global_parm_base_price = shl_data_history_ts_process['bid-price'][i] -1 
        print('*INFO* shl_global_parm_base_price : %d ' % shl_global_parm_base_price)

        
    print('---- Pre-Process ---')
    # pre-process: ccyy-mm-hh:mm:ss
    f_actual_datetime = shl_data_history_ts_process['ccyy-mm'][i] + ' ' + shl_data_history_ts_process['time'][i]
    f_actual_price4pm = shl_data_history_ts_process['bid-price'][i] -  shl_global_parm_base_price
    print('*INFO* f_actual_datetime   : %s ' %  f_actual_datetime)
    print('*INFO* f_actual_price4pm   : %d ' % f_actual_price4pm)
    
    # get Seasonality-Index
    f_actual_si = shl_intra_fetch_si(shl_data_history_ts_process['ccyy-mm'][i]
                                         ,shl_data_history_ts_process['time'][i]
                                         ,shl_data_parm_si)
    print('*INFO* f_actual_si         : %0.10f ' %  f_actual_si)
    f_1_step_si = shl_intra_fetch_si(shl_data_history_ts_process['ccyy-mm'][i]
                                         ,shl_data_history_ts_process['time'][i+1]
                                         ,shl_data_parm_si)
    print('*INFO* f_1_step_si         : %0.10f ' %  f_1_step_si)
    # get de-seasoned price: price4pmsi
    f_actual_price4pmsi = f_actual_price4pm / f_actual_si
    print('*INFO* f_actual_price4pmsi : %0.10f ' % f_actual_price4pmsi)
    


    if shl_data_history_ts_process['time'][i] == '11:29:00':
        shl_data_pm_1_step = pd.DataFrame() # initialize prediction dataframe at 11:29:00
        print('---- call prediction function shl_pm ---- %s' % shl_data_history_ts_process['time'][i])
        f_1_step_pred_les_level = f_actual_price4pmsi
        f_1_step_pred_les_trend = 0
        f_1_step_pred_les = f_1_step_pred_les_level + f_1_step_pred_les_trend
        f_1_step_pred_adj_misc = 0
#         f_1_step_pred_price_inc = (f_1_step_pred_les + f_1_step_pred_adj_misc) * f_actual_si
        f_1_step_pred_price_inc = (f_1_step_pred_les + f_1_step_pred_adj_misc) * f_1_step_si
        f_1_step_pred_price = f_1_step_pred_price_inc + shl_global_parm_base_price
        f_1_step_pred_price_rounded = round(f_1_step_pred_price/100, 0) * 100
        f_1_step_pred_dynamic_increment = shl_global_parm_dynamic_increment
        f_1_step_pred_set_price_rounded = f_1_step_pred_price_rounded + f_1_step_pred_dynamic_increment
        f_current_step_pred_les = f_1_step_pred_les
        f_current_step_pred_les_misc = f_1_step_pred_adj_misc
        f_current_step_pred_price_inc = f_1_step_pred_price_inc
        f_current_step_pred_price = f_1_step_pred_price
        f_current_step_pred_price_rounded = f_1_step_pred_price_rounded
        f_current_step_pred_dynamic_increment = f_1_step_pred_dynamic_increment # +200 or + 300
        f_current_step_pred_set_price_rounded = f_1_step_pred_set_price_rounded
        f_current_step_error = f_current_step_pred_price_inc - f_actual_price4pm # current second forecast error
    else:
        previous_time = shl_intra_fetch_previous_n_sec_time_as_str(shl_data_history_ts_process['time'][i], 1)
        previous_pred_les_level = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                            & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_les_level']
        print('     previous_pred_les_level : %f' % previous_pred_les_level)
        
        previous_pred_les_trend = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                            & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_les_trend']
        print('     previous_pred_les_trend : %f' % previous_pred_les_trend)
        
        f_current_step_pred_les = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_les']
        f_current_step_pred_les_misc = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_adj_misc']
        f_current_step_pred_price_inc = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_price_inc']
        f_current_step_pred_price = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_price']
        f_current_step_pred_price_rounded = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_price_rounded']
        f_current_step_pred_dynamic_increment = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_dynamic_increment']
        f_current_step_pred_set_price_rounded = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_set_price_rounded']

        f_current_step_error = f_current_step_pred_price_inc - f_actual_price4pm # current second forecast error
            
        if shl_data_history_ts_process['time'][i] == '11:29:50':
            # function to get average forecast error between 46~50 seconds: mean(f_current_step_error)
            shl_global_parm_short_weight_misc = (shl_data_pm_1_step.iloc[46:50]['f_current_step_error'].sum() \
                                             + f_current_step_error) / 5
            print('*INFO* shl_global_parm_short_weight_misc : %f' % shl_global_parm_short_weight_misc)
            
#         call prediction functino shl_pm, forcaste next k=1 step
        print('---- call prediction function shl_pm ---- %s' % shl_data_history_ts_process['time'][i])
        
        f_1_step_pred_les_level = shl_global_parm_alpha * f_actual_price4pmsi \
                                    + (1 - shl_global_parm_alpha) * (previous_pred_les_level + previous_pred_les_trend)
        print('     f_1_step_pred_les_level  : %f' % f_1_step_pred_les_level)
        
        f_1_step_pred_les_trend = shl_global_parm_beta * (f_1_step_pred_les_level - previous_pred_les_level) \
                                    + (1 - shl_global_parm_beta) * previous_pred_les_trend
        print('     f_1_step_pred_les_trend  : %f' % f_1_step_pred_les_trend)
        
        
        print('global shl_global_parm_alpha : ', shl_global_parm_alpha)
        print('global shl_global_parm_beta  : ', shl_global_parm_beta)
        
        f_1_step_pred_les = f_1_step_pred_les_level + f_1_step_pred_les_trend
        
        f_1_step_pred_adj_misc = shl_global_parm_short_weight_misc * shl_global_parm_short_weight * shl_global_parm_gamma
        
#         f_1_step_pred_price_inc = (f_1_step_pred_les + f_1_step_pred_adj_misc) * f_actual_si
        f_1_step_pred_price_inc = (f_1_step_pred_les + f_1_step_pred_adj_misc) * f_1_step_si
        f_1_step_pred_price = f_1_step_pred_price_inc + shl_global_parm_base_price
        f_1_step_pred_price_rounded = round(f_1_step_pred_price/100, 0) * 100
        f_1_step_pred_dynamic_increment = shl_global_parm_dynamic_increment
        f_1_step_pred_set_price_rounded = f_1_step_pred_price_rounded + f_1_step_pred_dynamic_increment
   
        
    # write results to shl_pm dataframe
            
    shl_data_pm_1_step_current = {
                         'ccyy-mm' : shl_data_history_ts_process['ccyy-mm'][i]
                        ,'time' : shl_data_history_ts_process['time'][i]
                        ,'bid' : shl_data_history_ts_process['bid-price'][i]
                        ,'datetime' : f_actual_datetime
                        ,'f_actual_price4pm' : f_actual_price4pm
                        ,'f_actual_si' : f_actual_si
                        ,'f_1_step_si' : f_1_step_si
                        ,'f_actual_price4pmsi' :  f_actual_price4pmsi
                        ,'f_1_step_pred_les_level' : f_1_step_pred_les_level
                        ,'f_1_step_pred_les_trend' : f_1_step_pred_les_trend
                        ,'f_1_step_pred_les' : f_1_step_pred_les
                        ,'f_1_step_pred_adj_misc' : f_1_step_pred_adj_misc
                        ,'f_1_step_pred_price_inc' : f_1_step_pred_price_inc
                        ,'f_1_step_pred_price' : f_1_step_pred_price
                        ,'f_1_step_pred_price_rounded' : f_1_step_pred_price_rounded
                        ,'f_1_step_pred_dynamic_increment' : f_1_step_pred_dynamic_increment # +200 or + 300
                        ,'f_1_step_pred_set_price_rounded' : f_1_step_pred_set_price_rounded
                        ,'f_current_step_pred_les' : f_current_step_pred_les
                        ,'f_current_step_pred_les_misc' : f_current_step_pred_les_misc
                        ,'f_current_step_pred_price_inc' : f_current_step_pred_price_inc
                        ,'f_current_step_pred_price' : f_current_step_pred_price
                        ,'f_current_step_pred_price_rounded' : f_current_step_pred_price_rounded
                        ,'f_current_step_pred_dynamic_increment' : f_current_step_pred_dynamic_increment # +200 or + 300
                        ,'f_current_step_pred_set_price_rounded' : f_current_step_pred_set_price_rounded
                        ,'f_current_step_error' : f_current_step_error
                        }
    shl_data_pm_1_step =  shl_data_pm_1_step.append(shl_data_pm_1_step_current, ignore_index=True)

In [ ]:
# shl_data_pm_1_step.iloc[2]
shl_data_pm_1_step.head()

In [ ]:
shl_data_pm_1_step.tail()

In [ ]:
plt.figure(figsize=(12,6))
plt.plot(shl_data_pm_1_step['bid'])
plt.plot(shl_data_pm_1_step['f_current_step_pred_price'])
# plt.plot(shl_data_pm_1_step['f_1_step_pred_price'].shift(1))

plt.figure(figsize=(12,6))
plt.plot(shl_data_pm_1_step['bid'])
plt.plot(shl_data_pm_1_step['f_current_step_pred_price'])
plt.plot(shl_data_pm_1_step['f_1_step_pred_price'])

In [ ]:

Start of prediction module: shl_pm


In [ ]:
# 11:29:51~
def predict_k_step_price(shl_data_pm_1_step, ccyy_mm, time, k):
    print('month & time  : ', ccyy_mm, time)
    print()
    
#     shl_data_pm_1_step_k = pd.DataFrame() # initialize prediction dataframe
    for sec in range(0, k):
        
        
        print('delta second(s) : ', sec)
        current_time  = shl_intra_fetch_future_n_sec_time_as_str(time, sec)
        print('current_time  : %s' % current_time)
        f_1_step_time  = shl_intra_fetch_future_n_sec_time_as_str(current_time, 1)
        print('f_1_step_time  : %s' % f_1_step_time)
        previous_time = shl_intra_fetch_previous_n_sec_time_as_str(current_time, 1)
        print('previous_time : %s' % previous_time)

        previous_pred_les_level = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_global_parm_ccyy_mm) \
                                            & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_les_level']
        print('     previous_pred_les_level : %f' % previous_pred_les_level)
        
        previous_pred_les_trend = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_global_parm_ccyy_mm) \
                                            & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_les_trend']
        print('     previous_pred_les_trend : %f' % previous_pred_les_trend)


        print('---- Pre-Process ---')
        ############ use predicted value for boost-trap
        previous_pred_price = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_global_parm_ccyy_mm) \
                                            & (shl_data_pm_1_step['time'] == previous_time)].iloc[0]['f_1_step_pred_price']
        # pre-process: ccyy-mm-hh:mm:ss
        f_actual_datetime = shl_global_parm_ccyy_mm + ' ' + current_time
#         f_actual_price4pm = shl_data_history_ts_process['bid-price'][i] -  shl_global_parm_base_price
        f_actual_price4pm = previous_pred_price -  shl_global_parm_base_price
        print('*INFO* f_actual_datetime   : %s ' %  f_actual_datetime)
        print('*INFO* previous_pred_price: %s ' %  previous_pred_price)
        print('*INFO* f_actual_price4pm   : %d ' % f_actual_price4pm)

        # get Seasonality-Index
        f_actual_si = shl_intra_fetch_si(shl_global_parm_ccyy_mm
                                             ,current_time
                                             ,shl_data_parm_si)
        try:
            f_1_step_si = shl_intra_fetch_si(shl_global_parm_ccyy_mm
                                                 ,f_1_step_time
                                                 ,shl_data_parm_si)
        except:
            f_1_step_si = shl_intra_fetch_si(shl_global_parm_ccyy_mm
                                                 ,current_time
                                                 ,shl_data_parm_si)            

        print('*INFO* f_actual_si         : %0.10f ' %  f_actual_si)
        # get de-seasoned price: price4pmsi
        f_actual_price4pmsi = f_actual_price4pm / f_actual_si
        print('*INFO* f_actual_price4pmsi : %0.10f ' % f_actual_price4pmsi)

        f_current_step_pred_les = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_les']
        f_current_step_pred_les_misc = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_adj_misc']
        f_current_step_pred_price_inc = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_price_inc']
        f_current_step_pred_price = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_price']
        f_current_step_pred_price_rounded = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_price_rounded']
        f_current_step_pred_dynamic_increment = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_dynamic_increment']
        f_current_step_pred_set_price_rounded = shl_data_pm_1_step[(shl_data_pm_1_step['ccyy-mm'] == shl_data_history_ts_process['ccyy-mm'][i]) \
                                                    & (shl_data_pm_1_step['time'] ==previous_time)].iloc[0]['f_1_step_pred_set_price_rounded']
        
        f_current_step_error = f_current_step_pred_price_inc - f_actual_price4pm # current second forecast error
        

        f_1_step_pred_les_level = shl_global_parm_alpha * f_actual_price4pmsi \
                                    + (1 - shl_global_parm_alpha) * (previous_pred_les_level + previous_pred_les_trend)
        print('     f_1_step_pred_les_level  : %f' % f_1_step_pred_les_level)
        f_1_step_pred_les_trend = shl_global_parm_beta * (f_1_step_pred_les_level - previous_pred_les_level) \
                                    + (1 - shl_global_parm_beta) * previous_pred_les_trend
        print('     f_1_step_pred_les_trend  : %f' % f_1_step_pred_les_trend)
        f_1_step_pred_les = f_1_step_pred_les_level + f_1_step_pred_les_trend
        
#         f_1_step_pred_adj_misc = 0
        f_1_step_pred_adj_misc = shl_global_parm_short_weight_misc * shl_global_parm_short_weight * (sec+2) * shl_global_parm_gamma
        
#         f_1_step_pred_price_inc = (f_1_step_pred_les + f_1_step_pred_adj_misc) * f_actual_si
        f_1_step_pred_price_inc = (f_1_step_pred_les + f_1_step_pred_adj_misc) * f_1_step_si
        f_1_step_pred_price = f_1_step_pred_price_inc + shl_global_parm_base_price
        f_1_step_pred_price_rounded = round(f_1_step_pred_price/100, 0) * 100
        f_1_step_pred_dynamic_increment = shl_global_parm_dynamic_increment
        f_1_step_pred_set_price_rounded = f_1_step_pred_price_rounded + f_1_step_pred_dynamic_increment 

#         write results to shl_pm dataframe
        shl_data_pm_1_step_current = {
                             'ccyy-mm' : shl_global_parm_ccyy_mm
                            ,'time' : current_time
                            ,'bid' : previous_pred_price
                            ,'datetime' : f_actual_datetime
                            ,'f_actual_price4pm' : f_actual_price4pm
                            ,'f_actual_si' : f_actual_si
                            ,'f_1_step_si' : f_1_step_si
                            ,'f_actual_price4pmsi' :  f_actual_price4pmsi
                            ,'f_1_step_pred_les_level' : f_1_step_pred_les_level
                            ,'f_1_step_pred_les_trend' : f_1_step_pred_les_trend
                            ,'f_1_step_pred_les' : f_1_step_pred_les
                            ,'f_1_step_pred_adj_misc' : f_1_step_pred_adj_misc
                            ,'f_1_step_pred_price_inc' : f_1_step_pred_price_inc
                            ,'f_1_step_pred_price' : f_1_step_pred_price
                            ,'f_1_step_pred_price_rounded' : f_1_step_pred_price_rounded
                            ,'f_1_step_pred_dynamic_increment' : f_1_step_pred_dynamic_increment # +200 or + 300
                            ,'f_1_step_pred_set_price_rounded' : f_1_step_pred_set_price_rounded
                            ,'f_current_step_pred_les' : f_current_step_pred_les
                            ,'f_current_step_pred_les_misc' : f_current_step_pred_les_misc
                            ,'f_current_step_pred_price_inc' : f_current_step_pred_price_inc
                            ,'f_current_step_pred_price' : f_current_step_pred_price
                            ,'f_current_step_pred_price_rounded' : f_current_step_pred_price_rounded
                            ,'f_current_step_pred_dynamic_increment' : f_current_step_pred_dynamic_increment # +200 or + 300
                            ,'f_current_step_pred_set_price_rounded' : f_current_step_pred_set_price_rounded
                            ,'f_current_step_error' : f_current_step_error
                            }
        print('---------------------------')
        shl_data_pm_1_step =  shl_data_pm_1_step.append(shl_data_pm_1_step_current, ignore_index=True)
        
    return shl_data_pm_1_step

In [ ]:
shl_data_pm_1_step_k_step = predict_k_step_price(shl_data_pm_1_step, shl_global_parm_ccyy_mm, '11:29:51', 10)

In [ ]:
shl_data_pm_1_step_k_step['f_current_step_pred_les_misc'].tail(11)

In [ ]:
# bid is predicted bid-price from shl_pm
plt.figure(figsize=(12,6))
plt.plot(shl_data_pm_1_step_k_step['bid'])
# plt.plot(shl_data_pm_1_step_k_step['f_1_step_pred_price'].shift(1))
plt.plot(shl_data_pm_1_step_k_step['f_current_step_pred_price'])

# bid is actual bid-price from raw dataset
shl_data_actual_bid = shl_data_history_ts_process[shl_global_parm_ccyy_mm_offset:shl_global_parm_ccyy_mm_offset+61].copy()
shl_data_actual_bid.reset_index(inplace=True)
plt.figure(figsize=(12,6))
plt.plot(shl_data_actual_bid['bid-price'])
# plt.plot(shl_data_pm_1_step_k_step['f_1_step_pred_price'].shift(1))
plt.plot(shl_data_pm_1_step_k_step['f_current_step_pred_price'])
# plt.plot(shl_data_pm_1_step_k_step['bid'])

End of prediction module: shl_pm


In [ ]:


In [ ]:
# actual price & oredicted price & error
pd.concat([shl_data_actual_bid['bid-price'].tail(11), shl_data_pm_1_step_k_step['f_current_step_pred_price'].tail(11), shl_data_pm_1_step_k_step['f_current_step_pred_price'].tail(11) - shl_data_actual_bid['bid-price'].tail(11)], axis=1, join='inner')

In [ ]:
shl_data_pm_1_step_k_step.iloc[57]
# shl_data_pm_1_step_k_step.iloc[50:61]

In [ ]:

End of shl_sm


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


The End