You are on page 1of 4

Hey Kyle:

I tested it out. This seems to be the configuration that works best for IB short. 

Shorting with 1% account risk with AUTO size based on selected stop price

DefShare=BP*0.8; Share=DefShare*0.3* Price * 0.01; Price = Price - Bid + 0.02;SShare = Share / Price; Share = DefShare - SShare; DefShare =
DefShare + SShare; SShare = Share; SShare = DefShare - SShare; Share = 0.5 * SShare; TogSShare; ROUTE =LIMIT; Price = Bid - 0.05;
TIF=DAY+; SELL=Send; DefShare = 500;                    

IB requires 30% equity as margin for short, and 25% equity as margin for long. 

Therefore, the discount on BP should be 0.25/0.3= 0.833333, so I just used 0.8 to be safe. 

 For the same reason, I used 0.3 instead of 0.333333333333333.  

From what I can tell, the user can't assign/create variables. The way I did the one in this thread was to use available variables that the user can access via the hotkey
/ montage. These can change depending on what ROUTE is selected.
SSHARE --> Display Box (next to share), this is an unsigned INT, read/write
SHARE --> Share Box, this is an INT, read/write
PRICE --> Price Box, this is a FLOAT, read/write
DEFSHARE --> Default Shares (not displayed, but accessible), this is an INT, read/write
TRAILPRICE --> Trailing Price, FLOAT, but only available if STOP is selected and stop type = Trailing, read/write
STOPPRICE --> Trigger Price, FLOAT, only available if STOP is selected and "trigger price" box is writeable, read/write
CAPSHARE --> String, write only
PREF --> String, write only.

Because prices are floats and the majority of variables available are INT based, you can always convert a float to an INT by multiplying by 100 and then dividing
by 100 later (to get it back to float), otherwise moving a FLOAT to an INT variable will drop the decimal portion ($100.99 becomes $100). For your request, if I'm
understanding it correctly, you don't need to do too much. 
StopPrice=Price-0.01;DefShare=BP*0.97;Price=AskPrice+0.01;SShare=30/
Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-
SShare;Share=0.5*SShare;TogSShare;ROUTE=LIMIT;Price=
Ask+0.05;TIF=DAY+;BUY=Send;DefShare=400;TriggerOrder=RT:STOP STOPTYPE:MARKET
PX:StopPrice-0.3 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

StopPrice=Price-0;DefShare=BP*0.925;Price=Ask-Price+0.00;SShare=30/Price;Share=DefShare-
SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-
SShare;Share=0.5*SShare;TogSShare;ROUTE=SMRTL;Price=
Ask+0.05;TIF=DAY+;BUY=Send;DefShare=200;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.05
ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

StopPrice=Price-0.01;DefShare=BP*0.8;Price=Ask-Price+0;SShare=40/Price;Share=DefShare-
SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-
SShare;Share=0.5*SShare;TogSShare;ROUTE=SMRTL;Price=
Ask+0.05;TIF=DAY+;BUY=Send;DefShare=400;TriggerOrder=RT:STOP STOPTYPE:MARKET
PX:StopPrice-0.3 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;
StopPrice=Price-0.01;DefShare=BP*0.8;Price=Ask-Price+0;SShare=30/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-
SShare;Share=0.5*SShare;TogSShare;ROUTE=SMRTL;Price= Ask+0.05;TIF=DAY+;BUY=Send;DefShare=400;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.7
ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

You might also like