Exemplo n.º 1
0
    //    END VARIABLES
    //    ------------------------------------------
    //   



    //   ------------------------------------------
    //   Main
    //   
    static void Main() {
        //  Create the ForexFeed Object
        feedapi fxfeed = new feedapi(access_key, symbol, interval, periods, price);
        //  fxfeed.setPrice("bid,ask")
        
        // Display a Conversion
        printConversion(fxfeed);

        //  Display the Quotes
        printData(fxfeed);

        //  Display the available Intervals
        printIntervals(fxfeed);

        //  Display the available Symbols
        printSymbols(fxfeed);
    }
Exemplo n.º 2
0
    //    END VARIABLES
    //    ------------------------------------------
    //



    //   ------------------------------------------
    //   Main
    //
    static void Main()
    {
        //  Create the ForexFeed Object
        feedapi fxfeed = new feedapi(access_key, symbol, interval, periods, price);

        //  fxfeed.setPrice("bid,ask")

        // Display a Conversion
        printConversion(fxfeed);

        //  Display the Quotes
        printData(fxfeed);

        //  Display the available Intervals
        printIntervals(fxfeed);

        //  Display the available Symbols
        printSymbols(fxfeed);
    }
Exemplo n.º 3
0
        public void Initialize(string accessKey, PriceType price)
        {
            _api = new feedapi(accessKey);

            switch (price)
            {
            case PriceType.Bid:
                _api.setPrice("bid");
                break;

            case PriceType.Mid:
                _api.setPrice("mid");
                break;

            case PriceType.Ask:
                _api.setPrice("ask");
                break;
            }
        }
Exemplo n.º 4
0
    // ''  
    // ''  Get a conversion and print it to System.Console
    // ''   
    private static void printConversion(feedapi fxfeed) {

       // Hashtable conversion = fxfeed.getConversion("EUR", "USD", "1");
        Hashtable conversion = fxfeed.getConversion("USD", "EUR", "1");

        Console.WriteLine("-------- Conversion --------");
        if (fxfeed.getStatus().Equals("OK")) {
            Console.Write(conversion["convert_value"] + " ");
            Console.Write(conversion["convert_from"] + " = ");
            Console.Write(conversion["conversion_value"] + " ");
            Console.Write(conversion["convert_to"] + " ");
            Console.WriteLine("(rate: " + conversion["conversion_rate"] + ")");
            Console.WriteLine("");
        }
        else {
            Console.WriteLine(("Status: " + fxfeed.getStatus()));
            Console.WriteLine(("ErrorCode: " + fxfeed.getErrorCode()));
            Console.WriteLine(("ErrorMessage: " + fxfeed.getErrorMessage()));
        }
    }
Exemplo n.º 5
0
    // ''
    // ''  Get a conversion and print it to System.Console
    // ''
    private static void printConversion(feedapi fxfeed)
    {
        // Hashtable conversion = fxfeed.getConversion("EUR", "USD", "1");
        Hashtable conversion = fxfeed.getConversion("USD", "EUR", "1");

        Console.WriteLine("-------- Conversion --------");
        if (fxfeed.getStatus().Equals("OK"))
        {
            Console.Write(conversion["convert_value"] + " ");
            Console.Write(conversion["convert_from"] + " = ");
            Console.Write(conversion["conversion_value"] + " ");
            Console.Write(conversion["convert_to"] + " ");
            Console.WriteLine("(rate: " + conversion["conversion_rate"] + ")");
            Console.WriteLine("");
        }
        else
        {
            Console.WriteLine(("Status: " + fxfeed.getStatus()));
            Console.WriteLine(("ErrorCode: " + fxfeed.getErrorCode()));
            Console.WriteLine(("ErrorMessage: " + fxfeed.getErrorMessage()));
        }
    }
