'''
股票t+0操作研究
当股票被套住,解套的方法,也就是说,如果买入某只股票,反而降价,这时可以再买入同等数量的该股票,等价格回升再将该相同数量股票卖出。
'''
security='000300.XSHG'
g.buynum=100
g.signal=0
now=datetime.datetime.now()
delta=datetime.timedelta(days=1)
n_days=now-delta
df1 = get_price(security, count = 1, end_date=n_days, frequency='daily', fields=['close','low'])
df2 = get_price(security, count = 1, end_date=datetime.datetime.now(), frequency='daily', fields=['open'])
if (df1['close']-df1['low'])<0:
if (df2['open']<df1['close'])&(g.signal==0):
buystock(security)
g.signal=1
if (g.signal==1)&(df2['open']>df1['close']):
sellstock(security)
g.signal=0