473,379 Members | 1,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

seeking better solution for resetting ID

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
2 1475

<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
<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: David | last post by:
I am a full-time freelance writer. I am seeking an established, professional web designer who has designed more than one successful website for freelance writers. The individual needs to be able...
20
by: Jim | last post by:
Hi, I am hoping that someone here can help me out. I am for the first time trying to implement a page design using only CSS instead of HTML tables. I've been able to get most of the page done...
7
by: semedao | last post by:
Hi, I am using cryptostream on both sides on tcp connection that pass data. I am also use asyc socket , so , the data that recieved in the callback method not always have the length of the buffer...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.