# Path: fooltrader/settings.py
# BOT_NAME = 'fooltrader'
# SPIDER_MODULES = ['fooltrader.spiders']
# NEWSPIDER_MODULE = 'fooltrader.spiders'
# COMPRESSION_ENABLED = True
# DOWNLOADER_MIDDLEWARES = {
#     'fooltrader.middlewares.ForbiddenHandleMiddleware': 1000,
# }
# AUTOTHROTTLE_DEBUG = False
# FOOLTRADER_STORE_PATH = os.environ.get('FOOLTRADER_STORE_PATH')
#     FOOLTRADER_STORE_PATH = '/home/xuanqi/workspace/github/fooltrader/data'
# STOCK_START_CODE = '000001'
# STOCK_END_CODE = '666666'
# US_STOCK_CODES = ['MSFT', 'AMZN', 'NVDA', 'SINA', 'AAPL']
# AVAILABLE_TICK_DATE = '2004-10-8'
# START_TICK_DATE = '2013-1-1'
# FORCE_DOWNLOAD_SECURITY_LIST = False
# DOWNLOAD_TXT_ENCODING = 'GB2312'
# AUTO_KAFKA = False
# KAFKA_HOST = 'localhost:9092'
# KAFKA_PATH = '/home/xuanqi/software/kafka_2.11-0.11.0.1'
# ZK_KAFKA_HOST = 'localhost:2181'
# DG_PATH = '/Users/xuanqi/software/delegate/DGROOT/bin/delegate'
# SUPPORT_SOCKS2HTTP = False
# TIME_FORMAT_MICRO = "%Y%m%d %H%M%S.%f"
# TIME_FORMAT_SEC = '%Y-%m-%d %H:%M:%S'
# TIME_FORMAT_DAY = '%Y-%m-%d'
# ES_HOSTS = ['localhost:9200']
# SMTP_HOST = 'smtpdm.aliyun.com'
# SMTP_PORT = '80'
# EMAIL_USER_NAME = ''
#     EMAIL_USER_NAME = os.environ.get('EMAIL_USER_NAME')
# EMAIL_PASSWORD = ''
#     EMAIL_PASSWORD = os.environ.get('EMAIL_PASSWORD')
# WEIXIN_APP_ID = ""
#     WEIXIN_APP_ID = os.environ.get("WEIXIN_APP_ID")
# WEIXIN_APP_SECRECT = ""
#     WEIXIN_APP_SECRECT = os.environ.get("WEIXIN_APP_SECRECT")
# EOS_MONGODB_URL = ""
#     EOS_MONGODB_URL = os.environ.get("EOS_MONGODB_URL")


import os
import fooltrader.utils.utils
from datetime import datetime
from fooltrader import settings
    return os.path.join(settings.FOOLTRADER_STORE_PATH, security_type, exchange)


def get_exchange_trading_calendar_path(security_type='future', exchange='shfe'):
    return os.path.join(get_exchange_dir(security_type, exchange), 'trading_calendar.json')


def get_exchange_cache_dir(security_type='future', exchange='shfe', the_year=None,
                           data_type="day_kdata"):
    if the_year:
        the_dir = os.path.join(settings.FOOLTRADER_STORE_PATH, ".cache", "{}.{}.cache".format(security_type, exchange))
        return os.path.join(the_dir, "{}_{}".format(the_year, data_type))
    return os.path.join(settings.FOOLTRADER_STORE_PATH, ".cache", "{}.{}.cache".format(security_type, exchange))


def get_exchange_cache_path(security_type='future', exchange='shfe', the_date=datetime.today(), data_type="day_kdata"):
    the_dir = get_exchange_cache_dir(security_type=security_type, exchange=exchange, the_year=the_date.year,
                                     data_type=data_type)
    if not os.path.exists(the_dir):
        os.makedirs(the_dir)
    return os.path.join(the_dir, fooltrader.utils.utils.to_time_str(the_time=the_date, time_fmt='%Y%m%d'))


# 标的相关
def get_security_list_path(security_type, exchange):
    return os.path.join(settings.FOOLTRADER_STORE_PATH, security_type, '{}.csv'.format(exchange))


def get_security_dir(item=None, security_type=None, exchange=None, code=None):
    if security_type and exchange and code:

