Buying Stocks With an Arduino

Hello Experts :),

I am starting a new project. My project idea is straight forward. I want to buy and sell stocks using Arduino. I want to see what can microcontrollers really do and what are their boundaries.

In my last project, I built a bluetooth controlled drone using an android app that built. This time I don't want to control any motors nor turn off the TV using Arduino; It's really simple and boring. I want to see if this Arduino is capable of doing more complicated stuff like trading stocks.

I have searched many websites and looked for many books for guidance, but failed to find any hints on how to start this project.

If this is possible to do, what do I need to learn and what to search for?

So far I have learnt how to use the ESP8226 wifi chip. I had fun connecting to my wifi and controlling relays using my phone. But what if I can control websites using this chip? Is this possible.

If this is possible to do, what do I need to learn and what to search for?

First thing you will need is an API description how to communicate with the backend of your broker.
If your broker doesn't offer an open API - you have to search for another broker.

noiasca:
First thing you will need is an API description how to communicate with the backend of your broker.
If your broker doesn't offer an open API - you have to search for another broker.

I have an account with TD Ameritrade. They have an open API. How to use those API's and make them communicate with Arduino.

Thanks for your reply.

  1. Understand how the API works, and what will be needed for it. Most likely they need HTTPS requests (dear god, I hope they do!), so that rules out some low end microcontrollers, for example.

  2. Figure out a "test" api request that won't actually result in any shares being bought or sold, but will verify that you're making the request correctly. Ideally, you would be able to make this request from your computer and see that you get the expected response (there's a chrome addon called Advanced REST Client that's really handy for making requests to test APIs). Make sure this works, and look at all the data being sent to and received from their server. Then use it to make a request that will actually make a trade - make sure you understand how it works with a real computer making the request.

  3. Using an appropriate arduino (determined in 1.), first verify that you can make a simple request over https - not to their API, just in general. How you do this will depend on what board you end up using, and how it's connecting to the internet, but there should be examples of making simple requests all over the place.

  4. Make the arduino do your test api request and just print out the response it gets to serial - make sure you can get the same result as you got on the computer.

  5. Before you make any request that could actually buy or sell stock, have the sketch just print out the requests it would be making, instead of just making them, so you can verify that it's going to do what you expect.

  6. Once that's working, you can... start making your arduino buy and sell stocks for you!

Be mighty careful that you've got measures in place to limit the amount of financial damage that a bug could do to you. It wouldn't do to end up in the poor house on account of a bug in your code....

Overall, though, this sounds fun, if sort of silly...

DrAzzy:
Be mighty careful that you've got measures in place to limit the amount of financial damage that a bug could do to you. It wouldn't do to end up in the poor house on account of a bug in your code....

Overall, though, this sounds fun, if sort of silly...

Thanks for the amazing reply. I will work on what you wrote and hopefully get some good results.

To be honest, having an arduino to handle streaming quotes, apply your strategies to stocks, generate and tracking orders, and handle errors, would be a little difficult. Plus Arduino doesn’t have much built-in storage, so reviewing logs could be difficult if anything goes wrong and crashes.

I’m using TD Ameritrade as well (mostly trading futures and options). I built a simple tool showing quotes only of some futures, using TD Ameritrade streaming API, but it does not have any trading logic.

Hope this could help.

Screen Shot 2020-06-27 at 01.26.13.png

noiasca:
First thing you will need is an API description how to communicate with the backend of your broker.
If your broker doesn't offer an open API - you have to search for another broker.

Where can I find a good broker? I've started to trade some months ago and I know that a very important detail in trading is to find a good broker. I'm looking also for a good platform for trading because now in the net there are a lot of scammers that are waiting for you to do some transactions and to still the money. I'm not trading the bitcoin or sth else, no. I decided to start trading the oil. I read from The buoyant oil traders | The Economist that it is very profitable today if to be a good analytic and to know the time when to take a right decision.

brandonh1987:
Where can I find a good broker?

Is this a programming question?

@brandonh1987

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Your other NECRO / HIJACK was deleted btw.

I did a quick Google search for: stock trading API. The first result was an ad for a website called Alpaca.markets. Someone has written a C++ client for their API and provided a bunch of examples. You could sign up for a free account and see if you can get the C++ library and examples to run on your Arduino.

Here are the examples for the third-party C++ client library for Alpaca.markets.

WARNING: There will be a lot of editing to make the library work in the Arduino environment. And then you might find there is not enough memory on the Arduino to get the library to work.

Seems a very strange sort of task to try to implement on an Arduino when it would be so much easier on a RaspberryPI or a cheap laptop.

But perhaps the expectation is that you will lose money on the trades so you want to minimise the amount you spend on the hardware :slight_smile:

A bit like wearing a cheap suit to visit a casino :slight_smile:

...R

Também estou procurando uma boa plataforma de negociação

@kyliehard21

These are ENGLISH sections.

Try a language closer to your native language: