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

You always comes through with amazing stuff for free, itā€™s seriously mind-blowing! Thank you so much for that.
I was going through the documentation and noticed that we can only place orders using your internal tickers, right? All the examples I saw had something like ā€œtickerā€: ā€œAAPL_US_EQā€. It would be awesome if we had the option to use something more universal like the ISIN or a more widely recognized identifier.

1 Like

Fetching the account cash (/api/v0/equity/account/cash) I can see that the returned total is not the same as the amount in ā€œAccount Valueā€, in the appā€™s header. Is there a delay to the API value (or vice-versa)?

Also, what does ppl mean? Comparing with the data in the app, I can see itā€™s the current return, but it would be nice to have the definition in the API docs.

1 Like

Hello @noop ,

Enjoying the API so much :slight_smile:
I have a suggestions for starters.
https://t212public-api-docs.redoc.ly/#operation/orders_1 It would be super helpful if we had a way to handle the returned data. Your web uses filters like olderThan :slight_smile: this way we would only be able to request smaller chunks of data.

Also, what is the default ordering for the orders history api? Seems like date desc but would be great to have a bit more visibility.

Edit: It would be super useful to have an action field just like the CSV download. Any you might consider making this a filter as well. This way, a user can achieve what they wanted with less requests :slight_smile:

Few notes here;

filledQuantity seem to be NULL and when mapped with UI I can see the data for this field. Yes, the docs mention ā€œApplicable to quantity ordersā€ but then there is no way to understand how much I purchased.

Quick example to illustrate;
I purchased Apple, paid Ā£3 and 0.0218819 is my Filled Qty.
The order filled for $171.15. If I knew the exchange rate at the time, I could find my filled quantity. But the api is missing exchange rate so I cannot get filled quantity.
I mean if there is away to calculate this, maybe Im missing it

Not sure dateExecuted is intentionally null

dateModified and dateCreated not users local time :slight_smile: The web UI return 18 May 2023, 15:01 and API return 2023-05-18T14:01:37.000Z

Thanks!

1 Like

@danguilherme basically ppl is the return value you see on your portfolio;
See screenshots and the data from the API;

{
    "free": 49433.65,
    "total": 50184.50,
    "ppl": 184.78,
    "result": 0.00,
    "invested": 566.07,
    "blocked": null
}

Hope this helps :pray:t2:
Screenshot 2023-05-24 at 17.08.17
Screenshot 2023-05-24 at 17.08.45

With the release of the new API, I am assuming there will be functionality to programmatically send orders.

I think a good idea would be to implement a way to create sub accounts to separate funds/ trades.

This would be similar to how pies work. It would be within your current account.

backend: Just label certain trades/ orders with a specific tag and keep track of funds.
frontend: Just filter the displayed funds/ trades for the tag.

This would be beneficial for anyone trying multiple strategies via a system/ algo strategy while also using a discretionary approach.

Will this be available for use within the ISA account?

I am unsure about the regulations for ISAs in this area.

Also; Iā€™d like to post this idea here as it related to the API concept.
(https://community.trading212.com/t/sub-account-feature-for-upcoming-api/62212)

3 Likes

@JamesJohn I have integrated the API with my ISA account and running analysis on it :blush:
So if I understood you correctly, yes it works with ISA account.
Please note; I have not tested any POST end points.

1 Like

First try:

The API says ā€œfree: 3.93ā€, but my account says Ā£3.91.

Somethingā€™s a bit wrong.

2 Likes

Sounds dead simple. Canā€™t believe nobodyā€™s doing it.
/s

1 Like

I mean you can be /s all you want.

From an engineering standpoint you can do it pretty much all via conditional UI rendering with some slight tweaks on the backend for a ā€œsub accountā€ uuid.

It doesnā€™t change the main functionality of the product or create a new user, just what is displayed for each sub account uuid.

But heyā€¦ /s

1 Like

One more suggestion / request would be to add a field on /metadata/instruments endpoint which is shortName. On the UI when we search for BCPT we get .

  {
    "ticker": "FCPTl_EQ",
    "type": "STOCK",
    "isin": "GG00B4ZPCJ00",
    "currency": "GBX",
    "shortName": "BCPT",
    "fullName": "Balanced Commercial Property Trust",
    "description": "Balanced Commercial Property Trust Ltd",
    "countryOfOrigin": "GG",
  }

But on the API we get,

    {
        "ticker": "FCPTl_EQ",
        "type": "STOCK",
        "workingScheduleId": 59,
        "isin": "GG00B4ZPCJ00",
        "currencyCode": "GBX",
        "name": "Balanced Commercial Property Trust",
        "minTradeQuantity": 1.00000000,
        "maxOpenQuantity": 99884.00000000,
        "addedOn": "2018-07-12T07:10:22.000EEST"
    }

Adding the shortName would help developers to better handle the data.
I have written a logic to map all Trading212 tickers with various sources already :slight_smile: But still many would enjoy this change.

1 Like

I was in the right mood, forgot that this isnā€™t Reddit and people get offended.

Sorry son. Thought that your solution may involve changes in their database structure, but Iā€™m not much of an engineer myself.

Cheers

2 Likes

Would love to be able to take advantage of using this to automate some of my portfolio tracking, just dont have the time to play with it. if anyone finds a portfolio tracker tool or has some tips on how I can pull simple info like Holdings / Portfolio value etc to Excel/CSV automated or has any websites utilising this API then please let me know :slight_smile:

1 Like

Looks like the Javascript option is now removed from the API :wink:
Will there be no XHR support @noop ?
image

hi is it possible to use this API on trading view or any other execution platform ? thank you

1 Like

First of all, big kudos for developing this. What would be great, is ability to make a ā€œFill or Killā€ limit order. Also, fetching the last price for the given ticker (if this functionality doesnā€™t already exist)

1 Like

Hello there , i want to export a list of all available stocks on trading 212 using an API

I have the next error appearing ,where do i find this key to unblock the API?
image

or does someone know how to do that export?

Thanks.

How are you trying to get the data @Hellstaff ? I can see their instruments :slight_smile: So the issue is not on Trading212 api. Maybe its the way you try to get it?

1 Like

Hi All,
Great news to have API available for testing.
One question for Equity orders (Place Limit order, Place Market order, Place Stop order, Place StopLimit order): I tried Market order and after many tries worked for Buy. How place a Sell order for same position?

My feedback so far:

  • Place market order is not working most of time (Internal Error)
  • Cancel by ID - does not output anything (except response.status_code) and most time is not working
    tested with python and curl also on practice. When these will work more reliable?
    Regards