By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,147 Members | 1,483 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,147 IT Pros & Developers. It's quick & easy.

seeking better solution for resetting ID

P: n/a
I use the following code to reset an ID when an order has been filled
by more than one trade. For example, order= buy 9 corn, order ID =
101. If the order is filled with three separate trades of, say, 3
each, I need three order IDs (i.e. 101.1, 101.2, 101.3). My simple
solution was to use a "char" set to '0' then increment the char for
each multiple ID. This works fine if there are only 10 "multi ID
trades", but after that the ascii symbols get weird. Any
recommendations for a better solution?

if(numTrades>1) //setting order ID for mult fills for single order
{
int dex=y;
char id='0';

for(int a=1; a<=numTrades; a++)
{
string s_id=".";
id+=1;
s_id+=id;
string multiTradeId=orderID+s_id;
vTrades[dex++].resetOrderId(multiTradeId);
}
}

Jun 2 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a

<ka*****@hotmail.comwrote in message ...
I use the following code to reset an ID when an order has been filled
by more than one trade. For example, order= buy 9 corn, order ID =
101. If the order is filled with three separate trades of, say, 3
each, I need three order IDs (i.e. 101.1, 101.2, 101.3). My simple
solution was to use a "char" set to '0' then increment the char for
each multiple ID. This works fine if there are only 10 "multi ID
trades", but after that the ascii symbols get weird. Any
recommendations for a better solution?
#include <sstream>
if(numTrades>1){ // setting order ID for mult fills for single order
int dex=y;
// char id='0';

for( int a( 1 ); a <= numTrades; ++a){
std::ostringstream sos;
sos << a;
std::string s_id( "." + sos.str() );

// id+=1;
string multiTradeId=orderID+s_id;
vTrades[dex++].resetOrderId(multiTradeId);
} // for(a)
}
If 'orderID' is a std::string, you could do:
std::string multiTradeId( orderID + "." + sos.str() );
So, it would look like this:

if( numTrades >1){ // setting order ID for mult fills for single order
int dex( y ); // whatever 'y' is set to???
for( int a( 1 ); a <= numTrades; ++a){
std::ostringstream sos;
sos << a;
std::string multiTradeId( orderID + "." + sos.str() );
vTrades[ dex++ ].resetOrderId( multiTradeId );
} // for(a)
} // if(numTrades)

--
Bob R
POVrookie
Jun 2 '07 #2

P: n/a
<ka*****@hotmail.comwrote in message
news:11**********************@q69g2000hsb.googlegr oups.com...
>I use the following code to reset an ID when an order has been filled
by more than one trade. For example, order= buy 9 corn, order ID =
101. If the order is filled with three separate trades of, say, 3
each, I need three order IDs (i.e. 101.1, 101.2, 101.3). My simple
solution was to use a "char" set to '0' then increment the char for
each multiple ID. This works fine if there are only 10 "multi ID
trades", but after that the ascii symbols get weird. Any
recommendations for a better solution?

if(numTrades>1) //setting order ID for mult fills for single order
{
int dex=y;
char id='0';

for(int a=1; a<=numTrades; a++)
{
string s_id=".";
id+=1;
s_id+=id;
string multiTradeId=orderID+s_id;
vTrades[dex++].resetOrderId(multiTradeId);
}
}
It depends, what do you want to happen after 9 fullfillments? Do you want
it to become 101.10 or 101.a or 101.A or soemthing else?
And if you use 101.a what do you want to happen after 36 fullfillments? In
other words, what comes after 101.z?
Jun 3 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.