changes
This commit is contained in:
13
demo.log
Normal file
13
demo.log
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
AT Teppy
|
||||||
|
AT Luni
|
||||||
|
AT Hamza
|
||||||
|
AA USD
|
||||||
|
AA BTC
|
||||||
|
SR 1 51EB851 28F5C28 33333333 28F5C28
|
||||||
|
AF 1 1 500000000
|
||||||
|
AF 2 0 3D09000000000
|
||||||
|
AF 3 0 3D09000000000
|
||||||
|
SR 0 28F5C28 0 19999999 28F5C28
|
||||||
|
OR 1 1 100000000 0 C35000000000
|
||||||
|
OR 2 0 9C4000000000 1 100000000
|
||||||
|
OR 3 0 753000000000 1 80000000
|
||||||
4
demo_orders.log
Normal file
4
demo_orders.log
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
OR 0 1 100000000 0 C35000000000
|
||||||
|
OR 1 1 100000000 0 C35000000000
|
||||||
|
OR 2 0 9C4000000000 1 100000000
|
||||||
|
OR 3 0 753000000000 1 80000000
|
||||||
11
demox.log
Normal file
11
demox.log
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
AT Teppy
|
||||||
|
AT Luni
|
||||||
|
AT Hamza
|
||||||
|
AA USD
|
||||||
|
AA BTC
|
||||||
|
SR 1 51EB851 28F5C28 33333333 19999999
|
||||||
|
AF 1 1 500000000
|
||||||
|
AF 2 0 3D09000000000
|
||||||
|
AF 3 0 3D09000000000
|
||||||
|
SR 0 51EB851 28F5C28 33333333 19999999
|
||||||
|
OR 1 1 100000000 0 C35000000000
|
||||||
18
royalty1.log
18
royalty1.log
@@ -1,8 +1,10 @@
|
|||||||
OR 3 0 1FE3FBAD19 1 27E6390B60
|
AT Teppy
|
||||||
OR 1 1 36D7DEE73 0 257D2AD487
|
AT Luni
|
||||||
OR 1 0 D06BEB6BD 1 DDD310931
|
AT Hamza
|
||||||
AF 1 0 19062A3F90
|
AA USD
|
||||||
AF 1 0 1FFCFCEF35
|
AA BTC
|
||||||
AF 1 0 1BED05581E
|
SR 1 51EB851 28F5C28 33333333 28F5C28
|
||||||
OR 3 1 98F9EFF44 0 266AA46814
|
AF 1 1 500000000
|
||||||
OR 1 0 1A10091947 1 273A6E40B5
|
AF 2 0 3D09000000000
|
||||||
|
AF 3 0 3D09000000000
|
||||||
|
SR 0 28F5C28 0 19999999 28F5C28
|
||||||
|
|||||||
15
royalty2.log
15
royalty2.log
@@ -1,15 +0,0 @@
|
|||||||
NOP Error: adduser
|
|
||||||
AT Teppy
|
|
||||||
AT Luni
|
|
||||||
AT Hamza
|
|
||||||
AA USD
|
|
||||||
AA BTC
|
|
||||||
SR 0 20000000 0 0 0
|
|
||||||
OR 3 0 1FE3FBAD19 1 27E6390B60
|
|
||||||
OR 1 1 36D7DEE73 0 257D2AD487
|
|
||||||
OR 1 0 D06BEB6BD 1 DDD310931
|
|
||||||
AF 1 0 19062A3F90
|
|
||||||
AF 1 0 1FFCFCEF35
|
|
||||||
AF 1 0 1BED05581E
|
|
||||||
OR 3 1 98F9EFF44 0 266AA46814
|
|
||||||
OR 1 0 1A10091947 1 273A6E40B5
|
|
||||||
|
|||||||
25
src/main.rs
25
src/main.rs
@@ -454,9 +454,11 @@ impl Market {
|
|||||||
}
|
}
|
||||||
fn dump(&mut self) {
|
fn dump(&mut self) {
|
||||||
println!("Dumping Market:");
|
println!("Dumping Market:");
|
||||||
println!("Money Supply:");
|
println!("Asset MoneySupply Royalty% Commission%");
|
||||||
for index in 0..self.assets.len() {
|
for index in 0..self.assets.len() {
|
||||||
println!(" {}: {}",self.number_to_asset(index).name,self.money_supply[&index]);
|
let ass=self.number_to_asset(index);
|
||||||
|
let aname=self.money_supply[&index].to_string();
|
||||||
|
println!(" {:<3}{:>16} {}/{} {}/{}",ass.name,aname,ass.royalty0_rate.fmt_pct2(),ass.royalty1_rate.fmt_pct2(),ass.commission0_rate.fmt_pct2(),ass.commission1_rate.fmt_pct2());
|
||||||
}
|
}
|
||||||
for (ap,pq) in &self.orders {
|
for (ap,pq) in &self.orders {
|
||||||
println!("Orders selling {} to buy {}:",self.number_to_name(ap.0),self.number_to_name(ap.1));
|
println!("Orders selling {} to buy {}:",self.number_to_name(ap.0),self.number_to_name(ap.1));
|
||||||
@@ -474,12 +476,14 @@ impl Market {
|
|||||||
royalty_amt);
|
royalty_amt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("Royalties accumulated but not captured:");
|
println!("Royalty Accum SpareChange");
|
||||||
for index in 0..self.assets.len() {
|
for index in 0..self.assets.len() {
|
||||||
self.royalties.entry(index).or_insert(RoyaltyTree::new());
|
self.royalties.entry(index).or_insert(RoyaltyTree::new());
|
||||||
let tot=self.royalties.get(&index).unwrap().acc_total();
|
let name=self.number_to_asset(index).name;
|
||||||
println!(" For {}: {}",self.number_to_asset(index).name,tot);
|
|
||||||
let rt=self.royalties.get_mut(&index).unwrap();
|
let rt=self.royalties.get_mut(&index).unwrap();
|
||||||
|
let sc=rt.spare_change;
|
||||||
|
let tot=rt.acc_total();
|
||||||
|
println!(" {:<3} {} {}",name,tot,sc);
|
||||||
for indexr in 0..rt.tree.len() {
|
for indexr in 0..rt.tree.len() {
|
||||||
let royalty_amt=rt.get_royalty(indexr);
|
let royalty_amt=rt.get_royalty(indexr);
|
||||||
let r=&rt.tree[indexr];
|
let r=&rt.tree[indexr];
|
||||||
@@ -492,7 +496,7 @@ impl Market {
|
|||||||
println!(" Index {} Weight {} Royalty {} OrderID {}",indexr,r.weight,royalty_amt,r.order_id);
|
println!(" Index {} Weight {} Royalty {} OrderID {}",indexr,r.weight,royalty_amt,r.order_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (k,v) in &rt.order_finder { println!(" Order ID {} at position {}",k,v); }
|
// Heavy Debug for (k,v) in &rt.order_finder { println!(" Order ID {} at position {}",k,v); }
|
||||||
}
|
}
|
||||||
println!("Trader Balances:");
|
println!("Trader Balances:");
|
||||||
for t in &self.traders {
|
for t in &self.traders {
|
||||||
@@ -545,7 +549,7 @@ impl Market {
|
|||||||
Result::ExecutedBatch(log)
|
Result::ExecutedBatch(log)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
fn retract_order(&mut self, order_id:usize) -> Result {
|
fn retract_order(&mut self, order_id:usize) -> Result { // Still need to credit back funds! But first fix the bug where we are creating commission0 from thin air in make_order (not charging seller)
|
||||||
let pair=self.order_finder.get(&order_id).unwrap();
|
let pair=self.order_finder.get(&order_id).unwrap();
|
||||||
let queue=self.orders.get_mut(pair).unwrap();
|
let queue=self.orders.get_mut(pair).unwrap();
|
||||||
let queue_index=*queue.order_finder.get(&order_id).unwrap();
|
let queue_index=*queue.order_finder.get(&order_id).unwrap();
|
||||||
@@ -633,7 +637,8 @@ impl Market {
|
|||||||
self.next_order_id+=1;
|
self.next_order_id+=1;
|
||||||
|
|
||||||
// Pay royalties to existing orders on the sell size
|
// Pay royalties to existing orders on the sell size
|
||||||
self.royalties.entry(sell_type).or_insert(RoyaltyTree::new()).add_royalty(royalty0_qty);
|
self.royalties.entry(sell_type).or_insert(RoyaltyTree::new()).add_royalty(royalty0_qty+royalty1_qty);
|
||||||
|
royalty_acc+=royalty0_qty+royalty1_qty;
|
||||||
|
|
||||||
// Create a new entry in the RoyaltyTree to accumulate for this Order
|
// Create a new entry in the RoyaltyTree to accumulate for this Order
|
||||||
let rt=self.royalties.entry(buy_type).or_insert(RoyaltyTree::new());
|
let rt=self.royalties.entry(buy_type).or_insert(RoyaltyTree::new());
|
||||||
@@ -647,7 +652,7 @@ impl Market {
|
|||||||
self.order_count+=1;
|
self.order_count+=1;
|
||||||
self.order_finder.insert(id,(sell_type,buy_type));
|
self.order_finder.insert(id,(sell_type,buy_type));
|
||||||
self.traders[owner].sub_balance(sell_type,sell_qty_remain);
|
self.traders[owner].sub_balance(sell_type,sell_qty_remain);
|
||||||
self.traders[0].add_balance(sell_type,commission0_qty);
|
commission_acc+=commission0_qty+commission1_qty;
|
||||||
self.traders[owner].order_finder.insert(id,(sell_type,buy_type));
|
self.traders[owner].order_finder.insert(id,(sell_type,buy_type));
|
||||||
log.push(format!("Moved {} {} ({}) to market",sell_qty_remain,self.number_to_name(sell_type),self.traders[owner].name));
|
log.push(format!("Moved {} {} ({}) to market",sell_qty_remain,self.number_to_name(sell_type),self.traders[owner].name));
|
||||||
}
|
}
|
||||||
@@ -1156,7 +1161,7 @@ fn interactive(m: &mut Market, mut out: Option<File>) {
|
|||||||
Ok(input) => {
|
Ok(input) => {
|
||||||
let tokens: Vec<&str> = input.split_whitespace().collect();
|
let tokens: Vec<&str> = input.split_whitespace().collect();
|
||||||
let cmd:Command=match tokens.as_slice() {
|
let cmd:Command=match tokens.as_slice() {
|
||||||
["dump"] => { m.dump(); Command::None },
|
["dump"] => { m.dump(); m.sanity_check(); Command::None },
|
||||||
["randomorder"] => { println!("Random OrderID: {:?}",m.random_order_id()); Command::None }
|
["randomorder"] => { println!("Random OrderID: {:?}",m.random_order_id()); Command::None }
|
||||||
["login", username] => {
|
["login", username] => {
|
||||||
if let Some(t)=m.trader_name2num.get_mut(*username) { trader=*t; println!("Logged in as {}",m.traders[trader].name) } else { println!("Trader {} not found.",username) }
|
if let Some(t)=m.trader_name2num.get_mut(*username) { trader=*t; println!("Logged in as {}",m.traders[trader].name) } else { println!("Trader {} not found.",username) }
|
||||||
|
|||||||
Reference in New Issue
Block a user