|
IAccount.getBalance() function is missing |
SFXbernhard
|
Post subject: IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Thu 21 Oct, 2010, 17:21
|
|
User rating: 21
Joined: Thu 19 May, 2011, 20:50 Posts: 413 Location: Germany, Munich
|
Could you please implement or show me a reliable work around to get the balance of the account
|
|
|
|
 |
[quantisan]
|
Post subject: Re: IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Sat 23 Oct, 2010, 00:21
|
|
User rating: 1
Joined: Fri 26 Mar, 2010, 19:19 Posts: 116 Location: Canada
|
|
|
|
 |
SFXbernhard
|
Post subject: Re: IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Thu 28 Oct, 2010, 05:57
|
|
User rating: 21
Joined: Thu 19 May, 2011, 20:50 Posts: 413 Location: Germany, Munich
|
I know, but I don't want the Equity, I want the amount of balance (cash money)!
|
|
|
|
 |
[MosheElisha]
|
Post subject: Re: IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Sat 30 Oct, 2010, 17:32
|
|
User rating: 0
Joined: Wed 28 Oct, 2009, 10:25 Posts: 13
|
I am also in need for such a method. IAccount.getBalance() should return an amount similar to IAccount.getEquity() but should not include profit / loss from current open positions.
|
|
|
|
 |
RoadRunner
|
Post subject: Re: IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Mon 08 Nov, 2010, 08:24
|
|
User rating: 3
Joined: Wed 18 May, 2011, 16:25 Posts: 331 Location: SwitzerlandSwitzerland
|
I agree, getBalance() would be good to have. It can get coded by ourselves, but it's an elementary method that I guess many of us would want to use.
Best regards, RR.
|
|
|
|
 |
Guest
|
Post subject: Re: JFOREX-2448 IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Mon 13 Dec, 2010, 14:20
|
|
User rating: -
|
Why wouldn't we try to coding it like this: currentBalance = IAccount.getEquity() - getAccountProfitLoss()
considering getAccountProfitLoss() as the current account drawdown or floating profit. An iteration would be needed to sum all account opened orders profit or loss. If profitLoss it's positive, we have current balance and not the equity as in this case would be greater then account balance. If profitLoss it's negative, as we substract this from equity, it would be an addition to lower equity in this case due to the drawdown, so it would be equity + loss = current balance. I am going to code this for myself as I need it too, and if someone it's interested just let me know, to post it here.
|
|
|
|
 |
[MosheElisha]
|
Post subject: Re: JFOREX-2448 IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Thu 13 Jan, 2011, 22:57
|
|
User rating: 0
Joined: Wed 28 Oct, 2009, 10:25 Posts: 13
|
@Guest - Please post the code. Does your code take commission into consideration?
|
|
|
|
 |
Guest
|
Post subject: Re: JFOREX-2448 IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Mon 23 May, 2011, 19:36
|
|
User rating: -
|
Sorry for the delay, here is some code I have for getting current account balance, it does not take commissions and interests into account, just a simple and useful function to get an idea about the balance. private double getBalance() { //calculating floating profit/loss considering all opened positions double profit_loss = 0.0; try { List<IOrder> orders_list = engine.getOrders(); for (IOrder order : orders_list) { if ( order.getState() == IOrder.State.FILLED ) profit_loss += order.getProfitLossInAccountCurrency(); } } catch (JFException jfe) { //put any exception related code here } //balance calculated based on JForex Account available Equity and floating profit/loss double accEquity = this.context.getAccount().getEquity(); accEquity = NormalizeDouble(accEquity, 2); double accBalance = accEquity - profit_loss; accBalance = NormalizeDouble(accBalance, 2); return (accBalance); }
private double NormalizeDouble( double value, int digits ) { double precision = Math.pow(10,digits); value = (int) (value * precision) / precision; return (value); }
|
|
|
|
 |
positiveday
|
Post subject: Re: JFOREX-2448 IAccount.getBalance() function is missing |
Post rating: 0
|
Posted: Sat 13 Aug, 2011, 13:46
|
|
User rating: 1
Joined: Wed 10 Aug, 2011, 13:58 Posts: 8 Location: ItalyItaly
|
getBalance() method of IAccount exist and works. The issue it's about the compiler inside Jforex platform that don't find the method. I compile and debug a Jforex strategy in NetBeans and I don't get any compile error about getBalance(), also in debug mode I read the balance of the account. 
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|