First post and odd-lot question...
This is a great group! I looked over the sample VB programs, opened
an account at IB and now my head is swimming with ideas. :)
I'm thinking of writing a utility that will monitor my open positions
during the day, then implement a trailing stop by updating a stop
order based on each stock's 14 day ATR X 3. I like this trailing
stop alot, and have been using it on a portfolio at Marketocracy.com
for 5 months now. It's up 8%... not too bad by only going long in a
bear market.
I program with VB6 and WebZinc (webzinc.net), a program that easily
grabs data off the web. It has a ton of uses and I highly recommend
it.
I know IB acccepts odd-lot stock orders for NYSE and Nasdaq stocks,
what about AMEX stocks? I wrote them a week ago and still no answer.
Thanx,
Brian
|
twsapi: How to make the Java API work?
I dont
know of Java, but something looks strange: you connect to "gw4.ibllc.com:4000"
which is the IB server on the Internet.
Dont
have you to connect to the local server (as in VB):
"127.0.0.1:7496"?
?
Michel.
[Michel]??-----Mensaje
original-----
De: philipyeh [mailto:philipyeh@...]
Enviado
el: lunes, 01 de julio de 2002 4:53
Para:
twsapi@...
Asunto: twsapi: How to make the Java API
work?
|
How to make the Java API work?
2
I am a new user of the TWS Java API.
I wrote a test program to test the reqMktData() method.
But I can not get any ticks data. What's problem in my
program? Could anybody help me?
Below is my test java program:
import com.ib.client.*;
public class ATMClient implements EWrapper
{
static final int BID_SIZE = 0;
static final int BID = 1;
static final int ASK = 2;
static final int ASK_SIZE = 3;
static final int LAST = 4;
static final int LAST_SIZE = 5;
EClientSocket m_client = new EClientSocket(this);
int m_id = 100000;
int o_id = 200000;
public static void main (String[] args)
{
ATMClient myapp = new ATMClient();
myapp.start("gw4.ibllc.com", "4000");
}
public void start(String host, String port)
{
m_client.eConnect(host, Integer.parseInt(port));
System.out.println("connect ok!");
Contract m_contract = new Contract();
m_contract.symbol = "ESU2";
m_contract.secType = "FUT";
m_contract.expiry = "200209";
m_contract.strike = 0.0;
m_contract.right = "C";
m_contract.exchange = "GLOBEX";
m_contract.currency = "USD";
m_client.reqMktData(m_id, m_contract);
}
public void tickPrice( int tickerId, int field, double price) {
// received price tick
System.out.println("id=" + tickerId + " " + getField(field)
+ "=" + price);
}
public void tickSize( int tickerId, int field, int size) {
// received size tick
System.out.println("id=" + tickerId + " " + getField(field)
+ "=" + size);
}
public void orderStatus(int orderId, String status, int filled,
int remaining, double price, int permId) {
// received order status
System.out.println("id=" + orderId + " status=" + status
+ " filled=" + filled + " remaining=" + remaining + " price=" +
price + " permId=" + permId);
// make sure id for next order is at least orderId+1
++o_id;
}
public void openOrder( int orderId, Contract contract, Order
order) {
// received open order
System.out.println( "id=" + orderId + " " + order.action
+ " " + order.quantity + " " + contract.symbol);
}
public void nextValidId(int orderId) {
// received next valid order id
o_id = orderId;
}
public void error(String str) {
// received error
System.out.println("*** Error: " + str);
}
public void connectionClosed() {
System.out.println("Connection Closed");
}
private String getField(int tickType) {
switch (tickType) {
case BID_SIZE: return "bidSize";
case BID: return "bidPrice";
case ASK: return "askPrice";
case ASK_SIZE: return "askSize";
case LAST: return "lastPrice";
case LAST_SIZE: return "lastSize";
default: return "unknown";
}
}
public void updateAccountValue(String key,String value,String
currency) {
System.out.println("key=" + key + ", value=" + value + ",
currency=" + currency);
}
public void updatePortfolio(Contract contract, int position,
double marketPrice, double marketValue) {
System.out.println("position=" + position + ", marketPrice="
+ marketPrice + ", marketValue=" + marketValue);
}
public void updateAccountTime(String timeStamp) {
System.out.println("timeStamp=" + timeStamp);
}
}
Thanks.
Philip Yeh.
|
twsapi: Re: order IDs
2
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?
|
How to get - Account Number
6
I have 2 accounts.
Anyone know how to get account number >>?
An example vb code line will do just fine.
ThanX
|
twsapi: Trader Guard - ES NQ futures ready app.
2
Can anybody tell me what is the web site address of twsapi
group? (NOT the email address).
Thanks.
|
AW: twsapi: Re: order IDs
That
is the reason why I do not use reqOpenOrders or
reqExecutions.
?
I just
request the portfolio/account data and check if "my accounting" gives the same
numbers as the values that I get from TWS.
I
found a problem with reqAccountData: If you request it several times, it doesn?t
work anymore.
?
I did
not use the permID, I have near to no problems with the OrderID that?I
provide when I post an order since I use the NextValidID that I get when I
connect to TWS. I store that ID and increase it every time I place an
order.
|
twsapi: Re: order IDs
Hi Marcus -
Have you ever tried reqopenorders and openorder1/openorder2? It seems
to me they behave strangely.
1. openorder1/openorder2 only fire once after reconnect
2. only one open order id is returned no matter how many open orders
you have
3. open order id changed upon reqopenorders called
Do you know what the permID for ? Thanks
|
stockwatchpro
2
Found this on silicon investor IB board. I tried stockwatchpro along
with IB today, works pretty good. I wish IB removed BEST routing
restriction on its API.
---------------------------------------------------------
Stock Watch Pro 2.3 with IB TWS integration just got released. Orders
can be initiated from Stock Watch Pro as follows:
- QuoteSheets (double-clicking on bid or ask)
- Level II or Island book (double-clicking on a market maker)
- Charts (from the right-click menu)
- From alerts when they trigger. SWP formula language allows you to
define any condition and associate an order with it.
Stock Watch Pro website: http://www.crontech.com/swp
For integration details see
http://www.crontech.com/swp/help/direct_access_trading.html
|
AW: twsapi: Re: order IDs
Hi
David,
?
I
use? a access database and MS-Access, which is included with MS-Office Pro.
I program in Access-VisualBasic for applications.
?
Normally, I get any change to the orderstatus immidiatly and store it
immidiatly in the database.
?
The
situation descriped below is just for the rare case that one application crashes
or the API connection breaks.
?
Marcus
|
twsapi: Re: order IDs
I do not use that many orders but your idea, Marcus, is a
fanatastic way to have a good, even though delayed, control of your orders.
Do you use any special db or just free dbjet
engine?
well done.
David
|
twsapi: Modifying an order & testing
3
I to would like to know how to place trailing
stops.
?
If you go to http://groups.yahoo.com/group/twsapi/
on the left about half way down
it should say "Files" there is some code there.
Also Jaba put together a simple project that you can download look at post
189.
?
As far as testing before you go live IB has a demo
that you can connect to.
?
Good luck,
?
Tonkadad
|
AW: twsapi: Re: order IDs
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@...]
Gesendet: Sunday, June 30, 2002 1:49 AM
An: twsapi@...
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
track of what you or your Automated Trading System is doing. You need
to store what was done, when, and why.
exit order number in each record. There are lots of other fields to
keep track of when, where, and why.
RS.TradesExit "seeks" this ExitOrderNumber and updates the when,
where, why fields.
Yahoo! Groups Sponsor
ADVERTISEMENT
To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|
order IDs
3
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
|
Autostoptrailing
Hi,
i tried to run autostoptrailing using dde interface and the example
from tws manuel. It didn't work properly. Any idea's ?
Thx for help
|
IB TWS API Thread at WL.
Hi, I'm Techguy:
I started an IB Automation thread at Wealth Lab, under the Automation
Category. Click here to read it. It may have some value to you, and
will certainly expose my limited programming ability - but there may
be some good information there for you as well.
http://www.wealth-lab.com/cgi-bin/WealthLab.DLL/topic?id=2654
Some of you may know me from elsewhere - other forums - same guy. If
you are in the Seattle or Portland area, we have a group of Trader
Programmers that meet regularly: Here is the contact info:
The PDX and Seatac Wealth Lab User Groups are now centralized at the
Yahoo Groups area. Members can post, view the calendar, upload files,
chat, and generally keep themselves informed of the PDX WLUG
happenings.
Membership is by moderator acceptance. Content is un-moderated.
All Backtesting / Trading suite Users / Programmers / Developers are
invited to attend (Tradestation, AMI, SmartQuant, Wealth Lab, C++
Users, etc. . . are invited to attend and participate in the
meetings - if for nothing else comradiere)
This User Group strives to meet monthly, and address topics of
interest to Trader Programmers. Emphasis is on the use of Wealth Lab
for Trading strategy testing and as use of a decision engine for
Trading automation.
For a brief synopsis of the groups and more about what we are all
about go here:
http://www.geocities.com/techguy1313/WL-User-Group-Home.html
A link to Wealth Lab is located on the page above.
For the sister SeaTac group membership request go here:
http://groups.yahoo.com/group/SeaTac_WLUG
For the Portland Oregon Wealth Lab User Group (PDX_WLUG) go here:
http://groups.yahoo.com/group/PDX_WLUG
|
twsapi: Market Making App
3
Hi JS,
?
I'd like to adapt your program to the futures markets I trade
through Interactive Brokers.? Unfortunately, unless you write your code in
C++, I won't be able to contribute much to the project.? But if you do get
your code working, I'd be happy to pay you something nominal for a copy of
it.
?
Regards,
Aaron Schindler
|
COM error trying to connect.
3
Hi,
Was trying to connect via COM but keep getting this error:
com_error: (-2147418113, 'Unexpected failure', None, None)
I checked my system and the TWS ActiveX control is registered. Also
the app is running (build 769.1) and logged in to EDEMO account. It
is also set to accept connections.
I'm using Python to connect, code as follows:
tws = Dispatch("TWS.TwsCtrl.1")
which works and creates the object exposing all it's methods and
properties.
However, when I try to connect:
tws.connect('', 7496)
I get the error. I've tried specifying the IP address as well, no
difference.
Anyone done it this way or am I missing something obvious?
Thanks in advance for any advice.
JC
|
twsapi: Trader Guard - ES NQ futures ready app.
5
How to go to TWSAPI file area?
|
Trader Guard - ES NQ futures ready app.
2
Addition to your existing IB TWS platform. I designed it for scalpers
to profit from every single trend change with "adaptive Automation
Engine" monitoring market tick by tick and in real time.
You will love it.
It will automate your profit collection at the topmost
point and also auto-escape from bad point of entry. This is what i
like the most.
Download it from twsapi file area. I'll post it here within 3 days
(finishing GUI design only)
If you inpatient or file is not there for any reason e-mail request
to me. I'll be happy to send you a copy.
traderguard@...
|