Update .gitignore and add files.
This commit is contained in:
2516
stockapp/sample/AAPL.csv
Normal file
2516
stockapp/sample/AAPL.csv
Normal file
File diff suppressed because it is too large
Load Diff
2518
stockapp/sample/AAPL_10year_data.csv
Normal file
2518
stockapp/sample/AAPL_10year_data.csv
Normal file
File diff suppressed because it is too large
Load Diff
2517
stockapp/sample/HUBB_10year_data.csv
Normal file
2517
stockapp/sample/HUBB_10year_data.csv
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
from futu import *
|
||||
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
|
||||
ret, data, page_req_key = quote_ctx.request_history_kline('HK.09992', start='2021-10-03', end='2021-11-08', max_count=50) # 每页5个,请求第一页
|
||||
ret, data, page_req_key = quote_ctx.request_history_kline('HK.00700', autype=AuType.NONE, start='2021-10-03', end='2021-11-08', max_count=50) # 每页5个,请求第一页
|
||||
if ret == RET_OK:
|
||||
print(data)
|
||||
print(data['code'][0]) # 取第一条的股票代码
|
||||
|
||||
12
stockapp/sample/get_personal_list.py
Normal file
12
stockapp/sample/get_personal_list.py
Normal file
@ -0,0 +1,12 @@
|
||||
from futu import *
|
||||
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
|
||||
|
||||
ret, data = quote_ctx.get_user_security("港股")
|
||||
if ret == RET_OK:
|
||||
print(data)
|
||||
if data.shape[0] > 0: # 如果自选股列表不为空
|
||||
print(data['code'][0]) # 取第一条的股票代码
|
||||
print(data['code'].values.tolist()) # 转为 list
|
||||
else:
|
||||
print('error:', data)
|
||||
quote_ctx.close() # 结束后记得关闭当条连接,防止连接条数用尽
|
||||
11
stockapp/sample/get_rehab.py
Normal file
11
stockapp/sample/get_rehab.py
Normal file
@ -0,0 +1,11 @@
|
||||
from futu import *
|
||||
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
|
||||
|
||||
ret, data = quote_ctx.get_rehab("US.AAPL")
|
||||
if ret == RET_OK:
|
||||
print(data)
|
||||
print(data['ex_div_date'][0]) # 取第一条的除权除息日
|
||||
print(data['ex_div_date'].values.tolist()) # 转为 list
|
||||
else:
|
||||
print('error:', data)
|
||||
quote_ctx.close() # 结束后记得关闭当条连接,防止连接条数用尽
|
||||
15
stockapp/sample/get_yh_kline.py
Normal file
15
stockapp/sample/get_yh_kline.py
Normal file
@ -0,0 +1,15 @@
|
||||
import yfinance as yf
|
||||
import pandas as pd
|
||||
|
||||
# 获取AAPL的股票数据
|
||||
stock = yf.Ticker("AAPL")
|
||||
|
||||
# 获取过去十年的日K线数据(前复权)
|
||||
hist_data = stock.history(period="10y", auto_adjust=False)
|
||||
|
||||
# 打印数据前几行
|
||||
print(hist_data.head())
|
||||
|
||||
# 保存到CSV文件
|
||||
hist_data.to_csv("AAPL_10year_data.csv")
|
||||
|
||||
17
stockapp/sample/get_yh_kline_download.py
Normal file
17
stockapp/sample/get_yh_kline_download.py
Normal file
@ -0,0 +1,17 @@
|
||||
import yfinance as yf
|
||||
import pandas as pd
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# 获取当前日期
|
||||
end_date = datetime.today().strftime('%Y-%m-%d')
|
||||
|
||||
# 获取十年前的日期
|
||||
start_date = (datetime.today() - timedelta(days=365*10)).strftime('%Y-%m-%d')
|
||||
|
||||
# 下载 AAPL 股票数据
|
||||
data = yf.download('AAPL', start=start_date, end=end_date)
|
||||
|
||||
# 将数据保存为 CSV 文件
|
||||
data.to_csv('AAPL.csv')
|
||||
|
||||
print(f"Downloaded AAPL stock data from {start_date} to {end_date} and saved to AAPL.csv")
|
||||
Reference in New Issue
Block a user