Initial commit of multiasset branch

This commit is contained in:
2018-11-30 12:27:41 +01:00
parent 45684a9d0e
commit bb18f7cf03
205 changed files with 8656 additions and 2750 deletions

View File

@ -0,0 +1,111 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim;
import opensesim.sesim.Assets.BasicAsset;
import opensesim.sesim.AssetPair;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AssetPairTest {
public AssetPairTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getAsset method, of class AssetPair.
*/
@Test
public void testGetAsset() {
System.out.println("getAsset");
AssetPair instance = new AssetPair(null,null);
opensesim.sesim.interfaces.Asset expResult = null;
opensesim.sesim.interfaces.Asset result = instance.getAsset();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
}
/**
* Test of getCurrency method, of class AssetPair.
*/
@Test
public void testGetCurrency() {
System.out.println("getCurrency");
AssetPair instance = new AssetPair(null,null);
opensesim.sesim.interfaces.Asset expResult = null;
opensesim.sesim.interfaces.Asset result = instance.getCurrency();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
}
/**
* Test of getSymbol method, of class AssetPair.
*/
@Test
public void testGetSymbol() {
System.out.println("getSymbol");
BasicAsset asset = new opensesim.sesim.Assets.BasicAsset("AAPL", "Apple", "Apple Inc.");
BasicAsset currency = new opensesim.sesim.Assets.BasicAsset("EUR", "Euro", "Euro desc");
AssetPair instance = new AssetPair(asset,currency);
String expResult = "AAPL/EUR";
String result = instance.getSymbol();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
}
}

View File

