API Support Forum
User Profile

Viewing User Profile for: JSmith5611


About

Aug 11, 2015 02:10 PM

Jun 04, 2020 08:15 AM

Jun 04, 2020 08:23 AM



Post Statistics
JSmith5611 has contributed to 49 posts out of 4744 total posts (1.03%) in 1760 days (0.00 posts per day).

20 most recent posts:

API Support » Issue with Symbol LookUp Jun 04, 2020 @ 08:15 AM (Total replies: 1)

add a .WithResultCount(int resultCount) to your SymbolLookupRequestBuilder. The default is 1.
Jason Smith


API Support » C++ COM Wrapper CancelOrder Not Functioning Jun 01, 2020 @ 03:08 PM (Total replies: 15)

There was a problem with the contractloadrequestBuilder.
It was fixed in version 4.0.1.42
Jason Smith


API Support » C++ COM Wrapper CancelOrder Not Functioning May 28, 2020 @ 01:42 PM (Total replies: 15)

i picked that particular event to corrupt because it would be easy to test.
Jason Smith


API Support » C++ COM Wrapper CancelOrder Not Functioning May 28, 2020 @ 01:33 PM (Total replies: 15)

I just double checked. I changed the _ATL_FUNC_INFO for OnOrderConfirmedInfo in the example to be incorrect (said there were 2 passed parameters when there are actually 3)

When sending an order, application crashed with the same call stack as yours.

Unfortunately figuring out which event in your case is the issue will be... difficult. COM, particularly in c++ isn't exactly easy to use.

May I ask why you decided on this route instead of .NET?

Jason Smith

Edited by JSmith5611 on May 28, 2020 01:35 PM

API Support » C++ COM Wrapper CancelOrder Not Functioning May 28, 2020 @ 07:09 AM (Total replies: 15)

Even with your code, I have been unable to reproduce this. However, reading through this thread again.. i think we're looking in the wrong place.

"I should have added, it does delete the order correctly, but it crashes the application in doing so. So I do believe I am getting the order correctly."

This, combined with your other order issues.. I think you have an event registration issue.
Jason Smith


API Support » C++ COM Wrapper CancelOrder Not Functioning May 26, 2020 @ 02:40 PM (Total replies: 15)

I have been trying repeatedly to replicate this issue to no avail. is there anyway you can send me your code so i can test myself?
Jason Smith


API Support » C++ COM Wrapper CancelOrder Not Functioning May 21, 2020 @ 08:05 AM (Total replies: 15)

Can I see your code that converts your (LPCTSTR)id to an int or long?

I've testing the example code, and it is cancelling orders just fine.. not sure why you cannot.
Also, what version of the COM api do you have installed?
Jason Smith


API Support » C++ COM Wrapper CancelOrder Not Functioning May 20, 2020 @ 01:10 PM (Total replies: 15)

Unfortunately, COM wrapper call stacks tend to be... not helpful at all.

My guess is that you're not getting the order correctly from your
IOrderPtr order = GetOrderPtr((LPCTSTR)id);
line. Yes, you check to see if the orderptr is null, but it still might not be valid.
Jason Smith


Order Execution » Issue with OCO and OSO order May 20, 2020 @ 10:30 AM (Total replies: 3)

Please note that all of these parameters, with descriptions, as well as strategy names, can be found by iterating through GFApi.Strategies.GetTemplates() structures.



To create a multi-bracket strategy:

First, check that server-strategies are enabled for your login. GFApi.Strategies.GetTemplates() should have a length > 0

Create the initial orderdraft as you would any other order. Let's call it 'initialOrderDraft'

Then get the default multibracket parameters:

var strategyParams = GFApi.Strategies.GetDefaultStrategyParams("MultiBracket");


Then, you can use this parameters object to configure exactly how you want the multi-bracket to function.
Setting a parameter is as simple as:

strategyParams.GetQualified(PARMETER NAME).value = VALUE

The list of paramter names, and possible values:

"Bracket1.Quantity": Number of contracts. - Default: 0 (Integer)
"Bracket1.Target.Factor": Profit target in ticks. - Default: 4 (Integer)
"Bracket1.Target.Type": Order type for Target: Limit or Market if Touched. - Default: LMT (LMT, MIT)
"Bracket1.OCO": If On then One Cancels Other, if Off then when one order of the bracket is filled the other order will not be cancelled. - Default: True (Bool)
"Bracket1.Stop.Factor": Initial Stop in ticks. - Default: 4 (Integer)
"Bracket1.Stop.Type": Order type for Stop: Stop or Trailing Stop. - Default: STP (STP, TRSTP)
"Bracket1.Stop.TrailingMode": How often the stop moves after Trigger is hit. - Default: EveryTick (EveryTick, EveryFactor, Once) (Optional)
"Bracket1.Stop.TrailingTrigger": Amount the trade needs to move in your favor before the stop moves (trails). - Default: 1 (Integer) (Optional)
"Bracket1.Stop.TrailingStop": Amount the stop moves after the Trigger is hit. - Default: 1 (Integer) (Optional)

