import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.CRITICAL)
import time
import requests
import json

# "stockPicker":{'pick':True,'dateList':['2014-07-01','2014-07-05']},
# "stockPicker":{'pick':False,'dateList':None},
strategy1 = \
{
    "stockPicker":{'pick':True,'dateList':None},
    "criteriaDict" : {'存货周转率':['最近一年',None,5],'主营收入同比':['最近一年',None,10],'流动资产':['最近一期',None,100000000]},
    "portforlio": ['600000'], 
    "benchmark": 'ZZ500', 
    "money": 5000000, 
    "startDate": '2016-04-01', 
    "endDate": '2018-04-12', 
    "turnover": 10, 
    "tradingHabit": "OpenPrice",
    "status":"init"
}

inputJson1 = \
{
    '1':strategy1 
}

strategy2 = \
{
    "stockPicker":{'pick':True,'dateList':['2015-05-05']},
    "criteriaDict" : {'存货周转率':['最近一年',5,None],'主营收入同比':['最近一年',50,20],'流动资产':['最近一期',5000000,None]},
    "portforlio": 'SZ50', 
    "benchmark": 'ZZ500', 
    "money": 5000000, 
    "startDate": '2017-04-01', 
    "endDate": '2018-04-12', 
    "turnover": 10, 
    "tradingHabit": "OpenPrice",
    "status":"init"
}

inputJson2 = \
{
    '2':strategy2 
}

strategy3 = \
{
    "stockPicker":{'pick':False,'dateList':None},
    "criteriaDict" : {'存货周转率':['最近一年',None,None],'主营收入同比':['最近一年',None,None],'流动资产':['最近一期',None,None]},
    "portforlio": 'SZ50', 
    "benchmark": 'SZ50', 
    "money": 5000000, 
    "startDate": '2016-04-01', 
    "endDate": '2018-04-12', 
    "turnover": 10, 
    "tradingHabit": "OpenPrice",
    "status":"init"
}

inputJson3 = \
{
    '3':strategy3 
}


#jsonList = [inputJson1,inputJson1,inputJson1,inputJson1,inputJson1]
'''
jsonList = []
for i in range(50):
    jsonList.append(inputJson1)
'''

jsonList = [inputJson1,inputJson2,inputJson3]
#jsonList = [inputJson1,inputJson3]

'''
for json in jsonList:
    r = requests.post('http://127.0.0.1:8080/post',params = {'myJson':str(json)} ) #
    print(r.status_code)
'''

for j in jsonList:
    r = requests.post('http://office.caisiapp.com:8488/p',json = json.dumps(j,ensure_ascii=False))#
    print(r.status_code)


