Example #1
0
        public BinaryPosition SendPosition(string Symbol, string PosType, double Amount, double Price, int LifeTimeMinutes, string OriginalID = null)
        {
            if (NewPositionInProgress)
            {
                DebugLog.WriteLine("SendPosition error: Another position opening in progress");
                return(null);
            }

            NewPositionInProgress = true;

            NewPositionError            = false;
            NewPositionErrorMessage     = string.Empty;
            NewPositionOpenPrice        = 0;
            NewPositionResponseReceived = false;
            NewPositionID = 0;

            int WinPercent    = -1;
            int LossPercent   = -1;
            int ParityPercent = -1;

            Timeframe tf = null;
            Symbol    s  = null;

            try
            {
                tf = TradeSettings.GetTimeframeByMinutes(LifeTimeMinutes);
                s  = TradeSettings.GetSymbolByName(Symbol);

                WinPercent    = s.PayoutWinByTimeframeID[tf.TimeframeID];
                LossPercent   = TradeSettings.PayoutLose;
                ParityPercent = TradeSettings.PayoutParity;
            }
            catch (Exception e)
            {
                DebugLog.WriteLine("SendPosition error: position is not supported | " + e.Message);
                NewPositionInProgress = false;
                return(null);
            }

            int    ts         = DateTimeToTimestamp(DateTime.UtcNow);
            string client_lts = ts.ToString() + "000";
            string rate_lts   = ts.ToString() + "000";


            if (s.AssetID <= 0 || GetDirectionID(PosType) <= 0 || tf.TimeframeID <= 0)
            {
                DebugLog.WriteLine("SendPosition error: position is not supported");
                NewPositionInProgress = false;
                return(null);
            }



            string Request = "{\"type\":\"REQUEST\",\"action\":\"option/buy\",\"body\":{\"option_type_id\":\"1\",\"direction_id\":" + GetDirectionID(PosType) + ",\"asset_id\":\"" + s.AssetID + "\",\"amount\":" + Amount + ",\"time_frame_id\":\"" + tf.TimeframeID + "\",\"win_percent\":" + WinPercent + ",\"loss_percent\":" + LossPercent + ",\"parity_percent\":" + ParityPercent + ",\"client_lts\":" + client_lts + ",\"rate_lts\":" + rate_lts + ",\"rate_value\":" + Price + ",\"forecast1\":" + Price + "},\"rid\":" + RequestID + "}";


            bool res = SendRequest(Request);

            while (!NewPositionResponseReceived)
            {
                System.Threading.Thread.Sleep(1000);
            }


            BinaryPosition pos = new BinaryPosition();

            pos.OpenTime        = DateTime.UtcNow;
            pos.LifeTimeMinutes = LifeTimeMinutes;
            pos.OriginalID      = OriginalID;
            pos.Symbol          = Symbol;
            pos.Type            = PosType;
            pos.AlpariID        = NewPositionID;
            pos.OpenPrice       = NewPositionOpenPrice;

            pos.PayoutWin    = WinPercent;
            pos.PayoutLose   = LossPercent;
            pos.PayoutParity = ParityPercent;


            if (NewPositionError)
            {
                DebugLog.WriteLine("Error opening position with OriginalID " + OriginalID + ": " + NewPositionErrorMessage);
                pos.Status = "Error";
            }
            else
            {
                DebugLog.WriteLine("New position opened");
                pos.Status = "Open";
                OpenPositions.Add(pos);
            }

            NewPositionID        = 0;
            NewPositionOpenPrice = 0;



            NewPositionInProgress = false;
            return(pos);
        }
