-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from Point72/tkp/slacktut
Start organizing examples, increase test coverage of examples
- Loading branch information
Showing
57 changed files
with
358 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Basics | ||
|
||
- [Simplest Possible Graph](./e1_basic.py) | ||
- [Ticking Graphs](./e2_ticking.py) | ||
- [Complete Example (Trading)](./e3_trade_pnl.py) | ||
- [Visualizing a Graph](./e4_show_graph.py) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from datetime import datetime | ||
|
||
import csp | ||
from csp import ts | ||
|
||
|
||
@csp.node | ||
def add(x: ts[int], y: ts[int]) -> ts[int]: | ||
return x + y | ||
|
||
|
||
@csp.graph | ||
def my_graph(): | ||
x = csp.const(1) | ||
y = csp.const(2) | ||
|
||
sum = add(x, y) | ||
|
||
csp.print("x", x) | ||
csp.print("y", y) | ||
csp.print("sum", sum) | ||
|
||
|
||
def main(): | ||
csp.run(my_graph, starttime=datetime.now()) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from datetime import datetime, timedelta | ||
|
||
import csp | ||
from csp import ts | ||
|
||
|
||
@csp.node | ||
def add(x: ts[int], y: ts[int]) -> ts[int]: | ||
return x + y | ||
|
||
|
||
@csp.node | ||
def accum(val: ts[int]) -> ts[int]: | ||
with csp.state(): | ||
s_sum = 0 | ||
if csp.ticked(val): | ||
s_sum += val | ||
return val | ||
|
||
|
||
@csp.graph | ||
def my_graph(): | ||
st = datetime(2020, 1, 1) | ||
|
||
# Dummy x values | ||
x = csp.curve(int, [(st + timedelta(1), 1), (st + timedelta(2), 2), (st + timedelta(3), 3)]) | ||
|
||
# Dummy y values | ||
y = csp.curve(int, [(st + timedelta(1), -1), (st + timedelta(3), -1), (st + timedelta(4), -1)]) | ||
|
||
# Add the time series | ||
sum = add(x, y) | ||
|
||
# Accumulate the result | ||
acc = accum(sum) | ||
|
||
csp.print("x", x) | ||
csp.print("y", y) | ||
csp.print("sum", sum) | ||
csp.print("accum", acc) | ||
|
||
|
||
def main(): | ||
start = datetime(2020, 1, 1) | ||
csp.run(my_graph, starttime=start) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Intermediate | ||
|
||
- [Graph Loops (`csp.feedback`)](./e1_feedback.py) | ||
- [Statistics Nodes](./e2_stats.py) | ||
- [Statistics Nodes with Numpy](./e3_numpy_stats.py) | ||
- [Expression Nodes with `exprtk`](./e4_exprtk.py) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Kafka Adapter | ||
|
||
- [Kafka Example](./e1_kafka.py) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Parquet Adapter | ||
|
||
- [Parquet Writer](./e1_parquet_writer.py) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Slack Adapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Websocket Adapter | ||
|
||
- [Websocket Output](./e1_websocket_output.py) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Writing Adapters | ||
|
||
- [Generic Push Adapter](./e1_generic_push_adapter.py) | ||
- [Pull Input Adapter](./e2_pullinput.py) | ||
- [Pull Input Adapter with Adapter Manager](./e3_adaptermanager_pullinput.py) | ||
- [Push Input Adapter](./e4_pushinput.py) | ||
- [Push Input Adapter with Adapter Manager](./e5_adaptermanager_pushinput.py) | ||
- [Output Adapter](./e6_outputadapter.py) | ||
- [Complete Input/Output Adapter with Adapter Manager](./e7_adaptermanager_inputoutput.py) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.