Closed zydjohnHotmail closed 2 years ago
Hi, It is technically possible by implementing your custom "require" function using C#. However, it would not be an elegant solution.
Topaz is not a JS Engine that is going to replace NodeJS Framework, but it brings Javascript flexibility to the .NET Framework.
If you need to run the NodeJS codebase, it is better to use the V8 JavaScript engine.
Therefore, if you use Topaz, it is best to stick to the .NET Framework / Libraries.
For your particular problem, I would recommend you: -Use a .NET alternative rather than the Ccxt. You may check this one: https://github.com/JKorf/CryptoExchange.Net
Hello: I want to know if I can use this repo to call some JavaScript in Node.JS. There is one Node.JS package CCXT, current version is: 2.0.84, its web version can be found here: https://cdn.jsdelivr.net/npm/ccxt@2.0.84/dist/ccxt.browser.js
I have the following short Node.JS code to use this package: D:\nodejs\CCXT_Markets>type ccxt_all_exchanges.js 'use strict'; const ccxt = require('ccxt'); console.log(ccxt.version); var all_exchanges = ccxt.exchanges console.log(all_exchanges) D:\nodejs\CCXT_Markets> To run this, try this command: D:\nodejs\CCXT_Markets>node ccxt_all_exchanges.js 2.0.84 [ 'aax', 'alpaca', 'ascendex', 'bequant', 'bibox', 'bigone', 'binance', 'binancecoinm', 'binanceus', 'binanceusdm', 'bit2c', 'bitbank', 'bitbay', 'bitbns', 'bitcoincom', 'bitfinex', 'bitfinex2', 'bitflyer', 'bitforex', 'bitget', 'bithumb', 'bitmart', 'bitmex', 'bitopro', 'bitpanda', 'bitrue', 'bitso', 'bitstamp', 'bitstamp1', 'bittrex', 'bitvavo', 'bkex', 'bl3p', 'blockchaincom', 'btcalpha', 'btcbox', 'btcex', 'btcmarkets', 'btctradeua', 'btcturk', 'buda', 'bw', 'bybit', 'bytetrade', 'cex', 'coinbase', 'coinbaseprime', 'coinbasepro', 'coincheck', 'coinex', 'coinfalcon', 'coinmate', 'coinone', 'coinspot', 'crex24', 'cryptocom', 'currencycom', 'delta', 'deribit', 'digifinex', 'exmo', 'flowbtc', 'fmfwio', 'ftx', 'ftxus', 'gate', 'gateio', 'gemini', 'hitbtc', 'hitbtc3', 'hollaex', 'huobi', 'huobijp', 'huobipro', 'idex', 'independentreserve', 'indodax', 'itbit', 'kraken', 'kucoin', 'kucoinfutures', 'kuna', 'latoken', 'lbank', 'lbank2', 'liquid', 'luno', 'lykke', 'mercado', 'mexc', 'mexc3', 'ndax', 'novadax', 'oceanex', 'okcoin', 'okex', 'okex5', 'okx', 'paymium', 'phemex', ... 20 more items ]
I want to know if I can use this repo to run the JavaScript, but return the exchange names to one big string to C#, so I can use Newtonsoft to parse the Json format data. Remember that console.log shows only the first 100 items, there are still 20 more items are hiding from displaying.
Then, if this is possible, then can I can go one step further, to call the following Node.JS script with Async function and pass 2 parameters.
D:\nodejs\CCXT_Markets>type ccxt_exchange1_markets.js 'use strict'; const ccxt = require('ccxt'); console.log(ccxt.version); const [nodejs, script1, exchange1, ticker1] = process.argv;
(async function () { let exchange = new ccxt[exchange1]; await exchange.loadMarkets(); console.log(exchange.id); let ticker_data = await exchange.fetchTicker(ticker1); console.log (ticker_data) }) ();
To use the script, pass 2 parameters, one is exchange name, as appeared in the first script, pick any one from the 120 items shown above; the second parameter is one crypto-currency name, like: BTC/USDT. The following is one example how to use the Node.JS code: D:\nodejs\CCXT_Markets>node ccxt_exchange1_markets.js binance BTC/USDT 2.0.84 (node:27588) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time (Use
node --trace-warnings ...
to show where the warning was created) binance { symbol: 'BTC/USDT', timestamp: 1667060872005, datetime: '2022-10-29T16:27:52.005Z', high: 21085, low: 20542, bid: 20873.4, bidVolume: 0.12873, ask: 20874.33, askVolume: 0.00239, vwap: 20756.97674033, open: 20703.87, close: 20874.96, last: 20874.96, previousClose: 20705.51, change: 171.09, percentage: 0.826, average: 20789.415, baseVolume: 255975.92477, quoteVolume: 5313286316.535715, info: { symbol: 'BTCUSDT', priceChange: '171.09000000', priceChangePercent: '0.826', weightedAvgPrice: '20756.97674033', prevClosePrice: '20705.51000000', lastPrice: '20874.96000000', lastQty: '0.00285000', bidPrice: '20873.40000000', bidQty: '0.12873000', askPrice: '20874.33000000', askQty: '0.00239000', openPrice: '20703.87000000', highPrice: '21085.00000000', lowPrice: '20542.00000000', volume: '255975.92477000', quoteVolume: '5313286316.53571490', openTime: '1666974472005', closeTime: '1667060872005', firstId: '2046781999', lastId: '2052933889', count: '6151891' } }D:\nodejs\CCXT_Markets>
Let me know if I can use the repo to run the above Node.JS scripts, if yes, please share some codes. I am using Visual Studio 2022 on Windows 10. Please advise, Thanks,