量化合約/合約量化/秒合約/永續(xù)合約/合約跟單/現(xiàn)貨期權(quán)期貨/交易所系統(tǒng)開發(fā)技術(shù)詳細
量化合約指的是目標(biāo)或任務(wù)具體明確,可以清晰度量。根據(jù)不同情況,表現(xiàn)為數(shù)量多少,具體的統(tǒng)計數(shù)字,范圍衡量,時間長度等等。所謂量化就是把經(jīng)過抽樣得到的瞬時值將其幅度離散,即用一組規(guī)定的電平,把瞬時抽樣值用最接近的電平值來表示。經(jīng)過抽樣的圖像,只是在空間上被離散成為像素(樣本)的陣列。而每個樣本灰度值還是一個由無窮多個取值的連續(xù)變化量,必須將其轉(zhuǎn)化為有限個離散值,賦予不同碼字才能真正成為數(shù)字圖像。這種轉(zhuǎn)化稱為量化。
def handle_bar(context,bar_dict):
...
if newPrice>=context.nextSellPrice:
logger.info("執(zhí)行高拋交易,對應(yīng)價格:{}".format(newPrice))
amount=context.portfolio.positions[context.s1].quantity
if amount>=context.tradeNumber:開發(fā)模式I35流程7O98設(shè)計O7I8
logger.info("執(zhí)行高拋交易,對應(yīng)數(shù)量:{}".format(context.tradeNumber))
order_shares(context.s1,-context.tradeNumber)
plot("S",newPrice)
elif amount>=100:
logger.info("執(zhí)行高拋交易,對應(yīng)數(shù)量:{}".format(amount))
order_shares(context.s1,-amount)
plot("S",newPrice)
calc_next_trade_price(context,newPrice)
obj={案例及源碼:MrsFu123
"nextSellPrice":context.nextSellPrice,
"nextBuyPrice":context.nextBuyPrice,
"curTradePrice":context.curTradePrice
}
context.buyTradeList.append(obj)
if newPrice<=context.nextBuyPrice:
logger.info("執(zhí)行低吸交易,對應(yīng)價格:{}".format(newPrice))
amount=int(context.portfolio.cash/newPrice/100.0)*100
if amount>=context.tradeNumber:
logger.info("執(zhí)行低吸交易,對應(yīng)數(shù)量:{}".format(context.tradeNumber))
order_shares(context.s1,context.tradeNumber)
plot("B",newPrice)
calc_next_trade_price(context,newPrice)
obj={
"nextSellPrice":context.nextSellPrice,
"nextBuyPrice":context.nextBuyPrice,
"curTradePrice":context.curTradePrice
}
context.sellTradeList.append(obj)