API Support Forum
OEC API > API Support > Net Liq in AccountSummary
Author Topic: Net Liq in AccountSummary
(20 messages, Page 1 of 1)
Moderators: VPfau
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 10, 2012 @ 04:20 PM             Msg. 1 of 20
We've made an Account Summary window similar to the Account Summary window in OEC Trader, but when we run them side-by-side we see that our "Net Liq" value becomes different than OEC Trader's.

We're not doing any complex math here. When we receive an Account update, we set the displayed value to Account.TotalBalance.NetLiquidatingValue.

You can see the divergence in this video:
http://www.screencast.com/t/VVYkLriPBXUv
(password is deltamd)

So I can only guess that we're using the wrong variable. What variable should we use to get the value that OEC Trader displays as in the graphic below?


Edited by THarnett81 on May 10, 2012 at 16:24:40
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 11, 2012 @ 03:39 PM             Msg. 2 of 20
Trader shows the next value:
NetLiquidatingValue - SettlePnL + OpenPnL

Victor Vins
Lead Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 11, 2012 @ 04:41 PM             Msg. 3 of 20

So the "Net Liq" displayed value is not actually Account.TotalBalance.NetLiquidatingValue?

That is unexpected.

So I should set my displayed value to be equal to your formula? (where all 3 operands are members of Account.TotalBalance)
Edited by THarnett81 on May 11, 2012 at 16:41:35
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 14, 2012 @ 04:04 PM             Msg. 4 of 20
Victor,

There is still a problem.

When the trader's position is not flat, it seems to work and the values in my app and OEC Trader seem to stay in sync.

But when the trader flattens his position, the numbers become different. See this video:
http://www.screencast.com/t/qzuW4Jjhd0YJ

Please advise.
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 17, 2012 @ 04:05 PM             Msg. 5 of 20
Hello. Does it sync after logon with flatten position?

Victor Vins
Lead Software Developer
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 17, 2012 @ 04:31 PM             Msg. 6 of 20
Moreover, I see you had balances for two currencies. Could you please check that your window is updating with "total" balance all the time?

Victor Vins
Lead Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 18, 2012 @ 04:39 PM             Msg. 7 of 20
"Does it sync after logon with flatten position?" - I think you're asking if the value is correct after login but before any orders are placed... is that right?

The market is closed right now, but we can get back to you on this.
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 18, 2012 @ 04:39 PM             Msg. 8 of 20
"Could you please check that your window is updating with "total" balance all the time?"

Here is the exact code line that pulls the value:
d.NetLiquidity = System.Convert.ToDecimal(
a.TotalBalance.NetLiquidatingValue - a.TotalBalance.SettlePnL + a.TotalBalance.OpenPnL);

Can you confirm this is correct?

Edited by THarnett81 on May 18, 2012 at 16:41:52
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 18, 2012 @ 04:41 PM             Msg. 9 of 20
Yes, this is correct.

Victor Vins
Lead Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 18, 2012 @ 04:42 PM             Msg. 10 of 20
(deleted)
Edited by THarnett81 on May 18, 2012 at 16:43:34
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 18, 2012 @ 04:44 PM             Msg. 11 of 20
I'm sorry, which post is correct?
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 18, 2012 @ 04:49 PM             Msg. 12 of 20
Both. It would be nice to compare values before any orders placed and positions opened; formula is correct.

The difference on your video was pretty close to value of non-USD balance in your account. It looked like your software updated the screen with total balance during active phase and just with USD balance when positions were closed.

Victor Vins
Lead Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 18, 2012 @ 05:04 PM             Msg. 13 of 20
Interesting.

I don't think we're doing that though. There is a single function that copies over the AccountSummary data. Any update uses that same block of assignments, which includes the line I had pasted.

Aside from checking the Net Liq after login (before any trading), what else can we look at?
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 18, 2012 @ 05:07 PM             Msg. 14 of 20
Could you turn on logging in OECAPI via http://www.openecry.com/api/api/OEC.Log.html class?

Victor Vins
Lead Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 18, 2012 @ 05:38 PM             Msg. 15 of 20
I turned on logging. Market's closed, so not much to see. Guess I'll have to get back to you later.
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 21, 2012 @ 01:38 PM             Msg. 16 of 20
What should I be looking for in this log, Victor?

Just a minute ago, I ran it, placed a few market orders followed by a flatten order, and there really isn't much to see in the log.

12:32:09.951 Dbg Reader Order Login to OEC Server 4.1.0.0
12:32:10.635 Dbg Reader Price Login to OEC Server 4.1.0.0
12:32:10.936 Dbg System #1 THarnett81 : Loading
12:32:13.048 Dbg System #1 THarnett81 : Loaded, API: 109.3785ms, Client: 2000.064ms
12:33:06.598 Dbg System #1 DOM ESM2 : 734643.17:33:06.5828231
12:33:06.674 Dbg System #1 DOM NQM2 : 734643.17:33:06.6609711
12:36:11.800 Dbg System #1 MainStream disconnected: System.Exception: app request
12:36:11.801 Dbg System #1 PriceStream disconnected: System.Exception: app request
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 21, 2012 @ 02:31 PM             Msg. 17 of 20
I just figured out that our Advanced Example uses the same formula above as Trader and describes how to turn on detailed logs. Could you try to run side-by-side all three applications? Advanced Example will need a minor changes in code to update Net Liq by price changes. I don't see any de-synchronizations when I ran the example and Trader.

Victor Vins
Lead Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 23, 2012 @ 06:54 PM             Msg. 18 of 20
Can you elaborate on this:
"Advanced Example will need a minor changes in code to update Net Liq by price changes"
Are you talking about the OnPriceChanged callback? (If yes, then I think I'll need to add code to track the Account and Currency myself since this event type does not give me that.)

Also, our app is not listening to OnBalancedChanged. Is it advised that we should be using this one (in addition to OnAccountSummaryChanged)?
Edited by THarnett81 on May 23, 2012 at 18:55:05
Edited by THarnett81 on May 23, 2012 at 18:55:37
Edited by THarnett81 on May 23, 2012 at 18:56:05
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 24, 2012 @ 11:15 AM             Msg. 19 of 20
Sorry, I was wrong with "Advanced Example will need a minor changes in code to update Net Liq by price changes" (looked to another branch of this sample): you don't need any changes there. All what you need is to listen OnBalanceChanged and OnAccountSummaryChanged events.

Victor Vins
Lead Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 24, 2012 @ 03:25 PM             Msg. 20 of 20
In my app, we're not listening to OnBalanceChanged. Do you think this might explain our unsynch'd values?