多个KEY值对应一个VALUE的MAP

http://www.deuxmille.org/archives/1797

在整理国内期货的高频数据,也就是CTP里面发送的500毫秒级的交易信息。目前有几个数据源,首要任务就是要把几个数据源校验+合并。最初的想法是比较毫秒级的时间标签,如果时间标签一样,交易信息不一样,则肯定有一份数据源是错误的。按照这一校验思路,发现郑商所一秒钟发两次数据,但是不区分millisec字段,按照上一思路即会出现时间标签一样但是交易信息里面的volume字段不一样的情况。这时的需求就是需要一个map,value是交易信息,key1是时间标签,key2是volume标签,先按照时间排序,时间相同的按照volume来排序。按照此需求我构造了以下的KEY类:

 
class DateTimeVol{
public:
 DateTimeVol(ptime t, long int v):t(t),v(v){};
 DateTimeVol(string ss,long int v):v(v){t=time_from_string(ss);};
 string operator()()const{
  return to_simple_string(t).substr(0,22)+","+boost::lexical_cast<string>(v);
 };
 bool operator>(const DateTimeVol& cdv2) const{
  if(this->t>cdv2.t)return true;
  else if(this->t==cdv2.t){
   if(this->v>cdv2.v) return true;
   else return false;
  }
  else return false;
 };
 
 bool operator<(const DateTimeVol& cdv2) const{
  if(this->t<cdv2.t)return true;
  else if(this->t==cdv2.t){
   if(this->v<cdv2.v) return true;
   else return false;
  }
  else return false;
 };
 
 bool operator==(const DateTimeVol& cdv2)const{
  if(this->t==cdv2.t&&this->v==cdv2.v) return true;
  else return false;
 };
 
 bool operator>=(const DateTimeVol& cdv2)const{
  return operator>(cdv2)||operator==(cdv2);
 };
 
 bool operator<=(const DateTimeVol& cdv2)const{
  return operator<(cdv2)||operator==(cdv2);
 };
 
 friend inline ostream&operator<<(ostream& os,const DateTimeVol& a){
  os<<a();
  return os;
 }
 
private:
 ptime t;
 long int v;
};

 

完美了解决以上提出的需求,但是新的问题出现了,时间标签一样,volume标签一样,交易信息不一样。比如500毫秒的时间间隔内没有发生成交的交易,但是ask,bid信息改变过。同样的几条这样标签的交易信息,我是无法区分时间上的先后的。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值