Exemplo n.º 6
0
    // ''
    // ''  Print the Symbols to System.Console
    // ''
    private static void printSymbols(feedapi fxfeed)
    {
        //
        //   Fetch the Symbols
        //
        Hashtable symbols = fxfeed.getAvailableSymbols(false);

        Console.WriteLine("-------- Symbols --------");
        if (fxfeed.getStatus().Equals("OK"))
        {
            //
            //   Get a Collection of values contained in HashMap
            //
            ICollection c = symbols.Values;

            //
            //   Obtain an Iterator for Collection
            //
            IEnumerator itr = c.GetEnumerator();

            //
            //   Iterate through the HashMap values iterator
            //
            while (itr.MoveNext())
            {
                Hashtable value = ((Hashtable)(itr.Current));
                Console.WriteLine(("Symbol: " + value["symbol"]));
                Console.WriteLine(("Title: " + value["title"]));
                Console.WriteLine(("Decimals: " + value["decimals"]));
                Console.WriteLine("");
            }
        }
        else
        {
            Console.WriteLine(("Status: " + fxfeed.getStatus()));
            Console.WriteLine(("ErrorCode: " + fxfeed.getErrorCode()));
            Console.WriteLine(("ErrorMessage: " + fxfeed.getErrorMessage()));
        }
    }
Exemplo n.º 7
0
    // ''
    // ''  Get the data and print it to System.Console
    // ''
    private static void printData(feedapi fxfeed)
    {
        //
        //   Fetch the Data
        //
        ArrayList quotes = fxfeed.getData();

        Console.WriteLine("-------- Quotes --------");
        if (fxfeed.getStatus().Equals("OK"))
        {
            Console.WriteLine(("Number of Quotes: " + fxfeed.getNumQuotes()));
            Console.WriteLine(("Copyright: " + fxfeed.getCopyright()));
            Console.WriteLine(("Website: " + fxfeed.getWebsite()));
            Console.WriteLine(("License: " + fxfeed.getLicense()));
            Console.WriteLine(("Redistribution: " + fxfeed.getRedistribution()));
            Console.WriteLine(("AccessPeriod: " + fxfeed.getAccessPeriod()));
            Console.WriteLine(("AccessPerPeriod: " + fxfeed.getAccessPerPeriod()));
            Console.WriteLine(("AccessThisPeriod: " + fxfeed.getAccessThisPeriod()));
            Console.WriteLine(("AccessRemainingThisPeriod: " + fxfeed.getAccessPeriodRemaining()));
            Console.WriteLine(("AccessPeriodBegan: " + fxfeed.getAccessPeriodBegan()));
            Console.WriteLine(("NextAccessPeriodStarts: " + fxfeed.getAccessPeriodStarts()));

            //
            //   Get an Iterator object for the quotes ArrayList using iterator() method.
            //
            IEnumerator itr = quotes.GetEnumerator();

            //
            //   Iterate through the ArrayList iterator
            //
            Console.WriteLine("----------------------------------------");
            Console.WriteLine("Iterating through Quotes...");
            Console.WriteLine("----------------------------------------");
            while (itr.MoveNext())
            {
                Hashtable quote = ((Hashtable)(itr.Current));
                Console.WriteLine(("Quote Symbol: " + quote["symbol"]));
                Console.WriteLine(("Title: " + quote["title"]));
                Console.WriteLine(("Time: " + quote["time"]));

                if ((fxfeed.getInterval() == 1))
                {
                    if (fxfeed.getPrice().Equals("bid,ask"))
                    {
                        Console.WriteLine(("Bid: " + quote["bid"]));
                        Console.WriteLine(("Ask: " + quote["ask"]));
                    }
                    else
                    {
                        Console.WriteLine(("Price: " + quote["price"]));
                    }
                }
                else
                {
                    Console.WriteLine(("Open: " + quote["open"]));
                    Console.WriteLine(("High: " + quote["high"]));
                    Console.WriteLine(("Low: " + quote["low"]));
                    Console.WriteLine(("Close: " + quote["close"]));
                }
                Console.WriteLine("");
            }
        }
        else
        {
            Console.WriteLine(("Status: " + fxfeed.getStatus()));
            Console.WriteLine(("ErrorCode: " + fxfeed.getErrorCode()));
            Console.WriteLine(("ErrorMessage: " + fxfeed.getErrorMessage()));
        }
    }
