public async Task <MyTradesResponse> GetMyTrades(string coin, string market)
        {
            var e = LogExecutionTime.Begin();

            var req = CreateRequest(HttpMethod.Get, BinanceEndpoints.MyTrades, $"symbol={coin}{market}&limit=25");
            var res = await GetResponse <List <BinanceMyTrade> >(req, BinanceEndpoints.MyTrades);

            if (res == null || res.Count == 0)
            {
                Logger.LogProxy($"Binance {coin} trades returned empty! Url: {req.RequestUri.AbsoluteUri}", res);

                return(new MyTradesResponse
                {
                    IsSuccess = false,
                    ErrorMessage = $"Binance {coin} trades returned empty! Url: {req.RequestUri.AbsoluteUri}"
                });
            }

            e.End(customMessage: $"{coin}-{market} at Binance ");

            return(new MyTradesResponse
            {
                IsSuccess = true,
                Trades = ProxyMapper.MapCoinTrade(res, coin)
            });
        }
Ejemplo n.º 2
0
        internal void Load()
        {
            if (_isLoaded)
            {
                return;
            }

            lock (_lockObject)
            {
                var relations = _objectMapper.DataService.GetRelations(_parentId);
                if (relations != null)
                {
                    foreach (var relation in relations)
                    {
                        if (relation.ToId == null)
                        {
                            continue;
                        }

                        base.Add(ProxyMapper.New <T>(relation.ToId.Value, _objectMapper, _proxyType));
                    }
                }
            }

            _isLoaded = true;
        }
Ejemplo n.º 3
0
        public object Save(object obj)
        {
            if (obj == null || ProxyMapper.IsProxy(obj))
            {
                return(obj);
            }

            var type = obj.GetType();

            var container = GetObjectsContainerItemForType(type);

            var item = new DbItem();

            DataService.Insert(item);

            var relation = new DbRelation
            {
                FromId     = container.Id,
                Identifier = type.Name, // This can be anything, really...
                ToId       = item.Id
            };

            DataService.Insert(relation);

            return(ProxyMapper.Save(obj, item.Id, this));
        }
Ejemplo n.º 4
0
        public Currency(JSONProxy.Item item) : base(item)
        {
            this.Type       = ProxyMapper.GetOrbType(item);
            this.ChaosValue = CurrencyHandler.GetChaosValue(this.Type);
            this.StackInfo  = ProxyMapper.GetStackInfo(item.Properties);

            this.UniqueIDHash = base.getHash();
        }
Ejemplo n.º 5
0
        public ProxyCollection(ObjectMapper objectMapper, int?parentId, bool manageRelations = false)
        {
            _lockObject      = new object();
            _objectMapper    = objectMapper;
            _parentId        = parentId;
            _manageRelations = manageRelations;
            _proxyType       = ProxyMapper.GetProxyType(typeof(T));

            _objectMapper.DataService.RelationAdded   += OnRelationAdded;
            _objectMapper.DataService.RelationRemoved += OnRelationRemoved;

            Load();
        }
Ejemplo n.º 6
0
        public FullBestiaryOrb(JSONProxy.Item item) : base(item)
        {
            ItemType = ItemType.Currency;

            Genus  = ProxyMapper.GetGenus(item.Properties);
            Group  = ProxyMapper.GetGroup(item.Properties);
            Family = ProxyMapper.GetFamily(item.Properties);

            // TODO: This item's explicit mods are the mods of the contained beast.  These could be various types of
            // mods ("prefix mod", "suffix mod", "monster mod", etc.), but only the name is provided in the JSON for
            // the explicit mod.  Compile a list of each of these types of mods and map them here, so we can style the
            // text of the mods correctly in the item tooltip.  Right now all of the mods have the default blue
            // foreground text and no other styling, which is only correct for prefix/suffix mods.  Note that the
            // in-game detailed tooltip uses "monster mod" for different kinds of mods, including bestiary beast mods
            // (bold white text with red outline) and bloodline mods (magenta text RGB(210, 0, 220)).
        }
