progress. Initial untested version
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Dict, List, Optional, cast
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
import pandas as pd
|
||||
|
||||
@@ -10,15 +8,14 @@ import pandas as pd
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.app import App
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.settings.cvtt_types import BookIdT, IntervalSecT
|
||||
from cvttpy_tools.timeutils import SecPerHour, current_nanoseconds
|
||||
from cvttpy_tools.settings.cvtt_types import IntervalSecT
|
||||
from cvttpy_tools.timeutils import SecPerHour, current_nanoseconds, NanoPerSec
|
||||
from cvttpy_tools.logger import Log
|
||||
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
from cvttpy_trading.trading.mkt_data.md_summary import MdTradesAggregate
|
||||
from cvttpy_trading.trading.trading_instructions import TradingInstructions
|
||||
from cvttpy_trading.trading.accounting.cvtt_book import CvttBook
|
||||
from cvttpy_trading.trading.trading_instructions import TargetPositionSignal
|
||||
|
||||
# ---
|
||||
@@ -29,23 +26,6 @@ from pairs_trading.apps.pairs_trader import PairsTrader
|
||||
from pairs_trading.lib.pt_strategy.pt_market_data import LiveMarketData
|
||||
|
||||
|
||||
"""
|
||||
--config=pair.cfg
|
||||
--pair=PAIR-BTC-USDT:COINBASE_AT,PAIR-ETH-USDT:COINBASE_AT
|
||||
"""
|
||||
|
||||
|
||||
# class TradingInstructionType(Enum):
|
||||
# TARGET_POSITION = "TARGET_POSITION"
|
||||
|
||||
|
||||
# @dataclass
|
||||
# class TradingInstruction(NamedObject):
|
||||
# type_: TradingInstructionType
|
||||
# exch_instr_: ExchangeInstrument
|
||||
# specifics_: Dict[str, Any]
|
||||
|
||||
|
||||
class PtLiveStrategy(NamedObject):
|
||||
config_: Config
|
||||
instruments_: List[ExchangeInstrument]
|
||||
@@ -59,12 +39,9 @@ class PtLiveStrategy(NamedObject):
|
||||
model_data_policy_: ModelDataPolicy
|
||||
pairs_trader_: PairsTrader
|
||||
|
||||
# ti_sender_: TradingInstructionsSender
|
||||
|
||||
# for presentation: history of prediction values and trading signals
|
||||
predictions_df_: pd.DataFrame
|
||||
trading_signals_df_: pd.DataFrame
|
||||
# book_: CvttBook
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -155,7 +132,15 @@ class PtLiveStrategy(NamedObject):
|
||||
await self._send_trading_instructions(trading_instructions)
|
||||
|
||||
def _is_md_actual(self, hist_aggr: List[MdTradesAggregate]) -> bool:
|
||||
return False # URGENT _is_md_actual
|
||||
LAG_THRESHOLD = 5 * NanoPerSec
|
||||
|
||||
if len(hist_aggr) == 0:
|
||||
Log.warning(f"{self.fname()} list of aggregates IS EMPTY")
|
||||
return False
|
||||
# MAYBE check market data length
|
||||
if current_nanoseconds() - hist_aggr[-1].time_ns_ > LAG_THRESHOLD:
|
||||
return False
|
||||
return True
|
||||
|
||||
def _create_md_df(self, hist_aggr: List[MdTradesAggregate]) -> pd.DataFrame:
|
||||
"""
|
||||
@@ -259,8 +244,8 @@ class PtLiveStrategy(NamedObject):
|
||||
|
||||
return trd_instructions
|
||||
|
||||
def _strength(self, scaled_disequilibrium) -> float:
|
||||
# URGENT PtLiveStrategy._strength()
|
||||
def _strength(self, scaled_disequilibrium: float) -> float:
|
||||
# TODO PtLiveStrategy._strength()
|
||||
return 1.0
|
||||
|
||||
def _create_open_trade_instructions(
|
||||
|
||||
Reference in New Issue
Block a user