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 Main5(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 STREAMING

        // get tinterfaces
        List<ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface();

        string tinterface1;
        if (tinterfaceTickList.Count > 1)
        {
            tinterface1 = tinterfaceTickList[1].name;
        }
        else
        {
            tinterface1 = tinterfaceTickList[0].name;
        }
        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 = 1.10548;

        string tinterface2 = tinterfaceTickList[0].name;
        ArthikaHFT.orderRequest order2 = new ArthikaHFT.orderRequest();
        order2.security = "GBP/USD";
        order2.tinterface = tinterface2;
        order2.quantity = 600000;
        order2.side = ArthikaHFT.SIDE_BUY;
        order2.type = ArthikaHFT.TYPE_LIMIT;
        order2.timeinforce = ArthikaHFT.VALIDITY_DAY;
        order2.price = 1.47389;

        // Open order streaming
        string id1 = wrapper.getOrderBegin(null, null, null, interval, new ArthikaHFTListenerImp5());
        Thread.Sleep(2000);

        // 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 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();
    }
Beispiel #4
0
    public static void Main5(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 STREAMING

        // get tinterfaces
        List <ArthikaHFT.tinterfaceTick> tinterfaceTickList = wrapper.getInterface();

        string tinterface1;

        if (tinterfaceTickList.Count > 1)
        {
            tinterface1 = tinterfaceTickList[1].name;
        }
        else
        {
            tinterface1 = tinterfaceTickList[0].name;
        }
        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       = 1.10548;

        string tinterface2 = tinterfaceTickList[0].name;

        ArthikaHFT.orderRequest order2 = new ArthikaHFT.orderRequest();
        order2.security    = "GBP/USD";
        order2.tinterface  = tinterface2;
        order2.quantity    = 600000;
        order2.side        = ArthikaHFT.SIDE_BUY;
        order2.type        = ArthikaHFT.TYPE_LIMIT;
        order2.timeinforce = ArthikaHFT.VALIDITY_DAY;
        order2.price       = 1.47389;

        // Open order streaming
        string id1 = wrapper.getOrderBegin(null, null, null, interval, new ArthikaHFTListenerImp5());

        Thread.Sleep(2000);

        // 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 order streaming
        wrapper.getOrderEnd(id1);

        Console.WriteLine("Press Enter to exit");
        Console.Read();
    }