I solved it like this. My class labels were -1, 0 and 1. So my num_class=3. I had to increment class labels by 1 in order to compatible with the range [0,3). Note that in this range 3 is excluded and valid labels are 0, 1, 2. So my converted class labels were 0,1,2.
In addition I change the code to use for multiple class classification. 
objective has been changed to 'multi:softmax' and 'num_class' param is added.
xgb1 = XGBClassifier(
    learning_rate=0.1,
    n_estimators=1000,
    max_depth=5,
    min_child_weight=1,
    gamma=0,
    subsample=0.8,
    colsample_bytree=0.8,
    objective='multi:softmax',
    nthread=4,
    scale_pos_weight=1,
    seed=27,
    num_class=3,
    )
In modelfit() finction 'auc' was replaced with 'merror'
def modelfit(alg, dtrain, predictors, useTrainCV=True, cv_folds=5, early_stopping_rounds=50):
if useTrainCV:
    xgb_param = alg.get_xgb_params()
    #change the class labels
    dtrain[target] = dtrain[target] + 1
    xgtrain = xgb.DMatrix(dtrain[predictors].values, label=dtrain[target].values)
    cvresult = xgb.cv(xgb_param, xgtrain, num_boost_round=xgb_param['n_estimators'], nfold=cv_folds,
                      metrics='merror', early_stopping_rounds=early_stopping_rounds)
    alg.set_params(n_estimators=cvresult.shape[0])
    print(cvresult.shape[0])
# Fit the algorithm on the data
alg.fit(dtrain[predictors], dtrain[target], eval_metric='merror')
# Predict training set:
dtrain_predictions = alg.predict(dtrain[predictors])
# Print model report:
print("\nModel Report")
print("Accuracy : %.4g" % metrics.accuracy_score(dtrain[target].values, dtrain_predictions))