I have an idea. How can I implement it?

Discussion in 'Automated Trading' started by ndisgiiet, Apr 2, 2021.

  1. Ok, so this is my first post here. You guys seem very knowledgeable and I figure you might be able to help me with my idea and the best and most efficient way to implement it. Let me preface this with, yes, I understand the inherent risk and the fact that the past does not predict the future. Having said that, I have a strategy that I am considering. I need to know the technicals on how to make it happen. Here is what will need to happen if possible:

    FULLY AUTOMATED
    - scan ALL stocks (I may narrow it down to all listed and/or non-OTC or whatever, but the point is, scan lots of stocks) at the opening bell every day (preferable within seconds of open)
    - The ones that meet my criteria, buy them as quickly as possible (hopefully within the first minute or seconds if possible). Whether I buy at market price or place limit orders is yet to be tested.
    - Let them ride and do there thing for the day (yes, I know...)
    - Sell all of them right before the closing bell, hopefully within a minute of closing if not seconds. I realize that working with stocks with very high volume will help with filling buys and sells easier/better.

    So to summarize, at 9:30AM, it would need to fully automate scanning and buying every stock that meets my criteria (could be thousands), and then sell them all at the end of the trading day. And would most likely only be a few shares (1 - 2 shares) of each, which should help with getting the buys and sells executed I would think.

    What broker/platform should I use to best do this? Obviously one without fees for trading stocks in bulk. I currently have TD Ameritrade and have been thinking about Tradestation, but you tell me based on my needs??? My brother is a programmer, so I am hoping he can help with APIs and programming stuff, but I need to know the best choices to make. Any input would be tremendously appreciated!
     
  2. gkishot

    gkishot

    What makes you think your idea is going to work?
     
  3. Thank you for responding. Dont laugh, but back testing using EOD data for all stocks since 1970ish timeframe. Lots and lots of spreadsheets and number crunching for patterns etc. But that's the other thing. I also want to be able to test forward my strategy while saving the funds to be able to meet the requirements for day trading. So whatever system is recommended to use, I would love to be able to simulate the strategy I describe above into a paper trading account to prove its worth with the real world stuff like slippage etc going on. So that would lead to another question. Lets assume someone could create a custom program/API for me to use and do what I mentioned, could that same strategy be used on a paper trading account? Right now, I can only paper trade or forward test one stock at a time pretty much. With the time sensitive requirement to place thousands of trades within seconds or a minute of open time, that aint doable manually.
     
  4. Snuskpelle

    Snuskpelle

    About robustness of that: Am I right in assuming you intend to get fills similar to open and close price respectively? Another layer of backtesting you could do would be on intraday data then, because the fills achievable IRL may be dissimilar from open price, particularly if the edge/trade is small. In other words it's a data snooping bias to assume the open price is available for a decision for a fill at that price. There are some places with free intraday data e.g. QuantConnect.com, if you e.g. precalculate a list of trades you would like to verify and then execute those trades the QC/Lean backtest sim on intraday data (second resolution). A bit of work, sure, so there may be faster ways - if you can get to forward testing faster then that is certainly preferable and you can skip another layer of backtesting.
     
  5. fan27

    fan27

    Unless your brother is highly interested in automated trading, he is going to tire of this project very quickly.
     
    Nobert, d08 and Snuskpelle like this.
  6. kmiklas

    kmiklas

    I wrote an algo to do something similar. I was playing the (dead cat) bounce. I scanned the SnP, looking for equities that had triggered the uptick rule, and timing a buy to catch a 1% bounce.

    To answer your questions:
    1. I did it with the Interactive Brokers API. It worked well.
    2. I used Python because IB is not a ULL or LL platform... you don't need the speed of C, and you'll pay BIG bucks for anything even close to LL.
    3. Buying at the open is a bad idea. There's a lot of price discovery going on, and the spreads can be enormously wide.. you can really get slaughtered by transaction costs and irrational movement.
    4. You can't just buy any instrument. You must check volume before you take a position. If an instrument has light volume, you may get stuck with a huge bid/ask spread, and may not be able to get out without taking a hit. I HATE sluggish instruments with big spreads!!
    5. In your scheme, you'll get killed by transaction costs. IB charges $1 for each trade up to 200 shares; to the best of my knowledge, this is the cheapest retail broker for what you're trying to do. if you're only buying 1-2 shares of thousands of stocks, you'll rack up thousands in fees. Perhaps better to focus on a narrower group of targets to minimize transaction costs.
    6. Finally, as a retail trader, you're always bottom of the totem pole. You'll get the worst fills... you're last in line.

    So, I didn't make any money... not because the algo was bad; because sometimes the damn stocks didn't bounce after a big drop. It was still a 50/50.

    Hope this helps. IB API link follows.
    https://interactivebrokers.github.io/tws-api/introduction.html
     
    Last edited: Apr 2, 2021
    johnnyrock, Tradex, qlai and 3 others like this.
  7. Snuskpelle

    Snuskpelle

    Define 'bad'. My experience is that it's possible to write high quality code that comes nowhere close to solving a trading problem - that's why this is a potentially very depressing business for a software engineer.
     
    d08 and kmiklas like this.
  8. kmiklas

    kmiklas

    The algo was "good" because is did exactly what I wanted it to do; in other words, the code was was correctly processing market data and issuing triggers.

    The strat was "bad," because it didn't make money. :,(

    In other words, the programming work was correct, but the strategy it embodied was not profitable.

    ...and it's not depressing; it's a tough game, but it inspires me. One good algo can set you up for life You can even lease successful algos for others to use without revealing the source.
     
    Last edited: Apr 2, 2021
    gkishot and Snuskpelle like this.
  9. Snuskpelle

    Snuskpelle

    Ah yeah, suspected as much. It sort of ties in with what @fan27 mentioned above as well. I hope OP's brother gets paid. :p
     
    fan27 and kmiklas like this.
  10. kmiklas

    kmiklas

    Yep... that's the advantage of being the programmer and not the analyst; you're guaranteed a check XD
     
    #10     Apr 2, 2021