示例#1
0
# encoding=utf-8
"""
本脚本用于维护一个本地的数据源
"""
# jq_login()
from data_source.Data_Sub import get_k_data_jq, get_all_stk
import os
import pandas as pd
from data_source.auth_info import jq_login
from sdk.MyTimeOPT import get_current_datetime_str, add_date_str

class LocalData:
    """
    数据本地化相关类
    """
    def __init__(self, stk_code, freq, save_dir):
        self.save_dir = save_dir
        self.save_url = self.save_dir + str(stk_code) + '.json'
        self.freq = freq
        self.stk_code = stk_code
        self.init_count = 800
        self.df = None
        # 创建保存文件夹
        self.make_dir()
        self.log = ''
    def download_data(self):
        """
        初次下载数据
        :return:
        """
        if self.data.empty:
            return

        # 增加“特征”数据
        self.add_feature()

        # 增加label
        self.add_label(roll_type='median')

        # 删除空值
        self.data = self.data.dropna(axis=0)


if __name__ == '__main__':

    jq_login()
    """ ------------------------------- 预测测试 -------------------------------- """
    stk = 'M2012.XDCE'
    rf_pre = RFPreprocess(save_dir=root_path + '/Server/rf/rf_model_save/',
                          stk_list=[stk],
                          freq='5m')
    feature = rf_pre.get_feature_data(stk, days=500)
    for idx in feature.index:
        feature.loc[idx,
                    'score'], feature.loc[idx, 'chance'] = rf_pre.predict_sig(
                        [feature.loc[idx, rf_pre.dpr.feature_col].values])

    # 画图展示
    feature.loc[:, 'date'] = feature.index
    feature.loc[:, 'date_str'] = feature.apply(lambda x: str(x['date'])[:10],
                                               axis=1)
示例#3
0
# encoding=utf-8
"""
根据标准差来计算格子
"""
import numpy as np
import pandas as pd
import copy
from server.futures.futures_sub.future_global_value import debug_date
from data_source.Data_Sub import get_k_data_jq
from data_source.auth_info import jq_login
from sdk.MyTimeOPT import add_date_str, get_current_date_str
from data_source.stk_data_class import StkData
from my_config.log import MyLog
import logging
logger_debug = MyLog('reseau_cal').logger
logger_eml = MyLog('reseau_cal_eml', file_level=logging.DEBUG).logger
"""---------------------- 定义全局变量 ------------------------"""
today_df_update_date = ''
today_df = pd.DataFrame()

class Reseau(StkData):
    """
    动态网格策略底层实现类
    """
    def __init__(self, stk_code):
        # 将一天用的网格信息记录下来,
        # 避免每次重复计算,实现一天只计算一次
        super().__init__(stk_code)
        self.stk_code = stk_code
    def cal_rt_rsv(self):