多个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(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->tt==cdv2.t){
   if(this->vt==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<

 

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

 

你可能感兴趣的:(CTP)