Esempio n. 1
0
        private async void buttonCall_Click(object sender, RoutedEventArgs e)
        {
            textTime.Text = "";
            _watch.Start();

            var priceProposalRequest = new PriceProposalRequest
            {
                proposal      = 1,
                amount        = "100",
                basis         = "payout",
                contract_type = "CALL",
                currency      = "USD",
                duration      = "60",
                duration_unit = "s",
                symbol        = "R_100"
            };
            var jsonPriceProposalRequest = JsonConvert.SerializeObject(priceProposalRequest);
            await _bws.SendRequest(jsonPriceProposalRequest);

            var jsonPriceProposalResponse = await _bws.StartListen();

            var priceProposal = JsonConvert.DeserializeObject <PriceProposalResponse>(jsonPriceProposalResponse);
            var id            = priceProposal.proposal.id;
            var price         = priceProposal.proposal.display_value;

            await _bws.SendRequest($"{{\"buy\":\"{id}\", \"price\": {price}}}");

            var jsonBuy = await _bws.StartListen();

            _watch.Stop();
            textTime.Text = _watch.ElapsedMilliseconds.ToString();
        }
Esempio n. 2
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            textTime.Text = "";
            _watch.Start();

            _status["Key"] = TextKey.Text;
            var auth = await _bws.Authorize(TextKey.Text);

            await _bws.SendRequest($"{{\"get_settings\":\"1\"}}");

            var jsonSettings = await _bws.StartListen();

            var settings = JsonConvert.DeserializeObject <Settings>(jsonSettings);
            await _bws.SendRequest($"{{\"get_account_status\":\"1\"}}");

            if (auth.authorize == null)
            {
                return;
            }

            _status["Username"] = auth.authorize.loginid;
            _status["Name"]     = auth.authorize.fullname;
            _status["Email"]    = auth.authorize.email;

            var typesUpperList = auth.authorize.scopes.Select(scope => scope.First().ToString().ToUpper() + string.Join("", scope.Skip(1))).ToList();

            _status["Type"]     = string.Join(", ", typesUpperList);
            _status["Currency"] = auth.authorize.currency;
            if (settings.get_settings != null)
            {
                _status["Country"] = settings.get_settings.country_code;
            }

            _status["Balance"] = auth.authorize.balance;

            var list = new ObservableCollection <KeyValuePair <string, string> >();

            foreach (var entry in _status)
            {
                list.Add(entry);
            }
            DataGrid1.ItemsSource = list;

            _watch.Stop();
            textTime.Text = _watch.ElapsedMilliseconds.ToString();
            _watch.Reset();
        }
Esempio n. 3
0
            static void Main(string[] args)
            {
                string data = "{\"ticks\":\"R_100\"}";

                var bws = new BinaryWs();

                bws.Connect().Wait();

                bws.SendRequest(data).Wait();
                bws.StartListen();

                Console.ReadLine();
            }