python發明者叫什麼 python test

2021-10-10 03:49:41 字數 2463 閱讀 4493

python_test

python_test

author: hukybo, date: 2020-08-31 22:13:30

tags:

'''backtest

start: 2020-09-03 00:00:00

end: 2020-09-04 00:00:00

period: 5m

baseperiod: 1m

exchanges:

mp=0 # 定義乙個全域性變數 mp=0空倉,=1開多單,=-1開空單

prc=0

def lessthan_0(arr):

arr_len=len(arr)

if arr[arr_len-1]>arr[arr_len-2] and arr[arr_len-2]<0 and arr[arr_len-1]>0:

return true

def morethan_100(arr):

arr_len=len(arr)

if arr[arr_len-1]100 and arr[arr_len-1]<100:

return true

def is_up(arr):

arr_len=len(arr)

if arr[arr_len-1]>arr[arr_len-2] and arr[arr_len-2]>arr[arr_len-3]:

return true

def is_down(arr):

arr_len=len(arr)

if arr[arr_len-1]

return true

def is_up_cross(arr1,arr2):

if arr1[len(arr1)-2]arr2[len(arr2)-1]:

return true

def is_down_cross(arr1,arr2):

if arr1[len(arr1)-2]>arr2[len(arr2)-2] and arr1[len(arr1)-1]

return true

def ontick():

exchange.setcontracttype("ma888")

bar_arr=exchange.getrecords(period_m5)

if len(bar_arr)<36:

return

all_macd=ta.macd(bar_arr,12,26,9)

dif=all_macd[0]

dif.pop()

dea=all_macd[1]

dea.pop()

all_kdj=ta.kdj(bar_arr,9,3,3)

j=all_kdj[2]

j.pop()

last_close=bar_arr[len(bar_arr)-1]['close']

global mp

global prc

if mp==0 and is_up_cross(dif,dea):

log("")

log("開始多倉")

exchange.setdirection("buy")

exchange.buy(last_close,1)

prc=last_close

mp=1

if mp==0 and is_down_cross(dif,dea):

log("")

log("開始空倉")

exchange.setdirection("sell")

exchange.sell(last_close,1)

prc=last_close

mp=-1

if mp==1 and (last_close-prc==10.0 or last_close-prc==-10.0):

log("平多前j值:",j[len(j)-1])

exchange.setdirection("closebuy")

exchange.sell(last_close-1,1)

mp=0

log("平多時j值:",j[len(j)-1])

log("平多倉")

log("")

if mp==-1 and (last_close-prc==-10.0 or last_close-prc==13.0):#空平條件:last_close當前價-prc開空單價,賺10元執行或者賠13元執行平倉

log("平空前j值:",j[len(j)-1])

exchange.setdirection("closesell")

exchange.buy(last_close-1,1)

mp=0

log("平空時j值:",j[len(j)-1])

log("平空倉")

log("")

def main():

while true:

ontick()

sleep(1000)

python發明者叫什麼 python是誰發明的

python是誰發明的?python 由 guido van rossum 荷蘭人吉多 範羅蘇姆 於1989年開發推出。python的歷史 名稱背後的故事 python的創始人為荷蘭人吉多 範羅蘇姆 guido van rossum 1989年聖誕節期間,在阿姆斯特丹,guido為了打發聖誕節的無趣...

快速排序演算法的發明者霍爾

霍爾 sir charles antony richard hoare 是一位英國計算機科學家,他也是著名的快速排序演算法的發明者。他出生於斯里蘭卡,1956年畢業於牛津大學。然後的兩年裡他服役於英國皇家海軍,主要工作任務是研究 的現代軍事,並因為這個原因開始學習俄語。在他結束服役後,他以研究生的身...

網際網路BBS發明者去世 享年74歲

現在,你還經常逛論壇嗎?網際網路程式設計客棧程式設計客棧論壇或者說bbs 電子公告牌 是們分享資訊 交流觀點 學習互助 拓展圈子等的www.cppcns.com一大方式之一,這一內容形態的發明人是來自美國的randy suess 以下簡稱 蘇思 遺憾的是,據外媒報道,12 月 10 日,蘇思在芝加哥...