Exemplo n.º 1
0
int main(int argc, char * argv[]){
  if(argc<2){
    fprintf(stdout,"Usage %s target [inputfile]\n",argv[0]);
    return EXIT_SUCCESS;
  }
  FILE *output=stdout, *input=stdin;
  (void) output;
  if(argc==3){
    input = fopen(argv[2],"r");
  }
  struct book theBook;
  theBook.asks = 0;
  theBook.bids = 0;
  theBook.nTrades = 0;
  if(!(sscanf(argv[1],"%u",&(theBook.target)))){
    fclose(input);
    fprintf(stdout,"Usage %s target [inputfile]\n",argv[0]);
    return EXIT_SUCCESS;
  }
  struct order *q=(struct order *)1;
  while(!(feof(input))){
    q = getOrderFromStream(input);
    if(q){
      addNewOrder(&theBook,q);
      //fprintf(stdout,"order added %u\n",theBook.clock);
      updatePrices(&theBook);
      //fprintf(stdout,"prices updated %u\n",theBook.clock);
      /*
      if(orderBookSanityCheck(&theBook)){
	fprintf(stdout,"Broken order book!!!\n");
	printBook(&theBook);
	freeBook(&theBook);
	return 1;
      }
      */
      //printBook(&theBook);
      //printOrder(stdout,q);
    }
  }
  if(argc==3){
    fclose(input);
  }
  //printBook(&theBook);
  freeBook(&theBook);
  fclose(input);
  return EXIT_SUCCESS;
}
Exemplo n.º 2
0
void menuSales::sUpdatePrices()
{
  updatePrices(parent, "", TRUE).exec();
}