Jump to content


  • Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by SirNewton

  1. Hello @Physicsman I am facing an issue with the Historical Data. No data coming in for date "2021-04-09 00:00:00" either ASK, BID or MID on EUR/USD and EUR/GBP No data coming in for date "2021-04-09 00:00:00" either ASK or MID on USD/JPY EUR/USD BID{"BarDate": "2021-04-08 00:00:00", "Open": 1.1865, "High": 1.19264, "Low": 1.18596, "Close": 1.19125}, {"BarDate": "2021-04-12 00:00:00", "Open": 1.18898, "High": 1.19032, "Low": 1.18877, "Close": 1.18906} EUR/GBP BID{"BarDate": "2021-04-08 00:00:00", "Open": 0.86389, "High": 0.86804, "Low": 0.86208, "Close": 0.86728}, {"BarDate": "2021-04-12 00:00:00", "Open": 0.86669, "High": 0.86823, "Low": 0.86656, "Close": 0.86811} USD/JPY ASK{"BarDate": "2021-04-08 00:00:00", "Open": 109.873, "High": 109.914, "Low": 109.008, "Close": 109.285}, {"BarDate": "2021-04-12 00:00:00", "Open": 109.85, "High": 109.85, "Low": 109.653, "Close": 109.733} Was the market for those Pairs closed on Friday? If not, are there any issues with the generation of Historical Data? The historical data I am collecting has a Span of 1 (i.e. daily). I tried pulling several times and I am seeing same issue each time. Thanks.
  2. I ran it a few more times, looks like it randomly omits date "2021-04-09 00:00:00" on any pairs. Sometimes is shows up and sometimes it doesn't. Looks like this issue started the passed week or so. Pretty recent issue.
  3. Hi @SupereeDuperee, the Time Range, I collect for Historical Data is Daily. The funny thing is, along with Ask, I also collect Bid and Mid, and neither for the same Pair had this issue.
  4. Hello PM, I am seeing Historical Data coming in out of bound. I noticed this because, I have set check constraint and because of Low being zero, my app crashed on the check. There might be others, but so far I have found this one. Please investigate why this is happened. ASK USD/CAD: {"BarDate": "2021-03-22 00:00:00", "Open": 1.25296, "High": 1.25426, "Low": 0.0, "Close": 1.25249} Thank you, SN
  5. It looks like instead of pairs (i.e. EURUSD), I need to use numbers like 401166448 to get historical data. See: https://ciapi.cityindex.com/TradingAPI/market/401166448/barhistory? Where can I get a list of pairs corresponding to the numbers?
  6. Hello @Physicsman While processing Historical data, I saw something unusual that I need your help with. We know that the Steaming Data along with the market closes on FRIDAY 9:59PM GMT And, we know that the Steaming Data along with the market opens on SUNDAY 10:00PM GMT And, we know that Each "day" historical data covers from midnight (00:00) to 23:59 GMT But, I noticed that in the Historical Data that was outside that range. See Blow: AUD/JPY: ASK: {"BarDate": "2021-02-20 00:00:00", "Open": 83.062, "High": 83.062, "Low": 83.062, "Close": 83.062} BID: {"BarDate": "2021-02-20 00:00:00", "Open": 82.912, "High": 82.912, "Low": 82.912, "Close": 82.912} USD/CHF: ASK: {"BarDate": "2021-02-20 00:00:00", "Open": 0.89672, "High": 0.89672, "Low": 0.89672, "Close": 0.89672} BID: {"BarDate": "2021-02-20 00:00:00", "Open": 0.89607, "High": 0.89607, "Low": 0.89607, "Close": 0.89607} USD/JPY: ASK: {"BarDate": "2021-02-20 00:00:00", "Open": 105.514, "High": 105.514, "Low": 105.514, "Close": 105.514} BID: {"BarDate": "2021-02-20 00:00:00", "Open": 105.392, "High": 105.392, "Low": 105.392, "Close": 105.392} 2021-02-20 is a Saturday. The other pairs, I am processing had a BarDate of "2021-02-19 00:00:00", which is what I expected. Can you please explain the discrepancy of the BarDate of pairs AUD/JPY, USD/CHF, and USD/JPY? Thank you.
  7. "According to the Pricing team, an erroneous price tick was sent after market close on Friday resulting in the Saturday price bar" By the way, if those price ticks are actual and not generated by error. I rather you keep it in the history. I can write code to combine those with Friday historical.
  8. Thank you. I looked through the full history and found similar out of bound entries. Will provide sqlscript used to find out of bound entries. Note: I use Postgres, but you should be able to do similar queries in other databases. In the DB datetime is "BarDate". Will give you Saturday and Sunday select * forex_history where extract(isodow from datetime)in(0,6,7) Or to see just Saturday select * forex_history where extract(isodow from datetime)=6
  9. @SupereeDuperee I get that,. I was just not expecting that amount of a spread change within a second.
  10. Closing trade

    Got it. Even though, I would rather control the order I close the trades myself, I have adjusted for FIFO. Thanks.
  11. Hello Physicsman, have a question using Close key value pair to close an existing trade. See: https://docs.labs.gaincapital.com/#Data Types/NewTradeOrderRequestDTO.htm Close integer[] List of existing open trade order IDs that require part or full closure. I tied it out on Postman with below JSON object: { "MarketId": 401484406, "Currency": null, "AutoRollover": false, "Direction": "sell", "Quantity": 1000, "QuoteId": 0, "PositionMethodId": 0, "BidPrice": 1.0001, "OfferPrice": 1.5001, "AuditId": "939239####", "TradingAccountId": ##########, "IfDone": null, "Close": ["779386607"], "Reference": null, "AllocationProfileId": 0, "OrderReference": null, "Source": null, "PriceTolerance": 0, "isTrade":true } And the response I get: { "Status": 4, "StatusReason": 112, "OrderId": 0, "Orders": [], "Quote": null, "Actions": [], "ErrorMessage": null } I looked up 112 StatusReason and according the documentation: https://docs.labs.gaincapital.com/#APICodesList.htm?Highlight=API Code Lookup Values I see it say, "NFA FIFO Account - Target closure restricted." What am I doing wrong here? How do I use Close with API NewTradeOrderRequest to close an existing trade? Thank you.
  12. Closing trade

    Why enforce FIFO in the US? Not sure, why that would be the case. Why would the US regulators enforce that?
  13. Closing trade

    Are you a US client? Yes, I am in the US. And I am a US client. Did you have more than one open position in the same market, and you were attempting to close one of those open positions specifically? Yes, I had several open in the same market and was trying to close one specifically. When I don't include anything in the CLOSE, it seems to close a random trade. I was hoping to use CLOSE to close a specific trade. Thank you.
  14. Real-time streaming and trading

    Thanks for your reply Physicsman. Have adjusted program.
  15. Streaming data seems off around closing. Any issues with the streaming of CAD/JPY today? Below, you can see the steaming data processed and sent to my Kafka servers. The datetime is in CST. As you can see timeframe between 021-02-12 15:59:57.814888 and 2021-02-12 15:59:58.064755 seems unusual. The BID went from 82.592 to 82.527 and the ASK went from 82.708 to 82.767. Difference from BID to ASK went from 82.708 - 82.592 = .116 to 82.767 - 82.527 = .24 that changed more than double. Is this correct? {'symbol': 'CADJPY', 'bid': '82.601', 'ask': '82.713', 'price': '82.657', 'DATETIME': '2021-02-12 15:59:56.738579'} {'symbol': 'CADJPY', 'bid': '82.599', 'ask': '82.714', 'price': '82.657', 'DATETIME': '2021-02-12 15:59:57.093342'} {'symbol': 'CADJPY', 'bid': '82.599', 'ask': '82.715', 'price': '82.657', 'DATETIME': '2021-02-12 15:59:57.321731'} {'symbol': 'CADJPY', 'bid': '82.598', 'ask': '82.714', 'price': '82.656', 'DATETIME': '2021-02-12 15:59:57.599380'} {'symbol': 'CADJPY', 'bid': '82.592', 'ask': '82.708', 'price': '82.650', 'DATETIME': '2021-02-12 15:59:57.814888'} {'symbol': 'CADJPY', 'bid': '82.527', 'ask': '82.767', 'price': '82.647', 'DATETIME': '2021-02-12 15:59:58.064755'} {'symbol': 'CADJPY', 'bid': '82.535', 'ask': '82.775', 'price': '82.655', 'DATETIME': '2021-02-12 15:59:58.844187'} {'symbol': 'CADJPY', 'bid': '82.533', 'ask': '82.773', 'price': '82.653', 'DATETIME': '2021-02-12 15:59:59.139130'} {'symbol': 'CADJPY', 'bid': '82.534', 'ask': '82.774', 'price': '82.654', 'DATETIME': '2021-02-12 15:59:59.347454'} {'symbol': 'CADJPY', 'bid': '82.527', 'ask': '82.767', 'price': '82.647', 'DATETIME': '2021-02-12 15:59:59.595988'} {'symbol': 'CADJPY', 'bid': '82.535', 'ask': '82.775', 'price': '82.655', 'DATETIME': '2021-02-12 15:59:59.855962'} {'symbol': 'CADJPY', 'bid': '82.535', 'ask': '82.775', 'price': '82.655', 'DATETIME': '2021-02-12 16:00:00.111481'}
  16. Can we trade as soon as real-time streaming data of pair begins on Sunday (for my location), or is there a delay? I noticed that the streaming data stopped at 23:59 GMT on Friday, will that always be the case? What GMT time does trading start on Monday? 0:00 GMT? How about the start time for the streaming data? The historical data covers 0:00 to 23:59 GMT of that day, correct? Is the complete historical data of that day available 0:00 GMT of the next day or is there a delay? Do we make up the AuditID ourselves or is it provided? If we are provided, please explain from where? If we make it up, can it be anything or do we need to follow a specific pattern for the template? Would you suggest to change the AuditID per trade? Should it be different for each pair type and/or direction? Is there a minimum or maximum API trade quantity? Does the below JSON object look valid for a trade? Also, am I missing any key/value pairs? Subsequently, can I omit any key/value pairs? TradeJson = { "MarketId": str(marketID), "Currency": None, "AutoRollover": False, "Direction": str(direction), "Quantity": str(qty), "QuoteId": 0, "PositionMethodId": 0, "BidPrice": str(bidPrice), "OfferPrice": str(sellPrice), "AuditId": "str(auditID)", "TradingAccountId": str(tradingAccountID]), "IfDone": None, "Close": None, "Reference": None, "AllocationProfileId": 0, "OrderReference": None, "Source": None, "MarketName": str(pair), "PriceTolerance": 0 } Please note: "None" in Python is the similar to a "null" in other languages.
  17. Real-time streaming and trading

    Another question on streaming. We have Bid, Offer, and Price in the streaming. I read Price was the price of the last trade. Is that for both Bid trades and Offer trades? Because depending on the direction, there is a price difference.
  18. Yes, I did read that PriceTolerance value "2" is good to use in another post. Physicsman would using PriceTolerance inflate the price we are buying or selling? Meaning if there are two trades, one with PriceTolerance set to 2 and another one set to 0. Would there be any price buy/sell differences between those trades?
  19. Real-time streaming and trading

    Hello Physicsman, You said, "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." I noticed on Yahoo Financial, in most cases streaming data for FOREX ends at 12:00am CST Saturday. GMT is 6 hours ahead of CST, that would put it Saturday 6:00 am GMT. Are these afterhours trades? If so, can we participate in afterhours trade? Is it possible to trade after the streaming data from lightstream (https://push.cityindex.com) stops? Thank you.
  20. Real-time streaming and trading

    Figures out why my JSON object was failing in the trade. Looks like there is a minimum Quantity of a 1000. So, I cannot trade anything lower?
  21. In the demo: https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-python/blob/master/src/stock_list_demo.py I would also suggest changing: def wait_for_input(): input("{0:-^80}\n".format("HIT CR TO UNSUBSCRIBE AND DISCONNECT FROM \ LIGHTSTREAMER")) To something like this: def wait_for_input(): while True: try: q = input("{0:-^80}\n".format("Press q than Enter to Unsubscribe and Disconnect from Lightstreamer")) if q == 'q': break except: break With the way it was written originally anytime you hit Enter it would exit. This way you can press 'q' than Enter to exit. Better control.
  22. Thanks Superee. Even though, I wrote my code in Python, your code was a good reference on what to do in the subscription. I successfully wrote everything in Python, but looking at the demo code given by Lightstreamer, I noticed that the error handling was pretty lacking. Those that are doing their code in Python, I suggest you do something like below: subscription.addlistener(on_item_update) # Adding the "on_item_update" function to Subscription sub_key = lightstreamer_client.subscribe(subscription) # Registering the Subscription try: wait_for_input() lightstreamer_client.unsubscribe(sub_key) # Unsubscribing from Lightstreamer by using the subscription key lightstreamer_client.disconnect() # Disconnecting Lightstreamer kafka_producer_obj.close() # Close Apache Kafka except KeyboardInterrupt: lightstreamer_client.unsubscribe(sub_key) lightstreamer_client.disconnect() kafka_producer_obj.close() print('Manual break by user') except Exception as e: lightstreamer_client.unsubscribe(sub_key) lightstreamer_client.disconnect() kafka_producer_obj.close() print(e) You can ignore the "kafka_producer_obj.close()". I have that because, I also use Kafka and need to close the connection on that too.
  23. I need to get the real-time data for pairs or symbols. Both Ask and Bid. I need to process that in either Python or NodeJS. Can you please provide the information to accomplish that? Or point me to the right location. If you have multiple ways of getting these data, please provide them and I will decide which works best for me. Thanks.
  24. Thanks for the info @Physicsman. I will use the Live URL. Hello @SupereeDuperee, Yes, please share your code. Would really appreciate that.
  25. Regarding REST Streaming APIs: https://ciapi.cityindex.com/tradingapi/ (Live) https://ciapipreprod.cityindextest9.co.uk/TradingApi (Pre-Prod) https://push.cityindex.com/ (Live) https://pushpreprod.cityindextest9.co.uk (Pre-Prod) Are the rates same (actual) when using Live or Pre-Prod? Any delay differences between using Live or Pre-Prod? How many rate refreshes each second on the API's? Any differences here, between Live and Pre-Prod?