prosperity3bt 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prosperity3bt/__init__.py +0 -0
- prosperity3bt/__main__.py +302 -0
- prosperity3bt/data.py +125 -0
- prosperity3bt/datamodel.py +153 -0
- prosperity3bt/file_reader.py +44 -0
- prosperity3bt/models.py +103 -0
- prosperity3bt/resources/__init__.py +0 -0
- prosperity3bt/resources/round0/__init__.py +0 -0
- prosperity3bt/resources/round0/prices_round_0_day_-2.csv +4001 -0
- prosperity3bt/resources/round0/trades_round_0_day_-2_nn.csv +1089 -0
- prosperity3bt/runner.py +303 -0
- prosperity3bt-0.1.0.dist-info/LICENSE +21 -0
- prosperity3bt-0.1.0.dist-info/METADATA +129 -0
- prosperity3bt-0.1.0.dist-info/RECORD +17 -0
- prosperity3bt-0.1.0.dist-info/WHEEL +5 -0
- prosperity3bt-0.1.0.dist-info/entry_points.txt +2 -0
- prosperity3bt-0.1.0.dist-info/top_level.txt +1 -0
prosperity3bt/models.py
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
from dataclasses import dataclass
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
import orjson
|
5
|
+
|
6
|
+
from prosperity3bt.datamodel import Trade
|
7
|
+
|
8
|
+
|
9
|
+
@dataclass
|
10
|
+
class SandboxLogRow:
|
11
|
+
timestamp: int
|
12
|
+
sandbox_log: str
|
13
|
+
lambda_log: str
|
14
|
+
|
15
|
+
def with_offset(self, timestamp_offset: int) -> "SandboxLogRow":
|
16
|
+
return SandboxLogRow(
|
17
|
+
self.timestamp + timestamp_offset,
|
18
|
+
self.sandbox_log,
|
19
|
+
self.lambda_log.replace(f"[[{self.timestamp},", f"[[{self.timestamp + timestamp_offset},"),
|
20
|
+
)
|
21
|
+
|
22
|
+
def __str__(self) -> str:
|
23
|
+
return orjson.dumps(
|
24
|
+
{
|
25
|
+
"sandboxLog": self.sandbox_log,
|
26
|
+
"lambdaLog": self.lambda_log,
|
27
|
+
"timestamp": self.timestamp,
|
28
|
+
},
|
29
|
+
option=orjson.OPT_APPEND_NEWLINE | orjson.OPT_INDENT_2,
|
30
|
+
).decode("utf-8")
|
31
|
+
|
32
|
+
|
33
|
+
@dataclass
|
34
|
+
class ActivityLogRow:
|
35
|
+
columns: list[Any]
|
36
|
+
|
37
|
+
@property
|
38
|
+
def timestamp(self) -> int:
|
39
|
+
return self.columns[1]
|
40
|
+
|
41
|
+
def with_offset(self, timestamp_offset: int, profit_loss_offset: float) -> "ActivityLogRow":
|
42
|
+
new_columns = self.columns[:]
|
43
|
+
new_columns[1] += timestamp_offset
|
44
|
+
new_columns[-1] += profit_loss_offset
|
45
|
+
|
46
|
+
return ActivityLogRow(new_columns)
|
47
|
+
|
48
|
+
def __str__(self) -> str:
|
49
|
+
return ";".join(map(str, self.columns))
|
50
|
+
|
51
|
+
|
52
|
+
@dataclass
|
53
|
+
class TradeRow:
|
54
|
+
trade: Trade
|
55
|
+
|
56
|
+
@property
|
57
|
+
def timestamp(self) -> int:
|
58
|
+
return self.trade.timestamp
|
59
|
+
|
60
|
+
def with_offset(self, timestamp_offset: int) -> "TradeRow":
|
61
|
+
return TradeRow(
|
62
|
+
Trade(
|
63
|
+
self.trade.symbol,
|
64
|
+
self.trade.price,
|
65
|
+
self.trade.quantity,
|
66
|
+
self.trade.buyer,
|
67
|
+
self.trade.seller,
|
68
|
+
self.trade.timestamp + timestamp_offset,
|
69
|
+
)
|
70
|
+
)
|
71
|
+
|
72
|
+
def __str__(self) -> str:
|
73
|
+
return (
|
74
|
+
" "
|
75
|
+
+ f"""
|
76
|
+
{{
|
77
|
+
"timestamp": {self.trade.timestamp},
|
78
|
+
"buyer": "{self.trade.buyer}",
|
79
|
+
"seller": "{self.trade.seller}",
|
80
|
+
"symbol": "{self.trade.symbol}",
|
81
|
+
"currency": "SEASHELLS",
|
82
|
+
"price": {self.trade.price},
|
83
|
+
"quantity": {self.trade.quantity},
|
84
|
+
}}
|
85
|
+
""".strip()
|
86
|
+
)
|
87
|
+
|
88
|
+
|
89
|
+
@dataclass
|
90
|
+
class BacktestResult:
|
91
|
+
round_num: int
|
92
|
+
day_num: int
|
93
|
+
|
94
|
+
sandbox_logs: list[SandboxLogRow]
|
95
|
+
activity_logs: list[ActivityLogRow]
|
96
|
+
trades: list[TradeRow]
|
97
|
+
|
98
|
+
|
99
|
+
@dataclass
|
100
|
+
class MarketTrade:
|
101
|
+
trade: Trade
|
102
|
+
buy_quantity: int
|
103
|
+
sell_quantity: int
|
File without changes
|
File without changes
|