mirror of
https://github.com/wassname/options_backtester.git
synced 2026-06-27 19:31:36 +08:00
Removed unused legacy code.
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
class Event():
|
||||
"""
|
||||
Event is base class providing an interface for all subsequent
|
||||
(inherited) events, that will trigger further events in the
|
||||
trading infrastructure.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class MarketEvent(Event):
|
||||
"""
|
||||
Handles the event of receiving a new market update with
|
||||
corresponding bars.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.type = "MARKET"
|
||||
|
||||
|
||||
class SignalEvent(Event):
|
||||
"""
|
||||
Handles the event of receiving a signal form the Strategy
|
||||
object.
|
||||
Portfolio object processes buy/sell orders.
|
||||
"""
|
||||
|
||||
def __init__(self, symbol, direction, strength):
|
||||
"""symbol: ticker symbol
|
||||
direction: BUY | SELL
|
||||
strength: (%Win chance, Win/Loss ratio)"""
|
||||
self.type = "SIGNAL"
|
||||
self.symbol = symbol
|
||||
self.direction = direction
|
||||
self.strength = strength
|
||||
@@ -1,29 +0,0 @@
|
||||
from .strategy import Strategy
|
||||
from ..event import SignalEvent
|
||||
|
||||
|
||||
class Balanced(Strategy):
|
||||
"""Balanced portfolio strategy.
|
||||
Inspired by Ray Dalio's all weather portfolio.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
data_handler,
|
||||
events,
|
||||
symbols=[
|
||||
"VOO", "GLD", "VNQ", "VNQI", "TLT", "TIP", "BNDX", "EEM",
|
||||
"RJI"
|
||||
]):
|
||||
self.data_handler = data_handler
|
||||
self.symbols = symbols
|
||||
self.events = events
|
||||
self._bought = False
|
||||
|
||||
def generate_signals(self, event):
|
||||
if not self._bought:
|
||||
for symbol in self.symbols:
|
||||
buy_signal = SignalEvent(
|
||||
symbol=symbol, direction="BUY", strength=(1.0, 100))
|
||||
self.events.put(buy_signal)
|
||||
|
||||
self._bought = True
|
||||
@@ -1,18 +0,0 @@
|
||||
from .strategy import Strategy
|
||||
from ..event import SignalEvent
|
||||
|
||||
|
||||
class Benchmark(Strategy):
|
||||
"""Simple buy and hold SPX strategy"""
|
||||
|
||||
def __init__(self, data_handler, events):
|
||||
self.data_handler = data_handler
|
||||
self.events = events
|
||||
self._bought = False
|
||||
|
||||
def generate_signals(self, event):
|
||||
if not self._bought:
|
||||
buy_signal = SignalEvent(
|
||||
symbol="SPX", direction="BUY", strength=(1.0, 100))
|
||||
self.events.put(buy_signal)
|
||||
self._bought = True
|
||||
@@ -1,15 +0,0 @@
|
||||
import os
|
||||
|
||||
|
||||
def get_data_dir():
|
||||
"""Reads data path from environment variable $OPTIONS_DATA_PATH.
|
||||
If it is not set, defaults to `data/`
|
||||
"""
|
||||
|
||||
if "OPTIONS_DATA_PATH" in os.environ:
|
||||
data_dir = os.path.expanduser(os.environ["OPTIONS_DATA_PATH"])
|
||||
else:
|
||||
data_dir = "data"
|
||||
os.mkdir(data_dir)
|
||||
|
||||
return data_dir
|
||||
Reference in New Issue
Block a user