金字塔PYTHON移動(dòng)止損策略代碼[金字塔模型]
相關(guān)標(biāo)簽:
?
【zzc_python】移動(dòng)止損范例
# 本Python代碼主要用于策略交易
# 可以自己import我們平臺(tái)支持的第三方python模塊,比如pandas、numpy等。
from PythonApi import *
from datetime import datetime
def init(context):
? ? context.hh = 0
? ??
?
?
?
# 你選擇的品種的數(shù)據(jù)更新將會(huì)觸發(fā)此段邏輯,例如日或分鐘歷史數(shù)據(jù)切片或者是實(shí)時(shí)數(shù)據(jù)切片更新。--(必須實(shí)現(xiàn))
def handle_bar(context):
? ? year = context.now.year
? ? month = context.now.month? ??
? ? day = context.now.day
? ? #print((year,month,day))
? ? if year==2018 and month==12 and day==3:
? ? ? ? buy_open("SQRB00", "Market",0 ,1)
? ? portfolio = get_portfolio ("RB00", 2)? ??
? ? bar_close = history_bars(\'SQRB00\',1,\'1d\',\'CLOSE\')
? ? if portfolio.buy_quantity>0 and bar_close>context.hh:
? ? ? ? context.hh = bar_close
? ? #print((context.hh,bar_close))
? ? if portfolio.buy_quantity>0 and (context.hh - bar_close)/context.hh >0.1:
? ? ? ? sell_close("SQRB00", "Market",0 ,1)
? ? ? ? context.hh = 0
?
{別忘了將本網(wǎng)告訴您身邊的朋友,向朋友傳達(dá)有用資料,也是一種人情,你朋友會(huì)感謝你的。}
?
有思路,想編寫各種指標(biāo)公式,交易模型,選股公式,還原公式的朋友
可聯(lián)系技術(shù)人員 QQ: 262069696 或微信:cxhjy888 進(jìn)行 有償收費(fèi) 編寫!(注:由于人數(shù)限制,QQ或微信請(qǐng)選擇方便的一個(gè)聯(lián)系我們就行,加好友時(shí)請(qǐng)簡(jiǎn)單備注下您的需求,否則無法通過。謝謝您!)
(怎么收費(fèi),代編流程等詳情請(qǐng)點(diǎn)擊查閱!)
(注:由于人數(shù)限制,QQ或微信請(qǐng)選擇方便的一個(gè)聯(lián)系我們就行,加好友時(shí)請(qǐng)簡(jiǎn)單備注下您的需求,否則無法通過。謝謝您!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容