Click here to Login

                                                   My trading algorithm won't stop buying shares


2021-08-27 09:33:27

I have a trading algorithm that I use in Python and have been testing over the course of the summer. For the most part, the algorithm runs very well but it ran into an issue this week where it purchased an excessive amount of shares in a very short amount of time (over the course of 4 milliseconds). So, I'm trying to implement safety mechanisms that would check each order before sending it to the broker to ensure a sort of buying spree doesn't occur (kind of like trying to avoid what happened to Knight Capital in 2012).

I know the parameters I want to keep track of for each order (excessive size, high frequency, etc.) but I'm trying to determine the best way to integrate the checks at a software-level to minimize latency. Right now, I'm debating between including the checks in the code for my trading strategy directly via software libraries or developing a separate system/service which would check all the trades before relaying them to my broker.

Does anyone have any suggestions (either from research of first-hand experience) as to which method is more efficient for implementing safety guards in a trading algorithm? Alternatively, does anyone have any resources they might suggest that may give me inspiration for my project?

Any and all help is welcome and greatly appreciated. Thanks in advance.

No more messages


No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"


Trading Items
Stop Trading Based on Your Portfolio Equity Return
Decreasing the Trailing Stop Level every Trading Bar
Stop Loss for the N-first Trading Bars only
Trading Range Breakout - Long Strategy
Insider trading data

How-to Lessons
How to optimize the stop limit of a trading system
How to create a trading system
How to get trading orders from a portfolio programmatically
How to optimize the number of positions in a trading system
How to optimize a neural network using a genetic algorithm

Related Forum Threads
Stop Loss for Intraday Trading System
Trading System Simulation Errors
Trading System Target Profit and Loss prices
Reinvest Dividends in Your Trading System - Script
Trading system on ranks ruleset but doesn't optimize

Blog Posts
5 position sizing techniques you can use in your trading system
Trading System: Buy stocks with the highest Sharpe ratio
Let me Show You How to Create Hundreds of Profitable Trading Syst...
The Ultimate Guide to Create Trading Systems in QuantShare
How to Optimize a Trading System with Thousands of Billions of Co...

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2022
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.