Thread: Submission of a order to buy

  1. #1
    Registered User
    Join Date
    Mar 2017
    Posts
    2

    Submission of a order to buy

    Hi guys.

    I am writing a code for submitting of order to buy, however it doesn't work. What I should do is to submit one limit order at a time.
    Could you please check it?



    /* Submission of order to buy */


    insert
    Code:
     if (r_i>0) {
    tot_cash[i]=cash[i]-limit_cash[i];
    tot_stocks[i]=stocks[i]-limit_stock[i];
    size=(int)(ran2(&idum)*(tot_cash[i]/b[i])));
    if(size<0){
    printf(“ERROR”, i, tot_stocks[i], stocks[i], limit_stock[i], size, b[i]);
    size=0;
    }
    if(size>stock_max) {
    size=stock_max;
    }
    for(n_trades=0; n_trades<size; n_trades++){
    if(N_a==0){
    temp=1;
    tr=0;
    sign_limit=1;
    vol_bid_limit ++;
    limit_cash[i]+=b[i];
    status[i]++;
    k=-1;
    while (k<N_b){
    k++
    if(b[i]<bl[k]) break;
    }
    k_insert=k;
    for(k = N_b - 1; k > k_insert - 1 ; k--) {
    bl[k+1]=bl[k];
    b_trader[k+1] = b_trader[k] ; bo_t_entry[k+1] = bo_t_entry[k]; 
    }
    bl[k_insert]= b[i]; b_trader[k_insert] = i; bo_t_entry[k_insert] = t; b_t_entry[i] = t;
    N_b ++; 
    }
    else if(N_a>0&&b[i]< al[N_a-1]){ 
    temp=1;
    tr =0;
    sign_limit=1; vol_bid_limit ++; limit_cash[i]+=b[i]; status[i] ++;
    k=-1;
    while( k < N_b){ 
    k++; 
    if(b[i] < bl[k]) break; } 
    k_insert=k;
    for(k = N_b - 1; k > k_insert - 1 ; k--){ 
    bl[k+1]=bl[k];
    b_trader[k+1] = b_trader[k] ; bo_t_entry[k+1] = bo_t_entry[k]; 
    }
    bl[k_insert]= b[i];
    b_trader[k_insert] = i; bo_t_entry[k_insert] = t; b_t_entry[i] = t;
    N_b ++; 
    } 
    else if (N_a >=1
    sign_market=1;
    vol_bid_market
    trading_volume
    p[t]=al[N_a-1];
    execution_time = t- ao_t_entry[N_a-1]; execution_time=1; 
    if(execution_time < TIME_MAX){ 
    distribution_time_a[execution_time]++; count_time_a++; 
    }
    b_t_trade[i] = t;
    b_t_entry[i] = t; status[a_trader[N_a-1]] --; a_t_trade[a_trader[N_a-1]] = t; stocks[i]++; stocks[a_trader[N_a-1]]--; limit_stock[a_trader[N_a-1]]--; 
    cash[a_trader[N_a-1]]+= al[N_a-1]; cash[i] -=al[N_a-1];
    } 
    } 
    }
    Many thanks.
    Last edited by Salem; 03-15-2017 at 08:14 AM. Reason: Fixed tags train wreck

  2. #2
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Your question is incomprehensible. Your code is unreadable.

    If you want help you'll have to try harder to describe your problem and you'll have to properly post and space/indent your code.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,664
    Quite how you expect us to comment on such badly indented code when all the variable declarations are missing and no statement as to what the input data looks like is beyond me.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Mar 2017
    Posts
    2
    Sorry, guys, for the unreadable code! Fortunately I solved this problem. The code was very long to write. Thanks anyway

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 04-01-2011, 04:13 PM
  2. Replies: 4
    Last Post: 03-06-2008, 03:38 PM
  3. 46 hours to assignment submission
    By technoXavage in forum Game Programming
    Replies: 9
    Last Post: 12-23-2003, 03:15 PM
  4. what is the significance of low order and high order bits
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 11-16-2002, 11:46 AM

Tags for this Thread