How to get account balance

4 replies

clonex / Ivan Hudec

Customer, bbp_participant, community, sq-ultimate, contributor, author, editor, 271 replies.

Visit profile

8 years ago #114190

Hi ,

 

im trying to get account balance in moment of computing order in public void computeForOrder(SQStats stats, StatsTypeCombination combination, SQOrder order, SQSettings settings, SQStats statsLong, SQStats statsShort)

 

There is a field

 

order.AccountBalance where im recieving 0.0 value

 

There is another method

 

order.getBalance(java.lang.String plType)   where i dont know what is string plType

 

Yes there are another ways how to compute this value but can you please explain how to use theese approaches?

 

Thanks in advance

 

 

Clonex

0

Tamas

Customer, bbp_participant, community, sq-ultimate, 73 replies.

Visit profile

8 years ago #132621

Hello Clonex,

 

balance is not calculated in statvalues but you can calcute it right in your snippet.

 

private double balanceInMoney = 0;
private double balanceInPct = 0;
private double balanceInPips = 0;

 

@Override
public void computeForOrder(SQStats stats, StatsTypeCombination combination, SQOrder order, SQSettings settings, SQStats statsLong, SQStats statsShort) throws Exception {
if(!order.isBalanceOrder()) {
  balanceInMoney+=order.PL;
  balanceInPct+=order.PctPL;
  balanceInPips+=order.PipsPL;
 
/*or for the particular combination 
private double balance = 0; 
 
if(!order.isBalanceOrder()) {
double PL = getPLByStatsType(order, combination);
balance+=PL;
}
*/
}
 
 
//in this moment you already know the balance 🙂
 
}
 
Best regards,
Tomas

0

clonex / Ivan Hudec

Customer, bbp_participant, community, sq-ultimate, contributor, author, editor, 271 replies.

Visit profile

8 years ago #132623

Hi Tamas,

this is I was looking for. 😉 So in generaly  class statvalues do you not recommend for calculating this type of statisticcs right?

 

Clonex

0

Tamas

Customer, bbp_participant, community, sq-ultimate, 73 replies.

Visit profile

8 years ago #132624

StatValues is a right place to compute any type of stats.

If you need the balance just compute and use it.

 

In SQOrder atributes AccountBalance/PipsAccountBalance/PctAccountBalance are used in Equity control module which change them all the time according to the trade size.

 

Best regards,

Tomas

0

clonex / Ivan Hudec

Customer, bbp_participant, community, sq-ultimate, contributor, author, editor, 271 replies.

Visit profile

8 years ago #132627

Excellent Tamas. Thank You. 

0

Viewing 4 replies - 1 through 4 (of 4 total)