Jump to content
Sign in to follow this  
vklimk

Quote mode trading workflow

Recommended Posts

We tried to investigate how to make trades with quotes but there is no documentation for it.
Could you please provide us with workflow for trading with quote? Here is the beginning:
1. User fills trade ticket with quite big qty and application call Trade method (using NewTradeOrderRequestDTO)
2. Server sends response which says that quote mode is initiated (ApiQuoteResponseDTO is filled)
3. Our application listen to Quote stream for QuoteDTOs with QuoteId equal to QuoteID received at step 2 inside ApiQuoteResponseDTO
4. Our application shows prices received from Quote stream at step 3.
5. User presses “Accept Quote” button.
6. … What our application has to do now? Which CIAPI method should be called and how method’s DTOs have to be filled to complete trading?
 

Share this post


Link to post

The completed workflow is given below. This will also be inserted into the next version of the CIAPI User Guide for future reference.

  1. User fills trade ticket with an oversize quantitiy and the application calls Trade method (using NewTradeOrderRequestDTO).
  2. Server sends response (ApiTradeOrderResponseDTO), Quote property is populated indicating quote mode is initiated (ApiQuoteResponseDTO is filled with appropriate properties, eg QuoteId, Status and StatusReason).
  3. The application listens to Quote stream for QuoteDTOs with QuoteId equal to QuoteId received at step 2 inside ApiQuoteResponseDTO.
  4. The application shows prices received from Quote stream at step 3.
  5. User presses Accept Quote button.
  6. Call Trade method (using NewTradeOrderRequestDTO) again, supplying the QuoteId (from Step 2) and either the BidPrice or OfferPrice, depending on if this is a Sell or Buy trade.
  7. Parse the server response (ApiTradeOrderResponseDTO) to see if the trade was successful and display appropriate message.
  8. Refresh your open positions, trade history, order history, and active orders display by making appropriate calls (ListOpenPositions, ListTradeHistory, ListStopLimitOrderHistory, ListActiveStopLimitOrders).

Share this post


Link to post

3. The application listens to Quote stream for QuoteDTOs with QuoteId equal to QuoteId received at step 2 inside ApiQuoteResponseDTO.

We tried to implement this workflow. Unfortunately we were not able to complete trade because of “Wrong quote” error at step 7.

Maybe we should process Status field of QuoteDTO? We are receiving “Pending” status immediately after Trade method response. Do we have to wait while status is changed to Accepted before allow User to press “Accept Quote” button?

Share this post


Link to post

Could you please clarify why described below error happens? We have open position with big qty and are trying to close it (with quote mode). Please look at our steps with detailed logs attached:

1. Making trade (close position):

10-24 06:46:14.065: D/iFX.DefaultJsonClient(308): Executing request[27]:https://ciapi.cityindex.com/TradingApi/order/newtradeorder?session=a40986cd-e78a-419c-bf44-f85d1c304d78&UserName=xx373404& 10-24 06:46:14.065: D/iFX.DefaultJsonClient(308): Request content:{“AuditId”:“sbRDBProdFX2333735”,“Close”:[465822167],“Direction”:“sell”,“BidPrice”:0.88262,“Quantity”:7700000.0,“OfferPrice”:0.88289,“MarketId”:400481148,“AutoRollover”:true,“TradingAccountId”:400216450}

2. Trade response from server:

10-24 06:46:14.905: D/iFX.DefaultJsonClient(308): Response[27]: {“OrderId”:0,“Orders”:[],“Quote”:{“QuoteId”:401661787,“Status”:1,“StatusReason”:7},“Status”:3,“StatusReason”:96}

3. Quote streaming (pending status):

10-24 06:46:15.165: D/iFX.QuoteModeHelper(308): Quote Updated: {“TypeId”:1,“BidPrice”:0.88262,“BidAdjust”:0.0,“OfferAdjust”:0.0,“OfferPrice”:0.88289,“Quantity”:7700000.0,“OrderId”:-1,“QuoteId”:401661787,“MarketId”:400481148,“StatusId”:1,“CurrencyId”:3} 10-24 06:46:15.175: D/iFX.QuoteModeHelper(308): Quote Updated: {“TypeId”:1,“BidPrice”:0.88262,“BidAdjust”:0.0,“OfferAdjust”:0.0,“OfferPrice”:0.88289,“Quantity”:7700000.0,“OrderId”:-1,“QuoteId”:401661787,“MarketId”:400481148,“StatusId”:1,“CurrencyId”:3}

4. Quote streaming (accepted status):

10-24 06:48:48.174: D/iFX.QuoteModeHelper(308): Quote Updated: {“TypeId”:1,“BidPrice”:0.88277,“BidAdjust”:0.0,“OfferAdjust”:0.0,“OfferPrice”:0.88304,“Quantity”:7700000.0,“OrderId”:-1,“QuoteId”:401661787,“MarketId”:400481148,“StatusId”:2,“CurrencyId”:3} 10-24 06:48:48.214: D/iFX.QuoteModeHelper(308): Quote Updated: {“TypeId”:1,“BidPrice”:0.88277,“BidAdjust”:0.0,“OfferAdjust”:0.0,“OfferPrice”:0.88304,“Quantity”:7700000.0,“OrderId”:-1,“QuoteId”:401661787,“MarketId”:400481148,“StatusId”:2,“CurrencyId”:3}

