49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
from Orders import BuyOrder, SellOrder
|
|
|
|
from typing import TYPE_CHECKING
|
|
if TYPE_CHECKING:
|
|
from datetime import datetime
|
|
|
|
from Common import TickData
|
|
from Brokerage_Simulation import BrokerageSimulation
|
|
|
|
from Account_Information import AccountInformation
|
|
from Orders import GenericLimitOrder, OrderFilledResponse
|
|
|
|
|
|
from strategies.Strategy_Template import StrategyTemplate
|
|
|
|
import random
|
|
|
|
|
|
class RandomStrategy(StrategyTemplate):
|
|
def __init__(self, symbol: str):
|
|
super().__init__(symbol)
|
|
|
|
self.status: int = 0 # 0 for no position, 1 for long, -1 for short
|
|
|
|
def react_to_market(self) -> list['GenericLimitOrder']:
|
|
positive_trend = random.choice([True, False])
|
|
|
|
order: GenericLimitOrder = None
|
|
if self.status == 0: # No current position
|
|
if positive_trend:
|
|
# Make a buy order
|
|
order: BuyOrder = None
|
|
elif self.status == 1: # Already long
|
|
if positive_trend:
|
|
pass
|
|
else:
|
|
# Make a sell order to close position
|
|
pass
|
|
elif self.status == -1: # We are short
|
|
if positive_trend:
|
|
# Make a buy order to close position
|
|
pass
|
|
else:
|
|
pass
|
|
|
|
return [order]
|
|
|
|
|