Jump to content
Sign in to follow this  
Amruta

Problem in Placing New Trade Order

Recommended Posts

I am using this python code to place a new trade order:

import requests
import json

SESSION = '3caf1b25-1d77-4bb2-bbf0-xxxxxxxxxxx'
SESSION_BUNDLE = '&Session='+SESSION+'&UserName=xxxxxxxxx'

null = None
false = False
true = True
bodyPlace = {"OcoOrder":null,
        "Type":null,
        "LastChangedDateTimeUTCDate":null,
        "ExpiryDateTimeUTC":null,
        "Applicability":null,
        "Direction":"buy",
        "ExpiryDateTimeUTCDate":null,
        "TriggerPrice":null,
        "BidPrice":1.4395,
        "AuditId":"8049808-0-0-0-R",
        "AutoRollover":false,
        "MarketId":401484392,
        "isTrade":true,
        "OfferPrice":1.4397,
        "OrderId":null,
        "LastChangedDateTimeUTC":null,
        "Currency":null,
        "Quantity":1,
        "QuoteId":null,
        "TradingAccountId":xxxxxxxxxxx,
        "MarketName":"GBP/USD",
        "PositionMethodId":1,
        "Status":null,
        "IfDone":[]}


r = requests.post('https://ciapi.cityindex.com/TradingAPI/order/newtradeorder?'+SESSION_BUNDLE, json = bodyPlace)
 

And getting the following response:

<Response [200]>
{'Status': 2, 'StatusReason': 75, 'OrderId': 0, 'Orders': [{'OrderId': 0, 'StatusReason': 81, 'Status': 10, 'OrderTypeId': 1, 'Price': 0.0, 'Quantity': 1.0, 'TriggerPrice': 0.0, 'CommissionCharge': 0.0, 'IfDone': [], 'GuaranteedPremium': 0.0, 'OCO': None, 'AssociatedOrders': {'Stop': None, 'Limit': None}, 'Associated': False}], 'Quote': None, 'Actions': [], 'ErrorMessage': None}

 

Could you help me understand where I am going wrong?

 

Share this post


Link to post

Hello Amruta,

The market you are attempting to trade is a spot FX market, which trades in units of actual currency in thousands with a minimum size of 1000. Your order request has specified a quantity = 1, which is below the minimum possible trade quantity of 1000. 

In the response you received, you can see the OrderStatusReason of 81 = Position below Web Min Size.

You can find the lookup table for the response codes in the API documentation: API Code Lookup Values.

Kind Regards, PM

Share this post


Link to post

Thank you! It works now. Another question I have is Can I get current market prices and Open price/closed price/low/high volume for each market for every 1 minute interval using only GCAPI calls and not using Lightstreamer?

Share this post


Link to post

Hi,

To receive live current market prices that update as the market price moves can only be received via Lightstreamer. The Price History calls via GCAPI returns only static market prices, which do not update as the market prices change. 

Kind Regards, PM

Share this post


Link to post

I'm trying to place a new buy and sell order using above api call. My question is: Where do I obtain the value of the field "AuditId"? The value used above is "8049808-0-0-0-R", which I got from one example given in the docs. 

Also are both 'MarketId' and 'MarketName' fields both mandatory or I can use just one of them.

Share this post


Link to post

Hi,

The AuditID is a unique identifier accompanying each price tick. You can read the value from the prices stream and would use the very latest one matching the most recent price tick you have received. 

MarkedID is mandatory but you can leave out MarketName if you prefer, although it is better to use it so you don't make a mistake. 

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