Jump to content

Vincent

Members
  • Content count

    41
  • Joined

  • Last visited

  • Days Won

    6

Vincent last won the day on August 7 2015

Vincent had the most liked content!

About Vincent

  • Rank
    Advanced Member

Recent Profile Visitors

71 profile views
  1. Step Margin's MarginFactor

    Hi Physicsman, Thanks. I am also aware of SimulateTrade api. I don't like it is because every time user changes the stack size, the client device need to make a request to the City SimulateTrade API in order to get the margin, which I think is unnecessary if we have all the values we needed to calculate it on client device. This is also much faster comparing to using SimulateTrade API. Now, I know there is no way for me to calculate the margin correctly on client device. Using SimulateTrade API is what I am going to fall back to. Thanks. Vincent
  2. Step Margin's MarginFactor

    Hi Physicsman, I am aware that ClientAccountMargin stream can provide the current margin requirements for the account. Yes, I am trying to compute the margin on the client side. I want to implement this because when an user is opening a position/trade, I want to show him the margin which require for this trade before he open it. If there is not way to know if an account is set to use Step Margin MF or Basic MF through API, I guess there is no way for me to calculate margin correctly on client side. Thanks. Vincent
  3. Step Margin's MarginFactor

    Hi Physicsman, Thank for the reply. You said: "All accounts belong to an account operator (AO), such as City Index GB, City Index Australia etc. At the AO level, we set whether accounts use Step Margin MF or Basic MF." How do I know if a account set to use Step Margin MF or Basic MF? Thanks. Vincent
  4. Hi, When clicked on market information icon, a market information data set is return to the browser. I am interested in "MarginFactor" and "Step Margin's MarginFactors" properties. I like to know when I should use "MarginFactor" ("MarginFactor": 160 as shown in the data at bottom) to calculate the margin. And when I should use "Step Margin's MarginFactors" which is depending on the trade quantity size? ... "Bands": [ { "LowerBound": 0, "MarginFactor": 70 }, { "LowerBound": 750, "MarginFactor": 150 }, ... Thanks. ============================================= Data Set: { "MarketInformation": [ { "MarketId": 400616150, "Name": "GBP/USD DFT", "ExchangeId": 56, "ExchangeName": "FX Dummy Exchange", "MarginFactor": 160, "MinMarginFactor": null, "MaxMarginFactor": null, "MarginFactorUnits": 27, "MinDistance": 1, "MinDistanceUnits": 27, "WebMinSize": 0.06560819, "MaxSize": 3280.4095, "MarketSizesCurrencyCode": "GBP", "MaxLongSize": 328.04095, "MaxShortSize": 328.04095, "Market24H": true, "PriceDecimalPlaces": 5, "DefaultQuoteLength": 30, "TradeOnWeb": true, "LimitUp": false, "LimitDown": false, "LongPositionOnly": false, "CloseOnly": false, "MarketEod": [], "PriceTolerance": 2, "ConvertPriceToPipsMultiplier": 10000, "MarketSettingsTypeId": 1, "MarketSettingsType": "Spread", "MobileShortName": "GBP/USD", "CentralClearingType": "No", "CentralClearingTypeDescription": "None", "MarketCurrencyId": 11, "PhoneMinSize": 0.5, "DailyFinancingAppliedAtUtc": "/Date(1430427600000)/", "NextMarketEodTimeUtc": "/Date(1430427600000)/", "TradingStartTimeUtc": null, "TradingEndTimeUtc": null, "MarketPricingTimes": [ { "DayOfWeek": 1, "StartTimeUtc": { "UtcDateTime": "/Date(1430427600000)/", "OffsetMinutes": 600 }, "EndTimeUtc": null }, { "DayOfWeek": 5, "StartTimeUtc": null, "EndTimeUtc": { "UtcDateTime": "/Date(1430511300000)/", "OffsetMinutes": -240 } } ], "MarketBreakTimes": [], "MarketSpreads": [ { "SpreadTimeUtc": "/Date(1430463600000)/", "Spread": 0.00015, "SpreadUnits": 27 }, { "SpreadTimeUtc": "/Date(1430501400000)/", "Spread": 0.0001, "SpreadUnits": 27 } ], "GuaranteedOrderPremium": 4, "GuaranteedOrderPremiumUnits": 1, "GuaranteedOrderMinDistance": 50, "GuaranteedOrderMinDistanceUnits": 27, "PriceToleranceUnits": 0.0001, "MarketTimeZoneOffsetMinutes": -240, "QuantityConversionFactor": 1, "PointFactorDivisor": 100, "BetPer": 0.0001, "MarketUnderlyingTypeId": 4, "MarketUnderlyingType": "FX", "AllowGuaranteedOrders": true, "OrdersAwareMargining": false, "OrdersAwareMarginingMinimum": 50, "CommissionChargeMinimum": null, "CommissionRate": null, "CommissionRateUnits": null, "ExpiryUtc": "/Date(1640995200000)/", "FutureRolloverUTC": null, "AllowRollover": false, "ExpiryBasisId": 2, "ExpiryBasisText": "Closing price on last day of dealing", "StepMargin": { "EligibleForStepMargin": true, "StepMarginConfigured": true, "InheritedFromParentAccountOperator": true, "Bands": [ { "LowerBound": 0, "MarginFactor": 70 }, { "LowerBound": 750, "MarginFactor": 150 }, { "LowerBound": 1400, "MarginFactor": 220 }, { "LowerBound": 2300, "MarginFactor": 300 }, { "LowerBound": 3000, "MarginFactor": 450 } ] }, "OptionTypeId": null, "OptionType": null, "StrikePrice": null, "MarketTypeId": 2, "MarketType": "Ordinary Market", "Weighting": 300, "FxFinancing": { "CaptureDateTime": "/Date(1430514000000)/", "LongPoints": 0.3, "ShortPoints": -0.52, "LongCharge": -0.2, "ShortCharge": -0.34, "Quantity": 1, "ChargeCurrencyId": 6, "DaysToRoll": 1 }, "UnderlyingRicCode": "43", "NewsUnderlyingOverrideType": "NamedItem", "NewsUnderlyingOverrideCode": "GBP/" } ] }
  5. Hi, Please refer to the screenshots in the attachment. The result I got from my calculation (89.4715) is different from the result I got from the Margin Calculator (58.50). Here is my cacluation 17894.3 (Buy price) * 0.005 (Margin Factor) * 1 (Quantity) = 89.4715 Am I missing something here? Thanks.
  6. Hi Physicsman, Thanks. Please let me explain why I need this change. Let's start with a trade which has a stop order and a limit order. Here is example of what data sets will be push to the client by order stream when stop order's trigger price of the trade order is edited: ============================================== Data Set 1 ============================================== 521520651 (limit order ID) 400616113 400340375 400482641 6 2 false \/Date(1423483864000)\/ 0 \/Date(1423483454000)\/ 2 1 2 Limit Accepted 1 ============================================== ============================================== Data Set 2 ============================================== 521520580 (stop order ID) 400616113 400340375 400482641 6 2 false \/Date(1423483864000)\/ 0 \/Date(1423483454000)\/ 2 1 2 Stop Accepted 1 ============================================== As you can see, the order stream only push limit order ID and stop order ID to the client. There is no way to know that the limit order and stop order are with the same trade order. So when client received "Data Set 1", it need to get/query the limit order to get its parent trade order. Update UI. When client received "Data Set 2", it need to do the similar thing again. One change, but two updates required. It just not very efficient. If order stream can return another dataset which contain trade order ID, I can just ignore "data set 1" and "data set 2". And get the trade order info (which contain the limit order and stop order info) and use the info to update the UI. One chagne and one update. Thanks.
  7. Hi Physyicsman, Attached "take profit limit" and "stop loss orders" to a trade DO push back the trade ID (with "take profit limit" order ID and "stop loss orders" order ID). It is when you edited the trigger price of "take profit limit" or "stop loss orders" of a trade, it will not return the trade ID. Thanks.
  8. Hi Physyicsman, Order stream push data to client when there is change in order. The data will be push to the client when there change in a "trade order", an "order order", a "stop order" or a "limit order". Both "trade order" and "order order" can have a stop order and a limit order. "But when you edit a stop order or a limit order's trigger price of an order. The order ID will be push back as well as stop order ID and limit order ID." What I mean here is that when you edit a stop order's trigger price of an "order order". Order stream will push back not just stop order ID (child order ID), but also "order order"s ID (parent order ID). It is the same when you edit a limit order's trigger price of an "order order". Order stream will push back not just limit order ID (child order ID), but also "order order"s ID (parent order ID). It is desirable since I don't need to query the child order ID to get the parent order ID. I wish this is happening to trade order as well. Please let me know if it is still not making sense. Thanks.
  9. Hi, This question is relate to order stream: http://docs.labs.cityindex.com/#Streaming%20Data/Orders.htm%3FTocPath%3DCIAPI%2520Reference|Streaming%2520Data|_____4 When editing a stop order's trigger level/price of a trade order, the order stream will only push back the stop order ID. And it will not push back the trade order ID (the parent order of stop order). When editing a limit order's trigger level/price of a trade order, the same thing happen as well. Limit order ID is pushed back. But when you edit a stop order or a limit order's trigger price of an order. The order ID will be push back as well as stop order ID and limit order ID. My 1st question is to find out if my observation (above statement) is correct. My 2nd question is possible to make the order stream to return trade order ID when only its stop order or limit order's trigger price have been changed. Thanks.
  10. Hi Physicsman, Could you ask your development team to provide some code used in City Index Advantage Web platform that is relate to subscription of order stream? Maybe I can use it as reference to spot the problem in my code. Thanks.
  11. Hi Physicsman, Sorry, I still don't understand it. I understand the calculation, but I don't know where some of key information is coming from. How do I know this : "bet per for shares is 1 cent (penny for GB stocks) movement"? I am looking at "Microsoft Corp CFD" market info page on City Index Advantage Web platform. It has minimum size, max long size, max short size...etc. And could we use "UK 100 CFD" as an example because it got a long open hour. I can try do the calculation by hand and compare the result with the web platform. Thanks.
  12. Hi, In relate to this topic: http://faq.labs.cityindex.com/index.php?/topic/975-streaming-data-orders/ In the attachment is my code (C#, VS2013) and screenshots. As shown in the screenshot, my code only recevie one order update after placing a trade with limit and stop on CI web platform. Thanks.
  13. Streaming Data > Orders

    Hi Physicsman, I have able to replicate your result. Thanks. But I havn't able to resolve my problem yet. I am still getting only two or one updated for a trade with limit or stop. By the way, my code don't have problem getting prices updates. Therefore the code should work with order update as well. Thanks for your help.
  14. Streaming Data > Orders

    Hi Physicsman, Thank you for your answer. But I am still stuck on this problem. Could you provide some information/method on how your developement team test this? I like to replicate it. I have also been monitoring the trafic of CI platform using my demo account: https://trade.loginandtrade.com/advantageweb/home.html?ts=1422256044884 But I didn't get the similar result as shown in your screenshots when I am openning a new trade. There were no "bind_session.txt" was push back at all on CI Platform. Another thing I don't understand is why I am able to received two sets of data, but not all the data. ================================================================ Here is my .NET code: ConnectionInfo private ConnectionInfo buildNewConnectionInfo(string username, string sessionToken) { var connInfo = new ConnectionInfo { PushServerUrl = "https://push.cityindex.com", Adapter = "STREAMINGALL", User = username, Password = sessionToken, Constraints = { MaxBandwidth = 999999 }, Polling = false //,PollingIdleMillis = 250,PollingMillis = 250 }; return connInfo; } ------------------------------------------------------------------------------------------------- Use ConnectionInfo to build the LsClient private LSClient createNewLsClient(ConnectionInfo connInfo, LsConnectionListener lsConnectionListener) { _lsClient = new LSClient(); try { _lsClient.OpenConnection(connInfo, lsConnectionListener); } //username or sessionToken in ConnectionInfo is incorrect. catch (PushUserException) { var ciEx = new CiStreamConnLoginFailException( string.Format("Unable to establish stream connection because username '{0}'or sessionToken '{1}' is incorrect", connInfo.User, connInfo.Password)); throw ciEx; } return _lsClient; } ------------------------------------------------------------------------------------------------- Use LsClient to subscribe to order stream public class OrdersApi : BaseApi<OrderDTO> { private const string _schema = "OrderId MarketId ClientAccountId TradingAccountId CurrencyId CurrencyISO Direction AutoRollover LastChangedTime OpenPrice OriginalLastChangedDateTime OriginalQuantity PositionMethodId Quantity Type Status ReasonId"; public OrdersApi(LSClient client) : base(client) { } public void Subscribe() { if (_isSubscribed) Unsubscribe(); var tableInfo = buildTableInfo(); var tbListener = new LsTableListener(); tbListener.UpdateReceivedHandler += onUpdateReceived; _tbKey = _lsClient.SubscribeTable( tableInfo, tbListener, false ); _isSubscribed = true; } private static SimpleTableInfo buildTableInfo() { string group = "ORDERS"; SimpleTableInfo tableInfo = new SimpleTableInfo( group, "MERGE", _schema, true ) { DataAdapter = "ORDERS" }; return tableInfo; } } ------------------------------------------------------------------------------------------------- BaseApi public abstract class BaseApi<T> { public EventHandler<CiUpdateReceivedEventArgs<T>> UpdateReceivedHandler; protected LSClient _lsClient; protected SubscribedTableKey _tbKey; public SubscribedTableKey SubscribedTableKey { get { return _tbKey; } } protected SimpleTableInfo _tableInfo; protected bool _isSubscribed = false; protected BaseApi(LSClient client) { _lsClient = client; } public void Unsubscribe() { if (_tbKey != null) _lsClient.UnsubscribeTable(_tbKey); _isSubscribed = false; } protected void onUpdateReceived(object sender, CiUpdateReceivedEventArgs<LsUpdate> e) { if (isUpdateNull(e.Update.UpdateInfo)) return; var update = e.Update.UpdateInfo; Debug.WriteLine("=============================================="); for (int i = 1; i < update.NumFields + 1; i++) { Debug.WriteLine(update.IsValueChanged(i) ? update.GetNewValue(i) : update.GetOldValue(i)); } Debug.WriteLine("=============================================="); var dto = Deserializer<T>.Deserialize(e.Update.UpdateInfo); var eventArgs = new CiUpdateReceivedEventArgs<T>(dto); UpdateReceivedHandler.SafeInvoke(this, eventArgs); } /// <summary> /// It seems some streams have a 'spin-up' process that can return an all null update /// until the data starts streaming. We were not catching this and null updates were /// sometimes throwing exceptions that were logged and then swallowed by LS. I think /// a better way is to determine if the update is emtpy (null) and simply not fire if so. /// /// Follows is a very simple check /// </summary> /// <param name="update"></param> /// <returns></returns> private static bool isUpdateNull(IUpdateInfo update) { for (int i = 1; i < update.NumFields + 1; i++) { object value = update.IsValueChanged(i) ? update.GetNewValue(i) : update.GetOldValue(i); if (value != null) { return false; } } return true; } }
  15. Hi Physicsman, Thank you for your answers. You calculation is very clear. I have one more question: "A trade size of £1/point is the equivalent of 100 shares. £2/point is equivalent to 200 shares and so on." Where could you find such information? How do you know a trade size of £1/point is the equivalent of 100 shares? Thanks.
×