Example #2
0
        void SetTradeSettings(string JsonSource)
        {
            #region json_example2

            /*
             * {"type":"RESPONSE","action":"trade_settings","body":{"22":5000,"23":5000,"settings":{"1":{"11":{"8":[175],"5":[160],"6":[165],"7":[170]},"12":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"13":{"8":[175],"5":[160],"6":[165],"7":[170]},"14":{"8":[175],"5":[160],"6":[165],"7":[170]},"15":{"8":[175],"5":[160],"6":[165],"7":[170]},"16":{"8":[175],"5":[160],"6":[165],"7":[170]},"17":{"8":[175],"5":[160],"6":[165],"7":[170]},"18":{"8":[175],"5":[160],"6":[165],"7":[170]},"19":{"8":[175],"5":[160],"6":[165],"7":[170]},"1":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"2":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"3":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"4":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"5":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"6":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"7":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"20":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"10":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]},"21":{"1":[160],"2":[165],"3":[165],"4":[170],"5":[175],"6":[180],"7":[185],"8":[200]}},"2":{"11":{"8":[175],"5":[160],"6":[165],"7":[170]},"12":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"13":{"8":[175],"5":[160],"6":[165],"7":[170]},"14":{"8":[175],"5":[160],"6":[165],"7":[170]},"15":{"8":[175],"5":[160],"6":[165],"7":[170]},"16":{"8":[175],"5":[160],"6":[165],"7":[170]},"17":{"8":[175],"5":[160],"6":[165],"7":[170]},"18":{"8":[175],"5":[160],"6":[165],"7":[170]},"19":{"8":[175],"5":[160],"6":[165],"7":[170]},"1":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"2":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"3":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"4":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"5":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"6":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"7":{"8":[200],"4":[175],"5":[180],"6":[185],"7":[190]},"20":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"10":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]},"21":{"8":[200],"3":[170],"4":[175],"5":[180],"6":[185],"7":[190]}},"3":{"11":{"8":[185],"5":[170],"6":[175],"7":[180]},"12":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"13":{"8":[185],"5":[170],"6":[175],"7":[180]},"14":{"8":[185],"5":[170],"6":[175],"7":[180]},"15":{"8":[185],"5":[170],"6":[175],"7":[180]},"16":{"8":[185],"5":[170],"6":[175],"7":[180]},"17":{"8":[185],"5":[170],"6":[175],"7":[180]},"18":{"8":[185],"5":[170],"6":[175],"7":[180]},"19":{"8":[185],"5":[170],"6":[175],"7":[180]},"1":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"2":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"3":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"4":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"5":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"6":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"7":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"20":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"10":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]},"21":{"8":[200],"3":[175],"4":[180],"5":[185],"6":[190],"7":[195]}},"4":{"11":{"8":[190],"5":[175],"6":[180],"7":[185]},"12":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"13":{"8":[190],"5":[175],"6":[180],"7":[185]},"14":{"8":[190],"5":[175],"6":[180],"7":[185]},"15":{"8":[190],"5":[175],"6":[180],"7":[185]},"16":{"8":[190],"5":[175],"6":[180],"7":[185]},"17":{"8":[190],"5":[175],"6":[180],"7":[185]},"18":{"8":[190],"5":[175],"6":[180],"7":[185]},"19":{"8":[190],"5":[175],"6":[180],"7":[185]},"1":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"2":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"3":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"4":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"5":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"6":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"7":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"20":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"10":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]},"21":{"8":[200],"3":[180],"4":[185],"5":[190],"6":[195],"7":[200]}}},"13":300000,"24":3000,"14":5000,"25":50,"15":5000,"26":0,"16":500,"27":0,"17":300,"18":5,"19":5,"2":0,"3":100,"group_id":1,"6":1,"8":20,"20":2,"21":300000},"rid":7}
             *
             * */
            #endregion

            /*
             * SortedDictionary<string, object> result = JsonDictionary.Deserialize(JsonSource);
             * SortedDictionary<string, object> body = (SortedDictionary<string, object>)result["body"];
             * Console.WriteLine(body["13"].ToString());
             */

            SortedDictionary <string, object> result = JsonDictionary.Deserialize(JsonSource);
            SortedDictionary <string, object> body   = (SortedDictionary <string, object>)result["body"];

            string PayoutLoseID   = TradeSettings.TradeSettingsDictionary["payout_lose"].ToString();
            string PayoutParityID = TradeSettings.TradeSettingsDictionary["payout_parity"].ToString();


            DebugLog.WriteLine("PayoutLose: " + body[PayoutLoseID].ToString());
            DebugLog.WriteLine("PayoutParity: " + body[PayoutParityID].ToString());

            TradeSettings.PayoutLose   = Convert.ToInt32(body[PayoutLoseID].ToString());
            TradeSettings.PayoutParity = Convert.ToInt32(body[PayoutParityID].ToString());

            SortedDictionary <string, object> settings = (SortedDictionary <string, object>)body["settings"];

            string OptionTypes_CallPut_ID = TradeSettings.OptionTypesDictionary["call_put"].ToString();
            SortedDictionary <string, object> CallPutSettings = (SortedDictionary <string, object>)settings[OptionTypes_CallPut_ID];

            foreach (KeyValuePair <string, object> asset in CallPutSettings)
            {
                try
                {
                    int    AssetID = Convert.ToInt32(asset.Key);
                    Symbol symbol  = TradeSettings.GetSymbolByAssetID(AssetID);

                    SortedDictionary <int, int> PayoutWinByTimeframeID_New = new SortedDictionary <int, int>();


                    SortedDictionary <string, object> assetTf = (SortedDictionary <string, object>)asset.Value;

                    foreach (KeyValuePair <string, object> tf in assetTf)
                    {
                        int TimeframeID = Convert.ToInt32(tf.Key);
                        SortedDictionary <string, object> pd = (SortedDictionary <string, object>)tf.Value;
                        int PayoutWin = Convert.ToInt32(pd["0"].ToString());

                        if (PayoutWinByTimeframeID_New.ContainsKey(TimeframeID))
                        {
                            PayoutWinByTimeframeID_New[TimeframeID] = PayoutWin;
                        }
                        else
                        {
                            PayoutWinByTimeframeID_New.Add(TimeframeID, PayoutWin);
                        }


                        DebugLog.WriteLine("PayoutWin (" + symbol.Name + " - " + TradeSettings.GetTimeframeByID(TimeframeID).LifeTimeMinutes + " min): " + PayoutWin);
                    }

                    symbol.PayoutWinByTimeframeID = PayoutWinByTimeframeID_New;
                }

                catch (Exception e) { }
            }



            return;
        }
