dev progress
This commit is contained in:
+17
-6
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, Coroutine, List
|
||||
import aiohttp.web as web
|
||||
|
||||
from cvttpy_tools.app import App
|
||||
from cvttpy_tools.config import Config
|
||||
@@ -8,6 +9,8 @@ from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.config import CvttAppConfig
|
||||
from cvttpy_tools.logger import Log
|
||||
from cvttpy_tools.settings.cvtt_types import BookIdT
|
||||
from cvttpy_tools.web.rest_service import RestService
|
||||
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
from cvttpy_trading.trading.mkt_data.md_summary import MdTradesAggregate
|
||||
@@ -17,11 +20,6 @@ from pairs_trading.lib.pt_strategy.live.live_strategy import PtLiveStrategy
|
||||
from pairs_trading.lib.live.mkt_data_client import CvttRestMktDataClient
|
||||
from pairs_trading.lib.live.ti_sender import TradingInstructionsSender
|
||||
|
||||
# import sys
|
||||
# print("PYTHONPATH directories:")
|
||||
# for path in sys.path:
|
||||
# print(path)
|
||||
|
||||
'''
|
||||
config http://cloud16.cvtt.vpn/apps/pairs_trading
|
||||
'''
|
||||
@@ -36,6 +34,7 @@ class PairsTrader(NamedObject):
|
||||
|
||||
live_strategy_: PtLiveStrategy
|
||||
pricer_client_: CvttRestMktDataClient
|
||||
rest_service_: RestService
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.instruments_ = []
|
||||
@@ -105,7 +104,16 @@ class PairsTrader(NamedObject):
|
||||
|
||||
|
||||
# # ------- CREATE REST SERVER -------
|
||||
# URGENT CREATE REST SERVER for dashboard communications
|
||||
self.rest_service_ = RestService(
|
||||
config_key=f"/api/REST"
|
||||
)
|
||||
|
||||
# --- Strategy Handlers
|
||||
self.rest_service_.add_handler(
|
||||
method="POST",
|
||||
url="/api/strategy",
|
||||
handler=self._on_api_request,
|
||||
)
|
||||
|
||||
async def subscribe_md(self) -> None:
|
||||
for exch_inst in self.instruments_:
|
||||
@@ -124,6 +132,9 @@ class PairsTrader(NamedObject):
|
||||
# Snapshot or update?
|
||||
await self.live_strategy_.on_mkt_data_hist_snapshot(hist_aggr=history)
|
||||
|
||||
async def _on_api_request(self, request: web.Request) -> web.Response:
|
||||
return web.Response() # TODO add API request handler implementation
|
||||
|
||||
async def run(self) -> None:
|
||||
Log.info(f"{self.fname()} ...")
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user