"Bracket2.Quantity": Number of contracts. - Default: 0 (Integer)
"Bracket2.Target.Factor": Profit target in ticks. - Default: 4 (Integer)
"Bracket2.Target.Type": Order type for Target: Limit or Market if Touched. - Default: LMT (LMT, MIT)
"Bracket2.OCO": If On then One Cancels Other, if Off then when one order of the bracket is filled the other order will not be cancelled. - Default: True (Bool)
"Bracket2.Stop.Factor": Initial Stop in ticks. - Default: 4 (Integer)
"Bracket2.Stop.Type": Order type for Stop: Stop or Trailing Stop. - Default: STP (STP, TRSTP)
"Bracket2.Stop.TrailingMode": How often the stop moves after Trigger is hit. - Default: EveryTick (EveryTick, EveryFactor, Once) (Optional)
"Bracket2.Stop.TrailingTrigger": Amount the trade needs to move in your favor before the stop moves (trails). - Default: 1 (Integer) (Optional)
"Bracket2.Stop.TrailingStop": Amount the stop moves after the Trigger is hit. - Default: 1 (Integer) (Optional)

"Bracket3.Quantity": Number of contracts. - Default: 0 (Integer)
"Bracket3.Target.Factor": Profit target in ticks. - Default: 4 (Integer)
"Bracket3.Target.Type": Order type for Target: Limit or Market if Touched. - Default: LMT (LMT, MIT)
"Bracket3.OCO": If On then One Cancels Other, if Off then when one order of the bracket is filled the other order will not be cancelled. - Default: True (Bool)
"Bracket3.Stop.Factor": Initial Stop in ticks. - Default: 4 (Integer)
"Bracket3.Stop.Type": Order type for Stop: Stop or Trailing Stop. - Default: STP (STP, TRSTP)
"Bracket3.Stop.TrailingMode": How often the stop moves after Trigger is hit. - Default: EveryTick (EveryTick, EveryFactor, Once) (Optional)
"Bracket3.Stop.TrailingTrigger": Amount the trade needs to move in your favor before the stop moves (trails). - Default: 1 (Integer) (Optional)
"Bracket3.Stop.TrailingStop": Amount the stop moves after the Trigger is hit. - Default: 1 (Integer) (Optional)

"StopOnClientDisconnection": Indicates that a strategy should be stopped if the client the strategy belongs to is disconnected. - Default: True (Bool)
"StopOnRootOrderCancelled": Indicates that a strategy should be stopped if the strategy root order is cancelled. - Default: True (Bool) (Optional)

For each bracket, the bracket itself is enabled if quantiy > 0, the profit target if its factor > 0, and the stop if its factor > 5.

forexample, setting bracket 1's quantity to 5 would be:
strategyParams.GetQualified("Bracket1.Quantity").value = 5;

after all parameters are set, the multi-bracket strategy can be started with:

var strategyId = GFApi.Strategies.Strategies.Start("MultiBracket", strategyParams.ToList(), initialOrderDraft); //.ToList() requires System.Linq

Once the strategy is verified as correct by the server, the GFApi.Strategies.StrategyConfirmed event will let you know (and give you a new ID)

Also, updates to the strategy's state will come from GFApi.Strategies.StrategyChanged event, including when new orders are placed.
Jason Smith

Edited by JSmith5611 on May 20, 2020 10:31 AM

Order Execution » Issue with OCO and OSO order May 20, 2020 @ 08:32 AM (Total replies: 3)

What you are proposing here will unfortunately not do what you intend.
SendOSO/SendOCOorders take orderdrafts, so it will create new orders every time.

However.. there is a way to achieve what I believe you want.
This to me looks like a multibracket order which we support through the GFApi.Strategies functionality... which isn't well documented as far as i know. I'll start writing up an document explaining how to use this feature.
Jason Smith


API Support » C++ COM Wrapper IContractLoadRequestBuilderPtr Crashing When Using WithSkipCount or WithResultCount May 19, 2020 @ 01:50 PM (Total replies: 1)

The problem seems to be specifically with WithSkipCount. WithResultCount should work, and WithSkipCount will be fixed on the next release.
Jason Smith


