Ejemplo n.º 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;
         }
 }
Ejemplo n.º 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())
         });
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 public static void RemoveOrder(this AccountDataModel account, ulong orderId)
 {
     lock (account.Orders)
         account.Orders.Remove(orderId);
 }
Ejemplo n.º 5
0
 public static List <OrderModel> GetOrders(this AccountDataModel account)
 {
     lock (account.Orders)
         return(account.Orders.Values.ToList());
 }
Ejemplo n.º 6
0
 public static void UpdateLiabilities(this AccountDataModel account, int asset, long liabilities)
 {
     lock (account.Balances)
         account.Balances[asset].Liabilities += liabilities;
 }
Ejemplo n.º 7
0
 public static void UpdateBalance(this AccountDataModel account, int asset, long amount)
 {
     lock (account.Balances)
         account.Balances[asset].Amount += amount;
 }
Ejemplo n.º 8
0
 public static List <BalanceModel> GetBalances(this AccountDataModel account)
 {
     lock (account.Balances)
         return(account.Balances.Values.ToList());
 }
Ejemplo n.º 9
0
 public static void UpdateNonce(this AccountDataModel account, long nonce)
 {
     lock (account)
         account.Nonce = nonce;
 }