Some people really don't understand the markets, i'm here for you!

I start this post with a wise note, I’m not looking to get into a heated discussion rather help you know my experiences in trading the markets…

Spoiler alert this is not going to be a long programming tech post, it’s more geared toward the average Joe getting into trading. If you’re looking for something like a boilerplate to algo trading. I had made a post in september Something to help people understand algos and stocks
I will be bring up some key points of the ideas of a boilerplate or as some call it a data pipeline (i’ll make a more graphic one soon)
Also if your interested in me writing up a topic for HFT (High Frequency Trading) post a comment and i’ll tell you all i know.

This is just for people who are interested in making their own algo based trading strategy. or what to look for when using one… in this topic i will only go over some tips for a beginning day trader. whos expecting to use or make a day trading platform and fall under the $25,000 minimum equity requirement. So let’s head off with the idea that you, can only do 3 day trades a week and you don’t want to be expected to be clicking. a single key on the keyboard, Well it can happen your algo just needs to follow percentages, rules and constraints, averaging, emulating. more on that below!

Ill start with averaging, this is the most important of all since without this your system will not know what direction the market is moving in. usually when your averaging your algo is looking at the last days market average and comparing that to the current days or as your emulating data to test machine learning it would be saving each move a trade is expected to do so it can use its averages as a whole to test the current market price of a trade that its in. it should also account for index direction and tracking stock like (SPY) “It is designed to track the S&P 500 stock market index”. averaging should also affect your gain for. at what percent you are looking to buy a stock.

Emulating data is very important in development but programmers can fall victim to bugs in the code and not see it in EMU so keep that in mind, here’s how so. a change of logic that is only accounted for in production that was missed in simulating the data. can wipe out all of your profit! so it is very important to do dry runs (Paper Trading). where no money is spent before rolling out your next release. an emulation of a trading day can help you determine what logic to implement into your trading strategy, testing each succession of data can give you a better prediction of accuracy.
Emulated Data

Production Data

Rules and constraints Im going to throw the two out there as an obvious meaning of logic, when you think of your logic though, don’t follow lead, yes using best practices is nice, just never let yourself drift from self discipline, always follow what you believe is the correct approach but don’t interfere with the trades. if you want more on this look into “Something to help people understand algos and stocks” a post i did awhile back.

Percentages buying a stock and knowing when to keep it. is two of the most hardest things but still fundamental of your trading strategy. lets say your in a room with 5 doors buying a stock should be as easy as opening a door and walking through it. but wait what door did you just walk through, this is the concept of memory and one of the biggest and important parts of running an algo. percentages are affected by anything, something, nothing and everything. your question might be how do you get the correct percent well let me break it down for you. Speed Speed Speed ! its widely known if your equipment is closest to the exchange you can be the first one in a stock… well not so fast now that the SEC has made a “speed bump” by adding a large amount of fiber cable to each connection to the matching server. you might be just as well off as the next guy, lets take the idea of a outperforming stock in the morning, in the next few paragraphs ill be going over some data that i think will help you see better what some are doing with measurements.
(Keep note this data is from emulation NOT LIVE DATA!)
Buying a stock
(This one is self explanatory - as its looking to buy the averages & gains are compared to the price that the stock is current at in the last 3 minutes )
(GAIN : 0.08 TIMESTAMP :09:51:00 FREQ : averages :3.42 2.01 COUNT:235)
(GAIN : 0.08 TIMESTAMP :09:43:00 FREQ : averages :8.95 3.06 COUNT:65)
(GAIN : 0.12 TIMESTAMP :09:53:00 FREQ : averages :1.98 8.95 COUNT:268)

 Selling a stock

 ( High| Low| Median - average| Timestamp| Price| Gains| Loss - 0 is a new High in the trade |  ) 
 ( NAN | 2.38 | NAN |  | 1580395480 | 2.38 | 11.6 | 0 |  ) 

 ( NAN | 2.36 | NAN |  | 1580395524 | 2.34 | 10.7 | -0.8 |  ) 

 ( NAN | 2.35 | NAN |  | 1580395576 | 2.33 | 8.8 | -2.6 |  ) 

 ( 2.38 | 2.35 | 2.365 | 1 | 1580395597 | 2.38 | 8.4 | -3 |  ) 

 ( 2.38 | 2.36 | 2.37 | 1 | 1580395637 | 2.39 | 10.7 | -0.8 |  ) 

 ( 2.38 | 2.362 | 2.371 | 1 | 1580395656 | 2.37 | 11.2 | -0.4 |  ) 

 ( 2.38 | 2.36 | 2.37 | 1 | 1580395690 | 2.35 | 10.2 | -1.3 |  ) 

 ( 2.38 | 2.36 | 2.37 | 1 | 1580395710 | 2.36 | 9.3 | -2.1 |  ) 

 ( 2.38 | 2.3613 | 2.37065 | 2 | 1580395736 | 2.37 | 9.8 | -1.7 |  ) 

 ( 2.38 | 2.3622 | 2.3711 | 2 | 1580395756 | 2.37 | 10.2 | -1.3 |  ) 

 ( 2.38 | 2.364 | 2.372 | 2 | 1580395772 | 2.38 | 10.2 | -1.3 |  ) 

 ( 2.38 | 2.3655 | 2.37275 | 2 | 1580395795 | 2.38 | 10.7 | -0.8 |  ) 

OK so now let’s look at a Production trade using Paper Trading With alpaca

The trade is as follows…

Market SELL
01/31/2020 09:59 AM





Limit BUY @ $1.12
01/31/2020 09:46 AM




Basic Tech You made it to this point pat yourself on the back and get some coffee. think of a trading strategy when your making it, much like yourself take your discipline in to account if your a programmer ask your self with each (if, loop, for) statement what can this affect, now there multiple parts of a trading strategy. but here’s what i believe will be the best route for anyone to follow, recently as i started implementing machine learning ive seen a few reasons to always push for more (money) so keep that in mind when programming. less of an idea of holding on to a trade but more of an idea to always wait for it to go past its average high (make more). because if not by the end of the day the only thing you have lost is the trade.

Feeding your application is among one of the most important things to cover since there are many data feeds that are delayed, there are differences in upstream providers and downstream providers. as there are also different reasons to use one over the other depending on your strategy. im not going to bring up any company names in this topic since this is meant more for you to understand the markets

Key Points
Somethings that change depending how fast the code can process are affected by the processing power, but mostly the read and write speed of your hardware, having a solid state hard drive over a spinning disk platter will greatly affect performance. and if the collar and the % that you have added to it does not account for this change, you will see your orders being rejected. so your loop just saw a stock jump over the gain, could be (16-20% usually) that you were just measuring for that stock, now this is where the broker and collar comes into play.

Hopefully by the end of this post you will have learned some new information that will help you in trading. Thank you

Some things to get past, i see a lot of post on this form about incorrect price data and api connection issues and i wanted to propose this since i have nothing to complain about with the companies i use. try to look at the fine details before making a post you’ll see there’s a lot of information covering a lot of topics, and more then likely someone has asked your question so just make a search before making a post. if not people like us are always here to help!


Hi! I hope this question is pertinent with your thread.
I would like to run the famous Hitoshi’s HFT-ish algo in paper trading, but it is not possible due to the data stream from Polygon, is that correct?
I only have a paper trading account and not a funded brokerage account and I’m no US resident, so I suppose I can’t access Polygon data, not even in paper trading, right?.
Is there a way to test an hft algorithm like this in paper trading?