Exemplo n.º 8
0
    // ''  
    // ''  Print the Symbols to System.Console
    // ''   
    private static void printSymbols(feedapi fxfeed) {
        //     
        //   Fetch the Symbols
        //      
        Hashtable symbols = fxfeed.getAvailableSymbols(false);
        Console.WriteLine("-------- Symbols --------");
        if (fxfeed.getStatus().Equals("OK")) {
            //       
            //   Get a Collection of values contained in HashMap
            //        
            ICollection c = symbols.Values;

            //       
            //   Obtain an Iterator for Collection
            //        
            IEnumerator itr = c.GetEnumerator();

            //       
            //   Iterate through the HashMap values iterator
            //        
            while (itr.MoveNext()) {
                Hashtable value = ((Hashtable)(itr.Current));
                Console.WriteLine(("Symbol: " + value["symbol"]));
                Console.WriteLine(("Title: " + value["title"]));
                Console.WriteLine(("Decimals: " + value["decimals"]));
                Console.WriteLine("");
            }
        }
        else {
            Console.WriteLine(("Status: " + fxfeed.getStatus()));
            Console.WriteLine(("ErrorCode: " + fxfeed.getErrorCode()));
            Console.WriteLine(("ErrorMessage: " + fxfeed.getErrorMessage()));
        }
    }
Exemplo n.º 9
0
    // ''  
    // ''  Get the data and print it to System.Console
    // ''   
    private static void printData(feedapi fxfeed) {
        //     
        //   Fetch the Data
        //      
        ArrayList quotes = fxfeed.getData();
        Console.WriteLine("-------- Quotes --------");
        if (fxfeed.getStatus().Equals("OK")) {
            Console.WriteLine(("Number of Quotes: " + fxfeed.getNumQuotes()));
            Console.WriteLine(("Copyright: " + fxfeed.getCopyright()));
            Console.WriteLine(("Website: " + fxfeed.getWebsite()));
            Console.WriteLine(("License: " + fxfeed.getLicense()));
            Console.WriteLine(("Redistribution: " + fxfeed.getRedistribution()));
            Console.WriteLine(("AccessPeriod: " + fxfeed.getAccessPeriod()));
            Console.WriteLine(("AccessPerPeriod: " + fxfeed.getAccessPerPeriod()));
            Console.WriteLine(("AccessThisPeriod: " + fxfeed.getAccessThisPeriod()));
            Console.WriteLine(("AccessRemainingThisPeriod: " + fxfeed.getAccessPeriodRemaining()));
            Console.WriteLine(("AccessPeriodBegan: " + fxfeed.getAccessPeriodBegan()));
            Console.WriteLine(("NextAccessPeriodStarts: " + fxfeed.getAccessPeriodStarts()));

            //       
            //   Get an Iterator object for the quotes ArrayList using iterator() method.
            //        
            IEnumerator itr = quotes.GetEnumerator();

            //       
            //   Iterate through the ArrayList iterator
            //        
            Console.WriteLine("----------------------------------------");
            Console.WriteLine("Iterating through Quotes...");
            Console.WriteLine("----------------------------------------");
            while (itr.MoveNext()){
                Hashtable quote = ((Hashtable)(itr.Current));
                Console.WriteLine(("Quote Symbol: " + quote["symbol"]));
                Console.WriteLine(("Title: " + quote["title"]));
                Console.WriteLine(("Time: " + quote["time"]));

                if ((fxfeed.getInterval() == 1)) {
                    if (fxfeed.getPrice().Equals("bid,ask")) {
                        Console.WriteLine(("Bid: " + quote["bid"]));
                        Console.WriteLine(("Ask: " + quote["ask"]));
                    }
                    else {
                        Console.WriteLine(("Price: " + quote["price"]));
                    }
                }
                else {
                    Console.WriteLine(("Open: " + quote["open"]));
                    Console.WriteLine(("High: " + quote["high"]));
                    Console.WriteLine(("Low: " + quote["low"]));
                    Console.WriteLine(("Close: " + quote["close"]));
                }
                Console.WriteLine("");
            }
        }
        else {
            Console.WriteLine(("Status: " + fxfeed.getStatus()));
            Console.WriteLine(("ErrorCode: " + fxfeed.getErrorCode()));
            Console.WriteLine(("ErrorMessage: " + fxfeed.getErrorMessage()));
        }
    }
Exemplo n.º 10
0
 public ForexFeeder(string symbol, int interval, int periods, string price)
 {
     _api = new feedapi(AccessKey, symbol, interval, periods, price);
 }