https://github.com/bitfinexcom/bfx-hf-strategy-dazaar
https://github.com/bitfinexcom/bfx-hf-strategy-dazaar
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bitfinexcom/bfx-hf-strategy-dazaar
- Owner: bitfinexcom
- License: apache-2.0
- Created: 2020-08-14T12:14:19.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-07T20:02:49.000Z (almost 4 years ago)
- Last Synced: 2025-04-11T06:18:04.996Z (about 1 year ago)
- Language: JavaScript
- Size: 44.9 KB
- Stars: 2
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# Bitfinex Honey Framework Dazaar Module
[](https://travis-ci.org/bitfinexcom/bfx-hf-strategy-exec)
This module can execute strategies built with `bfx-hf-strategy` on a live data stream from dazaar hypercores and dazaar market data.
### Features
* Execute trading strategies on the live Bitfinex markets using Bitfinex Terminal Streams
* Easy selling of trading signals on Dazaar
### Installation
```bash
npm i --save bfx-hf-strategy-dazaar
```
### Quickstart & Example
Full examples are in the [`examples/`](/examples) folder.
#### Selling Trading Signals on Dazaar
Full example in [./examples/example_ema_dazaar_sell.js](./examples/example_ema_dazaar_sell.js)
```js
const execDazaar = require('bfx-hf-strategy-dazaar')
const util = require('bfx-hf-strategy-dazaar/util')
const EMAStrategy = require('bfx-hf-strategy/examples/ema_cross')
const { SYMBOLS, TIME_FRAMES } = require('bfx-hf-util')
const market = {
symbol: SYMBOLS.BTC_USD,
tf: TIME_FRAMES.ONE_HOUR
}
const strategy = EMAStrategy(market)
const submitOrder = util.getSubmitOrderToFeed(sellFeed)
const { exec, stream } = await execDazaar(strategy, market, db, {
submitOrder,
includeTrades: false,
seedCandleCount: 10
})
let btState
for await (const data of stream) {
const { key, value } = data
btState = await exec(key, value)
}
```
#### Trade with Custom Order Submit Functions
You can use any custom function to handle trading signals, as long as it returns a promise.
Full example in [./examples/example_ema_websocket.js](./examples/example_ema_websocket.js)
```js
async function submitOrder (strategyState = {}, order = {}) {
const { amount, price, type } = order
// BFX WS API
// https://github.com/bitfinexcom/bitfinex-api-node
const o = new Order({
cid: Date.now(),
symbol: 'tETHUSD',
amount,
type,
price
}, ws)
await o.submit()
})
const { exec, stream } = await execDazaar(strategy, market, db, {
submitOrder,
includeTrades: false,
seedCandleCount: 10
})
```
### Docs
For executable examples refer to the [`examples/`](/examples) folder. JSDoc generated API documentation can be found [within `docs/api.md`](/docs/api.md).
### Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request