开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

twsapi: Re: order IDs


ruffstuff123
 

I think it should be possible to get the IDs from TWS.....
When TWS logs in it produces a list with standing orders.
Maybe also from a database...?

Best would be if a ticker could be entered in a 3rd party program.
That program checks if TWS already has that ticker active.
If not then it creates a new id.
If kinda afraid of what happens if you add/delete something directly
from TWS and after that start the program.
Big chance it resubmits the order.
Or am I overlooking something?



--- In twsapi@y..., "Marcus Jellinghaus" <Marcus_Jellinghaus@G...>
wrote:
I store everything in a database, including the order details and
the order
id.
When you have a Limit order which doesn?t get executed, and you
disconnect,
close TWS, open TWS, and reconnect through the API to TWS, then TWS
forget?s
the API order ID.

So I decided that I cancel all open orders manually in TWS and then
send all
open orders again from my programm to TWS.

Marcus

-----Ursprungliche Nachricht-----
Von: kxlin99 [mailto:klin@p...]
Gesendet: Sunday, June 30, 2002 1:49 AM
An: twsapi@y...
Betreff: twsapi: Re: order IDs


Hi there -

I would like to know how you manage order ids from session to
session. I meant you place an order and store the order id in your
table, what if the TWS/Windows crashed, and you need reboot the
machine, how do you change/cancel your open orders? Thanks

--- In twsapi@y..., Robert Carey <rcarey1@o...> wrote:
You have to keep track of your trading over time. You have to keep
track of what you or your Automated Trading System is doing. You
need
to store what was done, when, and why.
Besides, the IRS is coming on 4/15/2003 for sure, if not sooner.
That means storage of your trading events on a hard drive and with
backup.
I choose to use the Microsoft .mdb format and access it from VB
with DAO 3.6.
There is a table of trades. It has an entry order number and an
exit order number in each record. There are lots of other fields to
keep track of when, where, and why.
A recordset RS.TradesEnter is created indexed on the
openOrderNumber.
A recordset RS.TradesExit is created indexed on the
exitOrderNumber.
They both point to the same table.

Creating a unique entry order number is as follows.
RS.TradesEnter.MoveLast
thisEntryOrderNumber = RS.TradesEnter![openOrderNumber] + 2
thisExitOrderNumber = thisEntryOrderNumber + 1
Now create a new trade record.
RS.TradesEnter.AddNew
RS.TradesEnter![openOrderNumber] = thisEntryOrderNumber
RS.TradesEnter![closeOrderNumber] = thisExitOrderNumber
RS.TradesEnter.Update

When a fill arrives, whether partial of full, RS.TradesEnter
updates the when,where,why fields.
When you or your ATS decides to close a position,
RS.TradesExit "seeks" this ExitOrderNumber and updates the when,
where, why fields.
That should keep you and the IRS happy.
Comments?
RCarey

Yahoo! Groups Sponsor
ADVERTISEMENT



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@y...



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


Richard Foulk
 

Let's try to remember that the API is still beta. So if it doesn't
work propperly or reasonably or logically -- then please report it
to the IB folks so it can be fixed.

Don't just work around it in strange on crazy ways.

This is a great facility. Let's do our part to make it better.


Richard

} I think it should be possible to get the IDs from TWS.....
} When TWS logs in it produces a list with standing orders.
} Maybe also from a database...?
}
} Best would be if a ticker could be entered in a 3rd party program.
} That program checks if TWS already has that ticker active.
} If not then it creates a new id.
} If kinda afraid of what happens if you add/delete something directly
} from TWS and after that start the program.
} Big chance it resubmits the order.
} Or am I overlooking something?
}
}
}
} --- In twsapi@y..., "Marcus Jellinghaus" <Marcus_Jellinghaus@G...>
} wrote:
} > I store everything in a database, including the order details and
} the order
} > id.
} > When you have a Limit order which doesn?t get executed, and you
} disconnect,
} > close TWS, open TWS, and reconnect through the API to TWS, then TWS
} forget?s
} > the API order ID.
} >
} > So I decided that I cancel all open orders manually in TWS and then
} send all
} > open orders again from my programm to TWS.
} >
} > Marcus
} >
} > -----Ursprungliche Nachricht-----
} > Von: kxlin99 [mailto:klin@p...]
} > Gesendet: Sunday, June 30, 2002 1:49 AM
} > An: twsapi@y...
} > Betreff: twsapi: Re: order IDs
} >
} >
} > Hi there -
} >
} > I would like to know how you manage order ids from session to
} > session. I meant you place an order and store the order id in your
} > table, what if the TWS/Windows crashed, and you need reboot the
} > machine, how do you change/cancel your open orders? Thanks
} >
} > --- In twsapi@y..., Robert Carey <rcarey1@o...> wrote:
} > > You have to keep track of your trading over time. You have to keep
} > track of what you or your Automated Trading System is doing. You
} need
} > to store what was done, when, and why.
} > > Besides, the IRS is coming on 4/15/2003 for sure, if not sooner.
} > > That means storage of your trading events on a hard drive and with
} > backup.
} > > I choose to use the Microsoft .mdb format and access it from VB
} > with DAO 3.6.
} > > There is a table of trades. It has an entry order number and an
} > exit order number in each record. There are lots of other fields to
} > keep track of when, where, and why.
} > > A recordset RS.TradesEnter is created indexed on the
} > openOrderNumber.
} > > A recordset RS.TradesExit is created indexed on the
} exitOrderNumber.
} > > They both point to the same table.
} > >
} > > Creating a unique entry order number is as follows.
} > > RS.TradesEnter.MoveLast
} > > thisEntryOrderNumber = RS.TradesEnter![openOrderNumber] + 2
} > > thisExitOrderNumber = thisEntryOrderNumber + 1
} > > Now create a new trade record.
} > > RS.TradesEnter.AddNew
} > > RS.TradesEnter![openOrderNumber] = thisEntryOrderNumber
} > > RS.TradesEnter![closeOrderNumber] = thisExitOrderNumber
} > > RS.TradesEnter.Update
} > >
} > > When a fill arrives, whether partial of full, RS.TradesEnter
} > updates the when,where,why fields.
} > > When you or your ATS decides to close a position,
} > RS.TradesExit "seeks" this ExitOrderNumber and updates the when,
} > where, why fields.
} > > That should keep you and the IRS happy.
} > > Comments?
} > > RCarey