Hello anyone and everyone! New to this community, slowly learning the stock-trading Python commands.

I am having trouble with building a model that executes a buy of a stock after that stock has dropped. It must be according to the following logic:

 

1. Find Stock Ticker (we will use the ticker "STK" for this example)

 

2. Find open and close price of STK at each n increments (open price at start of 15 min candle vs close price at same 15 min candle). Any time resolution can be used.

 

3. IF (close price of stock at end of time increment < open price of stock at beginning of time increment):

      Place a market buy of the stock for the dollarAmountLost*(1.05). The market buy value is a dollar amount and would need to be rounded to the nearest share

In other words, if the stock drops over a specified time period, replace the dollar amount that was lost plus 5 percent as a share equivalent. Ideally the percent can be stored as a variable so it can be adjusted.

4. Print("You have placed an order for n shares of "STK" at time that order was placed)

 

Any help would be appreciated!

 

- Jay