㈠ python编程实现,判断用户从键盘输入的任意数字是否落入[1,100]区间,直接输出
n=int(input())
ifn>=1andn<=100:
print("%d在区间[1,100]内"%n)
else:
print("%d不在区间[1,100]内"%n)
㈡ 如何用python代码判断一段范围内股票最高点
Copyright © 1999-2020, CSDN.NET, All Rights Reserved
登录
python+聚宽 统计A股市场个股在某时间段的最高价、最低价及其时间 原创
2019-10-12 09:20:50
开拖拉机的大宝
码龄4年
关注
使用工具pycharm + 聚宽数据源,统计A股市场个股在某时间段的最高价、最低价及其时间,并打印excel表格输出
from jqdatasdk import *
import pandas as pd
import logging
import sys
logger = logging.getLogger("logger")
logger.setLevel(logging.INFO)
# 聚宽数据账户名和密码设置
auth('username','password')
#获取A股列表,包括代号,名称,上市退市时间等。
security = get_all_securities(types=[], date=None)
pd2 = get_all_securities(['stock'])
# 获取股票代号
stocks = list(get_all_securities(['stock']).index)
# 获取股票名称
stocknames = pd2['display_name']
start_date = '2015-01-01'
end_date = '2018-12-31'
def get_stocks_high_low(start_date,end_date):
# 新建表,表头列
# 为:"idx","stockcode","stockname","maxvalue","maxtime","lowvalue","lowtime"
result = pd.DataFrame(columns=["idx", "stockcode", "stockname", "maxvalue", "maxtime", "lowvalue", "lowtime"])
for i in range(0,stocks.__len__()-1):
pd01 = get_price(stocks[i], start_date, end_date, frequency='daily',
fields=None, skip_paused=False,fq='pre', count=None)
result=result.append(pd.DataFrame({'idx':[i],'stockcode':[stocks[i]],'stockname':
[stocknames[i]],'maxvalue':[pd01['high'].max()],'maxtime':
[pd01['high'].idxmax()],'lowvalue': [pd01['low'].min()], 'lowtime':
[pd01['low'].idxmin()]}),ignore_index=True)
result.to_csv("stock_max_min.csv",encoding = 'utf-8', index = True)
logger.warning("执行完毕!