Jump to content
kensplanet

Best way to know if Market is closed

Recommended Posts

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

Share this post


Link to post
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

Share this post


Link to post

Hi Superee,

It is the MarketPricingTimes 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

Share this post


Link to post

Hi!

I have a question on this topic. 

Will the opening and closing dates of the market change if there is some holiday on which the exchange does not work? Let's say the stock exchange closes at 10:00 pm on January 27th. What data will I see in these fields on January 25th and January 26th?

 

Best, wintermonth!

Share this post


Link to post

Hello,

Since our markets mirror the underlying, our systems will have close times of exchanges when they close differently than normal - for example due to public holidays etc.

The API will return the different close date/time that is stored in our backend system. In this example, we'd show a 10pm close on the 27th. 

Kind Regards, PM

Share this post


Link to post

Hi!

Can you please see "Procter and Gamble" stock (market id is 99571).

API says that it's trading from 08:00 to 00:00 UTC
But on platform it's from 13:30 to 08:00 UTC

 

How can i get the correct values via API?

Best, wintermonth!

Share this post


Link to post

Hello Wintermonth,

After some investigation, for equities (stocks and shares), the market open/close time uses the "TradingStartTimeUtc" and "TradingEndtimeUtc" fields. Ignore the MarketPricingTimes information.

FX Markets do continue to use the MarketPricingTimes fields. 

Looking at Proctor and Gamble open/close times on the API, it returns the correct time when using the right fields. Quick note: close time is 20:00 UTC (8pm) rather than 08:00 (8am), in the post above. 

Kind Regards, PM 

image.png

Share this post


Link to post

Thanks!

But what will i see in "TradingStartTimeUtc" and "TradingEndTimeUtc" fields if there are holidays from 2022-04-01 to  2022-04-05, and now it's 2022-04-02 for example? 

And what will i see in these fields on Saturday? 

Best, wintermonth!

Share this post


Link to post

Hi,

The screenshot in my previous post is the returned data from the MarketInformation call using the example market id of 99571. The Start and End times convert to the expected times.

Are you sending a HTTP GET call to https://ciapi.cityindex.com/TradingApi/market/99571/information

image.png

 

What is the returned data that you are receiving?

Kind Regards, PM

image.png

image.png

 

Share this post


Link to post

That's right, I get the same values.

The question is different. Do these values change in case of some holidays? For example, I implemented the following function: It obtains the values from these two fields as well as the current time in UTC. And it checks the condition, if the current time is between start_time and end_time, then it means that market is working, otherwise it does not work. Can I be sure that this function will work correctly in case of a weekend, for example, some kind of holiday or these fields are static?

Best, wintermonth!

Share this post


Link to post

Hello,

Sorry, I didn't read your previous question correctly. :)

An end of day (EoD) process is run late evening time (London) that prepares our backend for the next available trading day. Should a MarketInfo call be made after the EoD is finished, our backend will supply via the API the start and end date/time for the next trading day. It accounts for holidays and weekends. 

So in your example of holidays from 2022-04-01 to 2022-04-05, and 2022-04-06 is the next available trading day then it will return that information. 

All of our trading platforms use the API and the vast majority of our clients trade on our platforms. You can have confidence that the system handles holidays/weekends robustly!

Kind Regards, PM

 

Share this post


Link to post

Hello!

I just requested start time and end time again and the API returned following data for "Procter and Gamble":

start_time = 2022-04-03 13:30:00 (UTC)

end_time = 2022-04-03 20:00:00 (UTC)

( it's 2022-04-03 13:45:26 UTC now )

So, it says that trading is going on, but actually it's not (i've checked it on webplatform).

Best, wintermonth!

Share this post


Link to post

Our lives would have been so easier if we had an API function to check if the Market is Open or not.

in C#


public bool IsMarketOpen(int MarketId)
{
     //Do bunch of stuff
     return true/false;
}

Will this this DREAM ever come true!

Share this post


Link to post
20 hours ago, Physicsman said:

Hi Winter,

I'm checking with the team on the report above and will reply again when I have further information.

Kind Regards, PM

Hi Winter,

I've heard back from the team that there is a technical debt item / bug that is causing this to happen. It is currently in the queue to be prioritised and scheduled. 

Kind Regards, PM 

Share this post


Link to post
7 hours ago, SupereeDuperee said:

Our lives would have been so easier if we had an API function to check if the Market is Open or not.

in C#



public bool IsMarketOpen(int MarketId)
{
     //Do bunch of stuff
     return true/false;
}

Will this this DREAM ever come true!

Hi Superee,

Theoretically it could be possible at some point in the future, but not likely or probable at the moment.

Kind Regards, PM 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×