現(xiàn)貨期權(quán)交易所開發(fā)源碼,現(xiàn)貨期權(quán)交易所系統(tǒng)開發(fā)(海外版)
The development technology of digital currency exchange is a decentralized consensus mechanism to maintain a complete,distributed and tamper-proof ledger database.It enables participants in the blockchain to achieve a unified ledger system without establishing trust relationships. As a new information and network technology,blockchain uses encryption technology,distributed network and consensus mechanism to ensure that the information recorded by each node in the network is true and effective.Blockchain is constantly penetrating into all walks of life and has shown a good development trend. huobipro=ccxt.huobipro({ 'apiKey':'', 'secret':'', })開發(fā)流程I35分析7O98源碼O7I8 先使用ccxt獲取交易所的實例,然后獲取歷史k線,得到的數(shù)據(jù)使用dataframe格式接受 huobipro.fetch_ohlcv(symbol=symbol,limit=limit_num,timeframe=timeframe) 然后利用pandas提供的函數(shù)計算MA, df['median_short']=df['close'].rolling(n_short,min_periods=1).mean() df['median_long']=df['close'].rolling(n_long,min_periods=1).mean() 需求及邏輯開發(fā):mrsfu123 然后再找出買入賣出信號, #找出買入信號 condition1=df['median_short']>df['median_long']#短均線上穿長均線 condition2=df['median_short'].shift(1)<=df['median_long'].shift(1) df.loc[condition1&condition2,'signal']=1#產(chǎn)生買入信號的k線標(biāo)記為1 #找出賣出信號 condition1=df['median_short']<df['median_long']#短均線上穿長均線 condition2=df['median_short'].shift(1)>=df['median_long'].shift(1) df.loc[condition1&condition2,'signal']=0#產(chǎn)生賣出信號的k線標(biāo)記為0 有了交易信號,就可以獲取信號,再判斷進(jìn)行下單(huobipro.create_limit_buy/sell_order()了) 第五步:其實第四步就可以交易了,第五步是回測,一般來說先回測再根據(jù)回測結(jié)果選用策略,最后才進(jìn)行實盤 回測分析的相關(guān)有很多種,在這方面我也不是很懂,目前我還是習(xí)慣用累計利潤來進(jìn)行分析, #由signal計算出實際的每天持倉 df['pos']=df['signal'].shift() df['pos'].fillna(method='ffill',inplace=True) df['pos'].fillna(value=0,inplace=True) 到這里持倉信號就有了,就可以根據(jù)持倉和歷史k線的價格計算累計利潤了, df['change']=df['close'].pct_change(1)#根據(jù)收盤價計算漲跌幅 df['by_at_open_change']=df['close']/df['open']-1#開盤買入到收盤的漲跌幅 df['sell_next_open_change']=df['open'].shift(-1)/df['close']-1#這根收盤到下根開盤的漲跌幅 df.at[len(df)-1,'sell_next_open_change']=0#補(bǔ)全空值df.a