@ -0,0 +1,230 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim;
import opensesim.sesim.Assets.BasicAsset;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AssetTest {
public AssetTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getSymbol method, of class Asset.
*/
@Test
public void testGetSymbol() {
System.out.println("getSymbol");
BasicAsset instance = new BasicAsset();
String expResult = "EUR";
instance.setSymbol(expResult);
String result = instance.getSymbol();
assertEquals(expResult, result);
}
/**
* Test of getConfig method, of class Asset.
*/
@Test
public void testGetConfig() {
System.out.println("getConfig");
BasicAsset instance = new BasicAsset();
int decimals = 17;
String symbol = "EUR";
String description = "Eruo - Europaen currency";
String name = "Euro";
instance.setDecimals(decimals);
instance.setName(name);
instance.setDescription(description);
instance.setSymbol(symbol);
JSONObject result = instance.getConfig();
assertEquals(symbol, result.getString(BasicAsset.JSON_SYMBOL));
assertEquals(name, result.getString(BasicAsset.JSON_NAME));
assertEquals(description, result.getString(BasicAsset.JSON_DESCRIPTION));
assertEquals(decimals, result.getInt(BasicAsset.JSON_DECIMALS));
}
/**
* Test of putConfig method, of class Asset.
*/
@Test
public void testPutConfig() {
System.out.println("putConfig");
int decimals = 17;
String symbol = "EUR";
String name = "Euro";
String description = "Eruo - Europaen currency";
JSONObject cfg = new JSONObject();
cfg.put(BasicAsset.JSON_SYMBOL, symbol);
cfg.put(BasicAsset.JSON_NAME, name);
cfg.put(BasicAsset.JSON_DESCRIPTION, description);
cfg.put(BasicAsset.JSON_DECIMALS, decimals);
BasicAsset instance = new BasicAsset();
instance.putConfig(cfg);
assertEquals(symbol,instance.getSymbol());
assertEquals(name,instance.getName());
assertEquals(description,instance.getDescription());
assertEquals(decimals,instance.getDecimals());
}
/**
* Test of setSymbol method, of class Asset.
*/
@Test
public void testSetSymbol() {
System.out.println("setSymbol");
String symbol = "EUR";
BasicAsset instance = new BasicAsset();
instance.setSymbol(symbol);
String result = instance.getSymbol();
assertEquals(symbol, result);
}
/**
* Test of getName method, of class Asset.
*/
@Test
public void testGetName() {
System.out.println("getName");
BasicAsset instance = new BasicAsset();
String expResult = "Euro";
instance.setName(expResult);
String result = instance.getName();
assertEquals(expResult, result);
}
/**
* Test of setName method, of class Asset.
*/
@Test
public void testSetName() {
System.out.println("setName");
String name = "Euro";
BasicAsset instance = new BasicAsset();
instance.setName(name);
String result = instance.getName();
assertEquals(name, result);
}
/**
* Test of getDescription method, of class Asset.
*/
@Test
public void testGetDescription() {
System.out.println("getDescription");
BasicAsset instance = new BasicAsset();
String expResult = "Euro - European currency";
instance.setDescription(expResult);
String result = instance.getDescription();
assertEquals(expResult, result);
}
/**
* Test of setDescription method, of class Asset.
*/
@Test
public void testSetDescription() {
System.out.println("setDescription");
String description = "Eruo - Eruopean currency";
BasicAsset instance = new BasicAsset();
instance.setDescription(description);
String result = instance.getDescription();
assertEquals(description, result);
}
/**
* Test of getDecimals method, of class Asset.
*/
@Test
public void testGetDecimals() {
System.out.println("getDecimals");
BasicAsset instance = new BasicAsset();
int expResult = 7;
instance.setDecimals(expResult);
int result = instance.getDecimals();
assertEquals(expResult, result);
}
/**
* Test of setDecimals method, of class Asset.
*/
@Test
public void testSetDecimals() {
System.out.println("setDecimals");
int decimals;
decimals = 350;
BasicAsset instance = new BasicAsset();
instance.setDecimals(decimals);
int result = instance.getDecimals();
assertEquals(decimals, result);
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim;
import opensesim.Exchange;
import opensesim.sesim.Assets.BasicAsset;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class ExchangeTest {
public ExchangeTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of add method, of class Exchange.
*/
@Test
public void testAdd() {
System.out.println("add");
BasicAsset a = new BasicAsset();
a.setSymbol("EUR");
Exchange instance = new Exchange();
instance.add(a);
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
}
}

View File

@ -1,163 +0,0 @@
/*
* Copyright (c) 2017, tobias
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.SortedMap;
import java.util.TreeMap;
import java.lang.ClassLoader.*;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import sesim.Scheduler.TimerTaskRunner;
/**
*
* @author tobias
*/
public class Test {
static void tube() {
try {
System.out.printf("Hello %s\n", "args");
if (0 == 0) {
return;
}
} finally {
System.out.printf("Always %s\n", "the end");
}
System.out.print("haha\n");
}
static public String getFullClassName(String classFileName) throws IOException {
File file = new File(classFileName);
FileChannel roChannel = new RandomAccessFile(file, "r").getChannel();
ByteBuffer bb = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, (int) roChannel.size());
String x = new String();
//x.getClass().getClassLoader().loadClass(x);
//Class<?> clazz = defineClass((String)null, bb, (ProtectionDomain)null);
//return clazz.getName();
return "";
}
/* static private <T extends Number> void to(T n, Double o) {
if (Float == T) {
System.out.printf("Double ret %", o.floatValue());
n = (T) (Number) o.floatValue();
}
}
*/
static class Exer extends Thread {
int value = 0;
@Override
public void run() {
while (true) {
try {
System.out.printf("Exer getting Exer Lock");
synchronized (this) {
System.out.printf("Exer having Exer Lock wait 30000\n");
this.wait();
}
} catch (InterruptedException ex) {
System.out.printf("Interrupted\n");
}
System.out.printf("Exer Value %d\n", value);
}
}
}
static class Runner extends Thread {
}
static Scheduler s = new Scheduler();
static class MyTask implements TimerTaskRunner {
long ctr = 0;
@Override
public long timerTask() {
ctr++;
double r = 1;
for (int i = 0; i < 100000; i++) {
r = r + i * r;
r = r + 1.0;
}
synchronized (this) {
try {
wait(500);
} catch (InterruptedException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
}
}
System.out.printf("TimerTask %d %d %f\n", ctr, s.currentTimeMillis(), r);
return 1000;
}
@Override
public long getID() {
return 0;
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws InterruptedException, MalformedURLException, InstantiationException, IllegalAccessException, IOException {
double val = Math.log(12);
double rval = Math.exp(val);
System.out.printf("Result: %f, %f\n", val,rval);
}
}