Example #3
0
        void SetDictionary(dynamic Data)
        {
            #region json_example

            /*
             *
             * {"type":"RESPONSE","action":"dictionary","body":{"assets":[{"decimals":5,"name":"EURUSD","id":1},{"decimals":5,"name":"GBPUSD","id":2},{"decimals":5,"name":"USDCHF","id":3},{"decimals":3,"name":"USDJPY","id":4},{"decimals":5,"name":"USDCAD","id":5},{"decimals":5,"name":"AUDUSD","id":6},{"decimals":5,"name":"NZDUSD","id":7},{"decimals":3,"name":"EURJPY","id":10},{"decimals":5,"name":"EURGBP","id":11},{"decimals":3,"name":"GBPJPY","id":12},{"decimals":5,"name":"EURCAD","id":13},{"decimals":5,"name":"EURAUD","id":14},{"decimals":3,"name":"AUDJPY","id":15},{"decimals":5,"name":"GBPAUD","id":16},{"decimals":5,"name":"GBPCAD","id":17},{"decimals":5,"name":"GBPCHF","id":18},{"decimals":3,"name":"NZDJPY","id":19},{"decimals":3,"name":"XAUUSD","id":20},{"decimals":3,"name":"XAGUSD","id":21}],"currencies":[{"name":"EUR","id":978},{"name":"RUR","id":643},{"name":"USD","id":840},{"name":"GLD","id":10959}],"time_frames":[{"history_size":0,"period":60,"bar_size":1,"name":"1M","id":1},{"history_size":0,"period":300,"bar_size":5,"name":"5M","id":2},{"history_size":0,"period":900,"bar_size":15,"name":"15M","id":3},{"history_size":0,"period":1800,"bar_size":30,"name":"30M","id":4},{"history_size":0,"period":5,"bar_size":1,"name":"5S","id":100},{"history_size":0,"period":3600,"bar_size":60,"name":"1H","id":5},{"history_size":0,"period":7200,"bar_size":60,"name":"2H","id":6},{"history_size":0,"period":14400,"bar_size":300,"name":"4H","id":7},{"history_size":0,"period":86400,"bar_size":1800,"name":"1D","id":8}],"option_types":[{"id":1,"name":"call_put"},{"id":2,"name":"touch"},{"id":3,"name":"range"},{"id":4,"name":"spread"}],"operation_types":[{"name":"deposit","id":1},{"name":"withdrawal","id":2},{"name":"buy","id":3},{"name":"expiry","id":4},{"name":"compensation","id":7}],"directions":[{"name":"call","id":1},{"name":"put","id":2},{"name":"in","id":3},{"name":"out","id":4}],"option_states":[{"name":"approved","id":2},{"name":"started","id":3},{"name":"closed","id":6}],"option_expiry_reasons":[{"name":"time","id":1},{"name":"touch","id":2},{"name":"early","id":3}],"option_results":[{"name":"win","id":1},{"name":"loss","id":2},{"name":"parity","id":3}],"trade_settings":[{"name":"payout_win","id":1},{"name":"payout_lose","id":2},{"name":"payout_parity","id":3},{"name":"enable","id":6},{"name":"enable_permanent","id":7},{"name":"max_bet_643","id":13},{"name":"max_bet_840","id":14},{"name":"max_bet_978","id":15},{"name":"max_bet_10959","id":16},{"name":"min_bet_643","id":17},{"name":"min_bet_840","id":18},{"name":"min_bet_978","id":19},{"name":"min_bet_10959","id":20},{"name":"max_amount_active_options_643","id":21},{"name":"max_amount_active_options_840","id":22},{"name":"max_amount_active_options_978","id":23},{"name":"max_amount_active_options_10959","id":24},{"name":"early_win_percent","id":25},{"name":"early_loss_percent","id":26},{"name":"early_parity_percent","id":27}]},"rid":4}
             *
             *
             *
             * */
            #endregion


            DebugLog.WriteLine("Setting dictionary");

            #region settings
            try
            {
                foreach (dynamic element in Data.body.option_types)
                {
                    try
                    {
                        //DebugLog.WriteLine("Element name: " + element["name"]);

                        if (!TradeSettings.OptionTypesDictionary.ContainsKey((string)element["name"]))
                        {
                            TradeSettings.OptionTypesDictionary.Add((string)element["name"], (int)element["id"]);
                        }
                        else
                        {
                            TradeSettings.OptionTypesDictionary[(string)element["name"]] = (int)element["id"];
                        }
                    }
                    catch (Exception e) { DebugLog.WriteLine("Exception: " + e.Message); }
                }

                foreach (dynamic element in Data.body.operation_types)
                {
                    try
                    {
                        if (!TradeSettings.OperationTypesDictionary.ContainsKey((string)element["name"]))
                        {
                            TradeSettings.OperationTypesDictionary.Add((string)element["name"], (int)element["id"]);
                        }
                        else
                        {
                            TradeSettings.OperationTypesDictionary[(string)element["name"]] = (int)element["id"];
                        }
                    }
                    catch (Exception) { }
                }

                foreach (dynamic element in Data.body.directions)
                {
                    try
                    {
                        if (!TradeSettings.DirectionsDictionary.ContainsKey((string)element["name"]))
                        {
                            TradeSettings.DirectionsDictionary.Add((string)element["name"], (int)element["id"]);
                        }
                        else
                        {
                            TradeSettings.DirectionsDictionary[(string)element["name"]] = (int)element["id"];
                        }
                    }
                    catch (Exception) { }
                }

                foreach (dynamic element in Data.body.option_states)
                {
                    try
                    {
                        if (!TradeSettings.OptionStatesDictionary.ContainsKey((string)element["name"]))
                        {
                            TradeSettings.OptionStatesDictionary.Add((string)element["name"], (int)element["id"]);
                        }
                        else
                        {
                            TradeSettings.OptionStatesDictionary[(string)element["name"]] = (int)element["id"];
                        }
                    }
                    catch (Exception) { }
                }

                foreach (dynamic element in Data.body.option_expiry_reasons)
                {
                    try
                    {
                        if (!TradeSettings.OptionExpiryReasonsDictionary.ContainsKey((string)element["name"]))
                        {
                            TradeSettings.OptionExpiryReasonsDictionary.Add((string)element["name"], (int)element["id"]);
                        }
                        else
                        {
                            TradeSettings.OptionExpiryReasonsDictionary[(string)element["name"]] = (int)element["id"];
                        }
                    }
                    catch (Exception) { }
                }

                foreach (dynamic element in Data.body.option_results)
                {
                    try
                    {
                        if (!TradeSettings.OptionResultsDictionary.ContainsKey((string)element["name"]))
                        {
                            TradeSettings.OptionResultsDictionary.Add((string)element["name"], (int)element["id"]);
                        }
                        else
                        {
                            TradeSettings.OptionResultsDictionary[(string)element["name"]] = (int)element["id"];
                        }
                    }
                    catch (Exception) { }
                }

                foreach (dynamic element in Data.body.trade_settings)
                {
                    try
                    {
                        if (!TradeSettings.TradeSettingsDictionary.ContainsKey((string)element["name"]))
                        {
                            TradeSettings.TradeSettingsDictionary.Add((string)element["name"], (int)element["id"]);
                        }
                        else
                        {
                            TradeSettings.TradeSettingsDictionary[(string)element["name"]] = (int)element["id"];
                        }
                    }
                    catch (Exception) { }
                }
            }
            catch (Exception e) { DebugLog.WriteLine("SetDictiondary Error: " + e.Message); }
            #endregion


            #region symbols

            try
            {
                foreach (dynamic element in Data.body.assets)
                {
                    try
                    {
                        Symbol s = new Symbol((string)element["name"], (int)element["id"], (int)element["decimals"]);
                        TradeSettings.Symbols.Add(s);
                    }
                    catch (Exception e) { }
                }
            }
            catch (Exception e)
            {
            }


            #endregion


            #region timeframes

            try
            {
                foreach (dynamic element in Data.body.time_frames)
                {
                    try
                    {
                        int period  = (int)element["period"];
                        int minutes = (int)period / 60;
                        int id      = (int)element["id"];

                        Timeframe tf = new Timeframe(minutes, id);
                        TradeSettings.Timeframes.Add(tf);
                    }
                    catch (Exception e) { }
                }
            }
            catch (Exception e)
            {
            }

            #endregion



            return;
        }
