Update .gitignore and add files.

This commit is contained in:
2024-10-05 16:38:23 +08:00
parent a48dd47ebe
commit 50bbcd7ca5
21 changed files with 9531 additions and 7 deletions

2516
stockapp/sample/AAPL.csv Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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]) # 取第一条的股票代码

View 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() # 结束后记得关闭当条连接,防止连接条数用尽

View 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() # 结束后记得关闭当条连接,防止连接条数用尽

View 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")

View 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")