From cf30534a461576b2876c534d6f5dad47dc7a6f84 Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Fri, 19 Aug 2022 16:12:13 +0100 Subject: [PATCH 1/3] feat: Candle spec --- non-protocol-specs/0012-NP-CAND-candles.md | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 non-protocol-specs/0012-NP-CAND-candles.md diff --git a/non-protocol-specs/0012-NP-CAND-candles.md b/non-protocol-specs/0012-NP-CAND-candles.md new file mode 100644 index 000000000..6eb488700 --- /dev/null +++ b/non-protocol-specs/0012-NP-CAND-candles.md @@ -0,0 +1,43 @@ +# Candles + +Candle data represents the market information within a fixed time window of a market. The candle message will contains the the current price values as well as the price that the market was at when the time windows was started as well was the close price when the time window finishes. Every time the market information changes, the candle data will be updated and sent out to any subscribers of the data. Also when the time window expires and moves into a new window a candle update is sent out. This occures even if no movement has happened in the market. + +# Time periods for candles intervals + +The following time intervals must be supported by the candle subscription service + +* 1 minute interval +* 5 minute interval +* 15 minute interval (default) +* 1 hour interval +* 6 hour interval +* 1 day interval + +# Data inside a candle message + +The minimum amount of information that must be included in a candle message is: + +``` +type candle struct { + high // The highest price the market has been during this time window + low // The lowest price the market has been during this time window + open // The price the market was at when the time window started + close // The price the market was at when the time window closed + volume // The current traded volume in this time window + interval // How long is the time window +} +``` + +# When are messages sent + +A candle message is sent whenever the following is true: +* A change to the market occurs +* A new time window interval is started + +# Acceptence Criteria +* Subscriptions can be set up for any of the intervals above (0012-NP-CAND-001) +* When the mark price changes a candle update is sent (0012-NP-CAND-002) +* When the mark price moves above the previous high value, the high value is updated (0012-NP-CAND-003) +* When the mark price moves below the previous low price, the low price is updated (0012-NP-CAND-004) +* Any orders matched during an interval result in the volume in the candle increasing by the amount matched (0012-NP-CAND-005) +* At the start of a new interval a candle message is sent even if the market has not changed (0012-NP-CAND-006) From 7b92d0787210f60f598723c367f5219e983f4c38 Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Fri, 19 Aug 2022 16:17:20 +0100 Subject: [PATCH 2/3] feat: More specific about which market event causes an update --- non-protocol-specs/0012-NP-CAND-candles.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/non-protocol-specs/0012-NP-CAND-candles.md b/non-protocol-specs/0012-NP-CAND-candles.md index 6eb488700..7d556eb70 100644 --- a/non-protocol-specs/0012-NP-CAND-candles.md +++ b/non-protocol-specs/0012-NP-CAND-candles.md @@ -31,7 +31,7 @@ type candle struct { # When are messages sent A candle message is sent whenever the following is true: -* A change to the market occurs +* A trade occurs * A new time window interval is started # Acceptence Criteria From e4a23646917331576ca48448c06c2c20bdccf479 Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Fri, 19 Aug 2022 17:06:54 +0100 Subject: [PATCH 3/3] feat: Added info about time windows --- non-protocol-specs/0012-NP-CAND-candles.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/non-protocol-specs/0012-NP-CAND-candles.md b/non-protocol-specs/0012-NP-CAND-candles.md index 7d556eb70..db44e5fff 100644 --- a/non-protocol-specs/0012-NP-CAND-candles.md +++ b/non-protocol-specs/0012-NP-CAND-candles.md @@ -34,6 +34,10 @@ A candle message is sent whenever the following is true: * A trade occurs * A new time window interval is started +# When do the intervals run + +The time windows are created starting from midnight UTC so the 1 day interval will run though each day and start again at midnight. All other intervals start at the same time and roll over when required. This is to ensure that candles recieved from any data node on the network will give very similar results. + # Acceptence Criteria * Subscriptions can be set up for any of the intervals above (0012-NP-CAND-001) * When the mark price changes a candle update is sent (0012-NP-CAND-002)