Browse Source

feat: started the Prop strat

pull/19/head
QuentinN42 8 months ago
parent
commit
0cbf4fb78e
Signed by: number42 GPG Key ID: 2CD7D563712B3A50
  1. 44
      auto_trading/strat/prop.py

44
auto_trading/strat/prop.py

@ -0,0 +1,44 @@
from typing import List, Dict
import pandas as pd # type: ignore
from ..orders import Long, Short
from ..interfaces import Strategy, Order, PTFState, Indicator
from ..errors import StrategyInitError
class Prop(Strategy):
"""Proportional repartion from the indicator."""
def __init__(self, indicators: Dict[str, Indicator] = None):
"""Init the class"""
if not indicators or len(indicators) != 1:
raise StrategyInitError(
"This strat must be initialized with one indicator."
)
super().__init__(indicators=indicators)
self.indicator = list(indicators.keys())[0]
def execute(
self, data: pd.DataFrame, indicators_results: pd.DataFrame, state: PTFState
) -> List[Order]:
"""Just hold the value [to_hold].
Args:
data (DataFrame): The Data broker output.
For each time and each stock give (high, low, open, close).
indicators_results (DataFrame): Indicator-Stock valuated float.
For each indicator and each stock give -1 if realy bad and +1 if realy good.
Returns:
List[Order]: A list of orders to execute.
"""
orders: List[Order] = []
results = indicators_results[self.indicator]
# TODO: Calculate the new ptf desired state from the serie
# TODO: Create the orders to match the desired state
# TODO: Filter low orders
return orders # type: ignore
Loading…
Cancel
Save