哈希竞猜游戏系统丨哈希竞猜游戏系统开发(开发案例及详细)丨哈希竞猜游戏开发源码部署

109 阅读2分钟

  哈希函数是一种从任何一种数据中创建小的数字指纹的方法。哈希函数把消息或数据压缩成摘要,使得数据量变小,将数据的格式固定下来。该函数将数据打乱混合,重新创建一个叫做散列值的指纹。

  未来,人工智能技术将与其他学科知识融合,共同推动教育教学的发展。例如,人工智能技术和心理学、教育学等学科的结合,可以更好地了解学生的心理需求和学习情况,提供更加科学、全面的教育教学方案。

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

  }