### Retrieve Custom Factor Data (Python) Source: https://quant.10jqka.com.cn/view/help/8/index This Python function `get_sfactor_data` is used to retrieve pre-calculated custom factor data from the SuperMind platform. It requires specifying the start date, end date, a list of stock symbols, and a list of factor names to fetch. ```python from supermind import get_sfactor_data # Example: Get 'trix' factor data for specific stocks and date range start_date = '2017-01-01' end_date = '2018-10-10' stocks = ['000001.SZ', '000002.SZ'] factors = ['trix'] trix_data = get_sfactor_data(start_date, end_date, stocks, factors) # trix_data will be a dictionary where keys are factor names and values are pandas DataFrames # print(trix_data['trix'].head()) ``` -------------------------------- ### Custom Factor Algorithm Example (Python) Source: https://quant.10jqka.com.cn/view/help/8/index This Python code snippet demonstrates how to define a custom factor algorithm within the SuperMind platform. It includes a placeholder function `sfactor_data` where users can implement their logic for calculating factor values using provided data. The function must return a dictionary with factor names as keys and pandas DataFrames as values. ```python def sfactor_data(context): # context object contains data and parameters for factor calculation # Example: Fetching data for 'close' price close_data = context.get_data('close') # Example: Calculating a simple moving average (SMA) sma_10 = close_data.rolling(window=10).mean() # Example: Calculating a custom factor (e.g., Price - SMA10) custom_factor_values = close_data - sma_10 # Return the factor values in the required dictionary format # 'key' is the factor name, 'value' is a pandas DataFrame return { 'my_custom_factor': custom_factor_values } ``` -------------------------------- ### CSV Factor Upload Format Source: https://quant.10jqka.com.cn/view/help/8/index This example illustrates the required CSV format for uploading custom factor data. The CSV file must contain three columns: 'symbol' for the stock ticker, 'date' in 'YYYY-MM-DD' format, and 'value' for the calculated factor value. ```csv symbol,date,value 000001.SZ,2017-03-02,0.5 000001.SZ,2017-03-03,0.6 000002.SZ,2017-03-02,1.2 000002.SZ,2017-03-03,1.1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.