IB advisor acct with two sub-accts only one shorting allowed  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
hairyMug
Posts: 57
Joined: 03 Feb 2014
Has thanked: 5 times
Been thanked: 6 times

IB advisor acct with two sub-accts only one shorting allowed

Postby hairyMug » 24 Mar 2014

My advisor acct has one margin account and one IRA account. The IRA account does not allow short positions so when I send a short order, only 50 shares are filled by the broker and the other 50 shares are rejected (since the IRA account cannot go short).

So now I have a strategy with that shows 100 shares but really only 50 at broker so if I use the
"ChangeMarketPosition" command to adjust the strategy, when I go to COVER 50 shares, they get divided in half and only 25 are "covered" and the IRA buys 25... (since my orders get split at broker)

This results in an essentially flat position, -25 in one account and 25 in other, when really I wanted to close...

How would you suggest resolving this with code?

>> This has already occurred a few times...

Thanks for any suggestions!

Note: edited
Last edited by hairyMug on 25 Mar 2014, edited 1 time in total.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: IB advisor acct with two sub-accts only one shorting all

Postby Henry MultiСharts » 25 Mar 2014

Hello hairyMug,

Have you tried closing the position instead of reversing it? I.e. use Sell instead of SellShort.

hairyMug
Posts: 57
Joined: 03 Feb 2014
Has thanked: 5 times
Been thanked: 6 times

Re: IB advisor acct with two sub-accts only one shorting all

Postby hairyMug » 26 Mar 2014

will this work?

if (TradeManager != null )
if( (shortMkt)||(sellMkt ))
{
this.TradeManager.TradingProfiles[0].CurrentAccount = "shortAccount";
}
else
{
this.TradeManager.TradingProfiles[0].CurrentAccount = "advisorAccount";
}

The idea is when the order is NOT short or cover, send the order to the advisor account (which will split 50-50)...

If the order is Short or Cover, then just send it directly to the account that is allowed to short...


Is "this.TradeManager.TradingProfiles[0].CurrentAccount" a useable command and how would I set the broker plugin so this will work?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: IB advisor acct with two sub-accts only one shorting all

Postby Henry MultiСharts » 27 Mar 2014

hairyMug, that will work, but this is unmanaged orders approach. With this approach you are responsible for managing your orders. Please refer to the following post for more information.

hairyMug
Posts: 57
Joined: 03 Feb 2014
Has thanked: 5 times
Been thanked: 6 times

Re: IB advisor acct with two sub-accts only one shorting all

Postby hairyMug » 27 Mar 2014

"unmanaged" agreed...
I reviewed the referenced link but I am not sure if I need to define two profiles; one for short and one for long OR will it work to just set the current account?
I am not sure that just setting the "currentaccount" would be enough since it seems that it would need to "disconnect" and "reconnect" to set the new account at the broker??

Also, If I use it on a "per-chart" basis and sync the shares like this:

protected override void OnBrokerStategyOrderFilled(bool is_buy, int quantity, double avg_fill_price)
{
base.OnBrokerStategyOrderFilled(is_buy, quantity, avg_fill_price);
if(this.StrategyInfo.MarketPosition != quantity)
ChangeMarketPosition(quantity-this.StrategyInfo.MarketPosition, avg_fill_price, "qtyAdj");

}


Will that keep track of the shares?
Then I can get the number of shares from the strategy to cover/buy ?

Thanks!

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: IB advisor acct with two sub-accts only one shorting all  [SOLVED]

Postby Henry MultiСharts » 31 Mar 2014

I reviewed the referenced link but I am not sure if I need to define two profiles; one for short and one for long OR will it work to just set the current account?
You need to have a single broker profile.
I am not sure that just setting the "currentaccount" would be enough since it seems that it would need to "disconnect" and "reconnect" to set the new account at the broker??
Using "currentaccount" is enough for that.
Also, If I use it on a "per-chart" basis and sync the shares like this:
protected override void OnBrokerStategyOrderFilled(bool is_buy, int quantity, double avg_fill_price)
{
base.OnBrokerStategyOrderFilled(is_buy, quantity, avg_fill_price);
if(this.StrategyInfo.MarketPosition != quantity)
ChangeMarketPosition(quantity-this.StrategyInfo.MarketPosition, avg_fill_price, "qtyAdj");
}


Will that keep track of the shares?
Then I can get the number of shares from the strategy to cover/buy ?
If you do that to sync the broker position and positions in the strategies then market position will return you the current strategy position, which will be the same as the broker position.


Return to “MultiCharts .NET”