Skip to content

Commit a6cc1ff

Browse files
Johnny A. dos Santosvslee
authored andcommitted
Update readme (#494)
* Fix BL3P entry in the readme * Add alt to logo * Update README * VSCode stuff
1 parent 7b15124 commit a6cc1ff

File tree

8 files changed

+227
-59
lines changed

8 files changed

+227
-59
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,6 @@ launchSettings.json
454454

455455
## Project specific
456456
**/keys.bin
457+
dist/
458+
data/**
459+
!data/.gitkeep

.vscode/launch.template.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "CLI: Launch",
6+
"type": "coreclr",
7+
"request": "launch",
8+
"preLaunchTask": "build",
9+
"program": "${workspaceFolder}/src/ExchangeSharpConsole/bin/Debug/netcoreapp3.0/exchange-sharp.dll",
10+
"args": [
11+
// array with the arguments to test the CLI tool
12+
// e.g.
13+
"ws-orderbook", "-e", "bl3p", "-s", "btceur"
14+
],
15+
"cwd": "${workspaceFolder}/data/",
16+
"console": "internalConsole",
17+
"stopAtEntry": false
18+
},
19+
{
20+
// to be used with the CLI tool
21+
// on Debug configuration, all commands accept a --debug flag.
22+
// The program will print to the console the PID that you have to attach to.
23+
// e.g. `$ exchange-sharp ws-orderbook --debug -e bl3p`
24+
"name": "CLI: Attach",
25+
"type": "coreclr",
26+
"request": "attach",
27+
"processId": "${command:pickProcess}"
28+
}
29+
]
30+
}

.vscode/tasks.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/src/ExchangeSharpConsole/ExchangeSharpConsole.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile",
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"label": "publish",
22+
"command": "dotnet",
23+
"type": "process",
24+
"args": [
25+
"publish",
26+
"${workspaceFolder}/src/ExchangeSharpConsole/ExchangeSharpConsole.csproj",
27+
"-o",
28+
"${workspaceFolder}/dist",
29+
"-c",
30+
"${input:Configuration}",
31+
"/property:GenerateFullPaths=true"
32+
],
33+
"problemMatcher": "$msCompile"
34+
},
35+
{
36+
"label": "test",
37+
"command": "dotnet",
38+
"type": "process",
39+
"args": [
40+
"test",
41+
"${workspaceFolder}/src/ExchangeSharpConsole/ExchangeSharpConsole.csproj",
42+
"/property:GenerateFullPaths=true"
43+
],
44+
"problemMatcher": "$msCompile",
45+
"group": {
46+
"kind": "test",
47+
"isDefault": true
48+
}
49+
}
50+
],
51+
"inputs": [
52+
{
53+
"options": [
54+
"Debug",
55+
"Release"
56+
],
57+
"id": "Configuration",
58+
"type": "pickString",
59+
"default": "Debug",
60+
"description": "The configuration to build",
61+
}
62+
]
63+
}

BUILDING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
### Building
2+
3+
#### Required tools
4+
- [.NET Core SDK 3.0](https://dotnet.microsoft.com/download/dotnet-core/3.0) (you can check the exact version on `global.json` in the root folder).
5+
6+
#### Editing (Optional tooling)
7+
8+
On all platforms:
9+
- JetBrains Rider
10+
- VS Code (with C#/Omnisharp extension)
11+
- MonoDevelop
12+
13+
On Windows:
14+
- Visual Studio 2019
15+
16+
On Mac:
17+
- Visual Studio for Mac
18+
19+
### Compiling
20+
21+
All Platforms (command line): `dotnet build ExchangeSharp.sln` \
22+
Windows: Open ExchangeSharp.sln in Visual Studio and build/run \
23+
24+
#### Creating a release version
25+
26+
##### From the command line (bash/powershell):
27+
28+
`dotnet publish src/ExchangeSharpConsole -o $PWD/dist -c Release -r <RID>`
29+
30+
Change `<RID>` to whatever platform you are using. More info [here](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#using-rids).
31+
32+
##### From Visual Studio
33+
34+
You can also publish from Visual Studio (right click project, select publish), which allows easily changing the platform, .NET core version and self-contained binary settings.

README.md

Lines changed: 56 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
<img src='logo.png' width='600' />
1+
<img src='logo.png' width='600' alt="Project's logo" />
22

3-
[![Build Status](https://dev.azure.com/DigitalRuby/DigitalRuby/_apis/build/status/jjxtra_ExchangeSharp?branchName=master)](https://dev.azure.com/DigitalRuby/DigitalRuby/_build/latest?definitionId=5&branchName=master)
3+
[![Build Status](https://dev.azure.com/DigitalRuby/DigitalRuby/_apis/build/status/jjxtra_ExchangeSharp?branchName=master)](https://dev.azure.com/DigitalRuby/DigitalRuby/_build/latest?definitionId=5&branchName=master) [![NuGet](https://img.shields.io/nuget/dt/DigitalRuby.ExchangeSharp.svg)][nuget]
44

55
## Overview
6-
ExchangeSharp is a C# console app and framework for trading and communicating with various exchange API end points for cryptocurrency assets. Many exchanges are supported, along with web sockets, withdraws and more! Feel free to visit the discord channel at https://discord.gg/sHCUHH3 and chat with other developers.
6+
ExchangeSharp is a C# **framework/lib** and [console app](#Installing-the-CLI) for trading and communicating with [various](#Exchanges) exchange API end points for cryptocurrency assets. Many exchanges are supported, along with [web sockets](#Websockets), withdraws and more!
7+
8+
Feel free to visit the discord channel at https://discord.gg/sHCUHH3 and chat with other developers.
79

810
### Features
911
- Many exchanges supported with public, private and web socket API
1012
- Easy to use and well documented code and API
1113
- Optional global market symbol normalization, since each exchange has their own way of doing market symbols
12-
- Runs anywhere .NET core will run (Windows 8.1 or newer, MAC, Linux, iOS, Android, Unity 2018+, etc.)
14+
- Runs anywhere .NET Core runs. (Windows, Mac, Linux, Containers, Serverless, iOS, Android, [etc.](https://docs.microsoft.com/en-us/dotnet/core/about))
15+
- Can be used from [many different C# platforms](https://github.com/dotnet/standard/blob/master/docs/versions/netstandard2.0.md#platform-support)
16+
- Has a great [CLI](#Installing-the-CLI) that enables you to use all features from all exchanges right from your command line.
1317

1418
### Exchanges
1519
The following cryptocurrency exchanges are supported:
@@ -26,7 +30,7 @@ The following cryptocurrency exchanges are supported:
2630
| BitMEX | x | x | R O |
2731
| Bitstamp | x | x | R |
2832
| Bittrex | x | x | T R |
29-
| BL3P | x | | R O |
33+
| BL3P | x | x | R B | Trades stream does not send trade's ids.
3034
| Bleutrade | x | x | |
3135
| Coinbase | x | x | T R |
3236
| Digifinex | x | x | R B |
@@ -47,94 +51,85 @@ The following cryptocurrency exchanges are supported:
4751
The following cryptocurrency services are supported:
4852
- Cryptowatch (partial)
4953

54+
### Installing the CLI
55+
56+
On *nix systems:
57+
- Run this command `curl https://github.com/jjxtra/ExchangeSharp/raw/master/install-console.sh | sh`
58+
59+
On Windows (or manually):
60+
- Download the [latest binaries](https://github.com/jjxtra/ExchangeSharp/releases/latest) for your OS.
61+
- Unzip it into a folder that is in your environment variable `PATH` (`ctrl` + `shift` + `pause|break` -> Environment Variables)
62+
- Use it from the your preferred command-line emulator (e.g. Powershell, cmd, etc.)
63+
- `exchange-sharp --help` shows all available commands
64+
5065
### Notes
51-
ExchangeSharp uses 'marketSymbol' to refer to markets, or pairs of currencies.
66+
ExchangeSharp uses **`marketSymbol`** to refer to markets, or pairs of currencies.
5267

5368
Please send pull requests if you have made a change that you feel is worthwhile, want a bug fixed or want a new feature. You can also donate to get new features.
5469

55-
### Building
56-
Visual Studio 2017 is recommended. .NET 4.7.2+ or .NET core 2.2+ is required.
57-
If running on Windows, you should use Windows 8.1 or newer.
70+
### [Building/Compiling](./BUILDING.md)
5871

59-
If you must use an older Windows, you'll need to use the Websocket4Net nuget package, and override the web socket implementation by calling
72+
### Websockets
6073

61-
```ExchangeSharp.ClientWebSocket.RegisterWebSocketCreator(() => new ExchangeSharpConsole.WebSocket4NetClientWebSocket());```
74+
If you must use an older Windows (older than win8.1), you'll need to use the [Websocket4Net][websocket4net] nuget package, and override the web socket implementation by calling
6275

63-
See WebSocket4NetClientWebSocket.cs for implementation details.
64-
```
65-
Windows: Open ExchangeSharp.sln in Visual Studio and build/run
66-
Other Platforms: dotnet build ExchangeSharp.sln -f netcoreapp2.1
67-
Ubuntu Release Example: dotnet build ExchangeSharp.sln -f netcoreapp2.1 -c Release -r ubuntu.16.10-x64
76+
```csharp
77+
ExchangeSharp.ClientWebSocket.RegisterWebSocketCreator(
78+
() => new ExchangeSharpConsole.WebSocket4NetClientWebSocket()
79+
);
6880
```
6981

70-
You can also publish from Visual Studio (right click project, select publish), which allows easily changing the platform, .NET core version and self-contained binary settings.
82+
See [`WebSocket4NetClientWebSocket.cs`][websocket4net] for implementation details.
7183

7284
### Nuget
73-
<a href='https://www.nuget.org/packages/DigitalRuby.ExchangeSharp/'>![NuGet](https://img.shields.io/nuget/dt/DigitalRuby.ExchangeSharp.svg)
74-
``` PM> Install-Package DigitalRuby.ExchangeSharp -Version 0.6.3 ```
75-
</a>
7685

77-
### Order Example
78-
```csharp
79-
public static async Task OrderExample()
80-
{
81-
ExchangeKrakenAPI api = new ExchangeKrakenAPI();
82-
ExchangeTicker ticker = await api.GetTickerAsync("XXBTZUSD");
83-
Logger.Info("On the Kraken exchange, 1 bitcoin is worth {0} USD.", ticker.Bid);
86+
#### dotnet CLI
87+
[`dotnet add package DigitalRuby.ExchangeSharp --version 0.6.3`][nuget]
8488

85-
// load API keys created from ExchangeSharpConsole.exe keys mode=create path=keys.bin keylist=public_key,private_key
86-
api.LoadAPIKeys("keys.bin");
89+
#### Package Manager on VS
90+
[`PM> Install-Package DigitalRuby.ExchangeSharp -Version 0.6.3`][nuget]
8791

88-
/// place limit order for 0.01 bitcoin at ticker.Ask USD
89-
ExchangeOrderResult result = await api.PlaceOrderAsync(new ExchangeOrderRequest
90-
{
91-
Amount = 0.01m,
92-
IsBuy = true,
93-
Price = ticker.Ask,
94-
MarketSymbol = "XXBTZUSD"
95-
});
92+
### Examples
9693

97-
// Kraken is a bit funny in that they don't return the order details in the initial request, so you have to follow up with an order details request
98-
// if you want to know more info about the order - most other exchanges don't return until they have the order details for you.
99-
// I've also found that Kraken tends to fail if you follow up too quickly with an order details request, so sleep a bit to give them time to get
100-
// their house in order.
101-
await Task.Delay(500);
102-
result = await api.GetOrderDetailsAsync(result.OrderId);
94+
#### Creating an order
10395

104-
Logger.Info("Placed an order on Kraken for 0.01 bitcoin at {0} USD. Status is {1}. Order id is {2}.", ticker.Ask, result.Result, result.OrderId);
105-
}
106-
```
96+
There's a lot of examples on how to use the API in our [console application](./src/ExchangeSharpConsole/Options). \
97+
e.g.
98+
[`ExampleOption.cs`](./src/ExchangeSharpConsole/Options/ExampleOption.cs)
99+
100+
#### Getting ticker info via Web Sockets
107101

108-
### Web Socket Example
109102
```csharp
110103
public static async Task Main(string[] args)
111104
{
112105
// create a web socket connection to Binance. Note you can Dispose the socket anytime to shut it down.
106+
using var api = new ExchangeBinanceAPI();
113107
// the web socket will handle disconnects and attempt to re-connect automatically.
114-
ExchangeBinanceAPI b = new ExchangeBinanceAPI();
115-
using (var socket = await b.GetTickersWebSocket((tickers) =>
108+
using var socket = await api.GetTickersWebSocket(tickers =>
116109
{
117110
Console.WriteLine("{0} tickers, first: {1}", tickers.Count, tickers.First());
118-
}))
119-
{
120-
Console.WriteLine("Press ENTER to shutdown.");
121-
Console.ReadLine();
122-
}
111+
});
112+
113+
Console.WriteLine("Press ENTER to shutdown.");
114+
Console.ReadLine(true);
123115
}
124116
```
125117

126118
### Logging
127-
ExchangeSharp uses NLog internally currently. To log, use ExchangeSharp.Logger. Do not use Console.WriteLine to log messages.
119+
ExchangeSharp uses NLog internally _currently_. To log, use `ExchangeSharp.Logger`.
120+
121+
Do **not** use `Console.WriteLine` to log messages in the lib project.
128122

129-
Provide your own nlog.config or app.config nlog configuration if you want to change logging settings or turn logging off.
123+
Provide your own `nlog.config` or `app.config` nlog configuration if you want to change logging settings or turn logging off.
130124

131125
### Caching
132-
The ExchageAPI class provides a method caching mechanism. Use MethodCachePolicy to put caching behind public methods, or clear to remove caching. Some methods are cached by default. You can set ExchangeAPI.UseDefaultMethodCachePolicy to false to stop all caching as well.
126+
127+
The `ExchageAPI` class provides a method caching mechanism. Use `MethodCachePolicy` to put caching behind public methods, or clear to remove caching. Some methods are cached by default. You can set `ExchangeAPI.UseDefaultMethodCachePolicy` to `false` to stop all caching as well.
133128

134129
You can also set request cache policy if you want to tweak how the http caching behaves.
135130

136131
### How to contribute
137-
Please read the [contributing guideline](CONTRIBUTING.md) before submitting a pull request.
132+
Please read the [contributing guideline](CONTRIBUTING.md) **before** submitting a **pull request**.
138133

139134
### Consulting
140135
I'm happy to make customizations to the software for you and keep in private repo, email [email protected].
@@ -158,3 +153,6 @@ Thanks for visiting!
158153
Jeff Johnson
159154
160155
http://www.digitalruby.com
156+
157+
[nuget]: https://www.nuget.org/packages/DigitalRuby.ExchangeSharp/
158+
[websocket4net]: https://github.com/kerryjiang/WebSocket4Net

data/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Just to keep this folder here (this folder can be used to store data without commiting it to git)

install-console.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
if [ -z $INSTALL_DIR ]; then
6+
INSTALL_DIR=/usr/local/bin/
7+
else
8+
INSTALL_DIR="$(realpath -s $INSTALL_DIR)"
9+
fi
10+
11+
OS=
12+
case "$(uname -s)" in
13+
Darwin)
14+
OS=osx
15+
;;
16+
Linux)
17+
OS=linux
18+
;;
19+
CYGWIN*|MINGW32*|MSYS*)
20+
OS=win
21+
;;
22+
*)
23+
echo -e 'Failed to identify the OS.'
24+
return 1
25+
;;
26+
esac
27+
28+
TAG=$(curl -Ssf https://api.github.com/repos/johnnyasantoss/ExchangeSharp/releases/latest | jq -r .name)
29+
echo "Downloading version: '${TAG}'..."
30+
31+
curl -SfL# -o /tmp/exchangesharp.zip "https://github.com/johnnyasantoss/ExchangeSharp/releases/download/${TAG}/${OS}-x64.zip"
32+
33+
unzip -qq -o /tmp/exchangesharp.zip -d /tmp/exchangesharp/
34+
35+
sh -c "set -ex; sudo mv /tmp/exchangesharp/exchange-sharp ${INSTALL_DIR}exchange-sharp"
36+
37+
rm -rf /tmp/exchangesharp.zip /tmp/exchangesharp/
38+
39+
echo "🎉 Installed in ${INSTALL_DIR}exchange-sharp"

src/ExchangeSharpConsole/Options/ExampleOption.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ExampleOption : BaseOption, IOptionWithKey
1212
{
1313
public override async Task RunCommand()
1414
{
15-
var api = new ExchangeKrakenAPI();
15+
using var api = new ExchangeKrakenAPI();
1616
var ticker = await api.GetTickerAsync("XXBTZUSD");
1717

1818
Console.WriteLine("On the Kraken exchange, 1 bitcoin is worth {0} USD.", ticker.Bid);

0 commit comments

Comments
 (0)