Skip to content

Commit 02cbea2

Browse files
committed
Refine advanced strategy examples
1 parent ed9c639 commit 02cbea2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

examples/joinquant/advanced_strategy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ def process_initialize(context):
1919
# 每个单位时间(如果按天回测,则每天调用一次,如果按分钟,则每分钟调用一次)调用一次
2020
def handle_data(context, data):
2121
try:
22-
order(g.security, 100)
22+
order_target(g.security, 0)
23+
order_target(g.security, 100)
2324

25+
current_data = get_current_data()
26+
order_ = order(g.security, 100, LimitOrderStyle(current_data[g.security].low_limit))
27+
cancel_order(order_)
2428
finally:
2529
# 放在 finally 块中,以防原有代码抛出异常或者 return
2630
# 在函数结尾处加入以下语句,用来将模拟盘同步、跟单至实盘

examples/ricequant/advanced_strategy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def handle_bar(context, bar_dict):
1313
try:
1414
order_target_value(context.s1, 0)
1515
order_target_value(context.s1, 500)
16+
17+
order_ = order_shares(context.s1, 100, style=LimitOrder(bar_dict[context.s1].limit_down))
18+
cancel_order(order_)
1619
finally:
1720
# 放在 finally 块中,以防原有代码抛出异常或者 return
1821
# 在函数结尾处加入以下语句,用来将模拟盘同步至实盘

0 commit comments

Comments
 (0)