Skip to content

Commit

Permalink
Merge pull request #275 from Point72/tkp/brokenlinks
Browse files Browse the repository at this point in the history
Fix some broken links in examples, typos/misformatting in wiki
  • Loading branch information
timkpaine committed Jun 11, 2024
2 parents 370ef6b + 5b48191 commit fda7a19
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

The high level goal of `csp` is to make writing realtime code simple and performant. Write event driven code once, test it in simulation, then deploy as realtime without any code changes.

Here is a very simple example of a small `csp` program to calculate a [bid-ask spread](https://www.investopedia.com/terms/b/bid-askspread.asp). In this example, we use a constant bid and ask, but in the real world you might pipe these directly into your live streaming data source, or into your historical data source, without modifications to your core logic.
Here is a very simple example of a small `csp` program to calculate a [bid-ask spread](https://en.wikipedia.org/wiki/Bid%E2%80%93ask_spread). In this example, we use a constant bid and ask, but in the real world you might pipe these directly into your live streaming data source, or into your historical data source, without modifications to your core logic.

```python
import csp
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/api-references/Base-Nodes-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Given a mathematical expression, and a set of timeseries corresponding to variab

Args:

- **`expression_str`**: an expression, as per the [C++ Mathematical Expression Library](http://www.partow.net/programming/exprtk/) (see [readme](http://www.partow.net/programming/exprtk/code/readme.txt)
- **`expression_str`**: an expression, as per the [C++ Mathematical Expression Library](http://www.partow.net/programming/exprtk/) (see [readme](http://www.partow.net/programming/exprtk/code/readme.txt))
- **`inputs`**: a dict basket of timeseries. The keys will correspond to the variables in the expression. The timeseries can be of float or string
- **`state_vars`**: an optional dictionary of variables to be held in state between executions, and assignable within the expression. Keys are the variable names and values are the starting values
- **`trigger`**: an optional trigger for when to calculate. By default will calculate on any input tick
Expand Down
16 changes: 8 additions & 8 deletions docs/wiki/concepts/Historical-Buffers.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ The various historical access methods take the same arguments and return the val
- If providing **time** one can either provide a datetime for absolute time, or a timedelta for how far back to access.
**NOTE that timedelta must be negative** to represent time in the past..
- If **None** is provided, the range will begin "from the beginning" - i.e., the oldest tick in the buffer.
- **end_index_or_time:** same as start_index_or_time
- **`end_index_or_time`**: same as start_index_or_time
- If **None** is provided, the range will go "until the end" - i.e., the newest tick in the buffer.
- **`start_index_policy`**: only for use with datetime/timedelta as the start and end parameters.
- **\`TimeIndexPolicy.INCLUSIVE**: if there is a tick exactly at the requested time, include it
- **TimeIndexPolicy.EXCLUSIVE**: if there is a tick exactly at the requested time, exclude it
- **TimeIndexPolicy.EXTRAPOLATE**: if there is a tick at the beginning timestamp, include it.
- **`TimeIndexPolicy.INCLUSIVE`**: if there is a tick exactly at the requested time, include it
- **`TimeIndexPolicy.EXCLUSIVE`**: if there is a tick exactly at the requested time, exclude it
- **`TimeIndexPolicy.EXTRAPOLATE`**: if there is a tick at the beginning timestamp, include it.
Otherwise, if there is a tick before the beginning timestamp, force a tick at the beginning timestamp with the prevailing value at the time.
- **end_index_policy** only for use with datetime/timedelta and the start and end parameters.
- **TimeIndexPolicy.INCLUSIVE**: if there is a tick exactly at the requested time, include it
- **TimeIndexPolicy.EXCLUSIVE**: if there is a tick exactly at the requested time, exclude it
- **TimeIndexPolicy.EXTRAPOLATE**: if there is a tick at the end timestamp, include it.
- **`end_index_policy`**: only for use with datetime/timedelta and the start and end parameters.
- **`TimeIndexPolicy.INCLUSIVE`**: if there is a tick exactly at the requested time, include it
- **`TimeIndexPolicy.EXCLUSIVE`**: if there is a tick exactly at the requested time, exclude it
- **`TimeIndexPolicy.EXTRAPOLATE`**: if there is a tick at the end timestamp, include it.
Otherwise, if there is a tick before the end timestamp, force a tick at the end timestamp with the prevailing value at the time

Range access is optimized at the C++ layer and for this reason its far more efficient than calling the single value access methods in a loop, and they should be substituted in where possible.
Expand Down
3 changes: 2 additions & 1 deletion docs/wiki/get-started/First-Steps.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
csp is a graph-based stream processing library, where you create directed graphs for real-time event streaming workflows.
In this introductory tutorial, you will write a csp program to calculate the Bid-Ask Spread for specified `bid` and `ask` values.

> \[!TIP\]
> The bid–ask spread is the difference between the prices quoted for an immediate sale (ask) and an immediate purchase (bid) for stocks, futures contracts, options, or currency pairs in some auction scenario.
> ~ [Bid–ask spread on Wikipedia](https://en.wikipedia.org/wiki/Bid%E2%80%93ask_spread)
Expand Down Expand Up @@ -37,7 +38,7 @@ def spread(bid: ts[float], ask: ts[float]) -> ts[float]:

The `bid` and `ask` values are expected to be Time Series values.

> \[!NOTE\]
> \[!IMPORTANT\]
> csp nodes is strictly typed, and the type is enforced by the C++ engine.
This node needs to be executed each time the `ask` and `bid` values change, so we use the following built-in nodes:
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/get-started/IO-with-Adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In this tutorial, you write to, and read from, Parquet files on the local file s

csp has the `ParquetWriter` and `ParquetReader` adapters to stream data to and from Parquet files. Check out the complete [API in the Reference documentation](https://github.com/Point72/csp/wiki/Input-Output-Adapters-API#parquet).

> \[!NOTE\]
> \[!IMPORTANT\]
> csp can handle historical and real-time data, and the csp program remains similar in both cases.
## Example
Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/how-tos/Write-Historical-Input-Adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ x = csp.curve(int, [ (t1, v1), (t2, v2), .. ])
csp.print('x', x)
```

See example [e_14_user_adapters_01_pullinput.py](https://github.com/Point72/csp/blob/main/examples/4_writing_adapters/e_14_user_adapters_01_pullinput.py) for more details.
See example [e2_pullinput.pyy](https://github.com/Point72/csp/blob/main/examples/04_writing_adapters/e2_pullinput.py) for more details.

### PullInputAdapter - C++

Expand Down Expand Up @@ -223,7 +223,7 @@ class CSVReader:
Note that subscribe returns a `CSVReadAdapter` instance.
`CSVReadAdapter` is the *--graph--* time representation of the edge (similar to how we defined `csp.curve` above).
We pass it `self` as its first argument, which will be used to create the AdapterManager *--impl--*
- **`\_create`**: the method to create the *--impl--* object from the given *--graph--* time representation of the manager
- **`_create`**: the method to create the *--impl--* object from the given *--graph--* time representation of the manager

The `CSVReader` would then be used in graph building code like so:

Expand Down Expand Up @@ -412,4 +412,4 @@ CSVReadAdapter = py_managed_adapter_def( # 6
- **line 3**: this is where the instance of an adapter *--impl--* registers itself with the `CSVReaderImpl`.
- **line 6+**: this is where we define `CSVReadAdapter`, the *--graph--* time representation of a CSV adapter, returned from `CSVReader.subscribe`

See example [e_14_user_adapters_02_adaptermanager_siminput.py](https://github.com/Point72/csp/blob/main/examples/4_writing_adapters/e_14_user_adapters_02_adaptermanager_siminput.py) for another example of how to write a managed sim adapter manager.
See example [e3_adaptermanager_pullinput.py](https://github.com/Point72/csp/blob/main/examples/04_writing_adapters/e3_adaptermanager_pullinput.py) for another example of how to write a managed sim adapter manager.
2 changes: 1 addition & 1 deletion docs/wiki/how-tos/Write-Output-Adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Adapter managers function the same way for output adapters as for input adapters
### InputOutputAdapter - Python

As a as last example, lets tie everything together and implement a managed push input adapter combined with a managed output adapter.
This example is available in [e_14_user_adapters_06_adaptermanager_inputoutput.py](https://github.com/Point72/csp/blob/main/examples/4_writing_adapters/e_14_user_adapters_06_adaptermanager_inputoutput.py).
This example is available in [e7_adaptermanager_inputoutput.py](https://github.com/Point72/csp/blob/main/examples/04_writing_adapters/e7_adaptermanager_inputoutput.py).

First, we will define our adapter manager.
In this example, we're going to cheat a little bit and combine our adapter manager (graph time) and our adapter manager impl (run time).
Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/how-tos/Write-Realtime-Input-Adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The `py_push_adapter_def` creates a *--graph--* time representation of your adap
Note that the \*\*kwargs passed to `py_push_adapter_def` should be the names and types of the variables, like `arg1=type1, arg2=type2`.
These are the names of the kwargs that the returned input adapter will take and pass through to the `PushInputAdapter` implementation, and the types expected for the values of those args.

Example [e_14_user_adapters_03_pushinput.py](https://github.com/Point72/csp/blob/main/examples/4_writing_adapters/e_14_user_adapters_03_pushinput.py) demonstrates a simple example of this.
Example [e4_pushinput.py](https://github.com/Point72/csp/blob/main/examples/04_writing_adapters/e4_pushinput.py) demonstrates a simple example of this.

```python
from csp.impl.pushadapter import PushInputAdapter
Expand Down Expand Up @@ -128,7 +128,7 @@ If you dont need as much control as `PushInputAdapter` provides, or if you have
`csp.GenericPushAdapter` wraps a `csp.PushInputAdapter` implementation internally and provides a simplified interface.
The downside of `csp.GenericPushAdapter` is that you lose some control of when the input feed starts and stop.

Lets take a look at the example found in [e_14_generic_push_adapter.py](https://github.com/Point72/csp/blob/main/examples/4_writing_adapters/e_14_generic_push_adapter.py):
Lets take a look at the example found in [e1_generic_push_adapter.py](https://github.com/Point72/csp/blob/main/examples/04_writing_adapters/e1_generic_push_adapter.py):

```python
# This is an example of some separate thread providing data
Expand Down Expand Up @@ -203,7 +203,7 @@ The **\_create** is the bridge between the *--graph--* time `AdapterManager` rep
**\_create** will be called on the *--graph--* time `AdapterManager` which will in turn create the *--impl--* instance.
\_create will get two arguments, engine (this represents the runtime engine object that will run the graph) and memo dict which can optionally be used for any memoization that on might want.

Lets take a look at the example found in [e_14_user_adapters_04_adaptermanager_pushinput.py](https://github.com/Point72/csp/blob/main/examples/4_writing_adapters/e_14_user_adapters_04_adaptermanager_pushinput.py):
Lets take a look at the example found in [e5_adaptermanager_pushinput.py](https://github.com/Point72/csp/blob/main/examples/04_writing_adapters/e5_adaptermanager_pushinput.py):

```python
# This object represents our AdapterManager at graph time. It describes the manager's properties
Expand Down
2 changes: 1 addition & 1 deletion examples/03_using_adapters/parquet/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Parquet Adapter

- [Parquet Writer](./e1_parquet_writer.py)
- [Parquet Writer](./e1_parquet_write_read.py)
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/03_using_adapters/websocket/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Websocket Adapter

- [Websocket Output](./e1_websocket_output.py)
- [Websocket Output](./e2_websocket_output.py)
4 changes: 2 additions & 2 deletions examples/05_cpp/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# C++ Nodes and Adapters

- [C++ Node](./e1_cpp_node/)
- [C++ Node w/ `csp.Struct`](./e2_cpp_node_with_struct/)
- [C++ Node](./1_cpp_node/)
- [C++ Node w/ `csp.Struct`](./2_cpp_node_with_struct/)
2 changes: 1 addition & 1 deletion examples/06_advanced/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Advanced

- [Dynamic Graphs](./e1_dynamic.py)
- [Pandas Extension](./e2_pandas_extension_example.py)
- [Pandas Extension](./e2_pandas_extension.py)
2 changes: 1 addition & 1 deletion examples/07_end_to_end/mta.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@
"* https://pypi.org/project/nyct-gtfs/\n",
"* https://api.mta.info/#/landing\n",
"* https://developers.google.com/transit/gtfs-realtime\n",
"* https://github.com/Point72/csp/blob/main/examples/4_writing_adapters/e_14_user_adapters_03_pushinput.py\n",
"* https://github.com/Point72/csp/blob/main/examples/04_writing_adapters/e4_pushinput.py\n",
"* https://github.com/Point72/csp/wiki/5.-Adapters#realtime-adapters"
]
}
Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
- [Writing Adapters](./04_writing_adapters/)
- [Writing C++ Nodes and Adapters](./05_cpp/)
- [Advanced](./06_advanced/)
- [End to End Examples](./07_end_to_end/)
- [Just for fun!](./98_just_for_fun/)
- [Developer Tools](./99_developer_tools/)

0 comments on commit fda7a19

Please sign in to comment.