mirror of
https://github.com/wassname/options_backtester.git
synced 2026-07-21 12:40:27 +08:00
Fixed imports
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
from .strategy import Strategy, Condition
|
||||
from .strategy_leg import StrategyLeg
|
||||
from .strangle import Strangle
|
||||
from .signal import *
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from .strategy_leg import StrategyLeg
|
||||
from .strategy import Strategy
|
||||
from backtester.option import Direction, Type
|
||||
from backtester.enums import Direction, Type
|
||||
|
||||
|
||||
class Strangle(Strategy):
|
||||
|
||||
@@ -6,9 +6,8 @@ import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
from backtester.datahandler import Schema
|
||||
from backtester.option import Direction
|
||||
from backtester.enums import Direction, Signal, get_order
|
||||
from .strategy_leg import StrategyLeg
|
||||
from .signal import Signal, get_order
|
||||
|
||||
Condition = namedtuple('Condition', 'fields legs tolerance')
|
||||
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
from backtester.option import Type, Direction
|
||||
from backtester.enums import Type, Direction
|
||||
from backtester.datahandler import Schema
|
||||
|
||||
|
||||
class StrategyLeg:
|
||||
"""Strategy Leg data class"""
|
||||
|
||||
def __init__(self,
|
||||
name,
|
||||
schema,
|
||||
option_type=Type.CALL,
|
||||
direction=Direction.BUY):
|
||||
def __init__(self, name, schema, option_type=Type.CALL, direction=Direction.BUY):
|
||||
assert isinstance(schema, Schema)
|
||||
assert isinstance(option_type, Type)
|
||||
assert isinstance(direction, Direction)
|
||||
@@ -44,16 +39,13 @@ class StrategyLeg:
|
||||
|
||||
def _base_entry_filter(self):
|
||||
if self.direction == Direction.BUY:
|
||||
return (self.schema.type == self.type.value) & (self.schema.ask >
|
||||
0)
|
||||
return (self.schema.type == self.type.value) & (self.schema.ask > 0)
|
||||
else:
|
||||
return (self.schema.type == self.type.value) & (self.schema.bid >
|
||||
0)
|
||||
return (self.schema.type == self.type.value) & (self.schema.bid > 0)
|
||||
|
||||
def _base_exit_filter(self):
|
||||
return self.schema.type == self.type.value
|
||||
|
||||
def __repr__(self):
|
||||
return "StrategyLeg(name={}, type={}, direction={}, entry_filter={}, exit_filter={})".format(
|
||||
self.name, self.type, self.direction, self._entry_filter,
|
||||
self._exit_filter)
|
||||
self.name, self.type, self.direction, self._entry_filter, self._exit_filter)
|
||||
|
||||
Reference in New Issue
Block a user