Package: blankly
💨  Rapidly build and deploy quantitative models for stocks, crypto, and forex  🚀View Docs·Our Website·Join Our Newsletter·Getting StartedWhy Blankly?Blankly is an ecosystem for algotraders enabling anyone to build, monetize and scale their trading algorithms for stocks, crypto, futures or forex. The same code can be backtested, paper traded, sandbox tested and run live by simply changing a single line. Develop locally then deploy, iterate and share using the blankly platform.The blankly package is designed to beextremely precisein both simulation and live trading.The engineering considerations for highly accurate simulation are describedhereGetting started is easy - justpip install blanklyandblankly init.Check out ourwebsiteand ourdocs.Trade Stocks, Crypto, Futures, and ForexfromblanklyimportAlpaca,CoinbaseProstocks=Alpaca()crypto=CoinbasePro()futures=BinanceFutures()# Easily perform the same actions across exchanges & asset typesstocks.interface.market_order('AAPL','buy',1)crypto.interface.market_order('BTC-USD','buy',1)# Full futures feature setfutures.interface.get_hedge_mode()Backtest your trades, events, websockets, and custom dataimportblankly"""This example shows how backtest over tweets"""classTwitterBot(blankly.Model):defmain(self,args):whileself.has_data:self.backtester.value_account()self.sleep('1h')defevent(self,type_:str,data:str):# Now check if it's a tweet about Teslaif'tsla'indata.lower()or'gme'indata.lower():# Buy, sell or evaluate your portfoliopassif__name__=="__main__":exchange=blankly.Alpaca()model=TwitterBot(exchange)# Add the tweets json heremodel.backtester.add_custom_events(blankly.data.JsonEventReader('./tweets.json'))# Now add some underlying prices at 1 monthmodel.backtester.add_prices('TSLA','1h',start_date='3/20/22',stop_date='4/15/22')# Backtest or run liveprint(model.backtest(args=None,initial_values={'USD':10000}))Check out alternative data exampleshereAccurate Backtest HoldingsGo Live in One LineSeamlessly run your model live!# Just turn thisstrategy.backtest(to='1y')# Into thisstrategy.start()Dates, times, and scheduling adjust on the backend to make the experience instant.QuickstartInstallationFirst install Blankly usingpip. Blankly is hosted onPyPi.$pipinstallblanklyNext, just run:$blanklyinitThis will initialize your working directory.The command will create the fileskeys.json,settings.json,backtest.json,blankly.jsonand an example script calledbot.py.If you don't want to use ourinitcommand, you can find the same files in theexamplesfolder undersettings.jsonandkeys_example.jsonFrom there,insert your API keysfrom your exchange into the generatedkeys.jsonfile or take advantage of the CLI keys prompt.More information can be found on ourdocsDirectory formatThe working directory format should haveat leastthese files:project/
   |-bot.py
   |-keys.json
   |-settings.jsonAdditional InfoMake sure you're using a supported version of python. The module is currently tested on these versions:Python 3.7Python 3.8Python 3.9Python 3.10For more info, and ways to do more advanced things, check out ourgetting started docs.Supported ExchangesExchangeLive TradingWebsocketsPaper TradingBacktestingCoinbase Pro🟢🟢🟢🟢Binance🟢🟢🟢🟢Alpaca🟢🟢🟢🟢OANDA🟢🟢🟢FTX🟢🟢🟢🟢KuCoin🟢🟢🟢🟢Binance Futures🟢🟢🟢🟢FTX Futures🟡🟡🟢🟢Okx🟢🟢🟢🟢Kraken🟡🟡🟡🟡Keyless Backtesting🟢TD Ameritrade🔴🔴🔴🔴Webull🔴🔴🔴🔴Robinhood🔴🔴🔴🔴🟢  = working🟡  = in development, some or most features are working🔴  = planned but not yet in developmentRSI ExampleWe have a pre-built cookbook examples that implement strategies such as RSI, MACD, and the Golden Cross found in ourexamples.Other InfoSubscribe to our news!https://blankly.substack.com/p/coming-soonBugsPlease report any bugs or issues on the GitHub's Issues page.DisclaimerTrading is risky. We are not responsible for losses incurred using this software, software fitness for any particular purpose, or responsibility for any issues or bugs.
This is free software.ContributingIf you would like to support the project, pull requests are welcome.LicensingBlanklyis distributed under theLGPL License. See theLICENSEfor more details.New updates every day 💪.Art by DALL·E 2 - "Robots playfully trading stocks synthwave"