Beispiel #1
0
 public Forex(double value, CurrencyPairs currencyPair, int quantity)
 {
     this.Value        = value;
     this.currencyPair = currencyPair;
     this.quantity     = quantity;
     this.tranQuantity = quantity;
 }
 public TradeOperation(CurrencyPairs currencyPair, decimal volume, decimal price, DateTime tradeDate)
 {
     CurrencyPair = currencyPair;
     Volume       = volume;
     Price        = price;
     TradeDate    = tradeDate;
 }
        public void TradeForex(CurrencyPairs currencyPair, double price, int quantity, char action)
        {
            try
            {
                if (isForex == false)
                {
                    throw new InvalidTradeException("This account is not eligible for FOREX.");
                }

                try
                {
                    Forex newForex   = new Forex(price, currencyPair, quantity);
                    Trade forexTrade = new Trade(this, newForex, action);
                    TradeList.Add(forexTrade);
                }
                catch (InsufficientFundsException insufficientFundEx)
                {
                    throw insufficientFundEx;
                }
            }
            catch (InvalidTradeException forexEx)
            {
                throw forexEx;
            }
        }
Beispiel #4
0
 private void cnyusdButton_Click(object sender, EventArgs e)
 {
     currentSelectedCurrencyPair = CurrencyPairs.CNY2USD;
     OutputGroupBox.Show();
     stockSearchBox.Clear();
     resultBox.Text = currentSelectedCurrencyPair.ToString() + "   " + DateTime.Now.ToString();
     ForexOutput();
 }
        public void BookTrade(
            Guid buyerId, Guid sellerId, CurrencyPairs currencyPair, decimal volume, decimal price, DateTime date)
        {
            var trade = _factory.GetTrade(buyerId, sellerId);

            var tradeOperation = new TradeOperation(currencyPair, volume, price, date);

            trade.BookTrade(tradeOperation);
        }
Beispiel #6
0
        //public event EventHandler Load;

        public Form1()
        {
            currencypairs = new CurrencyPairs();
            login         = new Login();
            timeframes    = new Timeframes();

            this.Load += new EventHandler(Form1_Load);
            this.Load += Form1_Load;


            InitializeComponent();
        }
Beispiel #7
0
        private void stockSearchButton_Click(object sender, EventArgs e)
        {
            OutputGroupBox.Show();


            stockSymbol = stockSearchBox.Text;

            OutputGroupBox.Show();

            currentSelectedCurrencyPair = CurrencyPairs.None;

            resultBox.Text = stockSymbol.ToString() + "   " + DateTime.Now.ToString();

            StockOutput(stockSymbol);
        }
Beispiel #8
0
        ///getmarkets
        /// {
        ///     "success":"1",
        ///     "return":
        ///     [
        ///         {"marketid":"57","label":"ALF\/BTC","primary_currency_code":"ALF","primary_currency_name":"AlphaCoin","secondary_currency_code":"BTC","secondary_currency_name":"BitCoin","current_volume":"1784417.96329225","last_trade":"0.00000139","high_trade":"0.00000246","low_trade":"0.00000122","created":"2013-07-04 01:01:09"},
        ///         {"marketid":"43","label":"AMC\/BTC","primary_currency_code":"AMC","primary_currency_name":"AmericanCoin","secondary_currency_code":"BTC","secondary_currency_name":"BitCoin","current_volume":"32401.53135330","last_trade":"0.00000306","high_trade":"0.00000316","low_trade":"0.00000306","created":"2013-06-06 07:16:21"},
        ///         {"marketid":"66","label":"ANC\/BTC","primary_currency_code":"ANC","primary_currency_name":"AnonCoin","secondary_currency_code":"BTC","secondary_currency_name":"BitCoin","current_volume":"8808.27636700","last_trade":"0.00135000","high_trade":"0.00183900","low_trade":"0.00090000","created":"2013-07-21 20:48:02"},
        ///         ...
        ///         {"marketid":"67","label":"XNC\/LTC","primary_currency_code":"XNC","primary_currency_name":"XenCoin","secondary_currency_code":"LTC","secondary_currency_name":"LiteCoin","current_volume":"8203286.32267366","last_trade":"0.00011000","high_trade":"0.00012000","low_trade":"0.00008932","created":"2013-07-21 20:49:04"},
        ///         {"marketid":"103","label":"TIX\/XPM","primary_currency_code":"TIX","primary_currency_name":"Tickets","secondary_currency_code":"XPM","secondary_currency_name":"PrimeCoin","current_volume":"444654075.15056723","last_trade":"0.00000099","high_trade":"0.00000099","low_trade":"0.00000084","created":"2013-09-30 23:13:37"}
        ///     ]
        /// }
        public static CurrencyPairs  GetAll(string marketJson)
        {
            CurrencyPairs pairs   = new CurrencyPairs();
            JObject       jObject = JObject.Parse(marketJson);
            JArray        jarray  = JArray.Parse(jObject["return"].ToString());
            var           def     = new { primary_currency_code = "", secondary_currency_code = "", };

            foreach (var item in jarray)
            {
                var result = JsonConvert.DeserializeAnonymousType(item.ToString(), def);
                pairs.Add(CurrencyPair.All[result.primary_currency_code + result.secondary_currency_code]);
                //  CryptoCoin coin = new CryptoCoin() { Name = result.primary_currency_name, Code = result.primary_currency_code };
                //  if(!c.Contains(coin.Code))  c.Add(coin);
            }

            return(pairs);
        }
