㈠ 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("執行完畢!