Example #4
0
        public bool Connect()
        {
            DebugLog.WriteLine("Alpari client starting!");


            if (!Demo)
            {
                if (!LoginToWebsite())
                {
                    DebugLog.WriteLine("Error logging to website");
                    return(false);
                }



                if (!GetToken())
                {
                    DebugLog.WriteLine("No token");
                    return(false);
                }
            }
            else
            {
                DebugLog.WriteLine("DEMO MODE");
                Token = "token";
            }



            //return true;

            using (ws = new WebSocket("wss://my.alpari.ru/bo_ws/"))
            {
                ws.OnMessage += (sender, e) =>
                {
                    //DebugLog.WriteLine("Server says: " + e.Data);

                    var Data = JsonParser.Deserialize(e.Data);
                    OnMessage(Data, e.Data);
                };

                ws.OnClose += (sender, e) =>
                {
                    Connected = false;
                    DebugLog.WriteLine("CONNECTION CLOSED");
                };

                ws.OnError += (sender, e) =>
                {
                    DebugLog.WriteLine("Error: " + e.Message);
                    Connected = false;
                };
            }


            foreach (Cookie c in WebClient.Cookies)
            {
                ws.SetCookie(new WebSocketSharp.Net.Cookie(c.Name, c.Value, c.Path, c.Domain));
            }



            ws.Connect();


            ws.Send("{\"type\":\"REQUEST\",\"action\":\"auth\",\"body\":{\"token\":\"" + Token + "\"},\"rid\":" + RequestID + "}");
            ws.Send("{\"type\":\"REQUEST\",\"action\":\"time\",\"body\":{},\"rid\":" + RequestID + "}");

            while (!Connected && !Error)
            {
                System.Threading.Thread.Sleep(1000);
            }

            if (Connected)
            {
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"account\",\"body\":{},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"+account\",\"body\":{},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"dictionary\",\"body\":{},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"+trade_state\",\"body\":{},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"trade_state\",\"body\":{},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"trade_settings\",\"body\":{},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"+trade_settings\",\"body\":{},\"rid\":" + RequestID + "}");

                ws.Send("{\"type\":\"REQUEST\",\"action\":\"+rate\",\"body\":{\"asset_id\":1},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"rates/history\",\"body\":{\"asset_id\":1,\"bar_size\":15,\"limit\":181},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"rates/last\",\"body\":{},\"rid\":" + RequestID + "}");



                ws.Send("{\"type\":\"REQUEST\",\"action\":\"options\",\"body\":{},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"+option\",\"body\":{},\"rid\":" + RequestID + "}");

                ws.Send("{\"type\":\"REQUEST\",\"action\":\"traders_choice\",\"body\":{\"option_type_id\":\"1\",\"asset_id\":\"1\",\"time_frame_id\":\"3\"},\"rid\":" + RequestID + "}");
                ws.Send("{\"type\":\"REQUEST\",\"action\":\"+traders_choice\",\"body\":{\"option_type_id\":\"1\",\"asset_id\":\"1\",\"time_frame_id\":\"3\"},\"rid\":" + RequestID + "}");


                ws.Send("{\"type\":\"REQUEST\",\"action\":\"report\",\"body\":{\"limit\":10,\"offset\":0},\"rid\":" + RequestID + "}");

                Task t = Task.Run(() =>
                {
                    while (true)
                    {
                        WaitConnection();
                        ws.Send("{\"type\":\"REQUEST\",\"action\":\"time\",\"body\":{},\"rid\":" + RequestID + "}");
                        System.Threading.Thread.Sleep(3000);
                    }
                });
            }



            if (Connected)
            {
                DebugLog.WriteLine("\r\n**********************************************\r\nAlpari Websocket connected!!!\r\n**********************************************");
                return(true);
            }



            return(false);
        }