# -*- coding: utf-8 -*-
import os,sys
from PyQt4 import QtGui,QtCore

dataRoot = os.path.abspath(os.path.join(os.path.dirname(__file__),os.pardir,os.pardir,'histdata'))        
sys.path.append(dataRoot)        
import dataCenter as dataCenter    
from data.mongodb.DataSourceMongodb import Mongodb
import datetime as dt
def getSymbols():
    #mid 1)从excel赋值粘贴获得如下数据
    codesStr = """
               XAGUSD 
               """
    #mid 2)将字符串使用split()分割为list，默认会去除\n和所有空格。
    #codeList = ['000021.SZ','000022.SZ']
    codeList = [code.split('.')[0] for code in codesStr.split()]     
    return codeList
def subMain():
    DC = dataCenter.dataCenter()
    remoteDataSourceType = 'mt5'
    localStorageType = 'mongodb' 
    periodType = 'D'
    
    timeStart = dt.datetime(2000,10,20)
    timeEnd = dt.datetime.now()    
    
    # 1)get codes form eastmoney
    codeList =  getSymbols()
    # 2)download history data
    dataDict = DC.downloadHistData(providerType=remoteDataSourceType,storageType=localStorageType,periodType=periodType,
                                                codeList=codeList,timeFrom = timeStart,timeTo = timeEnd)
        
if __name__ == '__main__':
    #app = QtGui.QApplication(sys.argv)
    #mid-----------------------------------------------------------------------------------------------------------------------------

    subMain()
    
    #mid-----------------------------------------------------------------------------------------------------------------------------
    #sys.exit(app.exec_())       
[((6, 0, 6, 25), 'sys.path.append', 'sys.path.append', ({(6, 16, 6, 24): 'dataRoot'}, {}), '(dataRoot)', False, 'import os, sys\n'), ((20, 9, 20, 32), 'dataCenter.dataCenter', 'dataCenter.dataCenter', ({}, {}), '()', True, 'import dataCenter as dataCenter\n'), ((25, 16, 25, 39), 'datetime.datetime', 'dt.datetime', ({(25, 28, 25, 32): '2000', (25, 33, 25, 35): '10', (25, 36, 25, 38): '20'}, {}), '(2000, 10, 20)', True, 'import datetime as dt\n'), ((26, 14, 26, 31), 'datetime.datetime.now', 'dt.datetime.now', ({}, {}), '()', True, 'import datetime as dt\n'), ((5, 40, 5, 65), 'os.path.dirname', 'os.path.dirname', ({(5, 56, 5, 64): '__file__'}, {}), '(__file__)', False, 'import os, sys\n')]