I am trying to learn trading and I have searched everywhere but I just don't find an answer to this question. So:

Is it possible to create a trading bot and API for it completely from scratch, because my internet broker does not provide any kind of API for trading. Basically, if I wanted to trade right now, I would have to place every purchase and selling transaction manually.

I have coding experience but not with APIs. By googling "what is API" I get this answer:

An application programming interface (API) is a way for two or more computer programs or components to communicate with each other.

From this definition I would assume that I could just create an API myself. So basically I would write a program that interacts with my internet broker's website and places transactions automatically based on an algorithm. Is it possible to do this? If yes, please provide some learning sources.


1 Answer 1


It is possible to do what you are suggesting, however execution will likely be unstable. Specifically, you would likely use selenium (a python library) to interact with your chrome browser to place the trade in a similar manner that you would if you manually entered a trade.

There are risks associated with this, in which if anything changes on your broker's website, and your quasi-API is not built robustly, it could submit a rogue trade. It is also slow if you are looking to submit trades on a relative high frequency. Further, if you trade too often your profits will likely be diminished due to the cost of trading. Every trade has a bid-ask spread if you submit market orders, and most brokerages have a fee per buy and sell.

An API, specifically with a broker is maintained by the broker, and trades are executed directly from code instead of calling selenium to open a new chrome browser and log into your brokerage account to submit the trade. Additionally, I would recommend manually trading the first several trades of a new trading strategy so you can monitor if there are any errors in the code for execution.

I would highly suggest finding a broker with an API. Interactive Brokers has relatively low fees and a Python Trading API I believe.

In summary, you cannot create an API, however you can write a script to interact with a browser tab and submit trades manually the same way you currently are doing. Writing this script has several risks including speed, maintenance of the script, and security.

  • 2
    $\begingroup$ Good answer -- you covered the question that should have been asked...namely is it wise? $\endgroup$
    – Brian B
    Feb 26 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.