unsafe private void onTradesHandler(ulong tradeBuffLen, IntPtr marketStr) { var market = CString.ToString(marketStr); FreeString(marketStr); var tradesList = new List <Trade>(); for (int i = 0; i < (int)tradeBuffLen; i++) { tradesList.Add(subTradesBuff[i].ToTrade()); subTradesBuff[i].Dispose(); } if (!onTradesCbs.ContainsKey(market)) { return; } var trades = new TradesResponse(market, tradesList); this.onTradesCbs.TryGetValue(market, out var callbacks); foreach (var callback in callbacks) { callback(trades); } }
public AskBid ToAskBid() { return(new AskBid( CString.ToString(this.price), CString.ToString(this.qty) )); }
public Balance ToBalance() { return(new Balance( CString.ToString(this.asset), CString.ToString(this.total), CString.ToString(this.free) )); }
public MarketPair ToMarketPair() { return(new MarketPair( CString.ToString(this.baseSymbol), CString.ToString(this.quote), CString.ToString(this.symbol), CString.ToString(this.baseIncrement), CString.ToString(this.quoteIncrement), CString.ToString(this.baseMinPrice), CString.ToString(this.quoteMinPrice) )); }
public Trade ToTrade() { return(new Trade( CString.ToString(this.id), CString.ToString(this.buyerOrderId), CString.ToString(this.sellerOrderId), CString.ToString(this.marketPair), CString.ToString(this.price), CString.ToString(this.qty), CString.ToString(this.fees), this.side, this.liquidity, this.createdAt )); }
public Order ToOrder() { return(new Order( CString.ToString(this.id), CString.ToString(this.marketPair), CString.ToString(this.clientOrderId), this.createdAt, this.orderType, this.side, this.status, CString.ToString(this.size), CString.ToString(this.price), CString.ToString(this.remaining) )); }
unsafe private void onOrderbookHandler(ulong bidActualValueLen, ulong askActualValueLen, IntPtr marketStr, ulong lastUpdateId, ulong updateId) { var market = CString.ToString(marketStr); FreeString(marketStr); var bidsList = new List <AskBid>(); var asksList = new List <AskBid>(); for (int i = 0; i < (int)bidActualValueLen; i++) { bidsList.Add(subBidsBuff[i].ToAskBid()); subBidsBuff[i].Dispose(); } for (int i = 0; i < (int)askActualValueLen; i++) { asksList.Add(subAsksBuff[i].ToAskBid()); subAsksBuff[i].Dispose(); } if (!onOrderbookCbs.ContainsKey(market)) { return; } var latestOrderbook = new OrderbookResponse( market, asksList, bidsList, lastUpdateId, updateId ); this.onOrderbookCbs.TryGetValue(market, out var callbacks); foreach (var callback in callbacks) { callback(latestOrderbook); } }
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); }
private void handleResult(FFIResult result) { string message = "Unknown error"; if (result.message.ToInt64() != 0) { message = CString.ToString(result.message); FreeString(result.message); } switch (result.tag) { case ResultTag.Ok: return; case ResultTag.InvalidArgument: throw new ArgumentException(message); case ResultTag.BinanceError: throw new BinanceError(message); case ResultTag.CoinbaseError: throw new CoinbaseError(message); case ResultTag.NashProtocolError: throw new NashProtocolError(message); case ResultTag.MissingImplementation: throw new MissingImplementation(message); case ResultTag.AssetNotFound: throw new AssetNotFound(message); case ResultTag.NoApiKeySet: throw new NoApiKeySet(message); case ResultTag.InternalServerError: throw new InternalServerError(message); case ResultTag.ServiceUnavailable: throw new ServiceUnavailable(message); case ResultTag.Unauthorized: throw new Unauthorized(message); case ResultTag.SymbolNotFound: throw new SymbolNotFound(message); case ResultTag.SocketError: throw new SocketError(message); case ResultTag.GetTimestampFailed: throw new GetTimestampFailed(message); case ResultTag.ReqError: throw new ReqError(message); case ResultTag.InvalidHeaderError: throw new InvalidHeaderError(message); case ResultTag.InvalidPayloadSignature: throw new InvalidPayloadSignature(message); case ResultTag.IoError: throw new IoError(message); case ResultTag.PoisonError: throw new PoisonError(message); case ResultTag.JsonError: throw new JsonError(message); case ResultTag.ParseFloatError: throw new ParseFloatError(message); case ResultTag.UrlParserError: throw new UrlParserError(message); case ResultTag.Tungstenite: throw new Tungstenite(message); case ResultTag.TimestampError: throw new TimestampError(message); case ResultTag.UnkownResponse: throw new UnkownResponse(message); case ResultTag.NotParsableResponse: throw new NotParsableResponse(message); case ResultTag.MissingParameter: throw new MissingParameter(message); case ResultTag.WebSocketMessageNotSupported: throw new WebSocketMessageNotSupported(message); } }