logo

量化合约系统开发(参考版)丨量化合约开发(源码案例)

作者:开发薇_MrsFu1232023.03.14 14:05浏览量:219

简介:量化合约交易系统开发案例及源码

Hello World!  什么是量化交易?

  量化交易(Quantitative Trading)是通过数学模型和计算机算法对金融市场进行分析和预测,并基于此制定交易策略进行投资交易的一种交易方式。与传统的基本面分析、技术分析等方法不同,量化交易注重使用大量数据和科学的方法进行研究,减少了人为因素的影响,提高了交易的效率和准确性。

  量化交易的特征在于,它是一种基于数据和科学方法的交易方式,通常涉及大量数据分析、统计学、计算机科学等知识领域。与传统交易相比,量化交易使用了更加精细和高效的交易策略,能够更快速地获取市场信息、分析市场趋势和规律,并进行相应的交易决策。

  std::string logString=”[code|”+logMessage.code+”,order_type|”+logMessage.orderType+”,orderid|”+to_string(logMessage.orderid)+”,market_price_of_send_order|”+to_string(logMessage.currentPrice)+”,market_time_of_send_order|”+logMessage.currentMarketTime+”,send_order_price|”+to_string(logMessage.orderPrice)+”,send_order_time|”+logMessage.sendOrderTime+”,receive_trade_price|”+to_string(receiveTradePrice)+”,receive_trade_time|”+this->__tqz_getCurrentTime()+”,lots|”+to_string(lots)+”,volScale|”+to_string(this->_ctx->stra_get_comminfo(this->_code.c_str())->getVolScale())+”,order_comment|”+logMessage.orderComment+”]”;

  this->_ctx->tqz_writeLog(this->_tradeChange_log_filename,logString);

  }

  void WtHftStraDemo::__tqz_writeCancelOrderCountsLog(const std::string code){

  int now=this->__tqz_getCurrentHourMinute();

  if(now<1500||now>1630)

  return;

  uint32_t cancel_order_counts=this->_ctx->tqz_getCancelCounts(code.c_str());

  std::string logString=”[code|”+code+”,cancel_order_counts|”+to_string(cancel_order_counts)+”]”;

  this->_ctx->tqz_writeLog(this->__tqz_getLogFileName(CANCEL_ORDER_COUNTS_TYPE),logString);

  }

  TQZLogMessage WtHftStraDemo::__tqz_getNewLogMessage(std::string code,uint32_t orderid,double currentPrice,double orderPrice,char*orderType,std::string currentMarketTime,std::string sendOrderTime,std::string orderComment){

  return TQZLogMessage(code,orderid,currentPrice,orderPrice,orderType,currentMarketTime,sendOrderTime,orderComment);

  }

  uint64_t WtHftStraDemo::__getCurrentTimestamp(){

  const boost::posix_time::ptime now=boost::posix_time::microsec_clock::local_time();

  const boost::posix_time::time_duration timeOfDay=now.time_of_day();

  boost::posix_time::ptime epoch(boost::gregorian::date(1970,boost::gregorian::Jan,1));

  boost::posix_time::time_duration time_from_epoch=boost::posix_time::second_clock::universal_time()-epoch;

  return time_from_epoch.total_seconds();

  }

  bool WtHftStraDemo::__isNewScanInterval(const uint32_t scanInterval){

  uint64_t now=this->__getCurrentTimestamp();

  bool isNew=(now-this->_last_scan_time<scanInterval)?false:true;

  if(isNew)

  this->_last_scan_time=now;

  return isNew;

  }

  void WtHftStraDemo::__lockBuy(){

  this->_code_buy_lock=true;

  }

  void WtHftStraDemo::__lockSell(){

  this->_code_sell_lock=true;

  }

  void WtHftStraDemo::__lockShort(){

  this->_code_short_lock=true;

  }

  void WtHftStraDemo::__lockCover(){

  this->_code_cover_lock=true;

  }

  void WtHftStraDemo::__unlockBuy(){

  this->_code_buy_lock=false;

  }

  void WtHftStraDemo::__unlockSell(){

  this->_code_sell_lock=false;

  }

  void WtHftStraDemo::__unlockShort(){

  this->_code_short_lock=false;

  }

  void WtHftStraDemo::__unlockCover(){

  this->_code_cover_lock=false;

  }

相关文章推荐

发表评论