Giter Site home page Giter Site logo

iniself / noba Goto Github PK

View Code? Open in Web Editor NEW
82.0 2.0 21.0 941 KB

Noba not only backtrader as a quantitative investment platform, but also visualized using bokeh, which can get richer plot effects. Additionally, Noba also provide 'Ioc Container', 'Event System', 'Database Abstraction Layer', 'Pipeline System' and more.

License: GNU General Public License v3.0

Python 99.07% Jinja 0.80% JavaScript 0.13%
backtrader bokeh investment-analysis quantitative-finance quantitative-investment quantitative-trading

noba's Introduction

What is Noba

Noba means not only backtrader :)

You can visit noba documentation for more information: EN(coming soon) | 中文

The core of Noba is an ioc container, through which you can create BB service, which based on Backtrader(one quantitative backtest system) and Bokeh (use bokeh as the backend, Backtrader can get richer plot effects) * BB service would like to thank backtrader_plotting and btplotting for providing the main code for using bokeh as the backend for the backtrader

from noba import core
bt =  core.make('bb')

Of course, you can also create your own services based container. Combined with Pipeline System and Event System (which can be created directly through containers), noba can enable your quantitative projects to work in a more engineering methods

from noba import core
pipline =  core.make('pipeline')
cleaned_data = pipline.via("handle").send(raw_data).through([ChangeDataType, RepeatRowData, ExceptionData, MissingData]).then(lambda raw_data:raw_data)
from noba import core
event = core.make('event')
db_event = event.hub(['read_database_complete'])
db_event.watch('read_database_complete', lambda data:..., always=True)
...
db_event.fire('read_database_complete')

More importantly, Noba can create database service objects (dber) through containers. This is a Database Abstraction Layer. Through configuration files(one json file) and unified one set of APIs, you can operate the most common databases

from noba import core
dber =  core.make('db')
stocks = db.table('daily').where('Open==3578.73').or_where('High==3652.46').set_index('Date').get_except('OpenInterest')

Getting Started

  • Python >= 3.6 is required.
  • Suggest using conda to manage virtual environments

Installation

pip install noba
# or
pip install git+https://github.com/iniself/noba

Init noba project

mkdir your_noba_project
cd your_noba_project
noba init

Preparation

Here you can do some project configuration and write your own service provider, and so on. Please refer to the NOBA documentation for details

Write strategy

vim main.py

Only give Live Mode example, about Normal Mode and Optstrategy Mode pls refer to NOBA documentation

  • Add to cerebro as an analyzer (Live Mode):

    from noba import core
      ...
      ...
    bt = core.make('bb')
    cerebro = bt.Cerebro()
    cerebro.addstrategy(MyStrategy)
    cerebro.adddata(LiveDataStream()) # Note! Data is must Live Data
    cerebro.addanalyzer(bt.analyzers.Live, force_plot_legend=True, autostart=True)
    cerebro.run()
    # cerebro.plot() # do not run this line unless your data is not real-time
  • If you need to change the default port or share the plotting to public:

    cerebro.addanalyzer(bt.analyzers.Live, address="localhost", port=8889)
  • Note! In Jupyter you can plut to a single browser tab with iplot=False:

    cerebro.plot(plot, iplot=False)

Demos

https://iniself.github.io/noba/

Contact us

Telegram Channel: Aui_Say Discord Server: Aui and Friends

Sponsoring

If you want to support the development of noba, consider to support this project.

  • ETH: 0x0275779f70179748C6fCe1Fe5D7638DfA7e3F986

noba's People

Contributors

iniself avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

noba's Issues

ERROR:bokeh.server.views.ws:Refusing websocket connection.

Hello! I got the following error in notebook. I tried both VS Code and Jupyter Notebook - same error.

Appreciate any solution!

ERROR:bokeh.server.views.ws:Refusing websocket connection from Origin 'vscode-webview://0lj9hh483va927cadklatiu5affjj5cn3b349he4cl71d36qc4p6/'; use --allow-websocket-origin=0lj9hh483va927cadklatiu5affjj5cn3b349he4cl71d36qc4p6 or set BOKEH_ALLOW_WS_ORIGIN=0lj9hh483va927cadklatiu5affjj5cn3b349he4cl71d36qc4p6 to permit this; currently we allow origins {'localhost:8889'} WARNING:tornado.access:403 GET /ws?id=348b26a3-e939-4e81-b383-da0df5147ff8&origin=bce4bbf1-101d-44db-883b-e3db4f31e0a2&swVersion=4&extensionId=&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app&purpose=notebookRenderer (::1) 18.06ms

Empty output (no graph) in Jupyter Lab

When running the sample:

from backtrader_bokeh import bt as bt_bokeh
plot = bt_bokeh.Bokeh()
cerebro.plot(plot, iplot=False)

there is nothing displayed in the Jupyter Lab cell output except: " BokehJS 2.4.3 successfully loaded."

Versions of packages:

  • backtrader-bokeh==0.8.9
  • bokeh==2.4.3
  • jupyter-bokeh==3.0.7
  • jupyter-lab: 3.4.8

Is there something else I may be missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.