epsilab 0.1.0__tar.gz
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.
- epsilab-0.1.0/.gitignore +4 -0
- epsilab-0.1.0/LICENSE +201 -0
- epsilab-0.1.0/PKG-INFO +308 -0
- epsilab-0.1.0/README.md +92 -0
- epsilab-0.1.0/epsilab/__init__.py +6 -0
- epsilab-0.1.0/epsilab/__main__.py +40 -0
- epsilab-0.1.0/epsilab/client.py +155 -0
- epsilab-0.1.0/epsilab/exceptions.py +23 -0
- epsilab-0.1.0/epsilab/models.py +250 -0
- epsilab-0.1.0/examples/example.py +108 -0
- epsilab-0.1.0/pyproject.toml +40 -0
epsilab-0.1.0/.gitignore
ADDED
epsilab-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Epsilab
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
epsilab-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: epsilab
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for Epsilab live portfolio data (signals, weights, trades).
|
|
5
|
+
Project-URL: Homepage, https://www.epsilab.ai
|
|
6
|
+
Author: Epsilab
|
|
7
|
+
License: Apache License
|
|
8
|
+
Version 2.0, January 2004
|
|
9
|
+
http://www.apache.org/licenses/
|
|
10
|
+
|
|
11
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
12
|
+
|
|
13
|
+
1. Definitions.
|
|
14
|
+
|
|
15
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
16
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
17
|
+
|
|
18
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
19
|
+
the copyright owner that is granting the License.
|
|
20
|
+
|
|
21
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
22
|
+
other entities that control, are controlled by, or are under common
|
|
23
|
+
control with that entity. For the purposes of this definition,
|
|
24
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
25
|
+
direction or management of such entity, whether by contract or
|
|
26
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
27
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
28
|
+
|
|
29
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
30
|
+
exercising permissions granted by this License.
|
|
31
|
+
|
|
32
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
33
|
+
including but not limited to software source code, documentation
|
|
34
|
+
source, and configuration files.
|
|
35
|
+
|
|
36
|
+
"Object" form shall mean any form resulting from mechanical
|
|
37
|
+
transformation or translation of a Source form, including but
|
|
38
|
+
not limited to compiled object code, generated documentation,
|
|
39
|
+
and conversions to other media types.
|
|
40
|
+
|
|
41
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
42
|
+
Object form, made available under the License, as indicated by a
|
|
43
|
+
copyright notice that is included in or attached to the work
|
|
44
|
+
(an example is provided in the Appendix below).
|
|
45
|
+
|
|
46
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
47
|
+
form, that is based on (or derived from) the Work and for which the
|
|
48
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
49
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
50
|
+
of this License, Derivative Works shall not include works that remain
|
|
51
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
52
|
+
the Work and Derivative Works thereof.
|
|
53
|
+
|
|
54
|
+
"Contribution" shall mean any work of authorship, including
|
|
55
|
+
the original version of the Work and any modifications or additions
|
|
56
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
57
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
58
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
59
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
60
|
+
means any form of electronic, verbal, or written communication sent
|
|
61
|
+
to the Licensor or its representatives, including but not limited to
|
|
62
|
+
communication on electronic mailing lists, source code control systems,
|
|
63
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
64
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
65
|
+
excluding communication that is conspicuously marked or otherwise
|
|
66
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
67
|
+
|
|
68
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
69
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
70
|
+
subsequently incorporated within the Work.
|
|
71
|
+
|
|
72
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
73
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
74
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
75
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
76
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
77
|
+
Work and such Derivative Works in Source or Object form.
|
|
78
|
+
|
|
79
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
80
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
81
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
82
|
+
(except as stated in this section) patent license to make, have made,
|
|
83
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
84
|
+
where such license applies only to those patent claims licensable
|
|
85
|
+
by such Contributor that are necessarily infringed by their
|
|
86
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
87
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
88
|
+
institute patent litigation against any entity (including a
|
|
89
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
90
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
91
|
+
or contributory patent infringement, then any patent licenses
|
|
92
|
+
granted to You under this License for that Work shall terminate
|
|
93
|
+
as of the date such litigation is filed.
|
|
94
|
+
|
|
95
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
96
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
97
|
+
modifications, and in Source or Object form, provided that You
|
|
98
|
+
meet the following conditions:
|
|
99
|
+
|
|
100
|
+
(a) You must give any other recipients of the Work or
|
|
101
|
+
Derivative Works a copy of this License; and
|
|
102
|
+
|
|
103
|
+
(b) You must cause any modified files to carry prominent notices
|
|
104
|
+
stating that You changed the files; and
|
|
105
|
+
|
|
106
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
107
|
+
that You distribute, all copyright, patent, trademark, and
|
|
108
|
+
attribution notices from the Source form of the Work,
|
|
109
|
+
excluding those notices that do not pertain to any part of
|
|
110
|
+
the Derivative Works; and
|
|
111
|
+
|
|
112
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
113
|
+
distribution, then any Derivative Works that You distribute must
|
|
114
|
+
include a readable copy of the attribution notices contained
|
|
115
|
+
within such NOTICE file, excluding those notices that do not
|
|
116
|
+
pertain to any part of the Derivative Works, in at least one
|
|
117
|
+
of the following places: within a NOTICE text file distributed
|
|
118
|
+
as part of the Derivative Works; within the Source form or
|
|
119
|
+
documentation, if provided along with the Derivative Works; or,
|
|
120
|
+
within a display generated by the Derivative Works, if and
|
|
121
|
+
wherever such third-party notices normally appear. The contents
|
|
122
|
+
of the NOTICE file are for informational purposes only and
|
|
123
|
+
do not modify the License. You may add Your own attribution
|
|
124
|
+
notices within Derivative Works that You distribute, alongside
|
|
125
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
126
|
+
that such additional attribution notices cannot be construed
|
|
127
|
+
as modifying the License.
|
|
128
|
+
|
|
129
|
+
You may add Your own copyright statement to Your modifications and
|
|
130
|
+
may provide additional or different license terms and conditions
|
|
131
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
132
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
133
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
134
|
+
the conditions stated in this License.
|
|
135
|
+
|
|
136
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
137
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
138
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
139
|
+
this License, without any additional terms or conditions.
|
|
140
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
141
|
+
the terms of any separate license agreement you may have executed
|
|
142
|
+
with Licensor regarding such Contributions.
|
|
143
|
+
|
|
144
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
145
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
146
|
+
except as required for reasonable and customary use in describing the
|
|
147
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
148
|
+
|
|
149
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
150
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
151
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
152
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
153
|
+
implied, including, without limitation, any warranties or conditions
|
|
154
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
155
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
156
|
+
appropriateness of using or redistributing the Work and assume any
|
|
157
|
+
risks associated with Your exercise of permissions under this License.
|
|
158
|
+
|
|
159
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
160
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
161
|
+
unless required by applicable law (such as deliberate and grossly
|
|
162
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
163
|
+
liable to You for damages, including any direct, indirect, special,
|
|
164
|
+
incidental, or consequential damages of any character arising as a
|
|
165
|
+
result of this License or out of the use or inability to use the
|
|
166
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
167
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
168
|
+
other commercial damages or losses), even if such Contributor
|
|
169
|
+
has been advised of the possibility of such damages.
|
|
170
|
+
|
|
171
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
172
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
173
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
174
|
+
or other liability obligations and/or rights consistent with this
|
|
175
|
+
License. However, in accepting such obligations, You may act only
|
|
176
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
177
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
178
|
+
defend, and hold each Contributor harmless for any liability
|
|
179
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
180
|
+
of your accepting any such warranty or additional liability.
|
|
181
|
+
|
|
182
|
+
END OF TERMS AND CONDITIONS
|
|
183
|
+
|
|
184
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
185
|
+
|
|
186
|
+
To apply the Apache License to your work, attach the following
|
|
187
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
188
|
+
replaced with your own identifying information. (Don't include
|
|
189
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
190
|
+
comment syntax for the file format. We also recommend that a
|
|
191
|
+
file or class name and description of purpose be included on the
|
|
192
|
+
same "printed page" as the copyright notice for easier
|
|
193
|
+
identification within third-party archives.
|
|
194
|
+
|
|
195
|
+
Copyright 2025 Epsilab
|
|
196
|
+
|
|
197
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
198
|
+
you may not use this file except in compliance with the License.
|
|
199
|
+
You may obtain a copy of the License at
|
|
200
|
+
|
|
201
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
202
|
+
|
|
203
|
+
Unless required by applicable law or agreed to in writing, software
|
|
204
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
205
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
206
|
+
See the License for the specific language governing permissions and
|
|
207
|
+
limitations under the License.
|
|
208
|
+
License-File: LICENSE
|
|
209
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
210
|
+
Classifier: Operating System :: OS Independent
|
|
211
|
+
Classifier: Programming Language :: Python :: 3
|
|
212
|
+
Requires-Python: >=3.9
|
|
213
|
+
Requires-Dist: httpx>=0.27.0
|
|
214
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
215
|
+
Description-Content-Type: text/markdown
|
|
216
|
+
|
|
217
|
+
# Epsilab Python SDK
|
|
218
|
+
|
|
219
|
+
Minimal Python client and CLI for the Epsilab Website API (pass-through to Strategy-Engine). Auth uses an API key.
|
|
220
|
+
|
|
221
|
+
## Install
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
pip install epsilab
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Install from source
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
cd /home/matthew/Epsilab/Epsilab-API
|
|
231
|
+
python -m venv .venv && source .venv/bin/activate
|
|
232
|
+
pip install --upgrade pip
|
|
233
|
+
pip install .
|
|
234
|
+
# or for development
|
|
235
|
+
pip install -e .
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Environment
|
|
239
|
+
|
|
240
|
+
Set these variables or pass explicitly to the client:
|
|
241
|
+
|
|
242
|
+
- `EPSILAB_API_BASE` (default `https://www.epsilab.ai/api/ext/v1`)
|
|
243
|
+
- `EPSILAB_API_KEY` (a user API key created in Account Settings)
|
|
244
|
+
|
|
245
|
+
Note:
|
|
246
|
+
- API access requires an active Pro subscription. Requests from accounts without Pro will be rejected.
|
|
247
|
+
- Live endpoints are rate limited (e.g., ~1 request/second sustained with small bursts). Excessive requests will receive HTTP 429.
|
|
248
|
+
- Use `nextEtaMin` from `get_live_status()` to poll intelligently. For example, if `nextEtaMin=80.07`, you can sleep ~80 minutes before the next refresh instead of tight-loop polling. The results will be the same.
|
|
249
|
+
|
|
250
|
+
## Python Usage
|
|
251
|
+
|
|
252
|
+
```python
|
|
253
|
+
from epsilab import Epsilab
|
|
254
|
+
|
|
255
|
+
client = Epsilab(api_base="https://www.epsilab.ai/api/ext/v1", api_key="<epsk_live_...>")
|
|
256
|
+
|
|
257
|
+
# Note: Running the portfolio via API key is disabled. Use the website to initiate runs.
|
|
258
|
+
|
|
259
|
+
# Fetch live data (typed models)
|
|
260
|
+
latest = client.get_live_latest(return_results_if_fresh=True) # epsilab.models.LiveLatest
|
|
261
|
+
status = client.get_live_status() # epsilab.models.LiveStatus
|
|
262
|
+
signals = client.get_portfolio_signals(limit=500) # List[epsilab.models.PortfolioSignal]
|
|
263
|
+
weights = client.get_portfolio_weights(limit=500) # List[epsilab.models.PortfolioWeight]
|
|
264
|
+
trades = client.get_live_trades(status="PENDING,EXECUTED", include_positions=True) # List[epsilab.models.PortfolioTrade]
|
|
265
|
+
equity = client.get_live_equity(limit=200) # List[epsilab.models.EquityPoint]
|
|
266
|
+
|
|
267
|
+
print(latest)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## CLI Usage
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Set API key in env
|
|
274
|
+
export EPSILAB_API_KEY="<epsk_live_...>"
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Data models
|
|
278
|
+
|
|
279
|
+
- `get_live_latest()` → `LiveLatest` with fields:
|
|
280
|
+
- `run_id: Optional[str]`
|
|
281
|
+
- `timeframe: Optional[str]`
|
|
282
|
+
- `signals: List[PortfolioSignal]`
|
|
283
|
+
- `weights: List[PortfolioWeight]`
|
|
284
|
+
- `fresh: Optional[bool]`
|
|
285
|
+
- `recomputed: Optional[bool]`
|
|
286
|
+
|
|
287
|
+
- `get_live_status()` → `LiveStatus` with fields:
|
|
288
|
+
- `latest_run_id: Optional[str]`
|
|
289
|
+
- `timeframe: Optional[str]`
|
|
290
|
+
- `next_eta_minutes: Optional[float]`
|
|
291
|
+
- `counts: Dict[str, int]`
|
|
292
|
+
|
|
293
|
+
- `get_portfolio_signals()` → `List[PortfolioSignal]` with fields:
|
|
294
|
+
- `symbol: str`, `signal_type: str`, `strength: Optional[float]`, `timestamp: Optional[str]`, `date: Optional[str]`
|
|
295
|
+
|
|
296
|
+
- `get_portfolio_weights()` → `List[PortfolioWeight]` with fields:
|
|
297
|
+
- `symbol: str`, `final_weight: Optional[float]`, `raw_weight: Optional[float]`, `timestamp: Optional[str]`, `date: Optional[str]`
|
|
298
|
+
|
|
299
|
+
- `get_live_trades()` → `List[PortfolioTrade]` with fields:
|
|
300
|
+
- `id: str`, `symbol: str`, `side: str`, `qty: Optional[float]`, `planned_price: Optional[float]`, `planned_at: Optional[str]`, `status: str`, `reasoning: Optional[str]`
|
|
301
|
+
|
|
302
|
+
- `get_live_members()` → `List[PortfolioMember]` with fields:
|
|
303
|
+
- `strategy_id: str`, `effective_weight: Optional[float]`, `name: Optional[str]`, `visibility: Optional[str]`
|
|
304
|
+
|
|
305
|
+
- `get_live_equity()` → `List[EquityPoint]` with fields:
|
|
306
|
+
- `date: str`, `value: float`
|
|
307
|
+
|
|
308
|
+
All models expose `to_dict()`, `to_json()`, and `log()` helpers for convenient logging.
|
epsilab-0.1.0/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Epsilab Python SDK
|
|
2
|
+
|
|
3
|
+
Minimal Python client and CLI for the Epsilab Website API (pass-through to Strategy-Engine). Auth uses an API key.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install epsilab
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Install from source
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd /home/matthew/Epsilab/Epsilab-API
|
|
15
|
+
python -m venv .venv && source .venv/bin/activate
|
|
16
|
+
pip install --upgrade pip
|
|
17
|
+
pip install .
|
|
18
|
+
# or for development
|
|
19
|
+
pip install -e .
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Environment
|
|
23
|
+
|
|
24
|
+
Set these variables or pass explicitly to the client:
|
|
25
|
+
|
|
26
|
+
- `EPSILAB_API_BASE` (default `https://www.epsilab.ai/api/ext/v1`)
|
|
27
|
+
- `EPSILAB_API_KEY` (a user API key created in Account Settings)
|
|
28
|
+
|
|
29
|
+
Note:
|
|
30
|
+
- API access requires an active Pro subscription. Requests from accounts without Pro will be rejected.
|
|
31
|
+
- Live endpoints are rate limited (e.g., ~1 request/second sustained with small bursts). Excessive requests will receive HTTP 429.
|
|
32
|
+
- Use `nextEtaMin` from `get_live_status()` to poll intelligently. For example, if `nextEtaMin=80.07`, you can sleep ~80 minutes before the next refresh instead of tight-loop polling. The results will be the same.
|
|
33
|
+
|
|
34
|
+
## Python Usage
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from epsilab import Epsilab
|
|
38
|
+
|
|
39
|
+
client = Epsilab(api_base="https://www.epsilab.ai/api/ext/v1", api_key="<epsk_live_...>")
|
|
40
|
+
|
|
41
|
+
# Note: Running the portfolio via API key is disabled. Use the website to initiate runs.
|
|
42
|
+
|
|
43
|
+
# Fetch live data (typed models)
|
|
44
|
+
latest = client.get_live_latest(return_results_if_fresh=True) # epsilab.models.LiveLatest
|
|
45
|
+
status = client.get_live_status() # epsilab.models.LiveStatus
|
|
46
|
+
signals = client.get_portfolio_signals(limit=500) # List[epsilab.models.PortfolioSignal]
|
|
47
|
+
weights = client.get_portfolio_weights(limit=500) # List[epsilab.models.PortfolioWeight]
|
|
48
|
+
trades = client.get_live_trades(status="PENDING,EXECUTED", include_positions=True) # List[epsilab.models.PortfolioTrade]
|
|
49
|
+
equity = client.get_live_equity(limit=200) # List[epsilab.models.EquityPoint]
|
|
50
|
+
|
|
51
|
+
print(latest)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## CLI Usage
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Set API key in env
|
|
58
|
+
export EPSILAB_API_KEY="<epsk_live_...>"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Data models
|
|
62
|
+
|
|
63
|
+
- `get_live_latest()` → `LiveLatest` with fields:
|
|
64
|
+
- `run_id: Optional[str]`
|
|
65
|
+
- `timeframe: Optional[str]`
|
|
66
|
+
- `signals: List[PortfolioSignal]`
|
|
67
|
+
- `weights: List[PortfolioWeight]`
|
|
68
|
+
- `fresh: Optional[bool]`
|
|
69
|
+
- `recomputed: Optional[bool]`
|
|
70
|
+
|
|
71
|
+
- `get_live_status()` → `LiveStatus` with fields:
|
|
72
|
+
- `latest_run_id: Optional[str]`
|
|
73
|
+
- `timeframe: Optional[str]`
|
|
74
|
+
- `next_eta_minutes: Optional[float]`
|
|
75
|
+
- `counts: Dict[str, int]`
|
|
76
|
+
|
|
77
|
+
- `get_portfolio_signals()` → `List[PortfolioSignal]` with fields:
|
|
78
|
+
- `symbol: str`, `signal_type: str`, `strength: Optional[float]`, `timestamp: Optional[str]`, `date: Optional[str]`
|
|
79
|
+
|
|
80
|
+
- `get_portfolio_weights()` → `List[PortfolioWeight]` with fields:
|
|
81
|
+
- `symbol: str`, `final_weight: Optional[float]`, `raw_weight: Optional[float]`, `timestamp: Optional[str]`, `date: Optional[str]`
|
|
82
|
+
|
|
83
|
+
- `get_live_trades()` → `List[PortfolioTrade]` with fields:
|
|
84
|
+
- `id: str`, `symbol: str`, `side: str`, `qty: Optional[float]`, `planned_price: Optional[float]`, `planned_at: Optional[str]`, `status: str`, `reasoning: Optional[str]`
|
|
85
|
+
|
|
86
|
+
- `get_live_members()` → `List[PortfolioMember]` with fields:
|
|
87
|
+
- `strategy_id: str`, `effective_weight: Optional[float]`, `name: Optional[str]`, `visibility: Optional[str]`
|
|
88
|
+
|
|
89
|
+
- `get_live_equity()` → `List[EquityPoint]` with fields:
|
|
90
|
+
- `date: str`, `value: float`
|
|
91
|
+
|
|
92
|
+
All models expose `to_dict()`, `to_json()`, and `log()` helpers for convenient logging.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from dotenv import dotenv_values
|
|
6
|
+
from epsilab.client import EpsilabClient
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
# Read environment variables from .env (does not modify process env)
|
|
11
|
+
env = dotenv_values()
|
|
12
|
+
|
|
13
|
+
parser = argparse.ArgumentParser(prog="epsilab", description="Epsilab Strategy-Engine CLI")
|
|
14
|
+
sub = parser.add_subparsers(dest="cmd", required=True)
|
|
15
|
+
|
|
16
|
+
# run default portfolio
|
|
17
|
+
p_run = sub.add_parser("run-default-portfolio", help="Run user's default portfolio")
|
|
18
|
+
p_run.add_argument("--params", help="JSON dict of parameters to pass", default=None)
|
|
19
|
+
|
|
20
|
+
args = parser.parse_args()
|
|
21
|
+
|
|
22
|
+
client = EpsilabClient(
|
|
23
|
+
api_base=env.get("EPSILAB_API_BASE") or "https://www.epsilab.ai/api/ext/v1",
|
|
24
|
+
api_key=env.get("EPSILAB_API_KEY"),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
if args.cmd == "run-default-portfolio":
|
|
28
|
+
# Require API key
|
|
29
|
+
api_key = env.get("EPSILAB_API_KEY")
|
|
30
|
+
if api_key:
|
|
31
|
+
client.set_api_key(api_key)
|
|
32
|
+
if not client._api_key:
|
|
33
|
+
raise SystemExit("Not authenticated. Set EPSILAB_API_KEY.")
|
|
34
|
+
params = json.loads(args.params) if args.params else None
|
|
35
|
+
result = client.run_default_portfolio(params)
|
|
36
|
+
print(json.dumps(result, indent=2))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if __name__ == "__main__":
|
|
40
|
+
main()
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import httpx
|
|
3
|
+
from typing import Optional, Dict, Any, List
|
|
4
|
+
from dotenv import dotenv_values
|
|
5
|
+
from . import models
|
|
6
|
+
from .exceptions import AuthError, SubscriptionRequiredError, RateLimitError, ApiError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class EpsilabClient:
|
|
10
|
+
"""
|
|
11
|
+
Minimal Python client for the Epsilab Website API (pass-through to Strategy-Engine).
|
|
12
|
+
|
|
13
|
+
- Auth via API key sent as X-API-Key
|
|
14
|
+
- Persistent HTTP/2 connection via httpx.Client
|
|
15
|
+
- Targets the Website API base (e.g. https://www.epsilab.ai/api/ext/v1)
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
api_base: Optional[str] = None,
|
|
21
|
+
api_key: Optional[str] = None,
|
|
22
|
+
timeout_seconds: Optional[int] = None,
|
|
23
|
+
) -> None:
|
|
24
|
+
# Read variables from .env without mutating process env
|
|
25
|
+
env = {}
|
|
26
|
+
try:
|
|
27
|
+
env = dotenv_values()
|
|
28
|
+
except Exception:
|
|
29
|
+
env = {}
|
|
30
|
+
# Prefer Website API base (pass-through proxy). Example: https://www.epsilab.ai/api/ext/v1
|
|
31
|
+
self.api_base = (
|
|
32
|
+
(api_base or env.get("EPSILAB_API_BASE") or "https://www.epsilab.ai/api/ext/v1").rstrip("/")
|
|
33
|
+
)
|
|
34
|
+
# Default to 300s, can be overridden by param or env EPSILAB_HTTP_TIMEOUT
|
|
35
|
+
env_timeout = env.get("EPSILAB_HTTP_TIMEOUT")
|
|
36
|
+
self.timeout_seconds = (
|
|
37
|
+
int(timeout_seconds)
|
|
38
|
+
if timeout_seconds is not None
|
|
39
|
+
else int(env_timeout) if env_timeout else 300
|
|
40
|
+
)
|
|
41
|
+
# API key auth (preferred for service usage)
|
|
42
|
+
self._api_key: Optional[str] = api_key or env.get("EPSILAB_API_KEY")
|
|
43
|
+
# Persistent client (HTTP/2) with keep-alive
|
|
44
|
+
self._client = httpx.Client(base_url=self.api_base, timeout=self._make_timeout(), http2=True)
|
|
45
|
+
# Apply auth headers if present
|
|
46
|
+
if self._api_key:
|
|
47
|
+
self._client.headers.update({"X-API-Key": self._api_key})
|
|
48
|
+
|
|
49
|
+
def _make_timeout(self) -> httpx.Timeout:
|
|
50
|
+
# Longer read timeout for long-running operations; moderate connects/writes
|
|
51
|
+
return httpx.Timeout(read=float(self.timeout_seconds), connect=30.0, write=30.0, pool=60.0)
|
|
52
|
+
|
|
53
|
+
def _request(self, method: str, path: str, *, params: Optional[Dict[str, Any]] = None, json: Optional[Dict[str, Any]] = None) -> httpx.Response:
|
|
54
|
+
rel = path.lstrip("/")
|
|
55
|
+
resp = self._client.request(method.upper(), rel, params=params, json=json)
|
|
56
|
+
# Central error mapping
|
|
57
|
+
if resp.status_code >= 400:
|
|
58
|
+
msg = resp.text
|
|
59
|
+
if resp.status_code in (401, 403):
|
|
60
|
+
raise AuthError(msg)
|
|
61
|
+
if resp.status_code == 402:
|
|
62
|
+
raise SubscriptionRequiredError("Pro plan required for API access")
|
|
63
|
+
if resp.status_code == 429:
|
|
64
|
+
retry_after = None
|
|
65
|
+
try:
|
|
66
|
+
ra = resp.headers.get("Retry-After")
|
|
67
|
+
retry_after = float(ra) if ra is not None else None
|
|
68
|
+
except Exception:
|
|
69
|
+
retry_after = None
|
|
70
|
+
raise RateLimitError("Rate limit exceeded", retry_after)
|
|
71
|
+
raise ApiError(f"API error {resp.status_code}: {msg}")
|
|
72
|
+
return resp
|
|
73
|
+
|
|
74
|
+
# Context manager support for deterministic close
|
|
75
|
+
def close(self) -> None:
|
|
76
|
+
try:
|
|
77
|
+
self._client.close()
|
|
78
|
+
except Exception:
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
def __enter__(self):
|
|
82
|
+
return self
|
|
83
|
+
|
|
84
|
+
def __exit__(self, exc_type, exc, tb):
|
|
85
|
+
self.close()
|
|
86
|
+
|
|
87
|
+
# -----------------------------
|
|
88
|
+
# Authentication helpers
|
|
89
|
+
# -----------------------------
|
|
90
|
+
def set_api_key(self, api_key: str) -> None:
|
|
91
|
+
"""Use a per-user API key (recommended for headless/service clients)."""
|
|
92
|
+
self._api_key = api_key
|
|
93
|
+
self._client.headers.update({"X-API-Key": api_key})
|
|
94
|
+
|
|
95
|
+
# -----------------------------
|
|
96
|
+
# Strategy-Engine API: Live Portfolio
|
|
97
|
+
# -----------------------------
|
|
98
|
+
|
|
99
|
+
def get_live_latest(self, *, force: bool = False, tolerance_minutes: Optional[int] = None, return_results_if_fresh: bool = False) -> models.LiveLatest:
|
|
100
|
+
if not self._api_key:
|
|
101
|
+
raise RuntimeError("Not authenticated. Set EPSILAB_API_KEY or call set_api_key().")
|
|
102
|
+
params: Dict[str, Any] = {"force": force, "return_results_if_fresh": return_results_if_fresh}
|
|
103
|
+
if tolerance_minutes is not None:
|
|
104
|
+
params["tolerance_minutes"] = int(tolerance_minutes)
|
|
105
|
+
resp = self._request("GET", "api/portfolio/live/latest", params=params)
|
|
106
|
+
return models.parse_live_latest(resp.json())
|
|
107
|
+
|
|
108
|
+
def get_live_status(self) -> models.LiveStatus:
|
|
109
|
+
if not self._api_key:
|
|
110
|
+
raise RuntimeError("Not authenticated. Set EPSILAB_API_KEY or call set_api_key().")
|
|
111
|
+
resp = self._request("GET", "api/portfolio/live/status")
|
|
112
|
+
return models.LiveStatus.from_dict(resp.json())
|
|
113
|
+
|
|
114
|
+
def get_live_trades(self, *, status: Optional[str] = None, include_positions: bool = False, limit: int = 100) -> List[models.PortfolioTrade]:
|
|
115
|
+
if not self._api_key:
|
|
116
|
+
raise RuntimeError("Not authenticated. Set EPSILAB_API_KEY or call set_api_key().")
|
|
117
|
+
params: Dict[str, Any] = {"limit": int(limit), "include_positions": bool(include_positions)}
|
|
118
|
+
if status:
|
|
119
|
+
params["status"] = status
|
|
120
|
+
resp = self._request("GET", "api/portfolio/live/trades", params=params)
|
|
121
|
+
return models.parse_trades(resp.json())
|
|
122
|
+
|
|
123
|
+
def get_live_members(self, *, run_id: Optional[str] = None) -> List[models.PortfolioMember]:
|
|
124
|
+
if not self._api_key:
|
|
125
|
+
raise RuntimeError("Not authenticated. Set EPSILAB_API_KEY or call set_api_key().")
|
|
126
|
+
params: Dict[str, Any] = {}
|
|
127
|
+
if run_id:
|
|
128
|
+
params["run_id"] = run_id
|
|
129
|
+
resp = self._request("GET", "api/portfolio/live/members", params=params)
|
|
130
|
+
return models.parse_members(resp.json())
|
|
131
|
+
|
|
132
|
+
def get_live_equity(self, *, limit: int = 200) -> List[models.EquityPoint]:
|
|
133
|
+
if not self._api_key:
|
|
134
|
+
raise RuntimeError("Not authenticated. Set EPSILAB_API_KEY or call set_api_key().")
|
|
135
|
+
params = {"limit": int(limit)}
|
|
136
|
+
resp = self._request("GET", "api/portfolio/live/equity", params=params)
|
|
137
|
+
return models.parse_equity(resp.json())
|
|
138
|
+
|
|
139
|
+
def get_portfolio_signals(self, *, run_id: Optional[str] = None, limit: int = 1000, offset: int = 0) -> List[models.PortfolioSignal]:
|
|
140
|
+
if not self._api_key:
|
|
141
|
+
raise RuntimeError("Not authenticated. Set EPSILAB_API_KEY or call set_api_key().")
|
|
142
|
+
params: Dict[str, Any] = {"limit": int(limit), "offset": int(offset)}
|
|
143
|
+
if run_id:
|
|
144
|
+
params["run_id"] = run_id
|
|
145
|
+
resp = self._request("GET", "api/portfolio/signals", params=params)
|
|
146
|
+
return models.parse_signals(resp.json())
|
|
147
|
+
|
|
148
|
+
def get_portfolio_weights(self, *, run_id: Optional[str] = None, limit: int = 1000, offset: int = 0) -> List[models.PortfolioWeight]:
|
|
149
|
+
if not self._api_key:
|
|
150
|
+
raise RuntimeError("Not authenticated. Set EPSILAB_API_KEY or call set_api_key().")
|
|
151
|
+
params: Dict[str, Any] = {"limit": int(limit), "offset": int(offset)}
|
|
152
|
+
if run_id:
|
|
153
|
+
params["run_id"] = run_id
|
|
154
|
+
resp = self._request("GET", "api/portfolio/weights", params=params)
|
|
155
|
+
return models.parse_weights(resp.json())
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class EpsilabError(Exception):
|
|
2
|
+
"""Base exception for Epsilab SDK."""
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AuthError(EpsilabError):
|
|
6
|
+
"""Authentication or authorization failed (HTTP 401/403)."""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SubscriptionRequiredError(EpsilabError):
|
|
10
|
+
"""Subscription is required (HTTP 402)."""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class RateLimitError(EpsilabError):
|
|
14
|
+
"""Rate limit exceeded (HTTP 429)."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, message: str, retry_after: float | None = None) -> None:
|
|
17
|
+
super().__init__(message)
|
|
18
|
+
self.retry_after = retry_after
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ApiError(EpsilabError):
|
|
22
|
+
"""Generic API error (any other 4xx/5xx)."""
|
|
23
|
+
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, asdict
|
|
4
|
+
from typing import Any, Dict, List, Optional
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class PortfolioSignal:
|
|
10
|
+
symbol: str
|
|
11
|
+
signal_type: str
|
|
12
|
+
strength: Optional[float] = None
|
|
13
|
+
timestamp: Optional[str] = None
|
|
14
|
+
date: Optional[str] = None
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def from_dict(d: Dict[str, Any]) -> "PortfolioSignal":
|
|
18
|
+
return PortfolioSignal(
|
|
19
|
+
symbol=str(d.get("symbol") or ""),
|
|
20
|
+
signal_type=str(d.get("signalType") or d.get("signal_type") or d.get("type") or "").upper(),
|
|
21
|
+
strength=(None if d.get("strength") is None else float(d.get("strength"))),
|
|
22
|
+
timestamp=(d.get("signalTimestamp") or d.get("signal_timestamp")),
|
|
23
|
+
date=(d.get("signalDate") or d.get("signal_date")),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
27
|
+
return asdict(self)
|
|
28
|
+
|
|
29
|
+
def to_json(self) -> str:
|
|
30
|
+
return json.dumps(self.to_dict(), separators=(",", ":"))
|
|
31
|
+
|
|
32
|
+
def log(self) -> str:
|
|
33
|
+
base = f"{self.symbol} {self.signal_type}"
|
|
34
|
+
if self.strength is not None:
|
|
35
|
+
base += f" {self.strength}"
|
|
36
|
+
return base
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass
|
|
40
|
+
class PortfolioWeight:
|
|
41
|
+
symbol: str
|
|
42
|
+
final_weight: Optional[float] = None
|
|
43
|
+
raw_weight: Optional[float] = None
|
|
44
|
+
timestamp: Optional[str] = None
|
|
45
|
+
date: Optional[str] = None
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def from_dict(d: Dict[str, Any]) -> "PortfolioWeight":
|
|
49
|
+
return PortfolioWeight(
|
|
50
|
+
symbol=str(d.get("symbol") or ""),
|
|
51
|
+
final_weight=(None if d.get("final_weight") is None else float(d.get("final_weight"))),
|
|
52
|
+
raw_weight=(None if d.get("raw_weight") is None else float(d.get("raw_weight"))),
|
|
53
|
+
timestamp=(d.get("weightTimestamp") or d.get("weight_timestamp")),
|
|
54
|
+
date=(d.get("weightDate") or d.get("weight_date")),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
58
|
+
return asdict(self)
|
|
59
|
+
|
|
60
|
+
def to_json(self) -> str:
|
|
61
|
+
return json.dumps(self.to_dict(), separators=(",", ":"))
|
|
62
|
+
|
|
63
|
+
def log(self) -> str:
|
|
64
|
+
val = self.final_weight if self.final_weight is not None else self.raw_weight
|
|
65
|
+
return f"{self.symbol}:{val}"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass
|
|
69
|
+
class PortfolioTrade:
|
|
70
|
+
id: str
|
|
71
|
+
symbol: str
|
|
72
|
+
side: str
|
|
73
|
+
qty: Optional[float]
|
|
74
|
+
planned_price: Optional[float]
|
|
75
|
+
planned_at: Optional[str]
|
|
76
|
+
status: str
|
|
77
|
+
reasoning: Optional[str]
|
|
78
|
+
|
|
79
|
+
@staticmethod
|
|
80
|
+
def from_dict(d: Dict[str, Any]) -> "PortfolioTrade":
|
|
81
|
+
return PortfolioTrade(
|
|
82
|
+
id=str(d.get("id") or ""),
|
|
83
|
+
symbol=str(d.get("symbol") or ""),
|
|
84
|
+
side=str(d.get("side") or "").upper(),
|
|
85
|
+
qty=(None if d.get("qty") is None else float(d.get("qty"))),
|
|
86
|
+
planned_price=(None if d.get("planned_price") is None else float(d.get("planned_price"))),
|
|
87
|
+
planned_at=(d.get("planned_at") or None),
|
|
88
|
+
status=str(d.get("status") or "").upper(),
|
|
89
|
+
reasoning=d.get("reasoning"),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
93
|
+
return asdict(self)
|
|
94
|
+
|
|
95
|
+
def to_json(self) -> str:
|
|
96
|
+
return json.dumps(self.to_dict(), separators=(",", ":"))
|
|
97
|
+
|
|
98
|
+
def log(self) -> str:
|
|
99
|
+
return f"{self.symbol} {self.side} {self.status} x{self.qty}"
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@dataclass
|
|
103
|
+
class PortfolioMember:
|
|
104
|
+
strategy_id: str
|
|
105
|
+
effective_weight: Optional[float]
|
|
106
|
+
name: Optional[str] = None
|
|
107
|
+
visibility: Optional[str] = None
|
|
108
|
+
|
|
109
|
+
@staticmethod
|
|
110
|
+
def from_dict(d: Dict[str, Any]) -> "PortfolioMember":
|
|
111
|
+
return PortfolioMember(
|
|
112
|
+
strategy_id=str(d.get("strategy_id") or ""),
|
|
113
|
+
effective_weight=(None if d.get("effective_weight") is None else float(d.get("effective_weight"))),
|
|
114
|
+
name=d.get("name"),
|
|
115
|
+
visibility=d.get("visibility"),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
119
|
+
return asdict(self)
|
|
120
|
+
|
|
121
|
+
def to_json(self) -> str:
|
|
122
|
+
return json.dumps(self.to_dict(), separators=(",", ":"))
|
|
123
|
+
|
|
124
|
+
def log(self) -> str:
|
|
125
|
+
return f"{self.name or self.strategy_id}:{self.effective_weight}"
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@dataclass
|
|
129
|
+
class EquityPoint:
|
|
130
|
+
date: str
|
|
131
|
+
value: float
|
|
132
|
+
|
|
133
|
+
@staticmethod
|
|
134
|
+
def from_dict(d: Dict[str, Any]) -> "EquityPoint":
|
|
135
|
+
return EquityPoint(
|
|
136
|
+
date=str(d.get("date") or ""),
|
|
137
|
+
value=float(d.get("value") or 0.0),
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
141
|
+
return asdict(self)
|
|
142
|
+
|
|
143
|
+
def to_json(self) -> str:
|
|
144
|
+
return json.dumps(self.to_dict(), separators=(",", ":"))
|
|
145
|
+
|
|
146
|
+
def log(self) -> str:
|
|
147
|
+
return f"{self.date} {self.value}"
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
@dataclass
|
|
151
|
+
class LiveStatus:
|
|
152
|
+
latest_run_id: Optional[str]
|
|
153
|
+
timeframe: Optional[str]
|
|
154
|
+
next_eta_minutes: Optional[float]
|
|
155
|
+
counts: Dict[str, int]
|
|
156
|
+
|
|
157
|
+
@staticmethod
|
|
158
|
+
def from_dict(d: Dict[str, Any]) -> "LiveStatus":
|
|
159
|
+
lr = (d or {}).get("latestRun") or {}
|
|
160
|
+
return LiveStatus(
|
|
161
|
+
latest_run_id=(lr.get("id") if isinstance(lr, dict) else None),
|
|
162
|
+
timeframe=(lr.get("timeframe") if isinstance(lr, dict) else None),
|
|
163
|
+
next_eta_minutes=(None if d.get("nextEtaMinutes") is None else float(d.get("nextEtaMinutes"))),
|
|
164
|
+
counts={k: int(v) for k, v in ((d.get("counts") or {}).items())},
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
168
|
+
return asdict(self)
|
|
169
|
+
|
|
170
|
+
def to_json(self) -> str:
|
|
171
|
+
return json.dumps(self.to_dict(), separators=(",", ":"))
|
|
172
|
+
|
|
173
|
+
def log(self) -> str:
|
|
174
|
+
return f"runId={self.latest_run_id} tf={self.timeframe} nextEtaMin={self.next_eta_minutes} counts={self.counts}"
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
@dataclass
|
|
178
|
+
class LiveLatest:
|
|
179
|
+
run_id: Optional[str]
|
|
180
|
+
timeframe: Optional[str]
|
|
181
|
+
signals: List[PortfolioSignal]
|
|
182
|
+
weights: List[PortfolioWeight]
|
|
183
|
+
fresh: Optional[bool]
|
|
184
|
+
recomputed: Optional[bool]
|
|
185
|
+
|
|
186
|
+
@staticmethod
|
|
187
|
+
def from_dict(d: Dict[str, Any]) -> "LiveLatest":
|
|
188
|
+
results = (d or {}).get("results") or {}
|
|
189
|
+
run_id = d.get("runId") or None
|
|
190
|
+
tf = d.get("timeframe") or None
|
|
191
|
+
sigs = parse_signals(results)
|
|
192
|
+
wts = parse_weights(results)
|
|
193
|
+
return LiveLatest(
|
|
194
|
+
run_id=run_id,
|
|
195
|
+
timeframe=tf,
|
|
196
|
+
signals=sigs,
|
|
197
|
+
weights=wts,
|
|
198
|
+
fresh=d.get("fresh"),
|
|
199
|
+
recomputed=d.get("recomputed"),
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
203
|
+
return {
|
|
204
|
+
"run_id": self.run_id,
|
|
205
|
+
"timeframe": self.timeframe,
|
|
206
|
+
"signals": [s.to_dict() for s in self.signals],
|
|
207
|
+
"weights": [w.to_dict() for w in self.weights],
|
|
208
|
+
"fresh": self.fresh,
|
|
209
|
+
"recomputed": self.recomputed,
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
def to_json(self) -> str:
|
|
213
|
+
return json.dumps(self.to_dict(), separators=(",", ":"))
|
|
214
|
+
|
|
215
|
+
def log(self) -> str:
|
|
216
|
+
return (
|
|
217
|
+
f"runId={self.run_id} tf={self.timeframe} "
|
|
218
|
+
f"signals={len(self.signals)} weights={len(self.weights)} fresh={self.fresh} recomputed={self.recomputed}"
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def parse_signals(payload: Dict[str, Any]) -> List[PortfolioSignal]:
|
|
223
|
+
rows = (payload or {}).get("signals", []) if isinstance(payload, dict) else []
|
|
224
|
+
return [PortfolioSignal.from_dict(r) for r in rows]
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def parse_weights(payload: Dict[str, Any]) -> List[PortfolioWeight]:
|
|
228
|
+
rows = (payload or {}).get("weights", []) if isinstance(payload, dict) else []
|
|
229
|
+
return [PortfolioWeight.from_dict(r) for r in rows]
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def parse_trades(payload: Dict[str, Any]) -> List[PortfolioTrade]:
|
|
233
|
+
rows = (payload or {}).get("trades", []) if isinstance(payload, dict) else []
|
|
234
|
+
return [PortfolioTrade.from_dict(r) for r in rows]
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def parse_members(payload: Dict[str, Any]) -> List[PortfolioMember]:
|
|
238
|
+
rows = (payload or {}).get("members", []) if isinstance(payload, dict) else []
|
|
239
|
+
return [PortfolioMember.from_dict(r) for r in rows]
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def parse_equity(payload: Dict[str, Any]) -> List[EquityPoint]:
|
|
243
|
+
rows = (payload or {}).get("series", []) if isinstance(payload, dict) else []
|
|
244
|
+
return [EquityPoint.from_dict(r) for r in rows]
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def parse_live_latest(payload: Dict[str, Any]) -> LiveLatest:
|
|
248
|
+
return LiveLatest.from_dict(payload or {})
|
|
249
|
+
|
|
250
|
+
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from dotenv import load_dotenv # type: ignore
|
|
7
|
+
except Exception:
|
|
8
|
+
load_dotenv = None
|
|
9
|
+
|
|
10
|
+
from epsilab import Epsilab
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main():
|
|
14
|
+
if load_dotenv is not None:
|
|
15
|
+
try:
|
|
16
|
+
load_dotenv()
|
|
17
|
+
except Exception:
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
api_key = os.getenv("EPSILAB_API_KEY")
|
|
21
|
+
api_base = os.getenv("EPSILAB_API_BASE", "https://www.epsilab.ai/api/ext/v1")
|
|
22
|
+
|
|
23
|
+
if not api_key:
|
|
24
|
+
print("EPSILAB_API_KEY not set. Create an API key in Account Settings and export it.")
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
client = Epsilab(api_base=api_base, api_key=api_key)
|
|
28
|
+
|
|
29
|
+
start = time.time()
|
|
30
|
+
iterations = 5 # 5 * 5s = 25s
|
|
31
|
+
print(f"Polling live portfolio for ~{iterations * 5} seconds (every 5s)...\n")
|
|
32
|
+
try:
|
|
33
|
+
for i in range(iterations):
|
|
34
|
+
try:
|
|
35
|
+
ts = datetime.now(timezone.utc).isoformat()
|
|
36
|
+
latest = client.get_live_latest(return_results_if_fresh=True)
|
|
37
|
+
status = client.get_live_status()
|
|
38
|
+
|
|
39
|
+
# Determine run id and timeframe
|
|
40
|
+
run_id = latest.run_id or status.latest_run_id
|
|
41
|
+
timeframe = status.timeframe or latest.timeframe
|
|
42
|
+
|
|
43
|
+
# Fetch live data for this (or latest) run
|
|
44
|
+
signals = client.get_portfolio_signals(run_id=run_id, limit=200)
|
|
45
|
+
weights = client.get_portfolio_weights(run_id=run_id, limit=200)
|
|
46
|
+
trades = client.get_live_trades(status="PENDING,EXECUTED,CLOSED", include_positions=False, limit=200)
|
|
47
|
+
equity = client.get_live_equity(limit=200)
|
|
48
|
+
members = client.get_live_members(run_id=run_id)
|
|
49
|
+
|
|
50
|
+
next_eta = status.next_eta_minutes
|
|
51
|
+
sig_rows = signals
|
|
52
|
+
wt_rows = weights
|
|
53
|
+
tr_rows = trades
|
|
54
|
+
eq_series = equity
|
|
55
|
+
mem_rows = members
|
|
56
|
+
|
|
57
|
+
# Build samples for easy inspection
|
|
58
|
+
def _sample_sig(r) -> str:
|
|
59
|
+
return r.log()
|
|
60
|
+
|
|
61
|
+
def _sample_wt(r) -> str:
|
|
62
|
+
return r.log()
|
|
63
|
+
|
|
64
|
+
def _sample_tr(r) -> str:
|
|
65
|
+
return r.log()
|
|
66
|
+
|
|
67
|
+
def _sample_mem(r) -> str:
|
|
68
|
+
return r.log()
|
|
69
|
+
|
|
70
|
+
eq_last = (eq_series[-1] if eq_series else None)
|
|
71
|
+
eq_last_str = (eq_last.log() if eq_last else "n/a")
|
|
72
|
+
|
|
73
|
+
print(f"[{ts}] runId={run_id} tf={timeframe} nextEtaMin={next_eta}")
|
|
74
|
+
print(
|
|
75
|
+
f" signals: {len(sig_rows)} | sample: " + ", ".join(map(_sample_sig, sig_rows[:2]))
|
|
76
|
+
)
|
|
77
|
+
print(
|
|
78
|
+
f" weights: {len(wt_rows)} | sample: " + ", ".join(map(_sample_wt, wt_rows[:2]))
|
|
79
|
+
)
|
|
80
|
+
print(
|
|
81
|
+
f" trades : {len(tr_rows)} | sample: " + ", ".join(map(_sample_tr, tr_rows[:2]))
|
|
82
|
+
)
|
|
83
|
+
print(
|
|
84
|
+
f" members: {len(mem_rows)} | sample: " + ", ".join(map(_sample_mem, mem_rows[:2]))
|
|
85
|
+
)
|
|
86
|
+
print(
|
|
87
|
+
f" equity : {len(eq_series)} pts | last: {eq_last_str}"
|
|
88
|
+
)
|
|
89
|
+
except Exception as e:
|
|
90
|
+
print(f"Error during poll: {e}")
|
|
91
|
+
|
|
92
|
+
# Wait ~5 seconds between polls
|
|
93
|
+
try:
|
|
94
|
+
time.sleep(5)
|
|
95
|
+
except KeyboardInterrupt:
|
|
96
|
+
print("Interrupted by user during sleep. Exiting...")
|
|
97
|
+
break
|
|
98
|
+
except KeyboardInterrupt:
|
|
99
|
+
print("Interrupted by user. Exiting...")
|
|
100
|
+
|
|
101
|
+
elapsed = time.time() - start
|
|
102
|
+
print(f"\nDone. Elapsed ~{int(elapsed)}s.")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
if __name__ == "__main__":
|
|
106
|
+
main()
|
|
107
|
+
|
|
108
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.18"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "epsilab"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for Epsilab live portfolio data (signals, weights, trades)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
authors = [ { name = "Epsilab" } ]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"httpx>=0.27.0",
|
|
15
|
+
"python-dotenv>=1.0.1",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"License :: OSI Approved :: Apache Software License",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://www.epsilab.ai"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
epsilab = "epsilab.__main__:main"
|
|
28
|
+
|
|
29
|
+
[tool.hatch.build]
|
|
30
|
+
include = [
|
|
31
|
+
"epsilab/**",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"examples/**",
|
|
35
|
+
]
|
|
36
|
+
exclude = [
|
|
37
|
+
"portfolio.logs",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|