量化合約開發(專案)丨量化合約系統開發(方案詳細)丨量化合約系統原始碼版

xiaofufu發表於2023-02-28

  For quantitative trading,the most important thing is the establishment of models.Generally speaking,it is to use modern statistics and mathematical methods,use computer technology to find laws that can bring excess returns from massive historical data to formulate strategies,and use mathematical models to verify and solidify these laws and strategies,and then strictly implement them through programmed trading


  機器人內建多種交易策略,從“保守-”到“激進+”,滿足不同的風險型別。設定策略後,機器人將智慧分配每次進單的倉位和條件,嚴格執行交易策略,交易補單策略,根據當前行情,雲大資料實時調整。


  Calibration::Calibration(MNN::NetT*model,uint8_t*modelBuffer,const int bufferSize,const std::string&configPath)


  :_originaleModel(model){


  //when the format of input image is RGB/BGR,channels equal to 3,GRAY is 1


  int channles=3;


  //解析json


  rapidjson::Document document;


  {


  std::ifstream fileNames(configPath.c_str());


  std::ostringstream output;


  output<<fileNames.rdbuf();


  auto outputStr=output.str();


  document.Parse(outputStr.c_str());


  if(document.HasParseError()){


  MNN_ERROR("Invalid jsonn");


  return;開發需求及案例:MrsFu123


  }


  }


  auto picObj=document.GetObject();


  //構造ImageProcess::config物件,將json內容傳入


  ImageProcess::Config config;


  config.filterType=BILINEAR;


  config.destFormat=BGR;


  {


  if(picObj.HasMember("format")){


  auto format=picObj["format"].GetString();


  static std::map<std::string,ImageFormat>formatMap{{"BGR",BGR},{"RGB",RGB},{"GRAY",GRAY}};


  if(formatMap.find(format)!=formatMap.end()){


  config.destFormat=formatMap.find(format)->second;


  }


  }


  }


  if(config.destFormat==GRAY){


  channles=1;


  }


  config.sourceFormat=RGBA;


  std::string imagePath;


  _imageNum=0;


  {


  if(picObj.HasMember("mean")){


  auto mean=picObj["mean"].GetArray();


  int cur=0;


  for(auto iter=mean.begin();iter!=mean.end();iter++){


  config.mean[cur++]=iter->GetFloat();


  }


  }


  if(picObj.HasMember("normal")){


  auto normal=picObj["normal"].GetArray();


  int cur=0;


  for(auto iter=normal.begin();iter!=normal.end();iter++){


  config.normal[cur++]=iter->GetFloat();


  }


  }


  if(picObj.HasMember("width")){


  _width=picObj["width"].GetInt();


  }


  if(picObj.HasMember("height")){


  _height=picObj["height"].GetInt();


  }


  if(picObj.HasMember("path")){


  imagePath=picObj["path"].GetString();


  }


  if(picObj.HasMember("used_image_num")){


  _imageNum=picObj["used_image_num"].GetInt();


  }


  if(picObj.HasMember("feature_quantize_method")){


  std::string method=picObj["feature_quantize_method"].GetString();


  if(Helper::featureQuantizeMethod.find(method)!=Helper::featureQuantizeMethod.end()){


  _featureQuantizeMethod=method;


  }else{


  MNN_ERROR("not supported feature quantization method:%sn",method.c_str());


  return;


  }


  }


  if(picObj.HasMember("weight_quantize_method")){


  std::string method=picObj["weight_quantize_method"].GetString();


  if(Helper::weightQuantizeMethod.find(method)!=Helper::weightQuantizeMethod.end()){


  _weightQuantizeMethod=method;


  }else{


  MNN_ERROR("not supported weight quantization method:%sn",method.c_str());


  return;


  }


  }


  DLOG(INFO)<<"Use feature quantization method:"<<_featureQuantizeMethod;


  DLOG(INFO)<<"Use weight quantization method:"<<_weightQuantizeMethod;


  }


  std::shared_ptr<ImageProcess>process(ImageProcess::create(config));//生成ImageProcess物件


  _process=process;


  //read images file names


  Helper::readImages(_imgaes,imagePath.c_str(),&_imageNum);


  _initMNNSession(modelBuffer,bufferSize,channles);


  _initMaps();


  }


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

相關文章