### Install AKShare One Source: https://github.com/zwldarren/akshare-one/blob/main/README.md This command installs the akshare-one library using pip, making it available for use in Python projects. Ensure pip is installed and up-to-date for the best experience. ```bash pip install akshare-one ``` -------------------------------- ### Install AKShare One with TA-Lib Support Source: https://github.com/zwldarren/akshare-one/blob/main/docs/index.md Installs AKShare One along with the TA-Lib technical analysis library. This installation is recommended if you plan to use TA-Lib for advanced technical indicators. Note that TA-Lib itself needs to be installed separately following its official documentation. ```bash pip install akshare-one[talib] ``` -------------------------------- ### Get Financial Metrics Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/financial.md Retrieves key financial metrics for a given stock symbol. This data includes various ratios and performance indicators. ```APIDOC ## GET /api/financial/metrics ### Description Retrieves key financial metrics for a given stock symbol. This data includes various ratios and performance indicators. ### Method GET ### Endpoint /api/financial/metrics ### Parameters #### Query Parameters - **symbol** (str) - Required - Stock code (e.g., "600000") - **source** (str) - Optional - Data source ("eastmoney_direct"), defaults to "eastmoney_direct" ### Response #### Success Response (200) (Note: The specific fields returned for financial metrics can vary. Below is a representative example.) - **report_date** (str) - Report date - **roe** (float) - Return on Equity - **roa** (float) - Return on Assets - **eps** (float) - Earnings Per Share - **pe_ratio** (float) - Price-to-Earnings Ratio - **pb_ratio** (float) - Price-to-Book Ratio - **dividend_yield** (float) - Dividend Yield #### Response Example ```json { "data": [ { "report_date": "2023-12-31", "roe": 0.15, "roa": 0.08, "eps": 0.23, "pe_ratio": 20.5, "pb_ratio": 1.8, "dividend_yield": 0.015 } ] } ``` ``` -------------------------------- ### Get Real-time Stock Data in Python Source: https://github.com/zwldarren/akshare-one/blob/main/docs/index.md Fetches the latest real-time market data for a single stock. This function takes a stock symbol as input and returns a pandas DataFrame with current trading information. ```python from akshare_one import get_realtime_data # 获取单只股票实时数据 df = get_realtime_data(symbol="600000") print(df) ``` -------------------------------- ### Get Balance Sheet Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/financial.md Retrieves the balance sheet for a given stock symbol. This data includes assets, liabilities, and equity information. ```APIDOC ## GET /api/financial/balance_sheet ### Description Retrieves the balance sheet for a given stock symbol. This data includes assets, liabilities, and equity information. ### Method GET ### Endpoint /api/financial/balance_sheet ### Parameters #### Query Parameters - **symbol** (str) - Required - Stock code (e.g., "600000") - **source** (str) - Optional - Data source ("sina", "eastmoney_direct"), defaults to "sina" ### Response #### Success Response (200) - **report_date** (str) - Report date - **currency** (str) - Currency - **total_assets** (float) - Total assets - **current_assets** (float) - Total current assets - **cash_and_equivalents** (float) - Cash and cash equivalents - **inventory** (float) - Inventories - **current_investments** (float) - Trading financial assets - **trade_and_non_trade_receivables** (float) - Notes receivable and accounts receivable - **non_current_assets** (float) - Total non-current assets - **property_plant_and_equipment** (float) - Property, plant and equipment - **goodwill_and_intangible_assets** (float) - Goodwill and intangible assets - **investments** (float) - Long-term equity investments - **non_current_investments** (float) - Other non-current financial assets - **outstanding_shares** (float) - Paid-in capital (or share capital) - **tax_assets** (float) - Deferred tax assets - **total_liabilities** (float) - Total liabilities - **current_liabilities** (float) - Total current liabilities - **current_debt** (float) - Short-term borrowings - **trade_and_non_trade_payables** (float) - Notes payable and accounts payable - **deferred_revenue** (float) - Contract liabilities - **deposit_liabilities** (float) - Deposits and interbank deposits - **non_current_liabilities** (float) - Total non-current liabilities - **non_current_debt** (float) - Long-term borrowings - **tax_liabilities** (float) - Deferred tax liabilities - **shareholders_equity** (float) - Total owners' equity (or shareholders' equity) - **retained_earnings** (float) - Retained earnings - **accumulated_other_comprehensive_income** (float) - Accumulated other comprehensive income - **accounts_receivable** (float) - Accounts receivable - **prepayments** (float) - Prepayments - **other_receivables** (float) - Other receivables - **fixed_assets_net** (float) - Net fixed assets - **construction_in_progress** (float) - Construction in progress - **capital_reserve** (float) - Capital reserve - **current_ratio** (float) - Current ratio - **debt_to_assets** (float) - Debt-to-assets ratio - **minority_interest** (float) - Minority interests #### Response Example ```json { "data": [ { "report_date": "2023-12-31", "currency": "CNY", "total_assets": 1000000000.0, "current_assets": 500000000.0, "cash_and_equivalents": 100000000.0, "inventory": 50000000.0, "current_investments": 20000000.0, "trade_and_non_trade_receivables": 150000000.0, "non_current_assets": 500000000.0, "property_plant_and_equipment": 300000000.0, "goodwill_and_intangible_assets": 10000000.0, "investments": 100000000.0, "non_current_investments": 90000000.0, "outstanding_shares": 500000000.0, "tax_assets": 5000000.0, "total_liabilities": 400000000.0, "current_liabilities": 200000000.0, "current_debt": 50000000.0, "trade_and_non_trade_payables": 100000000.0, "deferred_revenue": 10000000.0, "deposit_liabilities": 40000000.0, "non_current_liabilities": 200000000.0, "non_current_debt": 150000000.0, "tax_liabilities": 5000000.0, "shareholders_equity": 600000000.0, "retained_earnings": 300000000.0, "accumulated_other_comprehensive_income": 10000000.0, "accounts_receivable": 130000000.0, "prepayments": 20000000.0, "other_receivables": 5000000.0, "fixed_assets_net": 280000000.0, "construction_in_progress": 10000000.0, "capital_reserve": 200000000.0, "current_ratio": 2.5, "debt_to_assets": 0.4, "minority_interest": 0.0 } ] } ``` ``` -------------------------------- ### Python Usage Example: Fetch Historical Data and Calculate SMA Source: https://github.com/zwldarren/akshare-one/blob/main/README.md This Python code demonstrates how to use AKShare One to fetch historical stock data and calculate a Simple Moving Average (SMA). It first imports the necessary functions, then retrieves daily historical data for a specified symbol and adjustment type. Finally, it calculates the 20-day SMA using the obtained historical data. ```python from akshare_one import get_hist_data from akshare_one.indicators import get_sma # Get historical data df = get_hist_data( symbol="600000", interval="day", adjust="hfq" ) # Calculate 20-day Simple Moving Average df_sma = get_sma(df, window=20) ``` -------------------------------- ### Get Income Statement Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/financial.md Retrieves the income statement (profit and loss statement) for a given stock symbol. This data includes revenue, expenses, and net income. ```APIDOC ## GET /api/financial/income_statement ### Description Retrieves the income statement (profit and loss statement) for a given stock symbol. This data includes revenue, expenses, and net income. ### Method GET ### Endpoint /api/financial/income_statement ### Parameters #### Query Parameters - **symbol** (str) - Required - Stock code (e.g., "600000") - **source** (str) - Optional - Data source ("sina", "eastmoney_direct"), defaults to "sina" ### Response #### Success Response (200) - **report_date** (str) - Report date - **currency** (str) - Currency - **revenue** (float) - Total revenue - **operating_revenue** (float) - Operating revenue - **total_operating_costs** (float) - Total operating costs - **cost_of_revenue** (float) - Cost of revenue - **operating_profit** (float) - Operating profit - **selling_general_and_administrative_expenses** (float) - Selling, general and administrative expenses - **operating_expense** (float) - Administrative expenses - **research_and_development** (float) - Research and development expenses - **interest_expense** (float) - Interest expense - **ebit** (float) - Earnings before interest and taxes - **income_tax_expense** (float) - Income tax expense - **net_income** (float) - Net income - **net_income_common_stock** (float) - Net income attributable to common stock - **net_income_non_controlling_interests** (float) - Net income attributable to non-controlling interests - **earnings_per_share** (float) - Earnings per share - **earnings_per_share_diluted** (float) - Diluted earnings per share - **investment_income** (float) - Investment income - **fair_value_adjustments** (float) - Fair value adjustments - **asset_impairment_loss** (float) - Asset impairment loss - **financial_expenses** (float) - Financial expenses - **taxes_and_surcharges** (float) - Taxes and surcharges - **other_comprehensive_income** (float) - Other comprehensive income - **total_comprehensive_income** (float) - Total comprehensive income #### Response Example ```json { "data": [ { "report_date": "2023-12-31", "currency": "CNY", "revenue": 800000000.0, "operating_revenue": 750000000.0, "total_operating_costs": 500000000.0, "cost_of_revenue": 450000000.0, "operating_profit": 250000000.0, "selling_general_and_administrative_expenses": 50000000.0, "operating_expense": 30000000.0, "research_and_development": 20000000.0, "interest_expense": 5000000.0, "ebit": 145000000.0, "income_tax_expense": 30000000.0, "net_income": 115000000.0, "net_income_common_stock": 110000000.0, "net_income_non_controlling_interests": 5000000.0, "earnings_per_share": 0.23, "earnings_per_share_diluted": 0.22, "investment_income": 1000000.0, "fair_value_adjustments": 500000.0, "asset_impairment_loss": 200000.0, "financial_expenses": 3000000.0, "taxes_and_surcharges": 1000000.0, "other_comprehensive_income": 2000000.0, "total_comprehensive_income": 117000000.0 } ] } ``` ``` -------------------------------- ### Get Real-time Stock Data Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/realtime.md This endpoint allows you to retrieve real-time stock market data. You can fetch data for all stocks or for specific symbols. Different data sources are available, each with its own characteristics and supported stock types (e.g., A-shares, Hong Kong stocks). ```APIDOC ## GET /realtime_data ### Description Retrieves real-time stock market data. ### Method GET ### Endpoint `/realtime_data` ### Parameters #### Query Parameters - **symbol** (str) - Optional - Stock symbol (e.g., "600000"). If not provided, data for all stocks is returned. - **source** (str) - Optional - Data source. Supported values: "eastmoney", "eastmoney_direct", "xueqiu". Defaults to "eastmoney_direct". !!! warning "Important Note" When using the "xueqiu" data source, the `symbol` parameter must be provided. !!! tip "Data Source Features" - The "eastmoney_direct" data source supports Hong Kong stocks (e.g., "00700" for Tencent Holdings). - The "eastmoney" data source retrieves real-time data for all stocks. For individual stocks, use "eastmoney_direct" or "xueqiu". ### Response #### Success Response (200) Returns a pandas DataFrame containing the following columns: - **symbol** (str) - Stock symbol - **price** (float) - Latest price - **change** (float) - Price change - **pct_change** (float) - Percentage change (%) - **timestamp** (datetime) - Timestamp - **volume** (int) - Volume traded (lots) - **amount** (float) - Turnover amount (yuan) - **open** (float) - Opening price - **high** (float) - High price - **low** (float) - Low price - **prev_close** (float) - Previous day's closing price #### Response Example ```json [ { "symbol": "600000", "price": 10.50, "change": 0.10, "pct_change": 0.96, "timestamp": "2023-10-27T10:30:00", "volume": 1000000, "amount": 10500000.0, "open": 10.45, "high": 10.55, "low": 10.40, "prev_close": 10.40 } ] ``` ### Request Example #### Get all stock real-time data ```python from akshare_one import get_realtime_data # Get real-time data for all stocks (using Eastmoney data source) df_all = get_realtime_data(source="eastmoney") print(f"Total stocks fetched: {len(df_all)}") print(df_all.head()) ``` #### Get single stock real-time data ```python # Get real-time data for SPDB (600000) df_single = get_realtime_data(symbol="600000") print(df_single) # View specific data if not df_single.empty: latest = df_single.iloc[0] print(f"Stock Symbol: {latest['symbol']}") print(f"Latest Price: {latest['price']}") print(f"Percentage Change: {latest['pct_change']:.2f}%") print(f"Volume: {latest['volume']} lots") ``` #### Get Hong Kong stock real-time data ```python # Get real-time data for Tencent Holdings (00700) in HK df_hk = get_realtime_data( symbol="00700", source="eastmoney_direct" ) print(df_hk) ``` #### Batch get multiple stocks data ```python # Define a list of stock symbols symbols = ["600000", "000001", "000002", "600036", "600519"] # Batch fetch real-time data realtime_data = [] for symbol in symbols: df = get_realtime_data(symbol=symbol, source="eastmoney_direct") if not df.empty: realtime_data.append(df) # Combine all data if realtime_data: import pandas as pd combined_df = pd.concat(realtime_data, ignore_index=True) print(combined_df[["symbol", "price", "pct_change"]]) ``` ``` -------------------------------- ### Get All Real-time Stock Data (Python) Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/realtime.md Fetches real-time market data for all stocks using the 'eastmoney' data source. It returns a pandas DataFrame containing detailed information for each stock. This function is useful for a comprehensive market overview. ```python from akshare_one import get_realtime_data # 获取所有股票实时数据(使用东方财富数据源) df_all = get_realtime_data(source="eastmoney") print(f"共获取 {len(df_all)} 只股票数据") print(df_all.head()) ``` -------------------------------- ### Batch Get Multiple Stocks Real-time Data (Python) Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/realtime.md Retrieves real-time market data for multiple stocks efficiently by iterating through a list of symbols. The function fetches data for each stock individually and then concatenates the results into a single pandas DataFrame. This approach is beneficial for analyzing a portfolio or a watchlist. ```python # 定义股票列表 symbols = ["600000", "000001", "000002", "600036", "600519"] # 批量获取实时数据 realtime_data = [] for symbol in symbols: df = get_realtime_data(symbol=symbol, source="eastmoney_direct") if not df.empty: realtime_data.append(df) # 合并所有数据 if realtime_data: import pandas as pd combined_df = pd.concat(realtime_data, ignore_index=True) print(combined_df[["symbol", "price", "pct_change"]]) ``` -------------------------------- ### Get Cash Flow Statement Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/financial.md Retrieves the cash flow statement for a given stock symbol. This data includes cash flows from operating, investing, and financing activities. ```APIDOC ## GET /api/financial/cash_flow ### Description Retrieves the cash flow statement for a given stock symbol. This data includes cash flows from operating, investing, and financing activities. ### Method GET ### Endpoint /api/financial/cash_flow ### Parameters #### Query Parameters - **symbol** (str) - Required - Stock code (e.g., "600000") - **source** (str) - Optional - Data source ("sina", "eastmoney_direct"), defaults to "sina" ### Response #### Success Response (200) - **report_date** (str) - Report date - **currency** (str) - Currency - **net_cash_flow_from_operations** (float) - Net cash flow from operating activities - **capital_expenditure** (float) - Cash paid for capital expenditures - **business_acquisitions_and_disposals** (float) - Net cash from acquisitions and disposals of businesses - **net_cash_flow_from_investing** (float) - Net cash flow from investing activities - **issuance_or_repayment_of_debt_securities** (float) - Cash received from issuing or repaying debt securities - **issuance_or_purchase_of_equity_shares** (float) - Cash received from issuing or purchasing equity shares - **net_cash_flow_from_financing** (float) - Net cash flow from financing activities - **change_in_cash_and_equivalents** (float) - Net increase/(decrease) in cash and cash equivalents - **effect_of_exchange_rate_changes** (float) - Effect of exchange rate changes on cash and cash equivalents - **ending_cash_balance** (float) - Ending cash and cash equivalents balance - **cash_from_sales** (float) - Cash received from sales of goods or rendering of services - **tax_refunds_received** (float) - Tax refunds received - **cash_paid_to_employees** (float) - Cash paid to and for employees - **taxes_paid** (float) - Taxes paid - **total_cash_inflow_from_operations** (float) - Total cash inflow from operating activities - **total_cash_outflow_from_operations** (float) - Total cash outflow from operating activities - **cash_from_investment_recovery** (float) - Cash received from recovery of investments - **cash_from_investment_income** (float) - Cash received from investment income - **cash_from_asset_sales** (float) - Cash received from disposal of assets - **total_cash_inflow_from_investing** (float) - Total cash inflow from investing activities - **total_cash_outflow_from_investing** (float) - Total cash outflow from investing activities - **cash_paid_for_dividends_and_interest** (float) - Cash paid for dividends, profit or interest - **cash_paid_for_debt_repayment** (float) - Cash paid for debt repayment - **total_cash_inflow_from_financing** (float) - Total cash inflow from financing activities - **total_cash_outflow_from_financing** (float) - Total cash outflow from financing activities - **beginning_cash_balance** (float) - Beginning cash and cash equivalents balance - **ending_cash** (float) - Ending cash balance - **ending_cash_equivalents** (float) - Ending cash equivalents balance #### Response Example ```json { "data": [ { "report_date": "2023-12-31", "currency": "CNY", "net_cash_flow_from_operations": 150000000.0, "capital_expenditure": -80000000.0, "business_acquisitions_and_disposals": 0.0, "net_cash_flow_from_investing": -70000000.0, "issuance_or_repayment_of_debt_securities": 20000000.0, "issuance_or_purchase_of_equity_shares": 30000000.0, "net_cash_flow_from_financing": 50000000.0, "change_in_cash_and_equivalents": 130000000.0, "effect_of_exchange_rate_changes": 0.0, "ending_cash_balance": 230000000.0, "cash_from_sales": 850000000.0, "tax_refunds_received": 500000.0, "cash_paid_to_employees": 150000000.0, "taxes_paid": 40000000.0, "total_cash_inflow_from_operations": 850500000.0, "total_cash_outflow_from_operations": 640000000.0, "cash_from_investment_recovery": 1000000.0, "cash_from_investment_income": 2000000.0, "cash_from_asset_sales": 5000000.0, "total_cash_inflow_from_investing": 8000000.0, "total_cash_outflow_from_investing": 78000000.0, "cash_paid_for_dividends_and_interest": 10000000.0, "cash_paid_for_debt_repayment": 40000000.0, "total_cash_inflow_from_financing": 50000000.0, "total_cash_outflow_from_financing": 50000000.0, "beginning_cash_balance": 100000000.0, "ending_cash": 230000000.0, "ending_cash_equivalents": 0.0 } ] } ``` ``` -------------------------------- ### Get Historical Stock Data in Python Source: https://github.com/zwldarren/akshare-one/blob/main/docs/index.md Retrieves historical daily stock price data for a specified symbol. This function requires the stock symbol, interval, adjustment type, and date range as input. It returns a pandas DataFrame containing the historical data. ```python from akshare_one import get_hist_data # 获取浦发银行前复权日线数据 df = get_hist_data( symbol="600000", interval="day", adjust="qfq", start_date="2024-01-01", end_date="2024-03-31" ) print(df.head()) ``` -------------------------------- ### Get Hong Kong Stock Real-time Data (Python) Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/realtime.md Fetches real-time market data for a Hong Kong stock using the 'eastmoney_direct' data source. This function allows specifying the stock symbol and data source to retrieve specific international market data. It is particularly useful for accessing data from the Hong Kong stock exchange. ```python # 获取腾讯控股港股实时数据 df_hk = get_realtime_data( symbol="00700", source="eastmoney_direct" ) print(df_hk) ``` -------------------------------- ### Get Single Stock Real-time Data (Python) Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/realtime.md Retrieves real-time market data for a specific stock identified by its symbol. This function returns a pandas DataFrame with the latest stock information, including price, change, and volume. It is useful for monitoring individual stock performance. ```python # 获取浦发银行实时数据 df_single = get_realtime_data(symbol="600000") print(df_single) # 查看具体数据 if not df_single.empty: latest = df_single.iloc[0] print(f"股票代码: {latest['symbol']}") print(f"最新价: {latest['price']}") print(f"涨跌幅: {latest['pct_change']:.2f}%") print(f"成交量: {latest['volume']} 手") ``` -------------------------------- ### Get Stock Historical Data (Python) Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/historical.md Retrieves historical stock market data using the `get_hist_data` function. Supports various intervals (minute, hour, day, week, month, year), adjustment types (none, qfq, hfq), and data sources (eastmoney, eastmoney_direct, sina). Requires the `akshare_one` and `pandas` libraries. Returns a pandas DataFrame. ```python from akshare_one import get_hist_data import pandas as pd # 获取浦发银行日线数据 df = get_hist_data(symbol="600000") print(df.head()) # 获取前复权日线数据 df = get_hist_data( symbol="600000", interval="day", adjust="qfq", start_date="2024-01-01", end_date="2024-03-31" ) print(f"数据条数: {len(df)}") print(df.head()) # 获取5分钟线数据(仅当前交易日) df = get_hist_data( symbol="600000", interval="minute", interval_multiplier=5, source="eastmoney_direct" ) print(df.tail()) # 获取腾讯控股港股数据 df = get_hist_data( symbol="00700", interval="day", source="eastmoney_direct", start_date="2024-01-01" ) print(df.head()) # 获取周线数据 df = get_hist_data( symbol="600000", interval="week", start_date="2023-01-01", end_date="2024-01-01" ) print(df.head()) ``` -------------------------------- ### Import Technical Indicators - Python Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/indicators.md Imports various technical indicator calculation functions from the akshare_one.indicators module. These functions are used to compute common financial analysis metrics. ```python from akshare_one.indicators import ( get_sma, get_ema, get_rsi, get_macd, get_bollinger_bands, get_stoch, get_atr, get_cci, get_adx, get_willr, get_ad, get_adosc, get_obv, get_mom, get_sar, get_tsf, get_apo, get_aroon, get_aroonosc, get_bop, get_cmo, get_dx, get_mfi, get_minus_di, get_minus_dm, get_plus_di, get_plus_dm, get_ppo, get_roc, get_rocp, get_rocr, get_rocr100, get_trix, get_ultosc ) ``` -------------------------------- ### 获取财务关键指标 - Python Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/financial.md 使用 `get_financial_metrics` 函数获取指定股票代码的财务关键指标。仅支持 'eastmoney_direct' 数据源。返回一个包含关键财务比率的 pandas DataFrame。 ```python import akshare as ak # 获取财务关键指标 financial_metrics_df = ak.get_financial_metrics(symbol="600000") print(financial_metrics_df) ``` -------------------------------- ### 获取资产负债表 - Python Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/financial.md 使用 `get_balance_sheet` 函数获取指定股票代码的资产负债表数据。支持 'sina' 数据源。返回一个包含详细财务指标的 pandas DataFrame。 ```python import akshare as ak # 获取资产负债表 balance_sheet_df = ak.get_balance_sheet(symbol="600000") print(balance_sheet_df) ``` -------------------------------- ### 获取现金流量表 - Python Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/financial.md 使用 `get_cash_flow` 函数获取指定股票代码的现金流量表数据。支持 'sina' 数据源。返回一个包含详细现金流信息的 pandas DataFrame。 ```python import akshare as ak # 获取现金流量表 cash_flow_df = ak.get_cash_flow(symbol="600000") print(cash_flow_df) ``` -------------------------------- ### 获取利润表 - Python Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/financial.md 使用 `get_income_statement` 函数获取指定股票代码的利润表数据。支持 'sina' 数据源。返回一个包含详细损益信息的 pandas DataFrame。 ```python import akshare as ak # 获取利润表 income_statement_df = ak.get_income_statement(symbol="600000") print(income_statement_df) ``` -------------------------------- ### Calculate SMA and MACD Indicators - Python Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/indicators.md Demonstrates how to fetch historical stock data and then apply Simple Moving Average (SMA) and MACD indicators using the akshare_one library. The `get_hist_data` function retrieves the data, and `get_sma` and `get_macd` perform the calculations. ```python from akshare_one import get_hist_data from akshare_one.indicators import get_sma, get_macd # 获取历史数据 df = get_hist_data(symbol="600000", interval="day") # 计算20日简单移动平均 df_sma = get_sma(df, window=20) # 计算MACD指标 df_macd = get_macd(df) ``` -------------------------------- ### get_hist_data() - Stock Historical Data Source: https://github.com/zwldarren/akshare-one/blob/main/docs/api/historical.md Retrieves historical stock market data. Supports various time granularities and adjustment methods. Parameters include stock symbol, interval, interval multiplier, start/end dates, adjustment type, and data source. ```APIDOC ## GET /api/hist_data ### Description This endpoint retrieves historical stock market data. It allows for customization of time intervals (minute, hour, day, week, month, year), interval multipliers, date ranges, and adjustment types (none, forward, backward). ### Method GET (simulated, function call in library) ### Endpoint `/api/hist_data` ### Parameters #### Query Parameters - **symbol** (str) - Required - Stock symbol (e.g., "600000") - **interval** (str) - Optional - Time granularity ('minute', 'hour', 'day', 'week', 'month', 'year'). Defaults to 'day'. - **interval_multiplier** (int) - Optional - Multiplier for the time interval (e.g., 5 for 5-minute intervals). Defaults to 1. - **start_date** (str) - Optional - Start date in 'YYYY-MM-DD' format. Defaults to '1970-01-01'. - **end_date** (str) - Optional - End date in 'YYYY-MM-DD' format. Defaults to '2030-12-31'. - **adjust** (str) - Optional - Adjustment type ('none', 'qfq', 'hfq'). Defaults to 'none'. - **source** (str) - Optional - Data source ('eastmoney', 'eastmoney_direct', 'sina'). Defaults to 'eastmoney'. ### Request Example ```json { "symbol": "600000", "interval": "day", "adjust": "qfq", "start_date": "2024-01-01", "end_date": "2024-03-31" } ``` ### Response #### Success Response (200) - **timestamp** (datetime) - Timestamp of the data point. - **open** (float) - Opening price. - **high** (float) - Highest price. - **low** (float) - Lowest price. - **close** (float) - Closing price. - **volume** (int) - Trading volume. #### Response Example ```json [ { "timestamp": "2024-01-02T00:00:00Z", "open": 7.80, "high": 7.85, "low": 7.75, "close": 7.82, "volume": 123456 } ] ``` ### Notes - `eastmoney_direct` source supports Hong Kong stocks (e.g., "00700"). - `eastmoney_direct` minute/hour data is limited to the current trading day. - Data coverage may vary between sources. - Adjustment types: `none` (original price), `qfq` (forward adjusted), `hfq` (backward adjusted). ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.