5. Making trade again (using Bid/Offer from Quote streaming):

10-24 06:48:49.944: D/iFX.DefaultJsonClient(308): Executing request[28]:https://ciapi.cityindex.com/TradingApi/order/newtradeorder?session=a40986cd-e78a-419c-bf44-f85d1c304d78&UserName=xx373404& 10-24 06:48:49.944: D/iFX.DefaultJsonClient(308): Request content:{“AuditId”:“sbRDBProdFX2333735”,“QuoteId”:“401661787”,“Close”:[465822167],“Direction”:“sell”,“BidPrice”:0.88277,“Quantity”:7700000.0,“OfferPrice”:0.88304,“MarketId”:400481148,“AutoRollover”:true,“TradingAccountId”:400216450}

6. Trade response from server:

10-24 06:48:50.335: D/iFX.DefaultJsonClient(308): Response[28]: {“OrderId”:0,“Orders”:[{“CommissionCharge”:0,“GuaranteedPremium”:0,“IfDone”:null,“OCO”:null,“OrderId”:0,“Price”:0,“Status”:10,“StatusReason”:62}],“Quote”:null,“Status”:2,“StatusReason”:75}

Error description:

InstructionStatusReason 75: Instruction processing has resulted in a Red Card. Please check details.

StatusReason 62: The bid/offer price entered is not valid within the last three seconds

Share this post


Link to post

 

The completed workflow is given below. This will also be inserted into the next version of the CIAPI User Guide for future reference.

  1. User fills trade ticket with an oversize quantitiy and the application calls Trade method (using NewTradeOrderRequestDTO).
  2. Server sends response (ApiTradeOrderResponseDTO), Quote property is populated indicating quote mode is initiated (ApiQuoteResponseDTO is filled with appropriate properties, eg QuoteId, Status and StatusReason).
  3. The application listens to Quote stream for QuoteDTOs with QuoteId equal to QuoteId received at step 2 inside ApiQuoteResponseDTO.
  4. The application shows prices received from Quote stream at step 3.
  5. User presses Accept Quote button.
  6. Call Trade method (using NewTradeOrderRequestDTO) again, supplying the QuoteId (from Step 2) and either the BidPrice or OfferPrice, depending on if this is a Sell or Buy trade.
  7. Parse the server response (ApiTradeOrderResponseDTO) to see if the trade was successful and display appropriate message.
  8. Refresh your open positions, trade history, order history, and active orders display by making appropriate calls (ListOpenPositions, ListTradeHistory, ListStopLimitOrderHistory, ListActiveStopLimitOrders).

 

Step 2 has been edited to correct some cut and paste errors. It is now correct.

Share this post


Link to post

 

The completed workflow is given below. This will also be inserted into the next version of the CIAPI User Guide for future reference.

  1. User fills trade ticket with an oversize quantitiy and the application calls Trade method (using NewTradeOrderRequestDTO).
  2. Server sends response (ApiTradeOrderResponseDTO), Quote property is populated indicating quote mode is initiated (ApiQuoteResponseDTO is filled with appropriate properties, eg QuoteId, Status and StatusReason).
  3. The application listens to Quote stream for QuoteDTOs with QuoteId equal to QuoteId received at step 2 inside ApiQuoteResponseDTO.
  4. The application shows prices received from Quote stream at step 3.
  5. User presses Accept Quote button.
  6. Call Trade method (using NewTradeOrderRequestDTO) again, supplying the QuoteId (from Step 2) and either the BidPrice or OfferPrice, depending on if this is a Sell or Buy trade.
  7. Parse the server response (ApiTradeOrderResponseDTO) to see if the trade was successful and display appropriate message.
  8. Refresh your open positions, trade history, order history, and active orders display by making appropriate calls (ListOpenPositions, ListTradeHistory, ListStopLimitOrderHistory, ListActiveStopLimitOrders).

 

duplicate

Share this post


Link to post

3. The application listens to Quote stream for QuoteDTOs with QuoteId equal to QuoteId received at step 2 inside ApiQuoteResponseDTO.

We tried to implement this workflow. Unfortunately we were not able to complete trade because of “Wrong quote” error at step 7.

Maybe we should process Status field of QuoteDTO? We are receiving “Pending” status immediately after Trade method response. Do we have to wait while status is changed to Accepted before allow User to press “Accept Quote” button?

@vklimk You are correct, you are seeing the error because the trade status is still at “Pending” and not “Accepted”. Are you using a test account on the “Live” environement? Peter has checked and you have access. You need to use a test account on “Live” so that your trades appear on the Dealer Console. Our Dealers can then approve the trade so the status will become “Accepted”.

