GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Stock84-dev/CCXTSharp: A cryptocurrency trading library with support for more than 100 bitcoin/altcoin exchanges. Uses original ccxt (python) code.

BranchesTags
Open more actions menu

Latest commit

 

History

12 Commits
12 Commits

Folders and files

NameName
Last commit message
Last commit date
CCXT
CCXT
 
 
CCXTSharp
CCXTSharp
 
 
CCXTSharpTest
CCXTSharpTest
 
 
Example
Example
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CCXTSharp.sln
CCXTSharp.sln
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

CCXTSharp

This is a c# wrapper for popular trading library ccxt. Methods and documentation are pretty simmilar to ccxt.

Instalation

Package manager

Install-Package CCXTSharp

Updating ccxt library

  1. Install python 3.5+ (python 3.7 isn't currently supported by pyinstaller). And add python to system PATH if not already added by instalation.
  2. Open cmd.
  3. pip install ccxt // if libraries are already installed then type pip install ccxt --upgrade
  4. pip install cfscrape

Updating ccxtAPI program

  1. Update ccxt library
  2. Navigate to\your\project\ccxt\scripts in file explorer
  3. shift + right click, Open command window here
  4. pyinstaller -w -F ccxtAPI.py // program will be created in dist folder
  5. replace old file

Architecture

Package contains compiled python code that has original ccxt api. C# part creates new proccess and runs compiled python code. Inter process communication is done with named pipes.

Examples

List supported exchanges.

// initialize and start process
CcxtAPI ccxtAPI = new CcxtAPI(@"..\..\ccxt\ccxtAPI.exe");	 
// get list of avaliable exchanges
List<string> exchangeIds = await ccxtAPI.GetExchangIds();		
// print all exchange ids
exchangeIds.ForEach(id => Console.WriteLine(id));
// it's preferred to exit other process if your program will close
await ccxtAPI.Close();

List all markets.

// initialize and run script in python interpreter
CcxtAPI ccxtAPI = new CcxtAPI(@"..\..\ccxt\scripts\ccxtAPI.py", @"D:\Program Files (x86)\Python36-32\python.exe");  
// gets list of markets on Binance exchange and prints their symbols
List<Market> markets = await ccxtAPI.FetchMarkets("binance");
markets.ForEach(m => Console.WriteLine(m.symbol));
await ccxtAPI.Close();

Checking for implementation.

CcxtAPI ccxtAPI = new CcxtAPI(@"..\..\ccxt\ccxtAPI.exe");
// if cryptopia has support for fetch tickers then fetch them
if((await ccxtAPI.GetExchangeHas("cryptopia")).fetchTickers == Has.Capability.True)
{
  Dictionary<string, Ticker> tickers = await ccxtAPI.FetchTickers("cryptopia");
  // foreach ticker print their symbol and change
  foreach (var ticker in tickers.Values)
  {
    Console.WriteLine(ticker.symbol + ": " + ticker.change);
  }
}
await ccxtAPI.Close();

Private API.

CcxtAPI ccxtAPI = new CcxtAPI(@"..\..\ccxt\ccxtAPI.exe");
// Authenticate
await ccxtAPI.ExchangeApiKey("binance", "my_api_key");
await ccxtAPI.ExchangeSecret("binance", "my_api_secret");
// Place order
Order order =  await ccxtAPI.CreateOrder("binance", "ETH/USDT", OrderType.limit, OrderSide.buy, 1, 210);
// Cancel placed order
await ccxtAPI.CancelOrder("binance", order.id, "ETH/USDT");
await ccxtAPI.Close();

Exception handling

CcxtAPI ccxtAPI = new CcxtAPI(@"..\..\ccxt\ccxtAPI.exe");
try
{
  Dictionary<string, Market> markets = await ccxtAPI.LoadMarkets("_1broker");
}
catch (CCXTException ex)
{
  // exception is handled by ccxt python library
  if (ex.HandledByCCXT)
    Console.WriteLine(ex.exceptionType.Value.ToString() + ex.Message);
  else
  {
    // there is a bug either in python ccxt or in CCXTSharp
    Console.WriteLine(ex.Message);
    // restart process
    ccxtAPI.Kill(); // message will popup "Failed to execute script ccxtAPI.py"
    // reinitialize and continue execution
    ccxtAPI = new CcxtAPI(@"..\..\ccxt\ccxtAPI.exe");
  }
}
// ...
await ccxtAPI.Close();

About

A cryptocurrency trading library with support for more than 100 bitcoin/altcoin exchanges. Uses original ccxt (python) code.

Topics

altcoinapiarbitragebitcoinbotbtcccxtcryptocryptocurrencye-commerceexchangeexchange-apiexchange-marketsinvestlibrarymarket-datamerchantstrategytradingtrading-api

Resources

Readme
MIT license
Activity

Stars

17 stars

Watchers

3 watching

Forks

10 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.