等级: 新手上路
- 注册:
- 2021-6-28
- 曾用名:
|
import time
import os
import csv
import numpy
import talib as ta
def init(context):
context.s = context.run_info.base_book_id
def before_trading(context):
pass
def handle_bar(context):
dd = get_indicator(context.s, 'zz', 'd', '1', 'self', 100, True, False, False)
kk = get_indicator(context.s, 'zz', 'k', '1', 'self', 100, True, False, False)
if dd[-1] == 1 and portfolio.sell_quantity>0:
buy_close(context.s,"market",0,portfolio.sell_quantity,serial_id = 1)
if kk[-1] == 1 and portfolio.buy_quantity>0:
sell_close(context.s,"market",0,portfolio.buy_quantity,serial_id = 2)
if dd[-1] == 1 and portfolio.buy_quantity==0:
buy_open(context.s, "market",0, 1,serial_id = 3)
if kk[-1] == 1 and portfolio.sell_quantity==0:
sell_open(context.s, "market",0, 1,serial_id = 4)
def after_trading(context):
pass
|
|