If you are not using a test account on “Live”, then the trades do not appear on the Dealer Console and they will forever remain in “Pending” mode!

Share this post


Link to post

Could you please clarify why described below error happens? We have open position with big qty and are trying to close it (with quote mode). Please look at our steps with detailed logs attached:

1. Making trade (close position):

10-24 06:46:14.065: D/iFX.DefaultJsonClient(308): Executing request[27]:https://ciapi.cityindex.com/TradingApi/order/newtradeorder?session=a40986cd-e78a-419c-bf44-f85d1c304d78&UserName=xx373404& 10-24 06:46:14.065: D/iFX.DefaultJsonClient(308): Request content:{“AuditId”:“sbRDBProdFX2333735”,“Close”:[465822167],“Direction”:“sell”,“BidPrice”:0.88262,“Quantity”:7700000.0,“OfferPrice”:0.88289,“MarketId”:400481148,“AutoRollover”:true,“TradingAccountId”:400216450}

2. Trade response from server:

10-24 06:46:14.905: D/iFX.DefaultJsonClient(308): Response[27]: {“OrderId”:0,“Orders”:[],“Quote”:{“QuoteId”:401661787,“Status”:1,“StatusReason”:7},“Status”:3,“StatusReason”:96}

3. Quote streaming (pending status):

10-24 06:46:15.165: D/iFX.QuoteModeHelper(308): Quote Updated: {“TypeId”:1,“BidPrice”:0.88262,“BidAdjust”:0.0,“OfferAdjust”:0.0,“OfferPrice”:0.88289,“Quantity”:7700000.0,“OrderId”:-1,“QuoteId”:401661787,“MarketId”:400481148,“StatusId”:1,“CurrencyId”:3} 10-24 06:46:15.175: D/iFX.QuoteModeHelper(308): Quote Updated: {“TypeId”:1,“BidPrice”:0.88262,“BidAdjust”:0.0,“OfferAdjust”:0.0,“OfferPrice”:0.88289,“Quantity”:7700000.0,“OrderId”:-1,“QuoteId”:401661787,“MarketId”:400481148,“StatusId”:1,“CurrencyId”:3}

4. Quote streaming (accepted status):

10-24 06:48:48.174: D/iFX.QuoteModeHelper(308): Quote Updated: {“TypeId”:1,“BidPrice”:0.88277,“BidAdjust”:0.0,“OfferAdjust”:0.0,“OfferPrice”:0.88304,“Quantity”:7700000.0,“OrderId”:-1,“QuoteId”:401661787,“MarketId”:400481148,“StatusId”:2,“CurrencyId”:3} 10-24 06:48:48.214: D/iFX.QuoteModeHelper(308): Quote Updated: {“TypeId”:1,“BidPrice”:0.88277,“BidAdjust”:0.0,“OfferAdjust”:0.0,“OfferPrice”:0.88304,“Quantity”:7700000.0,“OrderId”:-1,“QuoteId”:401661787,“MarketId”:400481148,“StatusId”:2,“CurrencyId”:3}

5. Making trade again (using Bid/Offer from Quote streaming):

10-24 06:48:49.944: D/iFX.DefaultJsonClient(308): Executing request[28]:https://ciapi.cityindex.com/TradingApi/order/newtradeorder?session=a40986cd-e78a-419c-bf44-f85d1c304d78&UserName=xx373404& 10-24 06:48:49.944: D/iFX.DefaultJsonClient(308): Request content:{“AuditId”:“sbRDBProdFX2333735”,“QuoteId”:“401661787”,“Close”:[465822167],“Direction”:“sell”,“BidPrice”:0.88277,“Quantity”:7700000.0,“OfferPrice”:0.88304,“MarketId”:400481148,“AutoRollover”:true,“TradingAccountId”:400216450}

6. Trade response from server:

10-24 06:48:50.335: D/iFX.DefaultJsonClient(308): Response[28]: {“OrderId”:0,“Orders”:[{“CommissionCharge”:0,“GuaranteedPremium”:0,“IfDone”:null,“OCO”:null,“OrderId”:0,“Price”:0,“Status”:10,“StatusReason”:62}],“Quote”:null,“Status”:2,“StatusReason”:75}

Error description:

InstructionStatusReason 75: Instruction processing has resulted in a Red Card. Please check details.

StatusReason 62: The bid/offer price entered is not valid within the last three seconds

As discussed over e-mail between Peter and vklimk:

1) The quote mode trading workflow was checked in the pre-production environment using the Flex ITP and is working correctly.

2) Looking at the vklimk’s requests, it appears that the right values are provided (adjusting the bid/offer correctly).

3) For the price audit, vklimk should be doing what the Flex ITP does and use a valid audit ID from within the last 3 seconds.

4) One thing that does look different is the Flex ITP is setting the OrderId to 0 in the trade request after the quote is accepted. This is something that vklimk could try.

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
Sign in to follow this  
×