Exemple #1
0
        unsafe public IEnumerable <Order> GetAllOpenOrders()
        {
            var orders     = new FFIOrder[256];
            var ordersLen  = orders.Length;
            var ordersList = new List <Order>();


            fixed(FFIOrder *orderBuff = orders.AsSpan())
            {
                handleResult(ExchangeClient.GetAllOpenOrders(
                                 _client_handle,
                                 (IntPtr)orderBuff, (UIntPtr)ordersLen, out var actualCandleLen
                                 ));
                for (int i = 0; i < (int)actualCandleLen; i++)
                {
                    ordersList.Add(orderBuff[i].ToOrder());
                    orderBuff[i].Dispose();
                }
            }

            return(ordersList);
        }
Exemple #2
0
        unsafe public IEnumerable <string> CancelAllOrders(string market)
        {
            var orders              = new IntPtr[1024];
            var ordersLen           = orders.Length;
            var cancelledOrdersList = new List <String>();

            fixed(IntPtr *orderBuff = orders.AsSpan())
            {
                handleResult(ExchangeClient.CancelAllOrders(
                                 _client_handle,
                                 market,
                                 (IntPtr)orderBuff, (UIntPtr)ordersLen, out var actualLen
                                 ));
                for (int i = 0; i < (int)actualLen; i++)
                {
                    cancelledOrdersList.Add(CString.ToString(orders[i]));
                    ExchangeClient.FreeString(orders[i]);
                }
            }

            return(cancelledOrdersList);
        }
Exemple #3
0
        unsafe public IEnumerable <Candle> GetHistoricRates(GetHistoricRatesRequest req)
        {
            var limit       = req.paginator == null ? 0 : req.paginator.limit;
            var candles     = new Candle[Math.Max(limit, 256)];
            var candlesLen  = candles.Length;
            var candlesList = new List <Candle>();


            fixed(Candle *candleBuff = candles.AsSpan())
            {
                handleResult(ExchangeClient.GetHistoricRates(
                                 _client_handle,
                                 req.market, req.interval, req.paginator,
                                 (IntPtr)candleBuff, (UIntPtr)candlesLen, out var actualCandleLen
                                 ));
                for (int i = 0; i < (int)actualCandleLen; i++)
                {
                    candlesList.Add(candles[i]);
                }
            }

            return(candlesList);
        }
Exemple #4
0
        unsafe public IEnumerable <Balance> GetAccountBalances(Paginator paginator)
        {
            var limit        = paginator == null ? 0 : paginator.limit;
            var balances     = new FFIBalance[Math.Max(limit, 256)];
            var balancesLen  = balances.Length;
            var balancesList = new List <Balance>();


            fixed(FFIBalance *balanceBuff = balances.AsSpan())
            {
                handleResult(ExchangeClient.GetAccountBalances(
                                 _client_handle,
                                 paginator,
                                 (IntPtr)balanceBuff, (UIntPtr)balancesLen, out var actualCandleLen
                                 ));
                for (int i = 0; i < (int)actualCandleLen; i++)
                {
                    balancesList.Add(balanceBuff[i].ToBalance());
                    balanceBuff[i].Dispose();
                }
            }

            return(balancesList);
        }
Exemple #5
0
        unsafe public IEnumerable <Trade> GetTradeHistory(GetTradeHistoryRequest req)
        {
            var limit      = req.paginator == null ? 0 : req.paginator.limit;
            var trades     = new FFITrade[Math.Max(limit, 256)];
            var tradesLen  = trades.Length;
            var tradesList = new List <Trade>();


            fixed(FFITrade *tradeBuff = trades.AsSpan())
            {
                handleResult(ExchangeClient.GetTradeHistory(
                                 _client_handle,
                                 req.market, req.orderId, req.paginator,
                                 (IntPtr)tradeBuff, (UIntPtr)tradesLen, out var actualCandleLen
                                 ));
                for (int i = 0; i < (int)actualCandleLen; i++)
                {
                    tradesList.Add(tradeBuff[i].ToTrade());
                    tradeBuff[i].Dispose();
                }
            }

            return(tradesList);
        }
Exemple #6
0
        unsafe public IEnumerable <Order> GetOrderHistory(GetOrderHistoryRequest req)
        {
            var limit      = req.paginator == null ? 0 : req.paginator.limit;
            var orders     = new FFIOrder[Math.Max(limit, 256)];
            var ordersLen  = orders.Length;
            var ordersList = new List <Order>();


            fixed(FFIOrder *orderBuff = orders.AsSpan())
            {
                handleResult(ExchangeClient.GetOrderHistory(
                                 _client_handle,
                                 req.market, req.paginator,
                                 (IntPtr)orderBuff, (UIntPtr)ordersLen, out var actualCandleLen
                                 ));
                for (int i = 0; i < (int)actualCandleLen; i++)
                {
                    ordersList.Add(orderBuff[i].ToOrder());
                    orderBuff[i].Dispose();
                }
            }

            return(ordersList);
        }
Exemple #7
0
        unsafe public double GetPriceTicker(string market)
        {
            var result = ExchangeClient.GetPriceTicker(_client_handle, market, out double price);

            return(price);
        }
Exemple #8
0
 public void Dispose()
 {
     ExchangeClient.FreeString(asset);
     ExchangeClient.FreeString(total);
     ExchangeClient.FreeString(free);
 }
Exemple #9
0
 public void Dispose()
 {
     ExchangeClient.FreeString(price);
     ExchangeClient.FreeString(qty);
 }