Jump to content

Physicsman

Administrators
  • Content count

    738
  • Joined

  • Last visited

  • Days Won

    18

Posts posted by Physicsman


  1. Hi Superee,

    It is the MarketPrcingTimes fields. Since these are Forex 24H trading markets, we've been using a shortcut internally and that is probably what is causing you confusion. 

    DayofWeek 0 is Sunday and DayofWeek 5 is Friday. Since we know that FX markets open on Sunday and close on Friday, we just take the current week's Sunday and Friday dates. The actual Date returned in the field is just today's date and close time of 22:00 hours. We're ignoring the date and appending the 22:00 hours close/open times to the Sunday Start and Friday End dates to get each weeks open/close. 

    Kind Regards, PM

    image.png


  2. Hi SirNewton,

    When you didn't include anything in the Close field the system should be closing your positions in the order they were opened going from first to second..., rather than closing them at random. 

    Reading through the following link on the rule, it looks as though the NFA's aim of implementing this FIFO rule was to prevent clients from "hedging", which is to have simultaneous offsetting long and short positions in the same market. 

    https://www.investopedia.com/terms/n/nfa-compliance-rule-2-43b.asp

    Kind Regards, PM


  3. Hi SirNewton,

    A couple of clarifying questions:

    1. Are you a US client? 
    2. Did you have more than one open position in the same market, and you were attempting to close one of those open positions specifically?

    The error message you are seeing is related to the case when the answers to both questions above are true. US clients are forced by the US regulator to close positions in a First In First Out (FIFO) order. For example, if you buy GBP/USD, then a little time later add to your buy position, and after some more time buy a 3rd position in GBP/USD. As a US client you must close the positions in the order you opened them. If you try to close say the 2nd or 3rd position out of sequence, then you will receive this error message.

    If the above doesn't apply to you we can investigate further. 

    Kind Regards, PM


  4. Hi Superee,

    In the first case, that is referring to any logs the user/developer such as yourself stores on the prices you are trading on. Should not need/want to keep logs on this type of information/transaction it is not required to successfuly use the API. 

    In the second case, it is also referring to the logs (if any) kept by the user/yourself on the API responses received for each call you send. Specifically, you would check the OrderStatusReason code in the response for additional information as to why you are receiving a red card.

    PS: the API documentation site has been back up for the past couple of weeks so you can go back to user that over the PDF file should you prefer.

    Kind Regards, PM


  5. Hi SirNewton,

    The PriceTolerance does not change the prices you see at all. It only affects the potential prices you can be filled (trade executed) at. That is, with PriceTolerance = 2, you are allowing the system to fill you with up to 2 points of slippage, whereas a Tolerance of zero means fill me at the price I am seeing right now only.

    Were the market price to have moved by even 1 point by the time the server receives your order request then the order request is rejected and no trade is executed.

    Kind Regards, PM


  6. Hi SirNewton,

    1) I'm not sure where Yahoo Finance are receiving their streamed prices from for those hours. You can only trade with us in within our open market hours. The GetMarketInformation call can query for the market hours we are open for each market you are looking to trade.

    2) The Price field in the Prices stream is the Mid price. So you can check for the Bid, Offer or Mid price as you prefer. 

    Kind Regards, PM


  7. Hi Superee,

    There's been a slight confusion in the error codes you are using that has sent you on a slight wild goose chase. 

    The first set of codes (in green below) are the InstructionStatus and InstructionStatusReason codes. It is the 2nd set of codes (in red below) that are the OrderStatus and OrderStatusReason codes. 158 = Price tolerance exceeded. 

    I see your in your trade request that you are overriding the default value of 2 to zero. A value of zero makes your trade request a "Fill or Kill" (FOK) order request. This means execute the trade at the price I am seeing right now and only this price. If the price should move by even 1 pip then kill my order and nothing done. If you loosen the price tolerance back to 2, then you are more likley to have the trade executed, although you can have up to 2 points of slippage.

    Note: if you are attempting to trade during volatile periods when the prices are moving very fast, you can still receive a 158 even with a price tolerance of 2. 

    Kind Regards, PM

     

    image.png


  8. Hello SirNewton,

    1) Yes, you can begin trading immediately upon a market opening. 

    2) Live price streaming stops when a market closes. As far as I know all markets are closed by Friday 9pm GMT, although there may be exceptions I don't know about.

    3) Different markets open at different times. There are many markets such as FX markets that open Sunday night at 10pm. Youu can always check the market open and close times for the markets you are interested in trading by making a GetMarketInformation call.

    4) We maintain varying amounts of historical data depending upon the market and upon the timeframe. For example, for the most popular / major markets we store more historical data compared to some other markets. We also store a longer history for the longer timeframes, such as daily, weekly data etc. For intra-day data such as 5 minutes bars for example, we may store only a day or 2.  Each "day" is from midnight (00:00) to 23:59 GMT.

    5) The historical data is available immediately. For example, a GetLatestPriceBars "daily" timeframe call for 1 bar will return yesterday's (Monday 8th Feb) complete bar, and today's (Tuesday 9th Feb) partial bar up to the moment at which the call was received. 

    6) The AuditID is read from the live streaming Prices stream. There is a unique AuditId accompanying each price tick.     

    7) The minimum and maximum trade quantities are set on a per market basis. You can find the min/max trade sizes for each market by making a GetMarketInformation call.

    8) Your trade call appears to cover all the required fields. The NewTradeOrderRequestDTO specifies the fields and also which ones are nullable.

    9) For Spot FX markets, 1000 is the minimum trade size. 

    Kind Regards, PM


  9. Hi Superee,

    ApiStopLimitOrderDTO also inherits from ApiOrderDTO and all of its properties, hence the link to that DTO in the documentation. Additionally, many of the Properties are nullable and can be dropped from the reqeusts. 

    image.png

     

    A valid trade request with attached stops/limits can be formed as in the following example:

    "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
                        }
                    }
                ],

    Kind Regards, PM

     


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


  11. Hello Superee,

    If your trade call is not using the actual live Bid/Offer prices at the time you send the call, you won't have it in your logs as to what price you received at the time the trade was made. I would suggest it is better to have the call to request the current Bid/Ask and use them in your trade call so you have it on record, but if that isn't something you check then it is your choice. 

    Similarly, the MarkeName field is there should you or another user require it in the trade call. If you don't require it, you can leave that from your call.

    Kind Regards, PM

     


  12. Hello,

    Our API documentation site is currently down but should be back online in the next few days. In the meantime, you can refer to the API documentation as a PDF in the attached file.

     CIAPI User Guide.pdf

    In answer to your question, you'll have to subscribe to the live prices stream using the third party LightStreamer API. You can find documentation for the Lighstreamer API at: https://lightstreamer.com/doc. You'll also need to download the correct Lightstreamer client development kit (CDK) for the programming language you are using, and that matches the Lightstreamer version we have on our servers (v7.03). CDKs for v7.03 at: https://lightstreamer.com/download/#ls70.

    Kind Regards, PM

     

    Quote

    The streaming API portion enables you to receive live real-time data streams for things such as market prices, news headlines, and account margin information.

    Real-time data is delivered from our servers through the use of long lived polling HTTP subscriptions to specific channels. The streams of real-time data that can be pushed to users are: prices, news headlines, client account margin, orders, and quotes. The streams are exposed using the third party Lightstreamer protocol, and require the use of the latest Lightstreamer client library.

    (Documentation, information and Lightstreamer client libraries can be accessed and downloaded from the Lightstreamer website here. A good place to start is General Concepts followed by Network Protocol Tutorial.)

    Long lived polling means that the data request rests on the server until an event is triggered, such as the arrival of data or a timeout occurring. Once an event is triggered, the request activates and sends a full response to the client.

    Various adapters are provided to enable subscription to the streams. The streams are grouped into adapters as follows:

    • STREAMINGALL adapter
      • PRICES
      • NEWSHEADLINES
      • CLIENTACCOUNTMARGIN
      • TRADEMARGIN
      • ORDERS
      • QUOTES
      • TRADINGACCOUNTMARGIN (this stream is only applicable to the GTS back-end)

         

    • CITYINDEXSTREAMINGDEFAULTPRICES adapter
      • DEFAULTPRICES

     

    In the Reference section of this documentation, the Streaming Data topic book provides stream and parameter information for the available channels.

    To receive streaming prices from the API, a few pre-requisites must be filled:

    1. An account on the appropriate environment, whether "Live" or "Pre-Prod".
    2. A client UI that can perform the login by creating a session (POST a Session) on the trading API address of the appropriate environment for the account.
    3. The client UI must then subscribe to Lightstreamer so that it can receive the live prices. Note: subscribing to the real-time data streams requires authentication information to subscribe.

      The credentials are your account user name and the password is the Session ID received when logging into the REST part of the API.
       

     


    • Hello,

      We have a project to automate documentation updates so that de-synchronisation such as the examples above no longer happen. Until that is implemented, the documentation is still being updated manually. 

      It looks as though the DTO fields page was not updated when new fields were added, although the page with the Trade calls were updated with the new fields. We're scheuling some updates to refresh the docs to clean up discrepancies such as this.

      Kind Regards, PM

       

       

       

       


    • Hi,

      Are you using a Direct Market Access (DMA) account? Those are our account types that don't allow users to attach Stops/limits to close a specific position. Or do you have an account under US jurisdiction? There are certain restrictions for those accounts too.

      I checked the API JSON code you are sending and it is in a valid format. It should work - if your account supports it.  

      Kind Regards, PM 

       

    • Hello,

      1) All clients use the same API, regardless of which brand they are with. That is why you have to use the correct Market ID for the markets that you can access and trade with your brand.

      2)  We use UTC (GMT) as the basis for time - it looks as though you've been converting the time to West Coast USA, which is -8 hours from GMT. When I run the conversion on the first bar above I see it as the bar starting on Thursday 21st Jan at midnight (00:00 hours). 

      image.png

       

      The second timestamp is the bar starting Friday 22nd Jan.

      image.png

      The 2nd price bar is the one you want for Friday's OHLC prices. 

      Kind Regards, PM

       

    ×