@@ -224,49 +224,49 @@ pub struct Ema
224
224
pub struct Price
225
225
{
226
226
/// pyth magic number
227
- pub magic : u32 ,
227
+ pub magic : u32 ,
228
228
/// program version
229
- pub ver : u32 ,
229
+ pub ver : u32 ,
230
230
/// account type
231
- pub atype : u32 ,
231
+ pub atype : u32 ,
232
232
/// price account size
233
- pub size : u32 ,
233
+ pub size : u32 ,
234
234
/// price or calculation type
235
- pub ptype : PriceType ,
235
+ pub ptype : PriceType ,
236
236
/// price exponent
237
- pub expo : i32 ,
237
+ pub expo : i32 ,
238
238
/// number of component prices
239
- pub num : u32 ,
239
+ pub num : u32 ,
240
240
/// number of quoters that make up aggregate
241
- pub num_qt : u32 ,
241
+ pub num_qt : u32 ,
242
242
/// slot of last valid (not unknown) aggregate price
243
- pub last_slot : u64 ,
243
+ pub last_slot : u64 ,
244
244
/// valid slot-time of agg. price
245
- pub valid_slot : u64 ,
246
- /// time-weighted average price
247
- pub twap : Ema ,
248
- /// time-weighted average confidence interval
249
- pub twac : Ema ,
245
+ pub valid_slot : u64 ,
246
+ /// exponential moving average price
247
+ pub ema_price : Ema ,
248
+ /// exponential moving average confidence interval
249
+ pub ema_confidence : Ema ,
250
250
/// space for future derived values
251
- pub drv1 : i64 ,
251
+ pub drv1 : i64 ,
252
252
/// space for future derived values
253
- pub drv2 : i64 ,
253
+ pub drv2 : i64 ,
254
254
/// product account key
255
- pub prod : AccKey ,
255
+ pub prod : AccKey ,
256
256
/// next Price account in linked list
257
- pub next : AccKey ,
257
+ pub next : AccKey ,
258
258
/// valid slot of previous update
259
- pub prev_slot : u64 ,
259
+ pub prev_slot : u64 ,
260
260
/// aggregate price of previous update
261
- pub prev_price : i64 ,
261
+ pub prev_price : i64 ,
262
262
/// confidence interval of previous update
263
- pub prev_conf : u64 ,
263
+ pub prev_conf : u64 ,
264
264
/// space for future derived values
265
- pub drv3 : i64 ,
265
+ pub drv3 : i64 ,
266
266
/// aggregate price info
267
- pub agg : PriceInfo ,
267
+ pub agg : PriceInfo ,
268
268
/// price components one per quoter
269
- pub comp : [ PriceComp ; 32 ]
269
+ pub comp : [ PriceComp ; 32 ]
270
270
}
271
271
272
272
#[ cfg( target_endian = "little" ) ]
@@ -307,16 +307,16 @@ impl Price {
307
307
}
308
308
309
309
/**
310
- * Get the time-weighted average price (TWAP ) and a confidence interval on the result.
311
- * Returns `None` if the twap is currently unavailable.
310
+ * Get the exponential moving average price (ema_price ) and a confidence interval on the result.
311
+ * Returns `None` if the ema_price is currently unavailable.
312
312
*
313
313
* At the moment, the confidence interval returned by this method is computed in
314
314
* a somewhat questionable way, so we do not recommend using it for high-value applications.
315
315
*/
316
- pub fn get_twap ( & self ) -> Option < PriceConf > {
316
+ pub fn get_ema_price ( & self ) -> Option < PriceConf > {
317
317
// This method currently cannot return None, but may do so in the future.
318
- // Note that the twac is a positive number in i64, so safe to cast to u64.
319
- Some ( PriceConf { price : self . twap . val , conf : self . twac . val as u64 , expo : self . expo } )
318
+ // Note that the ema_confidence is a positive number in i64, so safe to cast to u64.
319
+ Some ( PriceConf { price : self . ema_price . val , conf : self . ema_confidence . val as u64 , expo : self . expo } )
320
320
}
321
321
322
322
/**
0 commit comments