数字货币开源交易机器人汇总
近期花了三天时间了解了下网络上开源的加密货币交易机器人,现在备忘如下:
1、vnpy 量化交易平台
vn.py项目起源于国内私募的自主交易系统,2015年初启动时只是单纯的交易API接口的Python封装。随着业内关注度的上升和社区不断的贡献,目前已经一步步成长为一套全面的交易程序开发框架,用户群体也日渐多样化,包括私募基金、证券自营和资管、期货资管和子公司、高校研究机构、个人投资者等。
2、gocryptotrader
Cryptocurrency trading bot written in Golang
A cryptocurrency trading bot supporting multiple exchanges written in Golang.
Please note that this bot is under development and is not ready for production!
Exchange Support Table
Exchange | REST API | Streaming API | FIX API |
---|---|---|---|
Alphapoint | Yes | Yes | NA |
ANXPRO | Yes | No | NA |
Bitfinex | Yes | Yes | NA |
Bitstamp | Yes | Yes | NA |
BTCC | Yes | Yes | No |
BTCE | Yes | NA | NA |
BTCMarkets | Yes | NA | NA |
GDAX(Coinbase) | Yes | Yes | No |
Gemini | Yes | NA | NA |
Huobi | Yes | Yes | No |
ItBit | Yes | NA | NA |
Kraken | Yes | NA | NA |
LakeBTC | Yes | Yes | NA |
LocalBitcoins | Yes | NA | NA |
OKCoin (both) | Yes | Yes | No |
Poloniex | Yes | Yes | NA |
** NA means not applicable as the Exchange does not support the feature.
Current Features
- Support for all Exchange fiat and digital currencies, with the ability to individually toggle them on/off.
- REST API support for all exchanges.
- Websocket support for applicable exchanges.
- Ability to turn off/on certain exchanges.
- Ability to adjust manual polling timer for exchanges.
- SMS notification support via SMS Gateway.
- Basic event trigger system.
Planned Features
- WebGUI.
- FIX support.
- Expanding event trigger system.
- TALib.
- Trade history summary generation for tax purposes.
Please feel free to submit any pull requests or suggest any desired features to be added.
Compiling instructions
Download Go from https://golang.org/dl/
Using a terminal, type go get github.com/thrasher-/gocryptotrader
Change directory to the package directory, then type go install.
Copy config_example.json to config.json.
Make any neccessary changes to the config file.
Run the application!
Binaries
Binaries will be published once the codebase reaches a stable condition.
3、cointrader
Coin Trader
Coin Trader is a Java-based backend for trading cryptocurrencies, released under the Apache License. It features:
- Connectivity to many exchanges
- Control console (text)
- Basic order routing
- Simulated trading
- Live order execution
- Schema and persistence
- CSV output of market data
- Ad-hoc table reports
- Modular infrastructure
- Backtesting
- Accounting
- Library of quantitative indicators (TaLib)
- Bitcoin derivatives (Futures & Swaps)
- Implied price calculation across multiple markets
- Base currency accounting
- 24 Hr OHLC bars
Coin Trader’s future goals include:
- Reconciliation
- Flexible data output
- Web console & graphing
Video
Tim presents Coin Trader at the SF Bitcoin Dev meetup.
Setup
Coin Trader requires Java JDK 1.7, Maven, and a SQL database (MySQL default).
Setup Instructions
Support
See the Wiki for more information.
There’s no mailing list, so open a new issue for anything, help or just discussion. Tag it with “Question” and I’ll follow through with you.
Automated Trading
To implement signals and automated strategies, you connect Esper event queries to Java code like this:
@When( "select avg(priceAsDouble) from Trade.win:time(30 sec)" )
void checkMovingAverage( double avg )
{
if( avg > trigger )
context.publish( new MyIndicator(5.31) );
}
@When( "select * from MyIndicator where myIndicatorValue > 5.0" )
void enterTrade( MyIndicator s )
{
orders.create( Listings.BTC_USD, 1.0 )
.withLimit( 650.25 )
.place();
}
You then attach this class to a Context to receive Esper event rows as method invocations.
24Hr OHLC Bars
Strategy needs to implement a .getInterval() method to return a double in seconds of the size of the bar.
Default simple statful stretegy is 86400 (24Hr) cointrader-esper.cfg.xml
<plugin-view factory-class="org.cryptocoinpartners.esper.OHLCBarPlugInViewFactory" name="ohlcbar" namespace="custom"/>
epl
- Create an esper named window to add the OHLC bars into
create window OHLCShortWindow.win:length(10)
as
select *
from
Bar;
- Add the OHLC bars to it
insert into OHLCShortWindow
select *
from Trade.custom:ohlcbar(timestamp, priceCountAsDouble, market,TestStrategy.getInterval());
- Select values from OHLC bar window
select * from OHLCShortWindow as ohlc
TALIB Set Up
cointrader-esper.cfg.xml
<plugin-aggregation-function name="talib" function-class="org.cryptocoinpartners.esper.GenericTALibFunction"/>
epl
select coalesce(talib("atr", max, min, last, 9),0) as atr from OHLCShortWindow;
Console Demo
The Coin Trader Console gives you a peek into the engine.
$ ./cointrader.sh console
Coin Trader Console 0.3.0-SNAPSHOT
ct> help
Type "help {command}" for more detailed information.
Available commands:
• attach
• buy
• csv
• currencies
• data
• exchanges
• exit
• help
• jpa
• listings
• markets
• sell
• set
• unset
• unwatch
• watch
• watches
ct> data summary
+------------------+------------+-----------+
| Market | Num Trades | Num Books |
+------------------+------------+-----------+
| BTCE:BTC.USD | 8149 | 2671 |
| BITFINEX:BTC.USD | 3509 | 2551 |
| BITSTAMP:BTC.USD | 1344 | 901 |
| BITFINEX:DRK.USD | 1000 | 21 |
| BITFINEX:DRK.BTC | 1000 | 21 |
| BITFINEX:LTC.USD | 1000 | 22 |
| BITFINEX:LTC.BTC | 1000 | 22 |
| BTCCHINA:BTC.CNY | 134 | 31 |
| BTCCHINA:LTC.CNY | 110 | 31 |
| BTCCHINA:LTC.BTC | 102 | 31 |
| BTER:BTC.CNY | 47 | 7 |
| BTER:LTC.BTC | 38 | 84 |
| BTER:DOGE.CNY | 26 | 7 |
| BTER:NXT.CNY | 26 | 6 |
| BTER:DRK.CNY | 23 | 6 |
| BTER:DOGE.BTC | 23 | 6 |
| BTER:LTC.CNY | 21 | 7 |
| BTER:XCP.CNY | 20 | 6 |
| BTER:DRK.BTC | 19 | 6 |
| BTER:XCP.BTC | 18 | 12 |
| BTER:NXT.USD | 2 | 6 |
+------------------+------------+-----------+
ct> watch btc.usd
now watching BTC.USD
ct>
book: BITFINEX:BTC.USD 587.4 (0.317861) - 588.82 (-1.54641998)
book: BTCE:BTC.USD 583.92 (0.01499999) - 585.99 (-0.01819054)
book: BITSTAMP:BTC.USD 588.79 (0.99999999) - 590.33 (-0.19199999)
book: BITFINEX:BTC.USD 587.4 (0.317861) - 588.81 (-13.94196839)
book: BTCE:BTC.USD 583.92 (0.01499999) - 585.99 (-0.01819054)
trade: BITSTAMP:BTC.USD 590.33 (0.03489999)
book: BTCE:BTC.USD 583.92 (0.01499999) - 585.99 (-0.01819054)
book: BITFINEX:BTC.USD 587.4 (0.317861) - 588.8 (-31.37994228)
book: BTCE:BTC.USD 583.92 (0.01499999) - 585.99 (-0.01180944)
ct> unwatch btc.usd
no longer watching BTC.USD
ct> buy 10.0 bitfinex:btc.usd
Sending order SpecificOrder{id=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, parentOrder=null, market=BITFINEX:BTC.USD, volumeCount=1000000000}
Order has been placed. SpecificOrder{id=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, parentOrder=null, market=BITFINEX:BTC.USD, volumeCount=1000000000}
ct>
Filled order d5a2ff79-0eca-445d-a3b3-75d1e80265a7: Fill{order=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, market=BITFINEX:BTC.USD, price=585.57, volume=2.11486695}
Order is partially filled SpecificOrder{id=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, parentOrder=null, market=BITFINEX:BTC.USD, volumeCount=1000000000, averageFillPrice=585.57}
Filled order d5a2ff79-0eca-445d-a3b3-75d1e80265a7: Fill{order=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, market=BITFINEX:BTC.USD, price=585.58, volume=7.88513305}
Order has been completely filled. SpecificOrder{id=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, parentOrder=null, market=BITFINEX:BTC.USD, volumeCount=1000000000, averageFillPrice=585.57788513305}
ct> buy 1 btc.usd
Creating order GeneralOrder{id=a4664af4-a21d-4b77-a999-bc8a78a8d951, parentOrder=null, listing=BTC.USD, volume=1}
Order has been placed. SpecificOrder{id=3ff02408-8269-4bf9-929f-8d2ca060f6fc, parentOrder=a4664af4-a21d-4b77-a999-bc8a78a8d951, market=BITSTAMP:BTC.USD, volumeCount=100000000}
ct>
Filled order 3ff02408-8269-4bf9-929f-8d2ca060f6fc: Fill{order=3ff02408-8269-4bf9-929f-8d2ca060f6fc, market=BITSTAMP:BTC.USD, price=584.99, volume=1}
Order has been completely filled. SpecificOrder{id=3ff02408-8269-4bf9-929f-8d2ca060f6fc, parentOrder=a4664af4-a21d-4b77-a999-bc8a78a8d951, market=BITSTAMP:BTC.USD, volumeCount=100000000, averageFillPrice=584.99}
Order has been completely filled. GeneralOrder{id=a4664af4-a21d-4b77-a999-bc8a78a8d951, parentOrder=null, listing=BTC.USD, volume=1}
ct> buy 1 OKCOIN_THISWEEK:BTC.USD.THISWEEK limit 218.3
ct> exit
$