Files
quantconnect--lean/ToolBox/README.md
Stefano Raggi 934128cfa0 Binance Brokerage implementation (#4688)
* Binance Brokerage skeleton

* Market hours

* Implement Symbol Mapper

- known symbols available on /api/v1/exchangeInfo
- fiat currencies are pegged

* Implement GetCashBalance

* Implement GetAccountHoldings

- there are no pre-existing currency swaps
- cash balances are pulled and stored in the cashbook

* Implement GetOpenOrders

* Manage orders: PlaceOrder

* Manage orders: UpdateOrder

Update operation is not supported

* Manage orders: CancelOrder

* Messaging: order book

* Messaging: trades

* Messaging: combine streams

- connect to fake /ws/open channel on init
- case by channel name, but not event type

* Messaging: order depth updates

- ticker symbol is not enough as it pushes updates only once a second, this would be a very incomplete data stream
- fetch ticker snapshot if lastUpdateId == 0
- follow Binance instructions for keeping local orderbook fresh

* Messaging: user data streaming

- Request userDataStream endpoint to get listenKey
- keep listenkey alive
- handle order close event
- handle order fill event

* DataDownloader: get history

- we can aggregate minute candles for higher resolutions

* fix data stream

* Tests: FeeModel tests

* Tests: base brokerage tests

* Tests: download history

* Tests: symbol mapper

* Support StopLimit andd StopMarket orders

* StopMarket orders disabled

Take profit and Stop loss orders are not supported for any symbols (tested with BTCUSDT, ETHUSDT)

* Tests: StopLimit order

* Tests: crypto parsing

* Reissue user data listen key

* comment custom currency limitation

* rework websocket connections

* implement delayed subscription

* adapt ignore message

* add license banner

* use better suited exception type

* avoid message double parsing

* support custom fee values

* extract BinanceApiClient to manage the request/response between lean and binance

* use api events to invoke brokerage events

* do not allow to terminate session if it wasn't allocated.

* update binance exchange info

* tool to add or update binance exchange info

* ExchangeInfo basic test

* Rebase + Resharp

* Binance brokerage updates

- Fix sign bug in sell order fills
- Fix bug in GetHistory
- Remove duplicate symbol from symbol properties db

* Remove unused code

* Revert removal of account currency check

* Update symbols properties database

* Address review

* Address review

- Upgrade API endpoints from v1 to v3
- Updated sub/unsub for new subscription manager
- Subscribe best bid/ask quotes instead of full order book
- Added handling of websocket error messages
- Cleanup + refactor

* Update symbol properties database

* Remove list from symbol mapper

* Fix symbol mapper tests

* Address review

- Fix resubscribe after reconnect
- Fix quote tick edge case

* Fix EnsureCurrencyDataFeed for non-tradeable currencies

* Fix check in EnsureCurrencyDataFeed

* Reuse base class subscribe on reconnect

Co-authored-by: Adalyat Nazirov <aenazirov@gmail.com>
Co-authored-by: Martin-Molinero <martin@quantconnect.com>
2020-09-28 15:57:10 -03:00

3.4 KiB

alt tag Lean Data ToolBox

Join the chat at https://gitter.im/QuantConnect/Lean

Lean Home | Documentation | Download Lean

Introduction

Lean Engine is an open-source algorithmic trading engine built for easy strategy research, backtesting and live trading. We integrate with common data providers and brokerages so you can quickly deploy algorithmic trading strategies.

The ToolBox project is a command line program which wraps over 15 tools.

Usage

Each tool requires a different set of parameters, the only required argument is '--app=', which defines the target tool and is case insensitive.

Help information is available using the '--help' parameter.

Example: --app=YahooDownloader --tickers=SPY,AAPL --resolution=Daily --from-date=yyyyMMdd-HH:mm:ss --to-date=yyyyMMdd-HH:mm:ss

Available downloaders

  • '--app='
    • GDAXDownloader or GDAXDL
    • CryptoiqDownloader or CDL
    • DukascopyDownloader or DDL
    • FxcmDownloader or FDL
    • FxcmVolumeDownload or FVDL
    • IBDownloader or IBDL
    • KrakenDownloader or KDL
    • OandaDownloader or ODL
    • QuandlBitfinexDownloader or QBDL
    • YahooDownloader or YDL
    • IEXDownloader or IEXDL
    • BitfinexDownloader or BFXDL
    • BinanceDownloader or MBXDL
  • '--from-date=yyyyMMdd-HH:mm:ss' required
  • '--tickers=SPY,AAPL,etc' required, except for QuandlBitfinexDownloader (QBDL)
  • '--resolution=Tick/Second/Minute/Hour/Daily/All' required, except for QuandlBitfinexDownloader (QBDL), CryptoiqDownloader (CDL). Case sensitive. Not all downloaders support all resolutions, send empty for more information.
  • '--to-date=yyyyMMdd-HH:mm:ss' optional. If not provided 'DateTime.UtcNow' will be used

Available Converters

  • '--app='
    • AlgoSeekFuturesConverter or ASFC
      • '--date=yyyyMMdd' reference date.
    • AlgoSeekOptionsConverter or ASOC
      • '--date=yyyyMMdd' reference date.
    • CoinApiDataConverter or CADC
      • '--source-dir=' path to the raw CoinAPI data.
    • IVolatilityEquityConverter or IVEC
      • '--source-dir=' source archived IVolatility data.
      • '--source-meta-dir=' source archived IVolatility meta data.
      • '--destination-dir=' directory where Lean Data is located "Lean/Data".
      • '--resolution=Minute/Hour/Daily' resolution of your IVolatility data. Case insensitive.
    • KaikoDataConverter or KDC
      • '--market=' the exchange the data represents.
      • '--tick-type=Quote/Trade' the tick type being processed. Case insensitive.
      • '--source-dir=' path to the raw Kaiko data.
    • NseMarketDataConverter or NMDC
      • '--source-dir=' source directory of unzipped NSE data.
      • '--destination-dir=' directory where Lean Data is located "Lean/Data".
    • QuantQuoteConverter or QQC
      • '--source-dir=' directory where your QuantQuote order is extracted.
      • '--destination-dir=' directory where Lean Data is located "Lean/Data".
      • '--resolution=' resolution of the QuantQuote data.

Other tools

  • '--app='
    • CoarseUniverseGenerator or CUG