# Path: fooltrader/contract/files_contract.py
# def get_kdata_path(item, source=None, fuquan='bfq', year=None, quarter=None):
#     source = adjust_source(item, source)
#     if source == 'sina':
#         if not year and not quarter:
#             return os.path.join(get_kdata_dir(item, fuquan), 'dayk.csv')
#         else:
#             return os.path.join(get_kdata_dir(item, fuquan), '{}Q{}.csv'.format(year, quarter))
#     else:
#         return os.path.join(get_kdata_dir(item, fuquan), '{}_dayk.csv'.format(source))
# 
# Path: fooltrader/utils/utils.py
# def index_df_with_time(df, index='timestamp'):
#     df = df.set_index(df[index], drop=False)
#     df.index = pd.to_datetime(df.index)
#     df = df.sort_index()
#     return df
# 
# def to_time_str(the_time, time_fmt=TIME_FORMAT_DAY):
#     try:
#         if time_fmt == TIME_FORMAT_MICRO:
#             return to_timestamp(the_time).strftime(time_fmt)[0:-3]
#         else:
#             return to_timestamp(the_time).strftime(time_fmt)
#     except Exception as e:
#         return the_time
# 
# def to_float(str, default=None):
#     try:
#         return float(str.replace(',', ''))
#     except Exception as e:
#         return default


import pandas as pd
import scrapy
from scrapy import Request
from scrapy import Selector
from scrapy import signals
from fooltrader.contract.files_contract import get_kdata_path
from fooltrader.utils.utils import index_df_with_time, to_time_str, to_float
# -*- coding: utf-8 -*-




class Sp500Spider(scrapy.Spider):
    name = "sp500_spider"

    def __init__(self, name=None, **kwargs):

# Path: fooltrader/contract/files_contract.py
# def get_kdata_path(item, source=None, fuquan='bfq', year=None, quarter=None):
#     source = adjust_source(item, source)
#     if source == 'sina':
#         if not year and not quarter:
#             return os.path.join(get_kdata_dir(item, fuquan), 'dayk.csv')
#         else:
#             return os.path.join(get_kdata_dir(item, fuquan), '{}Q{}.csv'.format(year, quarter))
#     else:
#         return os.path.join(get_kdata_dir(item, fuquan), '{}_dayk.csv'.format(source))
# 
# Path: fooltrader/utils/utils.py
# def index_df_with_time(df, index='timestamp'):
#     df = df.set_index(df[index], drop=False)
#     df.index = pd.to_datetime(df.index)
#     df = df.sort_index()
#     return df
# 
# def to_time_str(the_time, time_fmt=TIME_FORMAT_DAY):
#     try:
#         if time_fmt == TIME_FORMAT_MICRO:
#             return to_timestamp(the_time).strftime(time_fmt)[0:-3]
#         else:
#             return to_timestamp(the_time).strftime(time_fmt)
#     except Exception as e:
#         return the_time
# 
# def to_float(str, default=None):
#     try:
#         return float(str.replace(',', ''))
#     except Exception as e:
#         return default


# Path: fooltrader/spiders/america/sp500_spider.py
import pandas as pd
import scrapy
from scrapy import Request
from scrapy import Selector
from scrapy import signals
from fooltrader.contract.files_contract import get_kdata_path
from fooltrader.utils.utils import index_df_with_time, to_time_str, to_float

# -*- coding: utf-8 -*-




class Sp500Spider(scrapy.Spider):
    name = "sp500_spider"

    def __init__(self, name=None, **kwargs):

        super().__init__(name, **kwargs)