Пример #1
0
 public static void UpdateOrder(this AccountDataModel account, ulong orderId, long amount)
 {
     lock (account.Orders)
         if (account.Orders.TryGetValue(orderId, out var order)) //trade could occur without adding the order to orderbook
         {
             order.Amount -= amount;
         }
 }
Пример #2
0
 public static void AddBalance(this AccountDataModel account, int asset, ConstellationInfo constellationInfo)
 {
     lock (account.Balances)
         account.Balances.Add(asset, new BalanceModel
         {
             AssetId = asset,
             Asset   = (constellationInfo.Assets.FirstOrDefault(a => a.Id == asset)?.DisplayName ?? asset.ToString())
         });
 }
Пример #3
0
        public static void AddOrder(this AccountDataModel account, ulong orderId, long amount, double price, ConstellationInfo constellation)
        {
            var orderModel = new OrderModel
            {
                Amount  = amount,
                Price   = price,
                OrderId = orderId
            };

            orderModel.Asset = constellation.Assets.FirstOrDefault(a => a.Id == orderModel.AssetId)?.DisplayName ?? orderModel.AssetId.ToString();
            lock (account.Orders)
                account.Orders.Add(orderId, orderModel);
        }
Пример #4
0
 public static void RemoveOrder(this AccountDataModel account, ulong orderId)
 {
     lock (account.Orders)
         account.Orders.Remove(orderId);
 }
Пример #5
0
 public static List <OrderModel> GetOrders(this AccountDataModel account)
 {
     lock (account.Orders)
         return(account.Orders.Values.ToList());
 }
Пример #6
0
 public static void UpdateLiabilities(this AccountDataModel account, int asset, long liabilities)
 {
     lock (account.Balances)
         account.Balances[asset].Liabilities += liabilities;
 }
Пример #7
0
 public static void UpdateBalance(this AccountDataModel account, int asset, long amount)
 {
     lock (account.Balances)
         account.Balances[asset].Amount += amount;
 }
Пример #8
0
 public static List <BalanceModel> GetBalances(this AccountDataModel account)
 {
     lock (account.Balances)
         return(account.Balances.Values.ToList());
 }
Пример #9
0
 public static void UpdateNonce(this AccountDataModel account, long nonce)
 {
     lock (account)
         account.Nonce = nonce;
 }