API Support » IContractLoadRequestBuilderPtr Missing Build Function in C++ GF_Api_COM Wrapper May 09, 2020 @ 08:19 AM (Total replies: 4)

Function should be available in 4.0.1.39.
Jason Smith


API Support » IContractLoadRequestBuilderPtr Missing Build Function in C++ GF_Api_COM Wrapper May 07, 2020 @ 10:10 AM (Total replies: 4)

hmm.. somehow that function is in ContractLoadRequestBuilder class, but not in the IContractLoadRequestBuilder interface. I'll fix it soon.
Jason Smith


API Support » COM API examples available Apr 27, 2020 @ 08:09 AM (Total replies: 0)

COM examples, both for vb (via excel) and c++ are now available from https://bitbucket.org/GainFuturesDev/comapisamples

Please update your COM libraries to the latest 4.0.1.37 before compiling:

https://api.gainfutures.com/WebAPI/api/Files/DownloadClientUpdate?clientUpdateId=2247 (x64)
https://api.gainfutures.com/WebAPI/api/Files/DownloadClientUpdate?clientUpdateId=2246 (x86)
Jason Smith

Edited by JSmith5611 on Apr 27, 2020 08:10 AM

API Support » GF COM API Excel Sample Apr 15, 2020 @ 11:51 AM (Total replies: 3)

The first COM example - Excel - has been migrated to GFAPI and is available on bitbucket.

C++ example is being worked on.
The Delphi example has been retired.

New versions of the COM GFAPI are also available:
https://api.gainfutures.com/WebAPI/api/Files/DownloadClientUpdate?clientUpdateId=2225 (x64 build)
https://api.gainfutures.com/WebAPI/api/Files/DownloadClientUpdate?clientUpdateId=2224 (x86 build)

We are actually surprised by the demand for the COM version of the API. We really thought that the .NET nuget package would be the primary use of our APIs.
Jason Smith

Edited by JSmith5611 on Apr 15, 2020 11:54 AM

API Support » Can't import package 'GFAPI' via NuGet Apr 14, 2020 @ 07:47 AM (Total replies: 4)

I was just able to replicate this using a fresh project under Visual Studio 2015.
If the project i was applying it to was set to use .NET Framework 4.6, it would fail to install with this error.

If the project was set to .NET Framework 4.6.2, it would work fine.

I think we may be incorrectly setting the minimum framework required in the .nuspec file.
Jason Smith


API Support » Can't import package 'GFAPI' via NuGet Apr 14, 2020 @ 07:27 AM (Total replies: 4)

To help with this,
What version of Visual Studio are you using?
what versions of the .net framework are installed?
Jason Smith


API Support » Not Receiving Account Balance and Position Updates Apr 13, 2020 @ 01:04 PM (Total replies: 4)

Looking through change logs, the only thing that has changed with these events recently is the
"When a price for a contract a position exists for updates' update for AccountSummaryChanged was being triggered multiple times for the same account for one update.

Does this (and the previous comment) explain the behavior, or do you need further assistance?
Jason Smith


API Support » Not Receiving Account Balance and Position Updates Apr 13, 2020 @ 10:07 AM (Total replies: 4)

Here are what should be triggering these events:

AccountSummaryChanged:
- When a currency rate changes and an account has a balance in that currency
- When contract margins change
- When Client.Margins.SetUseHypoPL(bool useHypoPL) is called (with a different value than currently set)
- When Client.Options.PLMode is changed
- When a price for a contract a position exists for updates
- when a fill occurs
- when a new position is entered

BalanceChanged:
- When commissions charged
- SettleP&L recalculated
- Position rolled
- Fill occurs (P&L)

AvgPositionChanged:
- When a currency rate changes and an account has a balance in that currency
- When contract margins change
- When Client.Margins.SetUseHypoPL(bool useHypoPL) is called (with a different value than currently set)
- When Client.Options.PLMode is changed
- when a fill occurs
- when a new position is entered

DetailedPositionChanged:
- When a currency rate changes and an account has a balance in that currency
- When Client.Margins.SetUseHypoPL(bool useHypoPL) is called (with a different value than currently set)
- When Client.Options.PLMode is changed
- when a fill occurs

If these events are not being triggered there may be a problem with your application.

are you calling Client.Threading.Advance() manually, or using GF.Api.Threading.GFClientRunner()?
Jason Smith


FIX Support » OrderCancelRequest Apr 08, 2020 @ 11:03 AM (Total replies: 3)

OrderID should be enough cancel the order correctly, and will be used first to find the order.
If it is not provided OrigClOrdID will be used. If neither are provided the cancel will be rejected.
Jason Smith