Jump to content


  • Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by SupereeDuperee

  1. Historical Data out of bound error

    @SirNewton Just curious was the Time Range (CandleStick) for the data, DAILY / Hourly ?
  2. Best way to know if Market is closed

    I submitted a GET for GBP/USD, response is = { "MarketInformation": { "MarketId": 401166448, "Name": "GBP/USD", "ExchangeId": 400000032, "ExchangeName": "FX (IFX) Retail Exchange", "MarginFactor": 2.0, "MinMarginFactor": null, "MaxMarginFactor": null, "ClientMarginFactor": 2.0, "MarginFactorUnits": 26, "MinDistance": 0.00001, "MinDistanceUnits": 27, "WebMinSize": 1000.0, "MaxSize": 50000000.0, "MarketSizesCurrencyCode": "USD", "MaxLongSize": 5000001.0, "MaxShortSize": 5000001.0, "Market24H": true, "PriceDecimalPlaces": 5, "DefaultQuoteLength": 5, "TradeOnWeb": true, "LimitUp": false, "LimitDown": false, "LongPositionOnly": false, "CloseOnly": false, "MarketEod": [], "PriceTolerance": 2.0, "ConvertPriceToPipsMultiplier": 10000, "MarketSettingsTypeId": 2, "MarketSettingsType": "CFD", "MobileShortName": "GBP/USD", "CentralClearingType": "No", "CentralClearingTypeDescription": "None", "MarketCurrencyId": 11, "PhoneMinSize": 5000.0, "DailyFinancingAppliedAtUtc": "/Date(1614117600000)/", "NextMarketEodTimeUtc": "/Date(1614117600000)/", "TradingStartTimeUtc": null, "TradingEndTimeUtc": null, "MarketPricingTimes": [ { "DayOfWeek": 5, "StartTimeUtc": null, "EndTimeUtc": { "UtcDateTime": "/Date(1614117600000)/", "OffsetMinutes": -300 } }, { "DayOfWeek": 0, "StartTimeUtc": { "UtcDateTime": "/Date(1614117600000)/", "OffsetMinutes": -300 }, "EndTimeUtc": null } ], "MarketBreakTimes": [], "MarketSpreads": [ { "SpreadTimeUtc": null, "Spread": 0.0001, "SpreadUnits": 27 } ], "GuaranteedOrderPremium": 10.0, "GuaranteedOrderPremiumUnits": 1, "GuaranteedOrderMinDistance": 50.0, "GuaranteedOrderMinDistanceUnits": 27, "PriceToleranceUnits": 0.0001, "MarketTimeZoneOffsetMinutes": -300, "QuantityConversionFactor": 1.0, "PointFactorDivisor": 100, "BetPer": 1.0, "MarketUnderlyingTypeId": 4, "MarketUnderlyingType": "FX", "AllowGuaranteedOrders": false, "OrdersAwareMargining": false, "OrdersAwareMarginingMinimum": null, "CommissionChargeMinimum": null, "CommissionRate": null, "CommissionRateUnits": null, "ExpiryUtc": null, "FutureRolloverUTC": null, "AllowRollover": false, "ExpiryBasisId": 1, "ExpiryBasisText": "", "StepMargin": { "EligibleForStepMargin": true, "StepMarginConfigured": true, "InheritedFromParentAccountOperator": true, "Bands": [ { "LowerBound": 0.0, "MarginFactor": 5.0 }, { "LowerBound": 7200000.0, "MarginFactor": 5.0 }, { "LowerBound": 14000000.0, "MarginFactor": 5.0 }, { "LowerBound": 21000000.0, "MarginFactor": 5.0 }, { "LowerBound": 54000000.0, "MarginFactor": 20.0 } ] }, "OptionTypeId": null, "OptionType": null, "StrikePrice": null, "MarketTypeId": 2, "MarketType": "Ordinary Market", "Weighting": 628, "FxFinancing": { "CaptureDateTime": "/Date(1614204000000)/", "PreviousCaptureDateTime": "/Date(1614117600000)/", "LongPoints": 0.15, "ShortPoints": -0.03, "LongCharge": -1.23, "PreviousLongCharge": -0.41, "ShortCharge": -0.99, "PreviousShortCharge": -0.33, "Quantity": 10000.0, "ChargeCurrencyId": 11, "DaysToRoll": 3, "PreviousDaysToRoll": 1 }, "UnderlyingRicCode": "GBPUSD", "NewsUnderlyingOverrideType": "NamedItem", "NewsUnderlyingOverrideCode": "GBP/", "TrailingStopConversionFactor": 0.0001, "IsKnockout": false, "Knockout": null } } Which value gives me the Weekly Market Close and Open day/times? Thank you. @Physicsman
  3. In the API PDF and (now offline) docs web site and also in this forum numerous time I have seen NewTradeOrderRequestDTO example like :- { "IfDone":[], "Direction":"buy", "ExpiryDateTimeUTCDate":null, "LastChangedDateTimeUTCDate":null, "OcoOrder":null, "Type":null, "ExpiryDateTimeUTC":null, "Applicability":null, "TriggerPrice":null, "BidPrice":1.4395, "AuditId":"8327595- 0- 0- 0- R", "AutoRollover":false, "MarketId":401166448, "OfferPrice":1.4397, "OrderId":0, "Currency":null, "Quantity":1, "QuoteId":null, "LastChangedDateTimeUTC":null, "PositionMethodId":1, "TradingAccountId":400239061, "MarketName":"GBP/USD", "Status":null, "isTrade":true } This is taken from Page# 208 of the GAIN_CAP_UserGuide PDF file itself. And it works just fine. However the "NewTradeOrderRequestDTO" description on Page# 350 of the same PDF (Screenshot attached) doesn't have any of these properties that are in the JSON above ExpiryDateTimeUTCDate LastChangedDateTimeUTCDate MarketName etc ... .. . Why there is a mismatch? Will "NewTradeOrderRequestDTO" Object work without any of these NEW fields if I send it to API Call? Thanks
  4. @Physicsman Thanks for the clarification. In MOST cases I am getting StatusReason=75 which translates into Where do I "check details" ?
  5. Hi @Physicsman you mentioned Also in Documentation for Status Resons #7 says about logs (PDF Page 79) InstructionStatusReason Code Description 1 OK. 2 Instance of type InstructionDTO must be provided. 3 Risk Process identifier does not exist. 4 Internal user identifier must be provided. 5 Session identifier must be provided. 6 Instruction source identifier does not exist. 7 Instruction processing has resulted in an Error. Please check log for details. Where is this "Log"? How can I access/view this log? Thank you.
  6. Streaming data seems off around closing

    @SirNewton Volatility rises and Liquidity lowers when the Major Market Closes, like near 5PM Eastern Time everyday. This causes the Spread to go HIGH for certain pairs. I have seen on GBP/NZD pairs spread go as high as 12, sometime 18 on regular day 5PM EST+ as well as on Friday 5PM EST+.
  7. An ApiIfDoneDTO JSON text is given below. The Child Items "Stop" and "Limit" are of type "ApiStopLimitOrderDTO" { "IfDone":[ { "Stop":{ "OrderId":778252070, "StatusReason":1, "Status":2, "OrderTypeId":2, "Price":0, "Quantity":1000, "TriggerPrice":1.36261, "CommissionCharge":0, "IfDone":[ ], "GuaranteedPremium":0, "OCO":null, "AssociatedOrders":{ "Stop":null, "Limit":null }, "Associated":false }, "Limit":{ "OrderId":778252069, "StatusReason":1, "Status":2, "OrderTypeId":3, "Price":0, "Quantity":1000, "TriggerPrice":1.36661, "CommissionCharge":0, "IfDone":[ ], "GuaranteedPremium":0, "OCO":null, "AssociatedOrders":{ "Stop":null, "Limit":null }, "Associated":false } } ] } My ApiIfDoneDTO class looks like :- public class ApiIfDoneDTO { #region Public Properties & Private Members /// <summary> /// The price at which the stop order will be filled. /// </summary> public ApiStopLimitOrderDTO Stop { get; set; } /// <summary> /// The price at which the limit order will be filled. /// </summary> public ApiStopLimitOrderDTO Limit { get; set; } #endregion #region Constructors private void Initilize() { } public ApiIfDoneDTO() { Initilize(); } #endregion } Problem is the above JSON text is providing an ARRAY but the ApiIfDoneDTO class has just TWO Properties - Stop and Limit. I cannot deserialize JSON text into ApiIfDoneDTO object withouth manually hacking the JSON Text. Is there any C# Developer OR JSON Expert who can show me what would be a Class Object that will Deserialize into from the Above JSON text (using NewtonSoft.JsonConverter) ? I will appreciate your help.
  8. I am trying to CLOSE an open position of EUR/GBP total Quantity 159000 which is accumulation of 4 separate ORDERs - attached ScreenShot. Here is the JSON that I submit to "order/newtradeorder" API URL { "MarketId":401484335, "Currency":null, "AutoRollover":false, "Direction":"sell", "Quantity":159000.0000, "QuoteId":0, "PositionMethodId":0, "BidPrice":1.0001, "OfferPrice":999.9999, "AuditId":"8870258", "TradingAccountId":401235826, "IfDone":null, "Close":[ 777333435, 777333437, 777333438, 778897685 ], "Reference":null, "AllocationProfileId":0, "OrderReference":null, "Source":null, "PriceTolerance":0 } I get the result with error : Status=2, Status Reason=75 { "Status":2, "StatusReason":75, "OrderId":0, "Orders":[ { "OrderId":0, "StatusReason":158, "Status":10, "OrderTypeId":1, "Price":0.0, "Quantity":0.0000, "TriggerPrice":0.0, "CommissionCharge":0.0, "IfDone":[ ], "GuaranteedPremium":0.0, "OCO":null, "AssociatedOrders":{ "Stop":null, "Limit":null }, "Associated":false } ], "Quote":null, "Actions":[ ], "ErrorMessage":null } Where Status Reason 75 = "The total quantity of guaranteed stop orders must be equal to trade order quantity." I have tested my Close Position API Calls and it works fine where the QUANTITY is like 123,000. If there are quantity in Hundredth and Tenth position, like 123,450 Then my API Calls fails. Even though in this example TOTAL Quantity is 159,000 still it fails because the Individual Open Positions have quantity in Hundredths and Tenth position. How do I overcome this situation? Thank you.
  9. Thanks for the detailed information. I will send CLOSE request with PriceTolerance value "2" so that most of the time close order would go through.
  10. Yes, it was DEMO Account. The outage was intermittent on Friday. Working fine this week. Thanks for checking.
  11. I am getting error message while accessing account info through this URL. It started sometime last night. https://ciapi.cityindex.com/TradingAPI/UserAccount/ClientAndTradingAccount?UserName=DC321983&Session=abcf29e-0a7d-4a79-8cec-72c2e967fcba Th GET Result :- { "HttpStatus": 500, "ErrorMessage": "Server error", "ErrorCode": 500 } Can anyone else please check if it is only me or everyone is affected? Thanks.
  12. OK, I found the issue - It's related to the "IfDone" class and how c# serializes it. In the Request JSON I have .... ... .. . "TradingAccountId":40319, "IfDone":{ "Stop":{ ... ... ... }, "Close":null, .... ... .. . But IfDone has to be an "ARRAY" Object in JSON, like .... ... .. . "TradingAccountId":40319, "IfDone":[{ "Stop":{ ... ... ... }], "Close":null, .... ... .. . The Square Brackets "IfDone" : [ { has to be there for the API Call to Work. In My C# Class "ApiIfDoneDTO" has TWO "ApiStopLimitOrderDTO" Properties Stop and Limit. But it is not an "Array". I can hack in to the NewtonSoft's JSON converted text and add "[" and "]" to the "IfDone" segment of the JSON. But not sure how to create the "ApiIfDoneDTO" Class that will create JSON with [ and] automatically.
  13. I am trying to submit a "GBP/JPY" Trade Order through API, that will do the same as the GUI Submission - screenshot attached. My "order/newtradeorder" POST body :- { "MarketId":401484385, "Currency":null, "AutoRollover":false, "Direction":"Buy", "Quantity":11000.0, "QuoteId":0, "PositionMethodId":1, "BidPrice":143.402, "OfferPrice":143.528, "AuditId":"7975276", "TradingAccountId":40319, "IfDone":{ "Stop":{ "Guaranteed":false, "TriggerPrice":142.979, "ExpiryDateTimeUTC":null, "Applicability":"GTC", "ParentOrderId":null, "TrailingDistance":null, "Associated":false, "OrderId":null, "Reference":null, "OrderReference":null, "AutoRollover":false, "MarketId":401484385, "Direction":"Sell", "Quantity":11000.0, "TradingAccountId":40319, "IfDone":null, "OcoOrder":null, "LastChangedDateTimeUTC":null, "AssociatedOrders":null }, "Limit":{ "Guaranteed":false, "TriggerPrice":144.038, "ExpiryDateTimeUTC":null, "Applicability":"GTC", "ParentOrderId":null, "TrailingDistance":null, "Associated":false, "OrderId":null, "Reference":null, "OrderReference":null, "AutoRollover":false, "MarketId":401484385, "Direction":"Sell", "Quantity":11000.0, "TradingAccountId":40319, "IfDone":null, "OcoOrder":null, "LastChangedDateTimeUTC":null, "AssociatedOrders":null } }, "Close":null, "Reference":null, "AllocationProfileId":0, "OrderReference":null, "Source":null, "PriceTolerance":0 } API Call produces no ERROR, a Trade is created/opened BUT NO STOP LIMIT Order created. I do not see any ERROR message in the RESPONSE :- { "Status": 1, "StatusReason": 1, "OrderId": 778264513, "Orders": [ { "OrderId": 778264513, "StatusReason": 1, "Status": 3, "OrderTypeId": 1, "Price": 143.446, "Quantity": 11000.0, "TriggerPrice": 0.0, "CommissionCharge": 0.0, "IfDone": [], "GuaranteedPremium": 0.0, "OCO": null, "AssociatedOrders": { "Stop": null, "Limit": null }, "Associated": false } ], "Quote": null, "Actions": [ { "ActionedOrderId": 0, "ActioningOrderId": 0, "Quantity": 11000.0, "ProfitAndLoss": 0.0, "ProfitAndLossCurrency": null, "OrderActionTypeId": 1 } ], "ErrorMessage": null } Second question: In my C# Classes some of the Integer Properties are not marked as "nullable", thus they show up in JSON with value '0', like "OrderId":0, instead on "OrderId":null. Can that cause problem?
  14. Ok, I should've guessed the "Inheritance" - may be I missed that to remember when studied the documentation. Thanks for pointing that out. I assume anytime I see something like :- ApiPrimaryMarketTagDTO > ApiMarketTagDTO I know "ApiPrimaryMarketTagDTO" class inherits from "ApiMarketTagDTO" class (in c# terms) Thanks for the info!
  15. I have a follow up question regarding attaching Stop/Limit order with a New Trade Order. Documentation says "NewTradeOrderRequestDTO" has "IfDone" property where I can attach STOP and LIMIT Orders. IfDone is consists of these two (in c#) properties public ApiStopLimitOrderDTO Stop { get; set; } public ApiStopLimitOrderDTO Limit { get; set; } And "ApiStopLimitOrderDTO" has these properties public bool Guaranteed { get; set; } public decimal TriggerPrice { get; set; } public string ExpiryDateTimeUTC { get; set; } public string Applicability { get; set; } public int? ParentOrderId { get; set; } public decimal? TrailingDistance { get; set; } public bool Associated { get; set; } in the ABOVE Example we have "IfDone": [ { "Limit": { "OrderId": null, "Direction": "sell", "Applicability": "gtc", "ExpiryDateTimeUTC": null, "Quantity": 100000, "TriggerPrice": 107.21416, "IfDone": [], "OcoOrder": null } } ], Here the IfDone's "Limit" does not conform to ApiStopLimitOrderDTO Properties. What am I missing here? What's the proper way to Attach Stop/Limit Order when sending a Trade-At-Market-Rate Order?
  16. I've been taking help from the API Documentation page = http://docs.labs.gaincapital.com/ but since last Friday night I cannot access the site. Is it under maintenance or moved to a different location? Can any one provide some info or new URL please? Thanks.
  17. I hope this link works. Visual Studio 2017/19 Solution Folder Ziipped . https://drive.google.com/file/d/1SavnJe6f_NRFE5-LYV9arewd893d7AdP/view?usp=sharing I created a Class to hold the rate info, and a List of that Rate Info Class - which keeps latest rate info , along with showing rates on the screen.
  18. OK, Sigh of Relief! On LIVE account the Margin Required Amount API Call returns RIGHT Value = 1369.xx. So we should be good in real life scenario.
  19. Also DO NOT USE the Pre-Prod URL - that has been deprecated. Use the LIVE Url for both DEMO and Live accounts.
  20. I am trying to get Margin Required amount for GBP/JPY, 20000 Quantity. I call POST on this URL https://ciapi.cityindex.com/TradingAPI/order/simulate/newtradeorder?UserName=demo210127&Session= The Request JSON is { "MarketId":401484385, "Currency":null, "AutoRollover":false, "Direction":"Buy", "Quantity":20000.0, "QuoteId":0, "PositionMethodId":1, "BidPrice":1.0001, "OfferPrice":999.9999, "AuditId":"1739236", "TradingAccountId":101295826, "IfDone":null, "Close":null, "Reference":null, "AllocationProfileId":0, "OrderReference":null, "Source":null, "PriceTolerance":0 } The Response JSON is:- { "Status": 1, "StatusReason": 1, "SimulatedCash": 49991.82, "ActualCash": 49991.82, "SimulatedTotalMarginRequirement": 2648.42, "ActualTotalMarginRequirement": 1280.36, "CurrencyId": 11, "Orders": [ { "StatusReason": 1, "Status": 3 } ] } From the documentation, if I am not wrong, "SimulatedTotalMarginRequirement": 2648.42, is the REQUIRED MARGIN Amount. I am using my DEMO account. However if I try to place a NEW TRADE ORDER from the WebTrader website, using the same DEMO account I get required margin amount = 1369.10. Screenshot attached. Why the margin requirement amount is not SAME from WebTrader and API call?
  21. I have created a C# .NET Console app that collects streaming rates (and saves to database). If you are interested I can share my code.
  22. I kind of assumed that and found the API Call to Open a Market Trade works fine without the NEW FIELDS. However I found this really interesting :- The Bid/Offer value has ABSOLUTELY no EFFECT as long as they are 0<Bid<Offer and CurrentRate falls within Bid/Offer range. So I am using Bid=1.0001 and Offer=999.9999 in my OpentMarketTrade API calls and it buys/sells at the current rate. I am skipping an API call to get Current Bid/Ask values. Is there any Serious Risk using Bid=1.0001 and Offer=999.9999 values in above scenario? {"MarketId":401484406,"Currency":null,"AutoRollover":false, "Direction":"Buy","Quantity":3000.0,"QuoteId":0,"PositionMethodId":0, "BidPrice":1.0001,"OfferPrice":9.9999,"AuditId":"6123214", "TradingAccountId":101958216,"IfDone":null,"Close":null,"Reference":null, "AllocationProfileId":0,"OrderReference":null,"Source":null, "MarketName":"EUR/USD","PriceTolerance":0} Also, The "MarketName":"EUR/USD" is useless, in above JSON i used MarketId=401484406 Which is USD/CAD so the "MarketName" is useless.
  23. Aaah Dang It! It was my Coding Error, in the "public class ApiOpenPositionDTO" I had public List<ApiAssociatedDTO> AssociatedOrders { get; set; } but CORRECT Format IS = public ApiAssociatedDTO AssociatedOrders { get; set; } Now it is DeSerializing just fine. ********* THIS THREAD /POST Can Be deleted as I found My Answer Myself But can be kept for Future Users ******
  24. After a successful GET call to "https://ciapi.cityindex.com/TradingAPI/order/openpositions?TradingAccountId=xxxx" I get the below response { "OpenPositions": [ { "OrderId": 776551478, "MarketId": 401484347, "MarketName": "EUR/USD", "Direction": "buy", "Quantity": 1000.0000, "Price": 1.212940000, "TradingAccountId": 403195826, "Currency": "USD", "Status": 3, "StopOrder": null, "LimitOrder": null, "LastChangedDateTimeUTC": "/Date(1611640457973)/", "CreatedDateTimeUTC": "/Date(1611640457972)/", "ExecutedDateTimeUTC": "/Date(1611640457972)/", "AutoRollover": false, "TradeReference": null, "ManagedTrades": [], "AllocationProfileId": 0, "AllocationProfileName": "", "AssociatedOrders": { "Stop": null, "Limit": null }, "FixedInitalMargin": 0.0, "PositionMethodId": 1 } ] } In my C# .NET App I am failing to convert the JSON text to Object, I am getting exception ListOpenPositionsResponseDTO listOpenPositions = JsonConvert.DeserializeObject<ListOpenPositionsResponseDTO>(JSON); Exception Error Message : I have attached the Classes files. Can any one please give me some ideas how to convert to .NET POC Object from JSON? OR Where I need to change? Exception message not much of a help pin-point the exact issue. ListOpenPositionsResponseDTO.cs ApiOpenPositionDTO.cs ApiAssociatedDTO.cs
  25. It's going to be a great PITA for that missing documentation URL. How difficult it is to put a landing HTML stating the documentation is under maintenance in the meantime download the PDF with the Link to the PDF? It's a 10 minute's job for any web developer / html coder - question is how Agile is your Web Development Team.