API Support Forum
User Profile

Viewing User Profile for: SOtziger3689


About

May 19, 2015 04:26 PM

May 29, 2015 04:10 PM

May 29, 2015 04:35 PM



Post Statistics
SOtziger3689 has contributed to 4 posts out of 5677 total posts (0.07%) in 3474 days (0.00 posts per day).

20 most recent posts:

API Support » Account balance May 29, 2015 @ 04:10 PM (Total replies: 7)

Ok, then this is probably a misunderstanding from my side how the account summary works. The part below, i.e., the account summary is always the same. After stopping and starting the application, even on the next day. Does it only change after a trade?

Account: API002602
NetLiq: $49'156.25
NetLiquidatingValue: $49'522.50
Cash: $49'303.75
Open P/L: $0.00
Settle P/L: $0.00
Initial Margin: $5'684.00
Net Options Value: $-147.50

API Support » Account balance May 29, 2015 @ 03:52 PM (Total replies: 7)

Dear Evgeny,

The username is SOtziger3689 and below is the sample application output. Hope this helps!

Thanks


D:\Projects\ConsoleSample\ConsoleSample\bin\Debug>ConsoleSample.exe
Connecting...
Press Ctrl-C to exit
OnLoginComplete: CompleteConnected=True
Accounts: 1, orders: 0, base contracts: 497
Account: API002602
NetLiq: $49'156.25
NetLiquidatingValue: $49'522.50
Cash: $49'303.75
Open P/L: $0.00
Settle P/L: $0.00
Initial Margin: $5'684.00
Net Options Value: $-147.50
Average Positions: 2
Average Position. API002602/ESM5: Net Pos: 1 @ 2120.125, Bought: 0, Sold 0, Prev Pos: 1 P/L: $0.00
Average Position. API002602/OESQ5 P1700: Net Pos: -1 @ 2.95, Bought: 0, Sold 0, Prev Pos: -1 P/L: $0.00
Account Summary Changed. API002602 (USD): P/L = -563.75. Total Net Liq: $48'592.50
Account Summary Changed. API002602 (USD): P/L = -551.25. Total Net Liq: $48'605.00
Account Summary Changed. API002602 (USD): P/L = -563.75. Total Net Liq: $48'592.50
Account Summary Changed. API002602 (USD): P/L = -551.25. Total Net Liq: $48'605.00
Account Summary Changed. API002602 (USD): P/L = -563.75. Total Net Liq: $48'592.50
Account Summary Changed. API002602 (USD): P/L = -551.25. Total Net Liq: $48'605.00
^C
D:\Projects\ConsoleSample\ConsoleSample\bin\Debug>


API Support » Account balance May 29, 2015 @ 03:13 PM (Total replies: 7)

Dear ETrifonov

Quote:
Can you please explain what you mean by "information doesn't update"?

You call DisplayAccount() method only once after success login.
And information should update each time you start application and logged in.

I mean the information doesn't update each time I start the application and logged in using my example during market hours with open positions. Hence, I start the application, stop it, wait 5 minutes, start again and the information doesn't update. I tried this multiple times and even waited for a few hours.
Edited by SOtziger3689 on May 29, 2015 at 15:15:59

API Support » Account balance May 27, 2015 @ 04:21 PM (Total replies: 7)

Dear Support,

I wrote a simple console application to display account information and open positions. The code below is a working example borrowed heavily from the official documentation.

If I end (CTRL + C) and restart the application, the DisplayAccount() information doesn't update. The information only updates after executing a trade.

My objective is to have a console application, which I can run once per day to write the above mentioned information to a text file.

Can I retrieve the current account information only using the OEC.API.OnAccountSummaryChangedEvent or OEC.API.OnBalanceChangedEvent event?

Thanks,
-S


using System;

namespace ConsoleSample
{
class Program
{
static OEC.API.OECClient oecapi;

static void Main(string[] args)
{
oecapi = new OEC.API.OECClient();
oecapi.UUID = "9e61a8bc-0a31-4542-ad85-33ebab0e4e86";
oecapi.Connect("api.openecry.com", 9200, "User", "Password", true);
Console.WriteLine("Connecting...");
oecapi.OnLoginComplete += new OEC.API.OnLoginCompleteEvent(onLoginComplete);
oecapi.OnLoginFailed += new OEC.API.OnLoginFailedEvent(onLoginFailed);
oecapi.OnDisconnected += new OEC.API.OnDisconnectedEvent(onDisconnected);
Console.WriteLine("Press Ctrl-C to exit");
System.Windows.Forms.Application.Run();
}

static void onLoginComplete()
{
Console.WriteLine("OnLoginComplete: CompleteConnected={0}", oecapi.CompleteConnected);
Console.WriteLine("\tAccounts: {0}, orders: {1}, base contracts: {2}", oecapi.Accounts.Count, oecapi.Orders.Count, oecapi.BaseContracts.Count);
DisplayAccount(oecapi.Accounts.First);
DisplayPositions(oecapi.Accounts.First);
}

static void onLoginFailed(OEC.Data.FailReason reason)
{
Console.WriteLine("OnLoginFailed: {0}", reason);
}

static void onDisconnected(bool unexpected)
{
Console.WriteLine("OnDisconnected: {0}", unexpected ? "unexpected" : "expected");
}

private static void DisplayAccount(OEC.API.Account account)
{
Console.WriteLine("Account: {0}", account.Spec);
OEC.API.Balance totalBalance = account.TotalBalance;
Console.WriteLine("\tNetLiq: {0:c}", totalBalance.NetLiq);
Console.WriteLine("\tNetLiquidatingValue: {0:c}", totalBalance.NetLiquidatingValue);
Console.WriteLine("\tCash: {0:c}", totalBalance.Cash);
Console.WriteLine("\tOpen P/L: {0:c}", totalBalance.OpenPnL);
Console.WriteLine("\tSettle P/L: {0:c}", totalBalance.SettlePnL);
Console.WriteLine("\tInitial Margin: {0:c}", totalBalance.InitialMargin);
Console.WriteLine("\tNet Options Value: {0:c}", totalBalance.LongCallOptionsValue + totalBalance.LongPutOptionsValue + totalBalance.ShortCallOptionsValue + totalBalance.ShortPutOptionsValue);
Console.WriteLine("Average Positions: {0}", account.AvgPositions.Count);
}

private static void DisplayPositions(OEC.API.Account account)
{
foreach (OEC.API.Position pos in account.AvgPositions)
{
Console.WriteLine("Average Position. {0}/{1}: Net Pos: {2} @ {3}, Bought: {4}, Sold {5}, Prev Pos: {6} P/L: {7:c}",
account.Spec, pos.Contract.Symbol, pos.Net.Volume, pos.Net.Price, pos.Long.Volume, pos.Short.Volume, pos.Prev.Volume, pos.OTE + pos.Gain);
}
}
}
}