关闭
您正在使用的浏览器版本较低,无法支持聚宽的某些特性。
为了获得更好的体验,推荐使用:
Google Chrome
或者
Mozilla Firefox
或者
IE9以上
。
返回主题列表
读取context中的数据与条件判断
595
listen
分享到:
微信
微博
雪球
评论
chenwenfeng1988
@197012Yly 少冒号
2021-02-24
草原狼
GOOD
2021-02-24
牛顶天
“详细介绍可以看API文档:**Context对象**” 这个链接点过去不是介绍 Contex对象了
2021-03-04
小猪2019
学习打卡!!
2021-03-08
彭彭和丁满
有人出现注释中文使用中文输入法但是出现的是拼音,空格或换行会转换成中文和拼音同时存在的情况吗,如下,这怎么解决 #ru g如果shou yi di yu如果收益低于
2021-03-10
逍遥disky
for year in range(2000,2021): if year % 100 != 0 and year % 4 == 0: print('%s是闰年' %year) elif year % 400 == 0: print('%s是闰年' %year) else: print('%s不是闰年' %year)
2021-03-28
wp0720
感谢感谢,正在学习
2021-03-29
耗子尾汁
def handle_data(context,data): date=context.current_dt.strftime("%Y-%m-%d") if date=='2018-03-01': order('000001.XSHE',100) elif date='2018-03-31': order_target('000001.XSHE',0)
2021-04-01
soar11
def initialize(context): #买个比亚迪股票 g.security='002594.XSHE' run_daily(period,time = 'every_bar') def period(context): #定义买入时间 buy_date = '2018-03-01' #定义卖出时间 sell_date = '2018-03-21' #把当前时间储存在一个变量里(重点是后面的时间转换) date=context.current_dt.strftime("%Y-%m-%d") #购买判断 if date == buy_date: order(g.security,100) print('买入一手比亚迪') elif date == sell_date: order_target(g.security,0) print('垃圾股票,溜了溜了') else: print('等待时机')
2021-04-03
挺近
@soar11 兄弟我也在研究聚宽,一起学习啊,加个微信aliwilliam
2021-04-08
挺近
def run(a): if a % 100 == 0: print("世纪年") elif a % 4 == 0 and a % 100 != 0: print("闰年") else: print("不是闰年")
2021-04-08
ymgui
打卡
2021-04-14
Pumpkin
打卡
2021-04-21
Bracy
学习完打卡
2021-04-27
在家
学习中
2021-04-28
XUSDT
# 导入聚宽函数库 from jqdata import * # 初始化 def initialize(context): # 定义策略每天运行 # 这里的period要和下面的period(context)对应 run_daily(period, time = 'every_bar') # 定义全局变量 g.security g.security = '002050.XSHE' # 使用前面自定义的context函数 def period(context): # 获取当前时间 time = context.current_dt # 符合时间条件即开仓 if time.year == 2018 and time.month == 3 and time.day == 1: order_target_value(g.security, 10000) # 符合时间条件即平仓 elif time.year == 2018 and time.month == 3 and time.day == 21: order_target(g.security, 0)
2021-04-30
XUSDT
@小白糖 注意缩进
2021-04-30
贾鲁河
@197012Yly 冒号.
2021-05-03
贾鲁河

2021-05-03
贾鲁河
 如图
2021-05-03
首页
上一页
7
8
9
10
11
12
13
14
15
16
下一页
尾页
您尚未登录,请
登录
或者
注册
聚宽发表回复。
取 消
提 交