# Path: fooltrader/settings.py
# BOT_NAME = 'fooltrader'
# SPIDER_MODULES = ['fooltrader.spiders']
# NEWSPIDER_MODULE = 'fooltrader.spiders'
# COMPRESSION_ENABLED = True
# DOWNLOADER_MIDDLEWARES = {
#     'fooltrader.middlewares.ForbiddenHandleMiddleware': 1000,
# }
# AUTOTHROTTLE_DEBUG = False
# FOOLTRADER_STORE_PATH = os.environ.get('FOOLTRADER_STORE_PATH')
#     FOOLTRADER_STORE_PATH = '/home/xuanqi/workspace/github/fooltrader/data'
# STOCK_START_CODE = '000001'
# STOCK_END_CODE = '666666'
# US_STOCK_CODES = ['MSFT', 'AMZN', 'NVDA', 'SINA', 'AAPL']
# AVAILABLE_TICK_DATE = '2004-10-8'
# START_TICK_DATE = '2013-1-1'
# FORCE_DOWNLOAD_SECURITY_LIST = False
# DOWNLOAD_TXT_ENCODING = 'GB2312'
# AUTO_KAFKA = False
# KAFKA_HOST = 'localhost:9092'
# KAFKA_PATH = '/home/xuanqi/software/kafka_2.11-0.11.0.1'
# ZK_KAFKA_HOST = 'localhost:2181'
# DG_PATH = '/Users/xuanqi/software/delegate/DGROOT/bin/delegate'
# SUPPORT_SOCKS2HTTP = False
# TIME_FORMAT_MICRO = "%Y%m%d %H%M%S.%f"
# TIME_FORMAT_SEC = '%Y-%m-%d %H:%M:%S'
# TIME_FORMAT_DAY = '%Y-%m-%d'
# ES_HOSTS = ['localhost:9200']
# SMTP_HOST = 'smtpdm.aliyun.com'
# SMTP_PORT = '80'
# EMAIL_USER_NAME = ''
#     EMAIL_USER_NAME = os.environ.get('EMAIL_USER_NAME')
# EMAIL_PASSWORD = ''
#     EMAIL_PASSWORD = os.environ.get('EMAIL_PASSWORD')
# WEIXIN_APP_ID = ""
#     WEIXIN_APP_ID = os.environ.get("WEIXIN_APP_ID")
# WEIXIN_APP_SECRECT = ""
#     WEIXIN_APP_SECRECT = os.environ.get("WEIXIN_APP_SECRECT")
# EOS_MONGODB_URL = ""
#     EOS_MONGODB_URL = os.environ.get("EOS_MONGODB_URL")


# Path: fooltrader/contract/files_contract.py
import os
import fooltrader.utils.utils
from datetime import datetime
from fooltrader import settings

    return os.path.join(settings.FOOLTRADER_STORE_PATH, security_type, exchange)


def get_exchange_trading_calendar_path(security_type='future', exchange='shfe'):
    return os.path.join(get_exchange_dir(security_type, exchange), 'trading_calendar.json')


def get_exchange_cache_dir(security_type='future', exchange='shfe', the_year=None,
                           data_type="day_kdata"):
    if the_year:
        the_dir = os.path.join(settings.FOOLTRADER_STORE_PATH, ".cache", "{}.{}.cache".format(security_type, exchange))
        return os.path.join(the_dir, "{}_{}".format(the_year, data_type))
    return os.path.join(settings.FOOLTRADER_STORE_PATH, ".cache", "{}.{}.cache".format(security_type, exchange))


def get_exchange_cache_path(security_type='future', exchange='shfe', the_date=datetime.today(), data_type="day_kdata"):
    the_dir = get_exchange_cache_dir(security_type=security_type, exchange=exchange, the_year=the_date.year,
                                     data_type=data_type)
    if not os.path.exists(the_dir):
        os.makedirs(the_dir)
    return os.path.join(the_dir, fooltrader.utils.utils.to_time_str(the_time=the_date, time_fmt='%Y%m%d'))


# 标的相关
def get_security_list_path(security_type, exchange):
    return os.path.join(settings.FOOLTRADER_STORE_PATH, security_type, '{}.csv'.format(exchange))


def get_security_dir(item=None, security_type=None, exchange=None, code=None):
    if security_type and exchange and code:

        return os.path.join(settings.FOOLTRADER_STORE_PATH, security_type, exchange, code)