0.0.3 • Published 5 years ago

mrg.volume_operation_storage v0.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

"Hello world" example:

require("./index")();

//calculation formula
//MirrorTradeData = FinalState - (InitialState + ManualChanges)

//In this example
//(InitialState + ManualChanges) => storageA.
//FinalState => storageB
//MirrorTradeData => storageC

require("./index")();

//calculation formula
//MirrorTradeData = FinalState - (InitialState + ManualChanges)

//In this example
//(InitialState + ManualChanges) => storageA.
//FinalState => storageB
//MirrorTradeData => storageC

let storageA = new mrg.VolumeOperationStorage();

//set initialData
//ask book part
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 120, 12, 0, 0, 0, 0, 0));
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 110, 11, 0, 0, 0, 0, 0));
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 100, 10, 0, 0, 0, 0, 0));
//bid book part
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 80, 0, 8, 0, 0, 0, 0));
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 70, 0, 7, 0, 0, 0, 0));
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 60, 0, 6, 0, 0, 0, 0));

//activate changes tracking
storageA.activateChangesTracking();

//add changes
//Sell limits
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 120, 1.2, 0, 0, 0, 0, 0));

//Buy limits
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 80, 0, 0.8, 0, 0, 0, 0));

//Sell market
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 80, 0, 0, 0.5, 0, 0, 0));
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 80, 0, 0, 0.6, 0, 0, 0));

//Buy market
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 120, 0, 0, 0, 0.3, 0, 0));
storageA.add(new mrg.PriceVolumeRecord("BTCUSD", 120, 0, 0, 0, 0.5, 0, 0));


let storageB =  new mrg.VolumeOperationStorage();
//set initialData
//ask book part
storageB.add(new mrg.PriceVolumeRecord("BTCUSD", 120, 10, 0, 0, 0, 0, 0));
storageB.add(new mrg.PriceVolumeRecord("BTCUSD", 110, 9, 0, 0, 0, 0, 0));
storageB.add(new mrg.PriceVolumeRecord("BTCUSD", 100, 8, 0, 0, 0, 0, 0));
//bid book part
storageB.add(new mrg.PriceVolumeRecord("BTCUSD", 80, 0, 6, 0, 0, 0, 0));
storageB.add(new mrg.PriceVolumeRecord("BTCUSD", 70, 0, 5, 0, 0, 0, 0));
storageB.add(new mrg.PriceVolumeRecord("BTCUSD", 60, 0, 4, 0, 0, 0, 0));


let storageC =  storageB.subtract(storageA);
console.log(storageC);