New Equity Trading API in Beta - Try it Out in Practice Mode!

Thanks for the quick answer!

Iā€™ve managed to find a button after I funded my account. May be that was the issue.

One more question then. Is there any chance to generate token to open trades on real money account and not in practice mode?

If this feature is not implemented yet, may be you know any plans regarding it?

It seems like the CSV download of historic orders provides more insightful data than the historic orders API. While the API allows you to see the trading price in the currency that the share was bought in, the CSV provides the data on the final resultant cost per order in GBP. Additionally, OTC orders different level of data to limit orders unlike the CSV download.

When using the portfolio endpoint, it does not seem possible to convert the share values to the same currency without introducing rates from elsewhere. The web UI provides the share values in a consistent GBP currency.

Is there perhaps a way to get the data from the CSV download into a json endpoint as opposed to a download request? Additionally, is there a way to get a consistent currency as a resultant value in the portfolio endpoint?

Thanks

2 Likes

The API is available only for virtual funds, and there are no immediate plans to introduce support for real money accounts. Iā€™ll keep you posted, though.

These are both functionalities that are not yet developed, but weā€™ll keep your feedback in mind once we allocate more resources to this project. Meanwhile, you can make use of the appā€™s CSV generator or tools such as CSV to JSON - CSVJSON.

1 Like

Yes I have developed workarounds in my scripting in the mean time. I appreciate your taking on of my feedback

1 Like

API is looking good.
If I have multiple currencies on my demo account - is there a way to specify which to use in the API? I couldnt find this in the documentation and it seems it will always use the default account currency (will ignore if I select to trade in asset currency in options).

Hi guys,

What is the correct way to calculate the portfolio as in the application, based on this response from https://live.trading212.com/api/v0/equity/account/cash ?

{
"free": 1.32,
"total": 8471.79,
"ppl": 1080.09,
"result": 1238.41,
"invested": 7390.38,
"pieCash": 1.32,
"blocked": null
}

image0

I see that INVESTED = FREE + INVESTED but Iā€™m missing something for the RETURN value.

Thanks for your help.

Hi Florin, this is the correct way to calculate the above:

Portfolio (current cash evaluation) == invested + ppl (potential profit/loss)
result == realised result on closed positions

Peter.Herring :wave: At the moment, the APY doesnā€™t support multi-currency accounts, but weā€™ll definitely work on rectifying this in the future.

Please make it possible to place an order with an amount instead of a shares quantity.

For placing a market order the request has to look like:

{
  "quantity": 0.1,
  "ticker": "AAPL_US_EQ"
}

Instead of quantity Iā€™d like to pass the amount, e.g. ā‚¬2.

1 Like

Trying the use the API demo for a equity, place market buy order, using target server - demo.trading212.com, and am getting a UNDEFINED error, clarification ā€œInsufficientFreeForStocksExceptionā€. Is a market BUY order been enabled ? I can do a market SELL order

image|907x627

Hi, Iā€™m really enjoying the API so far. I have been using it for months, and it has definitely had a hand in encouraging me to re-sub my ISA with T212!

Would it be possible to have the ā€œinstruments metadataā€ response include the market exchange name? Eg. ā€œLondon Stock Exchangeā€

Hello,
for API market order request I can see these input parameters:
{
ā€œquantityā€: 0.1,
ā€œtickerā€: ā€œAAPL_US_EQā€
}

Please, how can I specify take profit and stop loss values ?

Thank you
Jan

Hi T212,
This a great new feature and long awaited so thank you! Iā€™ve been trying it out and whilst the functionality works great, I would suggest changing the auth mechanism to OAuth (an industry standard) which would greatly improve security for us and you.
As Iā€™m not using this api personally, I have an app with a sizeable number of users, currently I effectively have to ask each user to copy and paste the token into my app for it to work.
Not only do I have to rely on them selecting the correct permissions for my app to work, I also donā€™t want to end up with api keys that have excessive permissions (such as execute order).
These problems are solved with OAuth as the app would ask for the correct permissions. It would also benefit T212 to use OAuth as then you would have a better understanding of what apps are using your apis, be able to regulate who is given the Exec Order permission, and regulate api rate limiting.
Great work so far!

Iā€™ve just opened an account with Trading 212 on the promise of the API which is excellent, but I cannot place live orders, this is super disappointing. I would move over Ā£100k of funds into Trading 212 if you supported order execution via the API. Currently Iā€™m stuck with US brokers such as Alpaca or BIKRā€™s awful API. Yourā€™s looks perfect, but the lack of order execution means its not usable.

Is there an official update from Trading212 with how this beta is going? Any changes planned?

+1 to the above comments - itā€™s a huge pity to have the API available on demo to submit orders, but to not have that functionality on real money accounts.

I am currently in the live stage testing of an algorithm, and it would be nice to be able to link this to my already existing T212 account rather than set up a new account with another broker.

Iā€™m sure the community would love an update on the status of moving from Beta :slightly_smiling_face:

At the time, itā€™s not possible as we donā€™t support API for Value orders.

InsufficientFreeForStocksException is shown when there are not enough free funds to place a Buy order. Check if thereā€™s enough balance before sending the request.

You can use Limit & Stop orders to create Take profit & Stop loss. E.g. if you open a position at a $100 current price, you can place a Limit SELL order with a Limit price of $110, which will be a 10% profit.

Happy to hear that, @Antidev :blush: You can get the instrument exchange name using the workingScheduleId property of the instrument:

  1. Get all exchanges using exchange metadata Trading212 Public API docs.
  2. Each exchange has a list of workingSchedules [id, timeEvents].
  3. Map instrument workingScheduleId to its respective exchange.

Thanks for the suggestion :pray: We will consider it once we restart the developments on the Public API.

Not sure about this one :pensive: You can give ChatGPT a try - you should be able to use anything that sends REST requests.

The Public API is still in beta testing, and we donā€™t have an ETA on when we will resume the developments. We will definitely keep you in the loop, though.

1 Like

I know. It was a suggestion to support it. :slightly_smiling_face:

Yes. I already do. Use the (ā€œMSXML2.XMLHTTPā€) object

Hello,

Im trying to do a simple query using the API which is fetch my pies along with their data.

In order to achieve that I have to first fetch the Pie ids using one function and then for each id I got to fetch each pie separately. For each pie you fetch there is a rate limit of 30s.

I understand the rate limit to avoid overhead, but the way your API works adds overhead. cause if I have 6 Pies I have to make 1 + 6 calls and for every call have a delay of 30 seconds. Why not a single call and get back a json with all my pies details and their instruments?

I know that API is something new, this is my feedback, lets make it better!
keep up the good work!

1 Like