1.0.0 • Published 3 months ago

bitfox v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

It is intended to be used by coders, developers, technically-skilled traders, data-scientists and financial analysts for building trading algorithms.

Warning

BitFox Documentation

$ npm i bitfox
$ npm install -g bitfox
let {BitFoxEngine, Strategy, SuperTrend, builder} = require("bitfox").bitfox;



(async  () =>{
    
    // Initialize the Engine
    let engine = builder()
        .requiredCandles(200)
        .sidePreference("long")
        .backtest(true)
        .pollRate(10)
        .public(true)
        .exchange("bybit")
        .symbol("ADAUSDT")
        .timeframe("15m")
        .amount(100)
        .profitPct(0.003)
        .fee(0.02)
        .key("FAKE_KEY")
        .secret("FAKE_SECRET")
        .life(false)
        .interval(10)
        .build(); 
    
    // Set up the Exchage Client
    await engine.setupAndLoadClient()
    
    // Leverage A Strategy from BitFoxes strategy repository
    engine.applyStrategy(SuperTrend)
    // or Alternatively 
    let bitfox = require("bitfox");
    engine.applyStrategy(bitfox.SuperTrend)
    
    
    // Set Up Event Handlers 
    engine.on('onStrategyResponse', (eventArgs) => {
        console.log(eventArgs)
    });
    engine.on('onMessage', (eventArgs) => {
        console.log(eventArgs)
    });
    engine.on('onError', (eventArgs) => {
        console.log(eventArgs)
    });
    engine.on('onOrderPlaced', (eventArgs) => {
        console.log(eventArgs)
    });
    engine.on('onOrderFilled', (eventArgs) => {
        console.log(eventArgs)
    });
    engine.on('onTradeComplete', (eventArgs) => {
        console.log(eventArgs)
    });
    engine.on('onStopLossTriggered', (eventArgs) => {
        console.log(eventArgs)
    });
    // SetUp Custom Event Handler (You need to fire the event yourself BitFox doesn't know about your Custom Event")
    engine.on('MyCustomEvent', (eventArgs) => {
        console.log(eventArgs)
    });
    
    // You could get the Event handler and fire an event by using below code
    engine.getEventEmitter().fireEvent("MyCustomEvent", {customEventData:"YourCustomEventData"})
    
    // Start The BitFox Engine
    await engine.run();
})();