Python

从金融角度看,Python是一种强大的编程语言,其简洁、易读的语法和丰富的库使其成为金融分析和建模的首选工具。金融机构广泛运用Python处理复杂数据、进行量化分析和风险评估。Python在金融领域的应用包括算法交易、投资组合优化、信用评分、风险管理等。其灵活性使金融专业人员能够快速响应市场变化,制定精确策略。

【平台使用】构建行业中性化哑变量矩阵时,1月数据,跑10分钟都跑不出来原因是?

#提取一级行业,可以获得5000多只股票的行业列表。

sql ='''
select *
from cn_stock_industry_component
where date between '2023-0-01' and '2023-01-07'
'''
import dai
ww = dai.query(sql).df()
www_uni = ww.drop_duplicates(subset='instrument')

www_uni

#获取cn_stock_bar1d表数据

sql = '''
select *

更新时间:2025-02-16 01:46

【代码报错】ModuleNotFoundError: No module named 'jqdata'

新建可视化空白稳定,粘贴Ai给写的代码后显示

  • \
    ModuleNotFoundError: No module named 'jqdata'
    

\

更新时间:2025-02-16 01:40

【代码报错】研究天蝎座的时候回测报错


Exception Traceback (most recent call last) <ipython-input-13-16424a2d66d6> in <module> 163 ) 164 --> 165 m23 = M.select_columns.v3( 166 input_ds=m22.data, 167 columns='date,instrument',

Exception: invalid module name: select_columns, version: v3, frie

更新时间:2025-02-16 01:08

【平台使用】NaTType does not support strftime

根据视频4.1.3可视化模块操作,提示这个报错,对于表字段的提取,应该最后加什么模块来展现或者输出数据呢?

{w:100}

更新时间:2025-02-15 15:51

【代码报错】UnboundLocalError:local variable 'feature_cols' referenced before assignment

这是什么问题?怎么解决?

更新时间:2025-02-15 15:22

【代码报错】运行出错:Remote I/O error


OSError                                   Traceback (most recent call last)
<ipython-input-3-cacd7d5799ae> in <module>
37 )
38
---> 39 m3 = M.general_feature_extractor.v7(
40     instruments=m1.data,
41     features=m2.data,

OSError: [Errno 121] Error reading bytes from file. Detail

更新时间:2025-02-15 14:51

【平台使用】custom_modules.features_short_user 实盘搜寻不到模块

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/var/app/enabled/biglearning/module2/common/moduleinvoker.cpython-38-x86_64-linux-gnu.so in biglearning.module2.common.moduleinvoker.ModuleInvok

更新时间:2025-02-15 12:25

【代码报错】报错 IndexError: single positional indexer is out-of-bounds

麻烦老师 帮忙看一下该报错怎么处理呢

更新时间:2025-02-14 10:45

【代码报错】报错

  • /home/aiuser/.ipython/profile_default/startup/000-aistudio.py:234: DeprecationWarning: This module is deprecated. Please use `from bigdatasource.api import D`.
  • return original_import(name, globals, locals, fromlist, level)
  • /home/aiuser/.ipython/profile_default/startup/000-aistudio.py:234: De

更新时间:2025-02-14 10:44

【代码报错】'NoneType' object has no attribute 'get_value'



这个信息是哪里出错了呢?

更新时间:2025-02-14 10:21

【代码报错】求助:时间会报错

    with t1 as (
    SELECT
        date,
        date_format(date,"%Y-%m-%d") as new_date,
        instrument,
        close,
    FROM
        cn_stock_bar1m
    WHERE
        1 = 1
        AND date >= '2024-03-01'
        AND date <= '2024-03-02'
    )   
    SELECT * FROM t

更新时间:2025-02-14 07:01

【代码报错】ModuleNotFoundError: No module named 'bigmodule'

ModuleNotFoundError

Traceback (most recent call last) Cell In[7], line 1 ----> 1 from bigmodule import M 3

# <aistudiograph> **[4 ](vsco

更新时间:2025-01-20 01:46

【代码报错】AttributeError: 'int' object has no attribute 'to_pydatetime'

运行bigtrader出现'int' object has no attribute 'to_pydatetime' 错误

https://bigquant.com/codesharev3/f57ba9ba-5de8-4748-8459-7fa473319887

日志 24 条 ▼

  • [2025-01-03 16:08:42] INFO: input_features_dai.v30 开始运行 ..
  • [2025

更新时间:2025-01-03 12:05

【平台使用】如何在 Python 模块中进行机器学习训练和预测?

请工程师给一个例子使用 python 模块,在python模块里做机器学习训练和预测

测试别的机器学习的模型,怎么操作,我看这里有一些,拉过去就可以了,这里没有的呢,只能用纯代码模式测试吗

请工程师给一个例子使用 python 模块,在python模块里做机器学习训练和预测

更新时间:2025-01-02 01:30

一文读懂遗传算法(附python)


几天前,我着手解决一个实际问题——大型超市销售问题。在使用了几个简单模型做了一些特征工程之后,我在排行榜上名列第 219 名。

{w:100%}{w:100}{w:100}{w:100}

虽然结果不错,但是我还是想做得更好。于是,我开始研究可以提高分数的优化方法。结果我果然找到了一个,它叫遗传算法。在把它应用到超市销售问题之后,最终我的分数在排行榜上一下跃居前列。

![{w:100%}{w:100}{w:100}{w:100}](/

更新时间:2024-12-31 08:29

夏普比率公式及使用技巧(含Python代码)

夏普比率(Sharpe Ratio)是衡量投资表现的一个指标,它通过比较投资的超额回报与其承担的风险来评估投资的性价比。由诺贝尔奖获得者威廉·夏普提出,是风险调整后的回报的一种度量。

通过BigQuant量化平台金融市场数据因子以及AI量化策略平台(PC端),可以验证夏普比率因子组成的AI量化策略有效性。

![](/wiki/api/attachments.redirect?id=8df056d7

更新时间:2024-12-13 05:59

【代码报错】KeyError: 'buy_signal'

我按照模板写的 单独调用一个vip因子进行测试

import dai
import pandas as pd
import numpy as np
import math
import warnings
from datetime import datetime, timedelta

from bigmodule import M
from bigtrader.finance.commission import PerOrder

## 设置开始和结束时间
sd = '2020-01-01'
ed = datetime.now().date().strftime

更新时间:2024-11-18 02:08

【代码报错】Parser Error: syntax error at or near "ORDER"

ORDER BY  报错 帮我看下哪里有问题

import dai


import pandas as pd

# 提取股票数据
stock_sql = """
WITH 
zuori1 AS (
    SELECT 
        cn_stock_bar1d.date, 
        cn_stock_bar1d.instrument,
        close,
        volume,
        volume AS volume_1,
        close AS close_1,
        pe_ttm,
    FRO

更新时间:2024-11-13 03:09

【代码报错】ValueError: Pandas data cast to numpy dtype of object. Check input data with np.asarray(data)

行业中性化

在复现行业中性化的代码报错

## 加载包
import dai
import pandas as pd
import numpy as np
import math
import warnings
from datetime import datetime, timedelta

from bigmodule import M
from bigtrader.finance.commission import PerOrder

niu_date= '2024-11-10'
today = datetime.now().date().strftime(

更新时间:2024-11-13 03:06

【代码报错】Vulkan 支持缺失&窗口创建失败,没有可用的驱动程序&显示服务器未运行/配置不正确

请教一下训练时报错的原因,报错信息如下

  • Exception in thread background thread for pid 1602:
  • Traceback (most recent call last):
  • File "/opt/pyenv/versions/3.11.8/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
  • self.run()
  • File "/opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/ipykernel/i

更新时间:2024-11-07 02:13

PB市净率公式及如何使用(含Python)

市净率(Price-to-Book Ratio,简称 P/B Ratio)是衡量公司股票价格相对于其账面价值的一个指标。这个比率通常用于评估公司股票的价值,尤其是在资产重要的行业(如金融业)中。

BigQuant金融市场历史数据因子平台以及AI量化策略平台(PC端),可以验证PB市净率因子组成的AI量化策略有效性。

![](/wiki/api/attachments.redirect?id=9e1

更新时间:2024-11-02 13:05

【代码报错】KeyError: 'indexes'

rs2 = dai.DataSource("cn_stock_valuation")
rs2.read_bdb()

KeyError                                  Traceback (most recent call last)
Cell In[15], line 2
      1 rs2 = dai.DataSource("cn_stock_valuation")
----> 2 rs2.read_bdb()

File /var/app/enabled/dai/_telemetry.py:189, in wrapper(*arg

更新时间:2024-10-31 01:40

【代码报错】IndexError: single positional indexer is out-of-bounds

又出现一个single positional indexer is out-of-bounds

请帮忙处理:

https://bigquant.com/codesharev3/d5e911e4-51e9-4684-a6f5-25cb97efc1dc

\

更新时间:2024-10-28 01:52

【其他】因子分析疑问

1、如果我的因子在sql之外还需要用Python做一些处理,请问提交因子的时候factor_sql 该怎么写?

2、因子分析中是否每个股票每个交易日都要有因子值,我是否可以每个股票只有月末有一个因子,其他时间都是空的。

更新时间:2024-10-10 10:10

【代码报错】KeyError: "DataFrame does not contain 'open' column"Output is truncated

KeyError: "DataFrame does not contain 'open' column"Output is truncated. View as a open in a text editor. Adjust cell output settings...

https://bigquant.com/codesharev3/fe4fb116-9952-42a2-aad4-91738ebaa77c

\

更新时间:2024-10-10 07:10

分页第1页第2页第3页第4页第5页
{link}