哈希競(jìng)猜游戲系統(tǒng)開(kāi)發(fā)(方案及邏輯)丨哈希競(jìng)猜游戲開(kāi)發(fā)(源碼及項(xiàng)目)
哈希函數(shù)是一種從任何一種數(shù)據(jù)中創(chuàng)建小的數(shù)字指紋的方法。哈希函數(shù)把消息或數(shù)據(jù)壓縮成摘要,使得數(shù)據(jù)量變小,將數(shù)據(jù)的格式固定下來(lái)。該函數(shù)將數(shù)據(jù)打亂混合,重新創(chuàng)建一個(gè)叫做散列值的指紋。
未來(lái),人工智能技術(shù)將與其他學(xué)科知識(shí)融合,共同推動(dòng)教育教學(xué)的發(fā)展。例如,人工智能技術(shù)和心理學(xué)、教育學(xué)等學(xué)科的結(jié)合,可以更好地了解學(xué)生的心理需求和學(xué)習(xí)情況,提供更加科學(xué)、全面的教育教學(xué)方案。
void WtHftStraDemo::tqz_marketMaking(const int codeLongOffsetTicks,const int codeShortOffsetTicks){
if(!this->__isMarketMakingAble())
return;
this->__lockBuy();//lock market_making.
this->__lockShort();
std::string buyOrderComment("code_buyOrder_marketMaking");
std::string shortOrderComment("code_shortOrder_marketMaking");
區(qū)塊鏈游戲系統(tǒng)開(kāi)發(fā)技術(shù)I59模式2OO7開(kāi)發(fā)3O69
double currentMidPrice=this->_last_mid_price;//make sure mid price of market making is same.
double buyOrderPrice=this->__tqz_getMarketMakingLongPrice(this->_code.c_str(),currentMidPrice,codeLongOffsetTicks);
double shortOrderPrice=this->__tqz_getMarketMakingShortPrice(this->_code.c_str(),currentMidPrice,codeShortOffsetTicks);
uint32_t buyOrderLocalid=this->_ctx->stra_enter_long(this->_code.c_str(),buyOrderPrice,UNIT,buyOrderComment.c_str());
uint32_t shortOrderLocalid=this->_ctx->stra_enter_short(this->_code.c_str(),shortOrderPrice,UNIT,shortOrderComment.c_str());
std::string currentMarketTimeString=this->__tqz_getCurrentMarketTime();
std::string sendOrderTimeString=this->__tqz_getCurrentTime();
關(guān)于區(qū)塊鏈項(xiàng)目技術(shù)開(kāi)發(fā)唯:yy625019,代幣發(fā)行、dapp智能合約開(kāi)發(fā)、鏈游開(kāi)發(fā)、多鏈錢包開(kāi)發(fā)
交易所開(kāi)發(fā)、量化合約開(kāi)發(fā)、互助游戲開(kāi)發(fā)、Nft數(shù)字藏品開(kāi)發(fā)、眾籌互助開(kāi)發(fā)、元宇宙開(kāi)發(fā)、swap開(kāi)發(fā)、
鏈上合約開(kāi)發(fā)、ido開(kāi)發(fā)、商城開(kāi)發(fā)等,開(kāi)發(fā)過(guò)各種各樣的系統(tǒng)模式,更有多種模式、制度、案例、后臺(tái)等,成熟技術(shù)團(tuán)隊(duì),歡迎實(shí)體參考。
this->_code_buy_order=buyOrderLocalid;
this->_code_buy_orders.insert(buyOrderLocalid);
this->_code_short_order=shortOrderLocalid;
this->_code_short_orders.insert(shortOrderLocalid);
if(!this->_record_hft_log)
return;
double currentPrice=this->_ctx->stra_get_price(this->_code.c_str());//current market price.
this->_log_message_map[buyOrderLocalid]=this->__tqz_getNewLogMessage(this->_code,buyOrderLocalid,currentPrice,buyOrderPrice,"buy_order",currentMarketTimeString,sendOrderTimeString,buyOrderComment);
this->_log_message_map[shortOrderLocalid]=this->__tqz_getNewLogMessage(this->_code,shortOrderLocalid,currentPrice,shortOrderPrice,"short_order",currentMarketTimeString,sendOrderTimeString,shortOrderComment);
}
void WtHftStraDemo::tqz_closePositions(const std::string code,const uint32_t closePositionsOffsetTicks){
if(this->_ctx->tqz_getLongPosition(code.c_str())>0){///close long positions.
this->tqz_sell(code,UNIT,closePositionsOffsetTicks,"code_sellOrder_closePositions");
}else if(this->_ctx->tqz_getShortPosition(code.c_str())>0){///close short positions.
this->tqz_cover(code,UNIT,closePositionsOffsetTicks,"code_coverOrder_closePositions");
}
}
void WtHftStraDemo::tqz_doReconnect(){
if(this->__closeCodeIsLock(true))
return;
double currentCodeLongLots=this->_ctx->tqz_getLongPosition(this->_code.c_str());
double currentCodeShortLots=this->_ctx->tqz_getShortPosition(this->_code.c_str());
if(currentCodeLongLots>0&¤tCodeLongLots>=currentCodeShortLots){///have long position&long lots big.
this->tqz_sell(this->_code,UNIT,OPEN_CLOSE_POSITION_OFFSET_TICKS,"code_sellOrder_reConnect");
}else if(currentCodeShortLots>0&¤tCodeLongLots<currentCodeShortLots){///have short position&short lots big.
this->tqz_cover(this->_code,UNIT,OPEN_CLOSE_POSITION_OFFSET_TICKS,"code_coverOrder_reConnect");
}
}
bool WtHftStraDemo::__isEntrustable(std::string code){
if(this->__isBeyondUpperlimitOrLowerlimit(code,OPEN_CLOSE_POSITION_OFFSET_TICKS,OPEN_CLOSE_POSITION_OFFSET_TICKS))///because cancel limit is 100.
return false;
if(this->_ctx->tqz_getCancelCounts(code.c_str())>(this->_cancel_limit_counts+10)){
this->_ctx->stra_log_text("[WtHftStraDemo::__isEntrustable],out of cancel limit counts when entrust,code:%s,如果這條log被記錄了,說(shuō)明策略執(zhí)行邏輯被強(qiáng)行干擾了",code.c_str());
return false;
}
return true;
}
void WtHftStraDemo::__initSessionStatus(TQZSessionStatus sessionStatus){
this->_current_session_status=sessionStatus;
switch(sessionStatus){
case CLOSE_POSTIONS_STATUS:{
break;
}
case MARKET_MAKING_STATUS:{//position and order is empty in theory.
this->__unlockAllOrders();
this->__tqz_clearPreviousSessionCache();
this->_re_marketMaking=true;
break;
}
case RE_CONNECT_STATUS:{
this->__tqz_writeCancelOrderCountsLog(this->_code);
this->_re_connect_ready=this->__tqz_queryReconnectResult();
}
default:
break;
}
}
bool WtHftStraDemo::__tqz_queryReconnectResult(){
double codeLongLots=this->_ctx->tqz_getLongPosition(this->_code.c_str());
double codeShortLots=this->_ctx->tqz_getShortPosition(this->_code.c_str());
return(codeLongLots<0.00001&&codeShortLots<0.00001);//hold positions is empty.
}
void WtHftStraDemo::__tqz_clearPreviousSessionCache(){
//緩存清理無(wú)效,成員變量換成指針類型;(每小節(jié)初始化時(shí)清理一次)
this->_code_buy_orders.erase(this->_code_buy_orders.begin(),this->_code_buy_orders.end());
this->_code_sell_orders.erase(this->_code_sell_orders.begin(),this->_code_sell_orders.end());
this->_code_short_orders.erase(this->_code_short_orders.begin(),this->_code_short_orders.end());
this->_code_cover_orders.erase(this->_code_cover_orders.begin(),this->_code_cover_orders.end());
this->_log_message_map.clear();
}