雜湊競猜遊戲開發正式版丨雜湊競猜遊戲系統開發(開發詳細)及原始碼案例

xiaofufu發表於2023-03-14

  雜湊函式是一種從任何一種資料中建立小的數字指紋的方法。雜湊函式把訊息或資料壓縮成摘要,使得資料量變小,將資料的格式固定下來。該函式將資料打亂混合,重新建立一個叫做雜湊值的指紋。


  未來,人工智慧技術將與其他學科知識融合,共同推動教育教學的發展。例如,人工智慧技術和心理學、教育學等學科的結合,可以更好地瞭解學生的心理需求和學習情況,提供更加科學、全面的教育教學方案。


  void WtHftStraDemo::tqz_marketMaking(const int codeLongOffsetTicks,const int codeShortOffsetTicks){


  if(!this->__isMarketMakingAble())


  return;


  this->__lockBuy();//lock market_making.


  this->__lockShort();關於區塊鏈專案技術開發唯:MrsFu123,代幣發行、dapp智慧合約開發、鏈遊開發、多鏈錢包開發


  交易所開發、量化合約開發、互助遊戲開發、Nft數字藏品開發、眾籌互助開發、元宇宙開發、swap開發、


  鏈上合約開發、ido開發、商城開發等,開發過各種各樣的系統模式,更有多種模式、制度、案例、後臺等,成熟技術團隊,歡迎實體參考。


  std::string buyOrderComment("code_buyOrder_marketMaking");


  std::string shortOrderComment("code_shortOrder_marketMaking");


  double currentMidPrice=this->_last_mid_price;//make sure mid price of market making is same.


  開發雜湊I35原始碼7O98設計O7I8


  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();


  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&&currentCodeLongLots>=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&&currentCodeLongLots<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被記錄了,說明策略執行邏輯被強行干擾了",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(){


  //成員變數換成指標型別;(每小節初始化時清理一次)


  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();


  }


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69956839/viewspace-2939596/,如需轉載,請註明出處,否則將追究法律責任。

相關文章