示例#1
0
        public BTCMarketsExchange(IDataStore _dataStore, ICurrencyPairRepository _currencyPairRepository)
        {
            wallets = new List<CurrencyWallet>();
            pairsToUpdate = new List<BTCMarketsCurrencyWalletPair>();
            syntheticPairsToUpdate = new List<BTCMarketsSyntheticCurrencyWalletPair>();

            dataStore = _dataStore;
            var btcWallet = new FixedFeeCurrencyWallet(0.001M,0.001M, CurrencyType.Bitcoin , this);
            var ltcWallet = new FixedFeeCurrencyWallet(0.01M, 0.01M, CurrencyType.Litecoin, this);
            var audWallet = new PercentageFeeCurrencyWallet(0.01M, 0.015M, CurrencyType.AUD, this);

            wallets.Add(btcWallet);
            wallets.Add(ltcWallet);
            wallets.Add(audWallet);

            var btcusd = new BTCMarketsCurrencyWalletPair(btcWallet, audWallet, _dataStore, "https://api.btcmarkets.net/market/BTC/AUD/tick");
            var ltcusd = new BTCMarketsCurrencyWalletPair(ltcWallet, audWallet, _dataStore, "https://api.btcmarkets.net/market/LTC/AUD/tick");
            var btcltc = new BTCMarketsSyntheticCurrencyWalletPair(btcWallet, ltcWallet, _dataStore, "https://api.btcmarkets.net/market/BTC/AUD/tick", "https://api.btcmarkets.net/market/LTC/AUD/tick");

            pairsToUpdate.Add(btcusd);
            pairsToUpdate.Add(ltcusd);
            syntheticPairsToUpdate.Add(btcltc);

            _currencyPairRepository.Store(btcusd);
            _currencyPairRepository.Store(ltcusd);
            _currencyPairRepository.Store(btcltc);
        }
示例#2
0
        private void UpdateQuotes(BTCMarketsSyntheticCurrencyWalletPair pair)
        {
            WebClient client = new WebClient();
            var source1 = client.DownloadString(pair.url);
            var source2 = client.DownloadString(pair.url2);

            var sourceTicker = JsonConvert.DeserializeObject<BTCMarketsTickerModel>(source1);
            var sourceTicker2 = JsonConvert.DeserializeObject<BTCMarketsTickerModel>(source2);

            var tick = new TickDataModel();

            tick.SourceExchange = sourceExchange + " Synthetic BTC/LTC";
            //tick.Average= sourceTicker.av
            //tick.Volum;
            tick.Last = sourceTicker.lastPrice / sourceTicker2.lastPrice;
            tick.Bid = sourceTicker.bestBid / sourceTicker2.bestAsk;
            tick.Ask = sourceTicker.bestAsk / sourceTicker2.bestBid;

            pair.Tick(tick);
            lastQuote = tick;

            return;
        }