Skip to content

Commit 8935a62

Browse files
jayantkJayant Krishnamurthyguibescos
authored
Set CI threshold to 3 (#305)
* Set CI threshold to 3 * fix tests??? * actually fix tests * fix this test also * Fix integer division Co-authored-by: Jayant Krishnamurthy <jkrishnamurthy@jumptrading.com> Co-authored-by: Guillermo Bescos Alapont <gbescos@stanford.edu>
1 parent 6d0ec16 commit 8935a62

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

program/rust/src/c_oracle_header.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ pub const PERMISSIONS_SEED: &str = "permissions";
2121

2222
/// If ci > price / PC_MAX_CI_DIVISOR, set publisher status to unknown.
2323
/// (e.g., 20 means ci must be < 5% of price)
24-
pub const MAX_CI_DIVISOR: i64 = 20;
25-
24+
pub const MAX_CI_DIVISOR: i64 = 3;
2625
/// Bound on the range of the exponent in price accounts. This number is set such that the
2726
/// PD-based EMA computation does not lose too much precision.
2827
pub const MAX_NUM_DECIMALS: i32 = 8;

program/rust/src/tests/test_upd_price.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn test_upd_price() {
214214
assert_eq!(price_data.agg_.status_, PC_STATUS_TRADING);
215215
}
216216

217-
populate_instruction(&mut instruction_data, 50, 6, 5);
217+
populate_instruction(&mut instruction_data, 50, 20, 5);
218218
update_clock_slot(&mut clock_account, 6);
219219

220220
// Publishing a wide CI results in a status of unknown.
@@ -239,7 +239,7 @@ fn test_upd_price() {
239239
{
240240
let price_data = load_checked::<PriceAccount>(&price_account, PC_VERSION).unwrap();
241241
assert_eq!(price_data.comp_[0].latest_.price_, 50);
242-
assert_eq!(price_data.comp_[0].latest_.conf_, 6);
242+
assert_eq!(price_data.comp_[0].latest_.conf_, 20);
243243
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 5);
244244
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
245245
assert_eq!(price_data.valid_slot_, 5);
@@ -249,7 +249,7 @@ fn test_upd_price() {
249249
}
250250

251251
// Crank one more time and aggregate should be unknown
252-
populate_instruction(&mut instruction_data, 50, 6, 6);
252+
populate_instruction(&mut instruction_data, 50, 20, 6);
253253
update_clock_slot(&mut clock_account, 7);
254254

255255
assert!(process_instruction(
@@ -266,7 +266,7 @@ fn test_upd_price() {
266266
{
267267
let price_data = load_checked::<PriceAccount>(&price_account, PC_VERSION).unwrap();
268268
assert_eq!(price_data.comp_[0].latest_.price_, 50);
269-
assert_eq!(price_data.comp_[0].latest_.conf_, 6);
269+
assert_eq!(price_data.comp_[0].latest_.conf_, 20);
270270
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 6);
271271
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
272272
assert_eq!(price_data.valid_slot_, 6);

program/rust/src/tests/test_upd_price_no_fail_on_error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn test_upd_price_no_fail_on_error_no_fail_on_error() {
116116
assert_eq!(price_data.comp_[0].latest_.price_, 42);
117117
assert_eq!(price_data.comp_[0].latest_.conf_, 9);
118118
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 1);
119-
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
119+
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_TRADING);
120120
assert_eq!(price_data.valid_slot_, 0);
121121
assert_eq!(price_data.agg_.pub_slot_, 1);
122122
assert_eq!(price_data.agg_.price_, 0);
@@ -158,7 +158,7 @@ fn test_upd_price_no_fail_on_error_no_fail_on_error() {
158158
assert_eq!(price_data.comp_[0].latest_.price_, 42);
159159
assert_eq!(price_data.comp_[0].latest_.conf_, 9);
160160
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 1);
161-
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
161+
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_TRADING);
162162
assert_eq!(price_data.valid_slot_, 0);
163163
assert_eq!(price_data.agg_.pub_slot_, 1);
164164
assert_eq!(price_data.agg_.price_, 0);

program/rust/src/tests/test_upd_sma.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ fn test_upd_sma() {
277277
assert_eq!(price_data.time_machine.current_epoch_denominator, 3 + 1 + 1);
278278
}
279279

280-
populate_instruction(&mut instruction_data, 50, 6, 5);
280+
populate_instruction(&mut instruction_data, 50, 20, 5);
281281
update_clock_slot(&mut clock_account, 6);
282282

283283
// Publishing a wide CI results in a status of unknown.
@@ -305,7 +305,7 @@ fn test_upd_sma() {
305305
{
306306
let price_data = load_checked::<PriceAccountWrapper>(&price_account, PC_VERSION).unwrap();
307307
assert_eq!(price_data.price_data.comp_[0].latest_.price_, 50);
308-
assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 6);
308+
assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 20);
309309
assert_eq!(price_data.price_data.comp_[0].latest_.pub_slot_, 5);
310310
assert_eq!(
311311
price_data.price_data.comp_[0].latest_.status_,
@@ -328,7 +328,7 @@ fn test_upd_sma() {
328328
}
329329

330330
// Crank one more time and aggregate should be unknown
331-
populate_instruction(&mut instruction_data, 50, 6, 6);
331+
populate_instruction(&mut instruction_data, 50, 20, 6);
332332
update_clock_slot(&mut clock_account, 7);
333333

334334
assert!(process_instruction(
@@ -345,7 +345,7 @@ fn test_upd_sma() {
345345
{
346346
let price_data = load_checked::<PriceAccountWrapper>(&price_account, PC_VERSION).unwrap();
347347
assert_eq!(price_data.price_data.comp_[0].latest_.price_, 50);
348-
assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 6);
348+
assert_eq!(price_data.price_data.comp_[0].latest_.conf_, 20);
349349
assert_eq!(price_data.price_data.comp_[0].latest_.pub_slot_, 6);
350350
assert_eq!(
351351
price_data.price_data.comp_[0].latest_.status_,

pyth/tests/test_update_price.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,6 @@ def get_publisher_acc(product_acc):
116116
assert publisher_acc['price'] == new_values[product]['price']
117117
assert publisher_acc['conf'] == new_values[product]['conf']
118118

119-
conf_threshold = new_values[product]['price'] / 20
119+
conf_threshold = new_values[product]['price'] // 3
120120
expected_status = 'unknown' if new_values[product]['conf'] > conf_threshold else 'trading'
121121
assert publisher_acc['status'] == expected_status

0 commit comments

Comments
 (0)