public static void Main11(string[] args) { // get properties from file getProperties(); wrapper = new AdharaHFT(domain, url_stream, url_polling, url_challenge, url_token, user, password, authentication_port, request_port, ssl, ssl_cert); bool auth = wrapper.doAuthentication(); if (!auth) { Console.WriteLine("Authentication failed"); Console.Read(); return; } // MODIFY PENDING ORDER WITH ORDER STREAMING // get tinterfaces List <AdharaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; // Open order streaming AdharaHFTListenerImp10 listener = new AdharaHFTListenerImp10(); string id1 = wrapper.getOrderBegin(null, null, null, interval, listener); Thread.Sleep(5000); // get current price double price = 0.0; List <AdharaHFT.priceTick> priceTickList1 = wrapper.getPrice(new List <string> { "EUR/USD" }, new List <string> { tinterface1 }, AdharaHFT.GRANULARITY_TOB, 1); foreach (AdharaHFT.priceTick tick in priceTickList1) { price = tick.price; } // Create pending order. If buy, order price must be lower than current price AdharaHFT.orderRequest order1 = new AdharaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface1; order1.quantity = 500000; order1.side = AdharaHFT.SIDE_BUY; order1.type = AdharaHFT.TYPE_LIMIT; order1.timeinforce = AdharaHFT.VALIDITY_DAY; order1.price = price - 0.01; List <AdharaHFT.orderRequest> orderList = wrapper.setOrder(new List <AdharaHFT.orderRequest> { order1 }); int tempid = -1; foreach (AdharaHFT.orderRequest orderresponse in orderList) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); tempid = orderresponse.tempid; } Thread.Sleep(5000); // Modify pending order Console.WriteLine("Modify order"); AdharaHFT.modOrder ordermod = new AdharaHFT.modOrder(); ordermod.fixid = listener.fixidDictionary[tempid]; ordermod.price = price - 0.015; ordermod.quantity = 200000; List <AdharaHFT.modifyTick> modifyList = wrapper.modifyOrder(new List <AdharaHFT.modOrder> { ordermod }); foreach (AdharaHFT.modifyTick modifyresponse in modifyList) { Console.WriteLine("FixId: " + modifyresponse.fixid + " Result: " + modifyresponse.result); } Console.WriteLine("Order modified"); Thread.Sleep(2000); // Close order streaming wrapper.getOrderEnd(id1); Console.WriteLine("Press Enter to exit"); Console.Read(); }
public static void Main9(string[] args) { // get properties from file getProperties(); wrapper = new AdharaHFT(domain, url_stream, url_polling, url_challenge, url_token, user, password, authentication_port, request_port, ssl, ssl_cert); bool auth = wrapper.doAuthentication(); if (!auth) { Console.WriteLine("Authentication failed"); Console.Read(); return; } // MODIFY PENDING ORDER WITH ORDER POLLING // get tinterfaces List <AdharaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; Console.WriteLine("Starting Polling1"); List <AdharaHFT.orderTick> orderTickList1 = wrapper.getOrder(null, null, new List <string> { AdharaHFT.ORDERTYPE_PENDING }); foreach (AdharaHFT.orderTick tick in orderTickList1) { Console.WriteLine("TempId: " + tick.tempid + " OrderId: " + tick.orderid + " Security: " + tick.security + " Account: " + tick.account + " Quantity: " + tick.quantity + " Type: " + tick.type + " Side: " + tick.side + " Status: " + tick.status + " Price: " + tick.limitprice); } Console.WriteLine("Polling1 Finished"); Thread.Sleep(2000); // get current price double price = 0.0; List <AdharaHFT.priceTick> priceTickList1 = wrapper.getPrice(new List <string> { "EUR/USD" }, new List <string> { tinterface1 }, AdharaHFT.GRANULARITY_TOB, 1); foreach (AdharaHFT.priceTick tick in priceTickList1) { price = tick.price; } // Create pending order. If buy, order price must be lower than current price AdharaHFT.orderRequest order1 = new AdharaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface1; order1.quantity = 500000; order1.side = AdharaHFT.SIDE_BUY; order1.type = AdharaHFT.TYPE_LIMIT; order1.timeinforce = AdharaHFT.VALIDITY_DAY; order1.price = price - 0.01; Console.WriteLine("Sending order"); int tempid = -1; string fixid = ""; List <AdharaHFT.orderRequest> orderList = wrapper.setOrder(new List <AdharaHFT.orderRequest> { order1 }); foreach (AdharaHFT.orderRequest orderresponse in orderList) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); tempid = orderresponse.tempid; } Console.WriteLine("Order sended order"); Thread.Sleep(2000); Console.WriteLine("Starting Polling2"); List <AdharaHFT.orderTick> orderTickList2 = wrapper.getOrder(null, null, new List <string> { AdharaHFT.ORDERTYPE_PENDING }); foreach (AdharaHFT.orderTick tick in orderTickList2) { Console.WriteLine("TempId: " + tick.tempid + " OrderId: " + tick.orderid + " Security: " + tick.security + " Account: " + tick.account + " Quantity: " + tick.quantity + " Type: " + tick.type + " Side: " + tick.side + " Status: " + tick.status + " Price: " + tick.limitprice); if (tempid == tick.tempid) { fixid = tick.fixid; } } Console.WriteLine("Polling2 Finished"); Thread.Sleep(2000); Console.WriteLine("Modify order"); AdharaHFT.modOrder ordermod = new AdharaHFT.modOrder(); ordermod.fixid = fixid; ordermod.price = price - 0.015; ordermod.quantity = 200000; List <AdharaHFT.modifyTick> modifyList = wrapper.modifyOrder(new List <AdharaHFT.modOrder> { ordermod }); foreach (AdharaHFT.modifyTick modifyresponse in modifyList) { Console.WriteLine("FixId: " + modifyresponse.fixid + " Result: " + modifyresponse.result); } Console.WriteLine("Order modified"); Thread.Sleep(2000); Console.WriteLine("Starting Polling3"); List <AdharaHFT.orderTick> orderTickList3 = wrapper.getOrder(null, null, new List <string> { AdharaHFT.ORDERTYPE_PENDING }); foreach (AdharaHFT.orderTick tick in orderTickList3) { Console.WriteLine("TempId: " + tick.tempid + " OrderId: " + tick.orderid + " Security: " + tick.security + " Account: " + tick.account + " Quantity: " + tick.quantity + " Type: " + tick.type + " Side: " + tick.side + " Status: " + tick.status + " Price: " + tick.limitprice); } Console.WriteLine("Polling3 Finished"); Console.WriteLine("Press Enter to exit"); Console.Read(); }