-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrategy.py
More file actions
27 lines (20 loc) · 935 Bytes
/
Copy pathStrategy.py
File metadata and controls
27 lines (20 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from abc import ABC, abstractmethod
from Brokerage import Brokerage
from DB import Event
from HistoricalData import HistoricalData
import datetime
class Strategy(ABC):
@abstractmethod
def run(self, timestamp: datetime.datetime, events: list[Event], brokerage: Brokerage, historical_data: HistoricalData):
pass
class BlankStrategy(Strategy):
def run(self, timestamp: datetime.datetime, events: list[Event], brokerage: Brokerage, historical_data: HistoricalData):
pass
class SAndP500Strategy(Strategy):
def run(self, timestamp: datetime.datetime, events: list[Event], brokerage: Brokerage, historical_data: HistoricalData):
if len(brokerage.get_positions()) > 0:
return
ivv_price = brokerage.get_ticker_price('IVV')
cash = brokerage.get_cash()
quantity = cash // ivv_price[1]
brokerage.place_buy_trade('IVV', quantity)