Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
trentmc committed Jan 27, 2025
1 parent a2611e4 commit 5ec0bab
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 25 deletions.
5 changes: 2 additions & 3 deletions pdr_backend/aimodel/test/test_aimodel_factory_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def test_aimodel_1var(approach: str, func: str):
imps = model.importance_per_var()
assert_array_equal(imps, np.array([1.0]))


@enforce_types
#@pytest.mark.parametrize("approach", APPROACH_OPTIONS)
# @pytest.mark.parametrize("approach", APPROACH_OPTIONS)
@pytest.mark.parametrize("approach", ["ClassifLinearRidge", "RegrLinearRidge"])
def test_aimodel_2vars(approach: str):
# settings, factory
Expand Down Expand Up @@ -271,8 +272,6 @@ def test_aimodel_4vars_response(approach: str, target_n_classes: int):
assert min(imps) == max(imps) == 0.25




@enforce_types
@pytest.mark.parametrize("approach", ["RegrLinearRidge", "RegrConstant"])
def test_aimodel__regr_0error__via_10000x(approach):
Expand Down
4 changes: 0 additions & 4 deletions pdr_backend/cli/cli_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ def add_argument_APPROACH(self):
self.add_argument("APPROACH", type=int, help="1|2|..")



@enforce_types
class PPSS_Mixin:
def add_argument_PPSS(self):
self.add_argument("PPSS_FILE", type=str, help="PPSS yaml settings file")



# ========================================================================
# argparser base classes
class CustomArgParser(NestedArgParser):
Expand Down Expand Up @@ -89,7 +87,6 @@ def __init__(self, description: str, command_name: str):
self.add_arguments_bulk(command_name, ["APPROACH", "PPSS"])



# ========================================================================
# actual arg-parser implementations are just aliases to argparser base classes
# In order of help text.
Expand Down Expand Up @@ -128,7 +125,6 @@ def print_args(arguments: Namespace, nested_args: dict):
OHLCVArgParser = _ArgParser_PPSS



# below, list each entry in defined_parsers in same order as HELP_LONG
defined_parsers = {
"do_sim": SimArgParser("Run simulation", "sim"),
Expand Down
1 change: 0 additions & 1 deletion pdr_backend/cli/cli_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ def do_ohlcv(args, nested_args=None):
ohlcv_data_factory = OhlcvDataFactory(ppss.lake_ss)
df = ohlcv_data_factory.get_mergedohlcv_df()
print(df)

4 changes: 1 addition & 3 deletions pdr_backend/cli/test/test_cli_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
from pdr_backend.ppss.ppss import PPSS as PPSSClass


class _PPSS:
PPSS_FILE = os.path.abspath("ppss.yaml")

Expand All @@ -36,7 +37,6 @@ class MockArgs(Namespace, _PPSS, _PPSS_OBJ):
return MockArgs()



_CLI_PATH = "pdr_backend.cli.cli_module"

# ===============================================================
Expand Down Expand Up @@ -65,8 +65,6 @@ def test_do_ohlcv(monkeypatch):
mock_f.assert_called()




@enforce_types
def test_do_main(capfd):
with patch("sys.argv", ["pdr", "help"]):
Expand Down
3 changes: 1 addition & 2 deletions pdr_backend/lake/ohlcv_data_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_mergedohlcv_df(self) -> pl.DataFrame:
"Cumulative Ticks",
]
df = rawohlcv_dfs[str(feed.exchange)][str(feed.pair)]

mergedohlcv_df = merge_rawohlcv_dfs(rawohlcv_dfs)
logger.info("Get historical data, across many exchanges & pairs: done.")

Expand Down Expand Up @@ -284,4 +284,3 @@ def _volbar_filename(self, feed: ArgFeed) -> str:
basename = f"volume_bar_{feed.exchange}_{pair_str}.parquet"
filename = os.path.join(self.ss.lake_dir, basename)
return filename

