You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
724 B

"""Yoyo strategy."""
from auto_trading.interfaces import Strategy
from auto_trading.orders import Long, Short
class Yoyo(Strategy):
"""A strat that buy a stock one time then sell it."""
def __init__(self, stock_name: str):
self.stock_name = stock_name = True
def execute(self, data, indicators_results, ptf_state):
market_price = data.loc[data.index[-1][0]].close.to_dict().get(self.stock_name)
if not market_price:
return []
if = False
todo = Long
else: = True
todo = Short
return [todo(self.stock_name, 0.1, market_price)]