Jump to content

SupereeDuperee

Members
  • Content count

    37
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by SupereeDuperee


  1. From my C# WinForm app, I am getting "(520) Origin Error" a lot this morning. Is server overloaded or has something changed? I get the error when I call to AUTHENTICATE. 2 out of 10 it would go through fine without error. After Authenticating I VALIDATE the session, and I get the same error again. 

    HttpWebResponse Error in https://ciapi.cityindex.com/TradingAPI/session/ : The remote server returned an error: (520) Origin Error.

     

    I also tried from Postman, randomly I get the same error, may be 1 in 10. Any idea?

    Postman Error:

    Quote

    Error 520

    Ray ID: 66dbd4ac2cf32b77 • 2021-07-12 17:01:24 UTC

    Web server is returning an unknown error

     
    You

    Browser

    Working
     
    Chicago

    Cloudflare

    Working
     
    ciapi.cityindex.com

    Host

    Error

    What happened?

    There is an unknown connection issue between Cloudflare and the origin web server. As a result, the web page can not be displayed.

    What can I do?

    If you are a visitor of this website:

    Please try again in a few minutes.

    If you are the owner of this website:

    There is an issue between Cloudflare's cache and your origin web server. Cloudflare monitors for these errors and automatically investigates the cause. To help support the investigation, you can pull the corresponding error log from your web server and submit it our support team. Please include the Ray ID (which is at the bottom of this error page). Additional troubleshooting resources.

    Cloudflare Ray ID: 66dbd4ac2cf32b77  Your IP: 73.282.205.214  Performance & security by Cloudflare

     


  2. Yes, I was not submitting as POST - so that was the User Error. But no success yet either - following your example.

    How are you passing the SessionId value to the POST request? I added session to the BODY, I get Session is not valid. However Session Id is valid - I checked "Session Validation"" and it was valid.

    I tried without the SessionId in the body, just like your Attached Pic. I get the same error - Session Not Valid.

    ListActiveOrders_API.PNG


  3. I have 3 open trades, with STOP / LIMIT Orders on each trade. I also have 11 PENDING Orders (to open trade at TRIGGER price in future). If I call "ActiveStopLimitOrders" API, I get total 17 results - (3x2+11). If I call "ListActiveOrders" I get NONE.

    What's the difference between these two API Calls? In which situation I would see some results for the "ListActiveOrders" call?

    *** I am a US Forex Trader.


  4. Yes, I am a US Forex.com user. I believe the DEMO Account does not MIMIC the US Forex.Com rules and thus my TESTing passed in DEMO trading but failing in PROD/Real-Life. At least ,now I know what's causing the problem. Thanks.

    I think I have to send a "newstoplimitorder' without any STOP/LIMIT children. Once the order gets fulfilled I can then attach  stop/limit order. I have to MONITOR periodically if the ORDER is fulfilled or not. RIGHT?

    For a US Forex Trader , like me, is it  possible:-

    1. Send a market BUY order for 10000 Units of USD/CAD rate = 1.0050,  with stop=1.0000, limit 1.0090
    2. Send  10000 Units of USD/CAD NewStopLimitOrder BUY for 1.0040
    3. At some point, NewStopLimitOrder for 1.0040 BUY executed. Can I attach Stop=1.0010 and Limit=1.0070 for this TRADE (this stop limit is different than EXISTING trade's Stop/Linit rates)?


  5. The API URL = https://ciapi.cityindex.com/TradingAPI/order/newstoplimitorder

    RequestJSON

    {"OrderId":0,"MarketId":401484338,"Currency":null,"AutoRollover":false,"Direction":"Buy","PositionMethodId":1,"Quantity":1000.0,"BidPrice":132.914,"OfferPrice":132.93,"AuditId":"4910693","TradingAccountId":XXYYZZ,"IfDone":{"Stop":{"Guaranteed":false,"TriggerPrice":132.629737794,"ExpiryDateTimeUTC":null,"Applicability":"GTC","ParentOrderId":null,"TrailingDistance":null,"Associated":false,"OrderId":0,"Reference":null,"OrderReference":null,"AutoRollover":false,"MarketId":401484338,"Direction":"Sell","Quantity":1000.0,"OriginalQuantity":0.0,"Price":null,"OriginalPrice":null,"TradingAccountId":401305136,"CurrencyId":0,"StatusId":0,"TypeId":0,"IfDone":null,"OcoOrder":null,"LastChangedDateTimeUTC":null,"AssociatedOrders":null},"Limit":null},"OcoOrder":null,"Applicability":null,"ExpiryDateTimeUTC":null,"Guaranteed":false,"TriggerPrice":132.749737794,"Reference":null,"AllocationProfileId":0,"OrderReference":null,"Source":null}

     

    ResponseJSON

    
    {"Status":4,"StatusReason":15,"OrderId":0,"Orders":[],"Quote":null,"Actions":[],"ErrorMessage":null}

     


  6. From my own/personal windows .net app I am sending Limit Order(s) and getting errors :-

    
    2021-05-16 19:02:34:136 : Order Placed for EUR/JPY Buy Amount=1000, Rate=132.749737794 Status=4 Reason=15
    2021-05-16 19:02:34:136 : Order FAILED FOR EUR/JPY : InstructionStatus=4=Error InstructionReason=15=Trigger level calculation type does not exist.

    At that 07:02nd Minute's OHLC for EUR/JPY = 132.934/.945/.927/927. My app was sending a BUY-LIMIT order @132.749xxx. So the price should not be a problem.

    Can some one please shed some light why the order failed? AND what that Error Message means? Thank you.

    *** What kind of encoding causing those weird "Â" to appear? (Just curious, not an issue)

     


  7. On 2/2/2021 at 9:21 AM, Physicsman said:

    Hi Ken,

    If you are subscribed to the live prices stream there is a field within the stream called StatusSummary. It indicates the current state of the market.

    Values are: 0 = Normal 1 = Indicative 2 = PhoneOnly 3 = Suspended 4 = Closed

    The only other alternative is to make a REST GetMarketInformation call that provides the market trading and break times. This will alow you to work out when a market is open or closed.

    Kind Regards, PM

    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


  8. Hi @Physicsman you mentioned 

    Quote

    ... .. .  you won't have it in your logs as to what price you received . .. ...

    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.


  9. 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.

     


  10. 4 hours ago, Physicsman said:

    Hi Superee,

    I checked with a few of my test accounts and they are all working fine. 

    1. Are you perhaps using a demo account? Demo accounts have a limited period of validity before they expire. Are you able to login with the account and can you perform any other API calls with it?

    Kind Regards, PM

    Yes, it was DEMO Account. The outage was intermittent on Friday. Working fine this week. Thanks for checking.


  11. 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.

     

     

    FX_MultiTrades.PNG


  12. 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.


  13. 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.

     


  14. 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?

     

    FX_Trade_GUI_Submitted.PNG

    FX_BuyWStopLoss.PNG


  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?

     

×