API Support Forum
User Profile

Viewing User Profile for: PLakshmanan


About

Jan 13, 2021 11:39 AM

Feb 09, 2021 11:35 PM

Feb 09, 2021 11:38 PM



Post Statistics
PLakshmanan has contributed to 2 posts out of 5593 total posts (0.04%) in 1198 days (0.00 posts per day).

20 most recent posts:

API Support » Connection error/Socket error Feb 09, 2021 @ 11:35 PM (Total replies: 2)

Hi,

Thanks for your reply.

I used both Price and Aggregate to connect but unfortunately both gives same error.

API Support » Connection error/Socket error Feb 03, 2021 @ 01:49 AM (Total replies: 2)

Hello,

I got "Connection error/Socket error" while making connection to GF server.

I am using.
.Net core 2.1
.Net framework 4.7.2
Nuget package 4.0.3.44

-----------------My code --------
GF.Api.IGFClient gfClient = GF.Api.Impl.GFApi.CreateClient();

var runner = new GF.Api.Threading.GFClientRunner(gfClient);
runner.Start();

gfClient.Connection.Price.LoginCompleted += GFClient_OnLoginComplete;
gfClient.Connection.Price.LoginFailed += GFClient_OnLoginFailed;
gfClient.Connection.Price.Disconnected += GFClient_OnDisconnected;
gfClient.Logging.ErrorOccurred += (client, e) => Console.WriteLine($"{e.Exception.Message}");

gfClient.Threading.Invoke(() =>
gfClient.Connection.Price.Connect(
new GF.Api.Connection.ConnectionContextBuilder()
.WithUserName("######")
.WithPassword("######")
.WithUUID("9e61a8bc-0a31-4542-ad85-33ebab0e4e86")
.WithPort(9210)
.WithHost("api.gainfutures.com")
.WithForceLogin(true)
.Build()));

gfClient.Threading.Invoke(() =>
{
if (!gfClient.Connection.Price.IsConnected)
return;

var account = gfClient.Accounts.Get().First();
GF.Api.Balances.IBalance totalBalance = account.TotalBalance;

Console.WriteLine($"Account: {account.Spec}");
Console.WriteLine($"\tNetLiq: {totalBalance.NetLiq:c}");
Console.WriteLine($"\tCash: {totalBalance.Cash:c}");
Console.WriteLine($"\tOpen P/L: {totalBalance.OpenPnL:c}");
Console.WriteLine($"\tTotal P/L: {totalBalance.RealizedPnL + totalBalance.OpenPnL:c}");
Console.WriteLine($"\tInitial Margin: {totalBalance.InitialMargin:c}");
Console.WriteLine($"\tNet Options Value: {totalBalance.LongCallOptionsValue + totalBalance.LongPutOptionsValue + totalBalance.ShortCallOptionsValue + totalBalance.ShortPutOptionsValue:c}");
Console.WriteLine($"Average Positions: {account.AvgPositions.Count}");
Console.WriteLine($"Orders: {gfClient.Orders.Get().Count}, last one: {(gfClient.Orders.Get().Count > 0 ? gfClient.Orders.Get().Last().ToString() : string.Empty)}");
Console.WriteLine();
});
--------------------------------------------------------------------

Please help me out on this.
Waiting for reply.