
等级: 新手上路
- 注册:
- 2025-6-3
- 曾用名:
|
刚使用python试图编个简单的代码。但是报错,自己试图debug,但是找不到terminal窗口来看print的内容。想求助老鸟看看,金字塔里python编程在哪看print的内容,如何debug?
我自己写的代码如下:
import numpy as np
def init(context):
# cash_limit的属性是根据用户需求自己定义的,你可以定义无限多种自己随后需要的属性
context.cash_limit = 5000
def handle_bar(context):
now_date=context.now
bar_len=3
previous_date=get_previous_trading_date(now_date,bar_len)
print(now_date)
print(previous_date)
bar_min=history_bars_date('SZ000001', previous_date, now_date, '1d', 'low')
bar_max=history_bars_date('SZ000001', previous_date, now_date, '1d', 'high')
if bar_min[1] == np.min(bar_min):
buy_open("SZ000001", "Market", 0 , 100,serial_id = 1)
if bar_max[1] == np.max(bar_max):
sell_close("SZ000001", "Market", 0 , 100,serial_id = 2)
def before_trading(context):
#获取平安银行EPS财务字段数据
dataval = fin_indicator('SZ000001', 'EPS', 1, 0, 0)
#将查询到的财务数据保存到context对象中
context.eps = dataval
def order_status(context, order):
#判断柜台回报信息,是否为全部成交。
if order.status=='filled':
print('全部成交')
点击回测,点击开始测试后,报错为:
执行Python脚本时遇到执行错误。类型:IndexError行:15描述: index 1 is out of bounds for axis 0 with size 1是否打开代码编辑窗口?
|
|