2 changes: 1 addition & 1 deletion pdr_backend/lake/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from pdr_backend.lake.csv_data_store import CSVDataStore


@pytest.fixture()
def _get_test_CSVDataStore():
def create_csv_datastore_identifier(tmpdir, name):
return CSVDataStore(tmpdir, name)

return create_csv_datastore_identifier

1 change: 0 additions & 1 deletion pdr_backend/lake/test/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,3 @@ def _addval(DATA: list, val: float) -> list:
4|40.4|41.4
"""
)

1 change: 0 additions & 1 deletion pdr_backend/ppss/lake_ss.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def fin_timestamp(self) -> UnixTimeMs:
"""
return UnixTimeMs.from_timestr(self.fin_timestr)


@enforce_types
def __str__(self) -> str:
s = "LakeSS:\n"
Expand Down
2 changes: 1 addition & 1 deletion pdr_backend/ppss/ppss.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __str__(self):
s += f"predictoor_ss={self.predictoor_ss}\n"
s += f"trader_ss={self.trader_ss}\n"
s += f"exchange_mgr_ss={self.exchange_mgr_ss}\n"

return s


Expand Down
1 change: 1 addition & 0 deletions pdr_backend/ppss/predictoor_ss.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pdr_backend.subgraph.subgraph_feed import SubgraphFeed
from pdr_backend.util.strutil import StrMixin


class PredictoorSS(StrMixin):
__STR_OBJDIR__ = ["d"]

Expand Down
9 changes: 4 additions & 5 deletions pdr_backend/sim/sim_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def run_one_iter(self, test_i: int, mergedohlcv_df: pl.DataFrame):
recent_ut = UnixTimeMs(int(mergedohlcv_df["timestamp"].to_list()[-1]))
timeframe: ArgTimeframe = predict_feed.timeframe # type: ignore
ut = UnixTimeMs(recent_ut - testshift * timeframe.ms)

# predict price direction
prob_up: float = self.model.predict_ptrue(X_test)[0] # in [0.0, 1.0]
prob_down: float = 1.0 - prob_up
Expand All @@ -157,7 +157,7 @@ def run_one_iter(self, test_i: int, mergedohlcv_df: pl.DataFrame):

# observe true price
true_up = next_close > cur_close

# update state
st.probs_up.append(prob_up)
st.profits.append(profit)
Expand All @@ -175,15 +175,14 @@ def _log_line(self, test_i, ut):
s += " ║"

s += f" prob_up={self.st.probs_up[-1]:.3f}"

s += " ║"

s += f" tdr_profit=${self.st.profits[-1]:6.2f}"
s += f" (cumul ${sum(self.st.profits):6.2f})"

logger.info(s)


@enforce_types
def save_state(self, i: int, N: int):
"Save state on this iteration Y/N?"
Expand Down
4 changes: 2 additions & 2 deletions pdr_backend/sim/sim_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from enforce_typing import enforce_types


# pylint: disable=too-many-instance-attributes
@enforce_types
class SimState:
Expand All @@ -27,10 +28,9 @@ def recent_metrics(
) -> List[Union[int, float]]:
"""Return most recent aimodel metrics + profit metrics"""
rm = {
"profit": self.profits[-1],
"profit": self.profits[-1],
}
if extras and "prob_up" in extras:
rm["prob_up"] = self.probs_up[-1]

return rm

1 change: 0 additions & 1 deletion pdr_backend/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
CAND_USDCOINS = ["USDT", "USDC", "DAI", "RAI", "USD"] # add more if needed
CAND_TIMEFRAMES = ["1s", "30s", "1m", "5m", "15m", "30m", "1h", "1d", "1w", "1M"]
CHAR_TO_SIGNAL = {"o": "open", "h": "high", "l": "low", "c": "close", "v": "volume"}

0 comments on commit 5ec0bab

Please sign in to comment.