public static void checkPrices() { if ((bestcanask < bestbaxbid && bestcanask > 0.0) || (bestbaxask < bestcanbid && bestbaxask > 0.0)) { ArthikaHFT.orderRequest orderask = new ArthikaHFT.orderRequest(); ArthikaHFT.orderRequest orderbid = new ArthikaHFT.orderRequest(); int quantity = 0; if (bestcanask < bestbaxbid && bestcanask > 0.0) { quantity = bestcanaskliquidity; if (bestcanaskliquidity > bestbaxbidliquidity) { quantity = bestbaxbidliquidity; } orderask.tinterface = tinterface2; orderbid.tinterface = tinterface1; orderask.price = bestcanask; orderbid.price = bestbaxbid; } if (bestbaxask < bestcanbid && bestbaxask > 0.0) { quantity = bestbaxaskliquidity; if (bestbaxaskliquidity > bestcanbidliquidity) { quantity = bestcanbidliquidity; } orderask.tinterface = tinterface1; orderbid.tinterface = tinterface2; orderask.price = bestbaxask; orderbid.price = bestcanbid; } orderask.security = "EUR/USD"; orderask.quantity = quantity; orderask.side = ArthikaHFT.SIDE_BUY; orderask.type = ArthikaHFT.TYPE_LIMIT; orderask.timeinforce = ArthikaHFT.VALIDITY_DAY; orderbid.security = "EUR/USD"; orderbid.quantity = quantity; orderbid.side = ArthikaHFT.SIDE_SELL; orderbid.type = ArthikaHFT.TYPE_LIMIT; orderbid.timeinforce = ArthikaHFT.VALIDITY_DAY; try { List <ArthikaHFT.orderRequest> orderList1 = wrapper.setOrder(new List <ArthikaHFT.orderRequest> { orderask, orderbid }); foreach (ArthikaHFT.orderRequest orderresponse in orderList1) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public static void Main10(string[] args) { // get properties from file getProperties(); wrapper = new ArthikaHFT(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; } // CANCEL PENDING ORDER WITH ORDER STREAMING // get tinterfaces List<ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; // Open order streaming ArthikaHFTListenerImp10 listener = new ArthikaHFTListenerImp10(); string id1 = wrapper.getOrderBegin(null, null, null, interval, listener); Thread.Sleep(5000); // get current price double price = 0.0; List<ArthikaHFT.priceTick> priceTickList1 = wrapper.getPrice(new List<string> { "EUR/USD" }, new List<string> { tinterface1 }, ArthikaHFT.GRANULARITY_TOB, 1); foreach (ArthikaHFT.priceTick tick in priceTickList1) { price = tick.price; } // Create pending order. If buy, order price must be lower than current price ArthikaHFT.orderRequest order1 = new ArthikaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface1; order1.quantity = 500000; order1.side = ArthikaHFT.SIDE_BUY; order1.type = ArthikaHFT.TYPE_LIMIT; order1.timeinforce = ArthikaHFT.VALIDITY_DAY; order1.price = price - 0.01; List<ArthikaHFT.orderRequest> orderList = wrapper.setOrder(new List<ArthikaHFT.orderRequest> { order1 }); int tempid = -1; foreach (ArthikaHFT.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); // Cancel pending order Console.WriteLine("Cancel order"); String fixid = listener.fixidDictionary[tempid]; List<ArthikaHFT.cancelTick> cancelList = wrapper.cancelOrder(new List<string> { fixid }); foreach (ArthikaHFT.cancelTick cancelresponse in cancelList) { Console.WriteLine("FixId: " + cancelresponse.fixid + " Result: " + cancelresponse.result); } Console.WriteLine("Order canceled"); Thread.Sleep(2000); // Close order streaming wrapper.getOrderEnd(id1); Console.WriteLine("Press Enter to exit"); Console.Read(); }
public static void Main10(string[] args) { // get properties from file getProperties(); wrapper = new ArthikaHFT(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; } // CANCEL PENDING ORDER WITH ORDER STREAMING // get tinterfaces List <ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; // Open order streaming ArthikaHFTListenerImp10 listener = new ArthikaHFTListenerImp10(); string id1 = wrapper.getOrderBegin(null, null, null, interval, listener); Thread.Sleep(5000); // get current price double price = 0.0; List <ArthikaHFT.priceTick> priceTickList1 = wrapper.getPrice(new List <string> { "EUR/USD" }, new List <string> { tinterface1 }, ArthikaHFT.GRANULARITY_TOB, 1); foreach (ArthikaHFT.priceTick tick in priceTickList1) { price = tick.price; } // Create pending order. If buy, order price must be lower than current price ArthikaHFT.orderRequest order1 = new ArthikaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface1; order1.quantity = 500000; order1.side = ArthikaHFT.SIDE_BUY; order1.type = ArthikaHFT.TYPE_LIMIT; order1.timeinforce = ArthikaHFT.VALIDITY_DAY; order1.price = price - 0.01; List <ArthikaHFT.orderRequest> orderList = wrapper.setOrder(new List <ArthikaHFT.orderRequest> { order1 }); int tempid = -1; foreach (ArthikaHFT.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); // Cancel pending order Console.WriteLine("Cancel order"); String fixid = listener.fixidDictionary[tempid]; List <ArthikaHFT.cancelTick> cancelList = wrapper.cancelOrder(new List <string> { fixid }); foreach (ArthikaHFT.cancelTick cancelresponse in cancelList) { Console.WriteLine("FixId: " + cancelresponse.fixid + " Result: " + cancelresponse.result); } Console.WriteLine("Order canceled"); Thread.Sleep(2000); // Close order streaming wrapper.getOrderEnd(id1); Console.WriteLine("Press Enter to exit"); Console.Read(); }
public static void Main13(string[] args) { // get properties from file getProperties(); wrapper = new ArthikaHFT(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; } // MULTIPLE ORDER CREATION // get tinterfaces List<ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; string tinterface2; if (tinterfaceTickList.Count > 1) { tinterface2 = tinterfaceTickList[1].name; } else { tinterface2 = tinterfaceTickList[0].name; } ArthikaHFT.orderRequest order1 = new ArthikaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface2; order1.quantity = 1000000; order1.side = ArthikaHFT.SIDE_BUY; order1.type = ArthikaHFT.TYPE_MARKET; order1.timeinforce = ArthikaHFT.VALIDITY_DAY; ArthikaHFT.orderRequest order2 = new ArthikaHFT.orderRequest(); order2.security = "EUR/USD"; order2.tinterface = tinterface1; order2.quantity = 1000000; order2.side = ArthikaHFT.SIDE_SELL; order2.type = ArthikaHFT.TYPE_MARKET; order2.timeinforce = ArthikaHFT.VALIDITY_DAY; ArthikaHFT.orderRequest order3 = new ArthikaHFT.orderRequest(); order3.security = "EUR/USD"; order3.tinterface = tinterface2; order3.quantity = 2000000; order3.side = ArthikaHFT.SIDE_BUY; order3.type = ArthikaHFT.TYPE_MARKET; order3.timeinforce = ArthikaHFT.VALIDITY_DAY; ArthikaHFT.orderRequest order4 = new ArthikaHFT.orderRequest(); order4.security = "EUR/USD"; order4.tinterface = tinterface1; order4.quantity = 2000000; order4.side = ArthikaHFT.SIDE_SELL; order4.type = ArthikaHFT.TYPE_MARKET; order4.timeinforce = ArthikaHFT.VALIDITY_DAY; ArthikaHFT.orderRequest order5 = new ArthikaHFT.orderRequest(); order5.security = "EUR/USD"; order5.tinterface = tinterface2; order5.quantity = 1000000; order5.side = ArthikaHFT.SIDE_BUY; order5.type = ArthikaHFT.TYPE_MARKET; order5.timeinforce = ArthikaHFT.VALIDITY_DAY; ArthikaHFT.orderRequest order6 = new ArthikaHFT.orderRequest(); order6.security = "EUR/USD"; order6.tinterface = tinterface1; order6.quantity = 1000000; order6.side = ArthikaHFT.SIDE_SELL; order6.type = ArthikaHFT.TYPE_MARKET; order6.timeinforce = ArthikaHFT.VALIDITY_DAY; Console.WriteLine("Starting Polling1"); List<ArthikaHFT.orderTick> orderTickList1 = wrapper.getOrder(new List<string> { "EUR/USD" }, null, null); foreach (ArthikaHFT.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); } Console.WriteLine("Polling1 Finished"); Thread.Sleep(5000); Console.WriteLine("Sending order"); List<ArthikaHFT.orderRequest> orderList1 = wrapper.setOrder(new List<ArthikaHFT.orderRequest> { order1, order2, order3, order4, order5, order6, order1, order2, order3, order4, order5, order6, order1, order2, order3, order4, order5, order6 }); foreach (ArthikaHFT.orderRequest orderresponse in orderList1) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); } List<ArthikaHFT.orderRequest> orderList2 = wrapper.setOrder(new List<ArthikaHFT.orderRequest> { order1, order2, order3, order4, order5, order6, order1, order2, order3, order4, order5, order6, order1, order2, order3, order4, order5, order6 }); foreach (ArthikaHFT.orderRequest orderresponse in orderList2) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); } List<ArthikaHFT.orderRequest> orderList3 = wrapper.setOrder(new List<ArthikaHFT.orderRequest> { order1, order2, order3, order4, order5, order6, order1, order2, order3, order4, order5, order6, order1, order2, order3, order4, order5, order6 }); foreach (ArthikaHFT.orderRequest orderresponse in orderList3) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); } Console.WriteLine("Order sended"); Thread.Sleep(5000); Console.WriteLine("Starting Polling2"); List<ArthikaHFT.orderTick> orderTickList2 = wrapper.getOrder(new List<string> { "EUR/USD" }, null, null); foreach (ArthikaHFT.orderTick tick in orderTickList2) { Console.WriteLine("TempId: " + tick.tempid + " OrderId: " + tick.orderid + " Security: " + tick.security + " Account: " + tick.account + " Quantity: " + tick.finishedquantity + " Type: " + tick.type + " Side: " + tick.side + " Status: " + tick.status); } Console.WriteLine("Polling2 Finished"); Console.WriteLine("Press Enter to exit"); Console.Read(); }
public static void Main3(string[] args) { // get properties from file getProperties(); wrapper = new ArthikaHFT(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; } // POSITION STREAMING // get tinterfaces List<ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; ArthikaHFT.orderRequest order1 = new ArthikaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface1; order1.quantity = 400000; order1.side = ArthikaHFT.SIDE_SELL; order1.type = ArthikaHFT.TYPE_LIMIT; order1.timeinforce = ArthikaHFT.VALIDITY_DAY; order1.price = 1.15548; string tinterface2; if (tinterfaceTickList.Count > 1) { tinterface2 = tinterfaceTickList[1].name; } else { tinterface2 = tinterfaceTickList[0].name; } ArthikaHFT.orderRequest order2 = new ArthikaHFT.orderRequest(); order2.security = "GBP/USD"; order2.tinterface = tinterface2; order2.quantity = 500000; order2.side = ArthikaHFT.SIDE_BUY; order2.type = ArthikaHFT.TYPE_LIMIT; order2.timeinforce = ArthikaHFT.VALIDITY_FILLORKILL; order2.price = 1.67389; // Open position streaming string id1 = wrapper.getPositionBegin(null, new List<string> { "EUR/USD", "GBP/USD" }, null, interval, new ArthikaHFTListenerImp3()); Thread.Sleep(5000); // Create two orders List<ArthikaHFT.orderRequest> orderList = wrapper.setOrder(new List<ArthikaHFT.orderRequest> { order1, order2 }); foreach (ArthikaHFT.orderRequest orderresponse in orderList) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); } Thread.Sleep(5000); // Close position streaming wrapper.getPositionEnd(id1); Console.WriteLine("Press Enter to exit"); Console.Read(); }
public static void Main9(string[] args) { // get properties from file getProperties(); wrapper = new ArthikaHFT(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 <ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; Console.WriteLine("Starting Polling1"); List <ArthikaHFT.orderTick> orderTickList1 = wrapper.getOrder(null, null, new List <string> { ArthikaHFT.ORDERTYPE_PENDING }); foreach (ArthikaHFT.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 <ArthikaHFT.priceTick> priceTickList1 = wrapper.getPrice(new List <string> { "EUR/USD" }, new List <string> { tinterface1 }, ArthikaHFT.GRANULARITY_TOB, 1); foreach (ArthikaHFT.priceTick tick in priceTickList1) { price = tick.price; } // Create pending order. If buy, order price must be lower than current price ArthikaHFT.orderRequest order1 = new ArthikaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface1; order1.quantity = 500000; order1.side = ArthikaHFT.SIDE_BUY; order1.type = ArthikaHFT.TYPE_LIMIT; order1.timeinforce = ArthikaHFT.VALIDITY_DAY; order1.price = price - 0.01; Console.WriteLine("Sending order"); int tempid = -1; string fixid = ""; List <ArthikaHFT.orderRequest> orderList = wrapper.setOrder(new List <ArthikaHFT.orderRequest> { order1 }); foreach (ArthikaHFT.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 <ArthikaHFT.orderTick> orderTickList2 = wrapper.getOrder(null, null, new List <string> { ArthikaHFT.ORDERTYPE_PENDING }); foreach (ArthikaHFT.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"); ArthikaHFT.modOrder ordermod = new ArthikaHFT.modOrder(); ordermod.fixid = fixid; ordermod.price = price - 0.015; ordermod.quantity = 200000; List <ArthikaHFT.modifyTick> modifyList = wrapper.modifyOrder(new List <ArthikaHFT.modOrder> { ordermod }); foreach (ArthikaHFT.modifyTick modifyresponse in modifyList) { Console.WriteLine("FixId: " + modifyresponse.fixid + " Result: " + modifyresponse.result); } Console.WriteLine("Order modified"); Thread.Sleep(2000); Console.WriteLine("Starting Polling3"); List <ArthikaHFT.orderTick> orderTickList3 = wrapper.getOrder(null, null, new List <string> { ArthikaHFT.ORDERTYPE_PENDING }); foreach (ArthikaHFT.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(); }
public static void Main7(string[] args) { // get properties from file getProperties(); wrapper = new ArthikaHFT(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; } // ORDER CREATION // get tinterfaces List <ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface; if (tinterfaceTickList.Count > 1) { tinterface = tinterfaceTickList[1].name; } else { tinterface = tinterfaceTickList[0].name; } ArthikaHFT.orderRequest order1 = new ArthikaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface; order1.quantity = 500000; order1.side = ArthikaHFT.SIDE_BUY; order1.type = ArthikaHFT.TYPE_MARKET; Console.WriteLine("Starting Polling1"); List <ArthikaHFT.orderTick> orderTickList1 = wrapper.getOrder(new List <string> { "EUR/USD" }, new List <string> { tinterface }, null); foreach (ArthikaHFT.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); } Console.WriteLine("Polling1 Finished"); Thread.Sleep(2000); Console.WriteLine("Sending order"); List <ArthikaHFT.orderRequest> orderList = wrapper.setOrder(new List <ArthikaHFT.orderRequest> { order1 }); foreach (ArthikaHFT.orderRequest orderresponse in orderList) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); } Console.WriteLine("Order sended"); Thread.Sleep(2000); Console.WriteLine("Starting Polling2"); List <ArthikaHFT.orderTick> orderTickList2 = wrapper.getOrder(new List <string> { "EUR/USD" }, new List <string> { tinterface }, null); foreach (ArthikaHFT.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); } Console.WriteLine("Polling2 Finished"); Console.WriteLine("Press Enter to exit"); Console.Read(); }
public static void Main3(string[] args) { // get properties from file getProperties(); wrapper = new ArthikaHFT(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; } // POSITION STREAMING // get tinterfaces List <ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; ArthikaHFT.orderRequest order1 = new ArthikaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface1; order1.quantity = 400000; order1.side = ArthikaHFT.SIDE_SELL; order1.type = ArthikaHFT.TYPE_LIMIT; order1.timeinforce = ArthikaHFT.VALIDITY_DAY; order1.price = 1.15548; string tinterface2; if (tinterfaceTickList.Count > 1) { tinterface2 = tinterfaceTickList[1].name; } else { tinterface2 = tinterfaceTickList[0].name; } ArthikaHFT.orderRequest order2 = new ArthikaHFT.orderRequest(); order2.security = "GBP/USD"; order2.tinterface = tinterface2; order2.quantity = 500000; order2.side = ArthikaHFT.SIDE_BUY; order2.type = ArthikaHFT.TYPE_LIMIT; order2.timeinforce = ArthikaHFT.VALIDITY_FILLORKILL; order2.price = 1.67389; // Open position streaming string id1 = wrapper.getPositionBegin(null, new List <string> { "EUR/USD", "GBP/USD" }, null, interval, new ArthikaHFTListenerImp3()); Thread.Sleep(5000); // Create two orders List <ArthikaHFT.orderRequest> orderList = wrapper.setOrder(new List <ArthikaHFT.orderRequest> { order1, order2 }); foreach (ArthikaHFT.orderRequest orderresponse in orderList) { Console.WriteLine("Id: " + orderresponse.tempid + " Security: " + orderresponse.security + " Side: " + orderresponse.side + " Quantity: " + orderresponse.quantity + " Price: " + orderresponse.price + " Type: " + orderresponse.type); } Thread.Sleep(5000); // Close position streaming wrapper.getPositionEnd(id1); Console.WriteLine("Press Enter to exit"); Console.Read(); }
public static void Main8(string[] args) { // get properties from file getProperties(); wrapper = new ArthikaHFT(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; } // CANCEL PENDING ORDER WITH ORDER POLLING // get tinterfaces List<ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface(); string tinterface1 = tinterfaceTickList[0].name; Console.WriteLine("Starting Polling1"); List<ArthikaHFT.orderTick> orderTickList1 = wrapper.getOrder(null, null, new List<string> { ArthikaHFT.ORDERTYPE_PENDING, ArthikaHFT.ORDERTYPE_CANCELED }); foreach (ArthikaHFT.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<ArthikaHFT.priceTick> priceTickList1 = wrapper.getPrice(new List<string> { "EUR/USD" }, new List<string> { tinterface1 }, ArthikaHFT.GRANULARITY_TOB, 1); foreach (ArthikaHFT.priceTick tick in priceTickList1) { price = tick.price; } // Create pending order. If buy, order price must be lower than current price ArthikaHFT.orderRequest order1 = new ArthikaHFT.orderRequest(); order1.security = "EUR/USD"; order1.tinterface = tinterface1; order1.quantity = 500000; order1.side = ArthikaHFT.SIDE_BUY; order1.type = ArthikaHFT.TYPE_LIMIT; order1.timeinforce = ArthikaHFT.VALIDITY_DAY; order1.price = price - 0.01; Console.WriteLine("Sending order"); int tempid = -1; string fixid = ""; List<ArthikaHFT.orderRequest> orderList = wrapper.setOrder(new List<ArthikaHFT.orderRequest> { order1 }); foreach (ArthikaHFT.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<ArthikaHFT.orderTick> orderTickList2 = wrapper.getOrder(null, null, new List<string> { ArthikaHFT.ORDERTYPE_PENDING, ArthikaHFT.ORDERTYPE_CANCELED }); foreach (ArthikaHFT.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("Cancel order"); List<ArthikaHFT.cancelTick> cancelList = wrapper.cancelOrder(new List<string> { fixid }); foreach (ArthikaHFT.cancelTick cancelresponse in cancelList) { Console.WriteLine("FixId: " + cancelresponse.fixid + " Result: " + cancelresponse.result); } Console.WriteLine("Order canceled"); Thread.Sleep(2000); Console.WriteLine("Starting Polling3"); List<ArthikaHFT.orderTick> orderTickList3 = wrapper.getOrder(null, null, new List<string> { ArthikaHFT.ORDERTYPE_PENDING, ArthikaHFT.ORDERTYPE_CANCELED }); foreach (ArthikaHFT.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(); }