Ejemplo n.º 7
0
        private void OnRelationAdded(DbRelation relation)
        {
            if (relation == null || relation.ToId == null || relation.FromId != _parentId)
            {
                return;
            }

            lock (_lockObject)
            {
                if (Contains(relation.ToId.Value))
                {
                    return;
                }

                base.Add(ProxyMapper.New <T>(relation.ToId.Value, _objectMapper, _proxyType));
            }
        }
        public async Task <AvailableCoinsResponse> GetExchangeInfo()
        {
            var req = CreateRequest(HttpMethod.Get, BinanceEndpoints.ExchangeInfo);
            var res = await GetResponse <BinanceResponses.GetExchangeInfo>(req, BinanceEndpoints.ExchangeInfo);

            if (!IsResultSuccess <AvailableCoinsResponse>(res, out var response) || res?.Coins == null)
            {
                Logger.LogProxy(
                    $"Binance GetExchangeInfo Error. Code: {response.ErrorCode} Message: {response.ErrorMessage}");

                var availableCoinsResponse = await GetCachedResponse <AvailableCoinsResponse>(BinanceEndpoints.ExchangeInfo);

                return(availableCoinsResponse.IsCached ? availableCoinsResponse : response);
            }

            var temp = new List <ProxyCoinInfoData>();

            BinanceEndpoints.TickerAndStats.Weight = res.Coins.Count;

            SetRateLimits(res.RateLimits);
            TimestampOffset = Util.UnixTimestampToDateTime(res.ServerTime) - DateTime.UtcNow;

            markets.Clear();
            availableMarkets.Clear();

            foreach (var coin in res.Coins)
            {
                var mapped = ProxyMapper.MapBinanceCoinInfo(coin);

                if (mapped == null)
                {
                    continue;
                }

                temp.Add(mapped);

                markets.AddOrAppend(mapped.Symbol, mapped.Market, (key, value) => markets[key].Add(value));
                availableMarkets.Add(mapped.Market);
            }

            response.Coins = temp;

            CacheResponse(BinanceEndpoints.ExchangeInfo, typeof(AvailableCoinsResponse), response);

            return(response);
        }
        public async Task <CoinsTickerResponse> GetTickers()
        {
            var e = LogExecutionTime.Begin();

            var req = CreateRequest(HttpMethod.Get, BinanceEndpoints.TickerAndStats);

            var res = await GetResponse <List <BinanceTicker> >(req, BinanceEndpoints.MyTrades);

            if (res == null || res.Count == 0)
            {
                Logger.LogProxy($"Binance tickers returned empty! Url: {req.RequestUri.AbsoluteUri}", res);

                return(new CoinsTickerResponse
                {
                    IsSuccess = false,
                    ErrorMessage = $"Binance tickers returned empty! Url: {req.RequestUri.AbsoluteUri}"
                });
            }

            var temp = new List <ProxyCoinTickerData>();

            foreach (var c in res)
            {
                c.Coin = ParseBinanceSymbol(c.Symbol, out c.Market);

                var coinTicker = ProxyMapper.MapBinanceTicker(c);

                if (coinTicker.Coin != null)
                {
                    temp.Add(coinTicker);
                }
            }

            e.End();

            return(new CoinsTickerResponse
            {
                IsSuccess = true,
                Tickers = temp
            });
        }
Ejemplo n.º 10
0
 public StackableItem(JSONProxy.Item item) : base(item)
 {
     StackInfo = ProxyMapper.GetStackInfo(item.Properties);
 }
Ejemplo n.º 11
0
 public object GetSingle(Type type, int id)
 {
     return(ProxyMapper.New(type, id, this));
 }
Ejemplo n.º 12
0
 public Essence(JSONProxy.Item item) : base(item)
 {
     Type = ProxyMapper.GetEssenceType(item);
 }
Ejemplo n.º 13
0
 public Currency(JSONProxy.Item item) : base(item)
 {
     Type       = ProxyMapper.GetOrbType(item);
     ChaosValue = CurrencyHandler.GetChaosValue(Type);
 }
Ejemplo n.º 14
0
 public BreachBlessing(JSONProxy.Item item) : base(item)
 {
     Type = ProxyMapper.GetBreachType(item);
 }
Ejemplo n.º 15
0
 public Net(JSONProxy.Item item) : base(item)
 {
     NetTier = ProxyMapper.GetNetTier(item.Properties);
 }
Ejemplo n.º 16
0
 public Leaguestone(JSONProxy.Item item) : base(item)
 {
     Charges = ProxyMapper.GetCharges(item.Properties);
     Rarity  = getRarity(item);
 }