问答交流

【平台使用】3.0版本内存问题

由bqp8687s创建,最终由small_q 被浏览 14 用户

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 = '2010-01-01'
#ed = '2022-01-01'
ed =  datetime.now().strftime("%Y-%m-%d %H:%M:%S")

sql = f"""
    SELECT 
        date,
        instrument,
        total_market_cap,
        roe_avg_ttm,
        pe_ttm,
        pb,
        name,
        gross_profit_ttm,
        m_nanavg(gross_profit_ttm,1440)/m_nanstd(gross_profit_ttm,1440) AS WD,
        m_avg(volume,20),
        sw2014_level2
    FROM
        cn_stock_prefactors
    WHERE
        st_status = 0
""" 
date = dai.query(sql,filters={'date':[sd,ed]}).df().dropna()
date['market_cap_rank'] = date['total_market_cap'].rank(pct=True)
df = date[(date['market_cap_rank'] >= 0.4) & (date['market_cap_rank'] <= 0.6)]

这个查询应该是不复杂的吧。但是它却显示 OutOfMemoryException: Out of Memory Error: failed to pin block of size 256.0 KiB (6.0 GiB/6.0 GiB used)求解

评论
  • 使用的是K1服务器
  • 24年的数据,并且字段较多,涉及计算,请升级服务器
{link}