Beispiel #9
0
        private CurrencyPairs GetSupportPairs()
        {
            CurrencyPairs supportPairs = new CurrencyPairs();
            Assembly      assembly     = Assembly.GetExecutingAssembly();
            string        resourceName = assembly.GetName().Name + ".SupportPair.txt";
            Stream        stream       = assembly.GetManifestResourceStream(resourceName);

            using (TextReader textReader = new StreamReader(stream))
            {
                string        json  = textReader.ReadToEnd();
                List <string> pairs = JsonConvert.DeserializeObject <List <string> >(json);
                foreach (string item in pairs)
                {
                    supportPairs.Add(CurrencyPair.All[item]);
                }
            }
            return(supportPairs);
        }
Beispiel #10
0
        /// <summary>
        /// Async method to get list of orders by currency pair
        /// </summary>
        /// <param name="currencyPairs">Currency pair</param>
        /// <returns>Order list object, that contains timestamp, asks and bids lists (if there is an error - error info)</returns>
        public async Task <OrderList> GetOrderListByCurrencyPair(CurrencyPairs currencyPairs)
        {
            var _response = await _httpClient.GetStringAsync(Helpers.GetRequestUrl(Constants.API_V2_URL,
                                                                                   Constants.GET_ORDER_LIST_ACTION,
                                                                                   currencyPairs.ToString()));

            JObject _root      = JObject.Parse(_response);
            var     _orderList = new OrderList
            {
                Asks      = Helpers.GetOrders(_root, Constants.ASKS_LIST_NAME),
                Bids      = Helpers.GetOrders(_root, Constants.BIDS_LIST_NAME),
                Error     = _root[Constants.ERROR_KEY]?.ToString(),
                Reason    = _root[Constants.REASON_KEY]?.ToString(),
                Status    = _root[Constants.STATUS_KEY]?.ToString(),
                Timestamp = _root[Constants.TIMESTAMP_KEY].ToString()
            };

            return(_orderList);
        }
Beispiel #11
0
        private void logoutButton_Click(object sender, EventArgs e)
        {
            CustomerList.Clear();
            currentSelectedCurrencyPair = CurrencyPairs.None;
            newCustomer = null;


            bankerGroup.Hide();
            tradeGroupBox.Hide();
            OutputGroupBox.Hide();

            Customer.Reset();
            resultBox.Clear();

            accountCombo.DataSource  = null;
            account2Combo.DataSource = null;
            amountPriceBox.Clear();

            Application.Exit();
        }
Beispiel #12
0
 public CurrencyPair(CurrencyPairs currencyPair)
 {
     _currencyPair = currencyPair;
     _baseCurrency = currencyPair.ToString().Split('_')[0];
     _quoteCurrency = currencyPair.ToString().Split('_')[1];
 }