You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Collect more then one candle per product and timeframe.
- On events you get all candles for this collection.
- Products and timeframes can now be removed from the collection.
- Added function to get the average time difference between messages and local time.
Copy file name to clipboardExpand all lines: README.md
+44-14
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# Candles
2
2
3
-
Candles gives you the ability to create candlesticks from your tick data. The candlesticks will be created from live tick data and not historical tick data. For example, via websocket clients.
3
+
Candles gives you the ability to create candlesticks from your tick data. The candlesticks will be created from live tick data and not historical tick data. For example, via websocket clients.
4
4
5
5
### About
6
6
7
-
This project started as an fork of [gdax-candles](https://github.com/swimclan/gdax-candles).
7
+
This project started as an fork of [gdax-candles](https://github.com/swimclan/gdax-candles).
8
8
During use, it turned out that there was a need to use it on other exchanges. So it changed to candles.
9
9
10
10
## Installation
@@ -72,6 +72,7 @@ Candlestick {
72
72
ratio: '1.00000000' },
73
73
closed: true,
74
74
market: 'bullish' }
75
+
*/
75
76
```
76
77
### Constructor
77
78
@@ -92,8 +93,8 @@ const Candlecollection = new candles(options);
92
93
```
93
94
94
95
*`enabled` Enabling the correction of timelag.
95
-
* `fixed` for a fixed lag between your provider and you local system set fixed to true. Otherwise the lagtime will be calculated be the given message timestamp, you have to pass.
96
-
* `value` only when fixed lag selected, the lag in ms has to be specified.
96
+
*`fixed`For a fixed lag between your provider and you local system set fixed to true. Otherwise the lagtime will be calculated by the given message timestamp, you have to pass.
97
+
*`value`Only when fixed lag selected, the lag in ms has to be specified.
97
98
*`samples` For the calculated lagtime an average of x samples will be calculated.
98
99
99
100
### Functions
@@ -105,16 +106,37 @@ After creating an instance of candles, you have to add products and timeframes.
*`product` You can set a name for your own, but it make sense to put the name of the currencypair in here. You have to tell candle this name, every time you update the current candle.
112
-
* `timeframe` Setup the timeframe of your choice. The timeframes have to be writen in any number of s=seconds, m=minutes, h=hours and d=days. Feel free to use 13m or 7s as well as 21h.
113
+
*`timeframe` Setup the timeframe of your choice. The timeframes have to be writen in any number of s=seconds, m=minutes, h=hours and d=days. Feel free to use 13m or 7s as well as 21h.
113
114
Product and Timeframe can both be arrays. Then for every product the given timeframe will be created. You can also seperate it.
115
+
*`serieslength`[optional] If you like to collect a amount of last x candles, set the amount here. If not passed, only the last candle will be hold in memmory.
114
116
115
117
```js
116
118
Candlecollection.addProduct('ETH-USD', '30s');
117
-
Candlecollection.addProduct('BTC-USD', '1m');
119
+
Candlecollection.addProduct('BTC-USD', '1m', 60);
120
+
```
121
+
122
+
#### removeProduct()
123
+
124
+
Removing products is as easy as adding, just provide the product(s) and timeframe(s).
* `product` The name you set in addProduct() before.
153
+
*`product` The name you set in addProduct() before.
132
154
*`price` The actual price you got from provider.
133
155
*`size` This is an optional parameter. If your provider don't give you any volume information, just leave it. Then your candlesticks volume will be 0.
134
156
135
157
#### adjustClock()
136
158
137
-
If you setup timelag correction, by enabling and setting samples count, you can pass your message timestamps to candles. Candles will build an average of these and your system clock, so the timestamp of the created candle will more accorate.
159
+
If you setup timelag correction, by enabling and setting samples count, you can pass your message timestamps to candles. Candles will build an average of these and your system clock, so the timestamp of the created candle will be more accorate.
138
160
139
161
```js
140
162
Candlecollection.adjustClock(timestamp);
141
163
```
142
164
143
165
*`timestamp` Will be the timestamp from your providers message.
144
166
167
+
#### getTimeDrift()
168
+
169
+
Gives you the average difference between exchange and local time. Depends on the timediff options you set. The value is in ms.
170
+
171
+
```js
172
+
Candlecollection.getTimeDrift();
173
+
```
174
+
145
175
### Events
146
176
147
-
Events emitted from candles. For all events the current candle will be passed.
177
+
Events emitted from candles. For all events the current candle and the candle collection will be passed.
148
178
149
179
*`open` when a new candle created
150
180
*`close` when a candle is closed
@@ -156,21 +186,21 @@ These events can be more specific by adding the timeframe and/or the productname
156
186
*`open BTC-USD 1m` when a new candle of product 'BTC-USD' with timeframe '1m' created
157
187
*`open 1m` when a new candle with timeframe '1m' created
0 commit comments