Package: quantlet
QuantLETQuantLET- an event driven framework for large scale real-time analytics.Copyright (C) 2006 Jorge M. Faleiro Jr.QuantLET is an open source, event-driven framework for rapid development and deployment of real-time analytical
models intended to be executing in large scale, in terms of data intensiveness or computing power (your spreadsheet can't do that).You can see afew examples of the frameworkoutlining the use of signals in a moving average cross-over strategy or how to define and use 'infinite spreadsheets'.There is also a large number of examples produced during my doctorate research and sprinkled across many articles. TheBlack Magic paperdescribes an end-to-end investigation of the use of data to detect profit opportunities in equities using price momentum. The financial languageSIGMAalso part of the same research borrowed some ideas from QuantLET, and vice-versa.The nature of any quantitative framework require a number of quite heavy auxiliary libraries and resources. QuantLET is no exception. You can pick and choose a specific extensions (as python extras) based on what you intend to do with the framework.DevelopmentIf you intend to try out the source code please make yourself aware of thelicense. It is recommended the use of containers and cloud services. At the time of this writing I usedVSCodeandRemote Containers. You will also needpoetryandpre-commit.gitclonegit@gitlab.com:jfaleiro/quantlet.gitcdquantlet
poetryinstallAll code check and quality procedures are done as part ofpre-commit. These checks are mandatory and are a condition for automatic build and release.poetryshell
pre-commitinstallGit pre commit hooks are installed and from this point on all checks are done locally as a condition for agit committo succeed. CI-CD is done bygitlab. You can find the spec for each component in the source tree.UseTypicalsetuptoolsuse throughpip. You can use the bare bones version:pipinstallquantletOr any of the extensions (extras). If you need one single extension, saystrats:pipinstallquantlet[strats]If you want multiple extensions, like reactives and deep learning for example, you add each extension separated by comma:pipinstallquantlet[reactives,dl]You don't want to use the wildcardquantlet[*]and install all extras. Python is not really an environment geared toward large scale software development and this will bring in all depenedencies, across all extensions. Inpipandpoetryfor example this might lead to a few hours of dependency resolution alone. There are way more uses and features in QuantLET than we would like to admit and you can possibly need for one application, so be parcimonious.Each extension is defined in a project namedquantlet-[extension]. Dependencies on QuantLET'spyproject.tomlare defined like this:"quantlet.reactives"={git="https://gitlab.com/jfaleiro/quantlet-reactives.git",rev="release/0.0.1",develop=true,optional=true}This type of dependency is resolved throughgit. In each case you might need read access to the specificgitlabrepository. Feel free to investigate and get in touch if you need access or details.quantlet-streamsQuantLET elements of stream processing (filtering, grouping, selection, functional operations) on canonical and data frames format.[1,3,4,7,8]>>apply(lambdax:dict(x=x)))==[{'x':1},{'x':3},{'x':4},{'x':7},{'x':8}]This is thestreaming facetdefined as part of the financial languageSIGMA.quantlet-reactivesFast and simple framework for reactive programming. A declarative paradigm that allows the definition of what has to be done through reactive relationships, letting the computational representation automatically take care of when to do it, and which results are produced, similar to cells in an electronic spreadsheet representing values and a formula.v=[R(i)for_inrange(10000)]c=sum(*v)foriinv:i.v=normal()print(c.v)>>0.0035This is thereactives facetdefined as part of the financial languageSIGMA.quantlet-big-reactivesSupport for reactive use cases that must reply on very large data: infinite reactive graphs (infinite spreadsheets) associated to non-structured repositories. Reactives are organized in distributed nodes, allowing for automatic persistence and in memory allocation beyond the limits of one single computer.quantlet-timeseriesFast timeseries functions and transformations. Large store and retrievals of sequencial datasets infastparquetthroughtsstore.quantlet-agentsSynchronous and asynchronous agents for discrete-event simulation. This is related to thedistributionandsimulation facetsdefined as part of the financial languageSIGMA.quantlet-stratsFinancial strategies and analytics. Elements of numeric processing, data analysis, plotting and tabular transformations. Basically strats are classified in bands,BandsDefine higher a lower limits around an ongoing signal, e.g., for Bollinger and fixed bands:# Bollinger bandsa=(simple_dataframe>>std(price_tag='price')>>bollinger(ma_tag='price'))assertround(a.upper.mean(),2)==1.94assertround(a.lower.mean(),2)==-2.02# Fixed bandsa=(simple_dataframe>>fixed(ma_tag='price'))assertround(a.upper.mean(),2)==-0.05assertround(a.lower.mean(),2)==-0.03FiltersDerive a new sequence based on a original signal, e.g.# RMA, recursive moving averageassertlist(map(lambdax:dict(y=x),[1.0,2.0,3.0,4.0,5.0,6.0])>>rma(m=3))==[{'y':1.0,'rma':1.0},{'y':2.0,'rma':1.5},{'y':3.0,'rma':2.0},{'y':4.0,'rma':3.0},{'y':5.0,'rma':4.0},{'y':6.0,'rma':5.0}]# EWMA, exponentially weighted moving averageassertlist(list(map(lambdax:dict(y=x),[1.0,2.0,3.0,4.0,5.0,6.0]))>>ewma(input_tag='y'))==[{'y':1.0,'ewma':1.0},{'y':2.0,'ewma':1.1},{'y':3.0,'ewma':1.29},{'y':4.0,'ewma':1.561},{'y':5.0,'ewma':1.9049},{'y':6.0,'ewma':2.31441}]Financial engineeringCommon financial calculation QLets.Returns and cash flow streams: Absolute, single and multiple periods. Continous and discrete compounding.Options: Binomial lattice, single and multiple period binomial reactive option pricing. Black scholes model. Put-call parity pricing. Greeks.Hedging: Delta hedging. Stop price hedging.SeedingGenerators of financial sequences.Timeseries seedingRandom walk and brownian motions. Random uniform seedingStatsStatistical transformations.Uniform distributionAutocorrelation metricsInflection pointsquantlet-mlOperations related to machine learning transformations: feature engineering, interpolations, incremental and batch learning. Thisarticleis an example of [nowcasting][https://en.wikipedia.org/wiki/Nowcasting_(economics)] of trading signals using arobot traderusing incremental learning inquantlet-ml:(retrieve('XXXX',start='2013-01-01',end='2017-12-31')[['Adj.Close','Adj.Volume']]>>apply(adjust_columns)>>scale(['adj_price','adj_volume'],scalers=[price_scaler,volume_scaler])>>one_hot(["dow","dom","month"])>>window_shift(['adj_price','adj_volume'],5,separator='-')>>online_fit_predict(model,'predicted_adj_price',error_type='squared',response_variable_tag='adj_price',ignore_tags=['Date'])>>ewma('error',alpha=.2,output_tag='ewme')>>unscale(['adj_price','predicted_adj_price','adj_price-1','adj_price-2','adj_price-3','adj_price-4','adj_price-5'],scalers=[price_scaler]*7,index_column='Date'))It usesQLetsfor basic operations of window shifting, scaling, one-hot encoding, and online fit and predict in one step for streams.quantlet-dlExtension ofquantlet-mlto support deep-learning libraries and algorithms. CurrentlyKerasandTensorFlow.quantlet-scratchpadSupport for interactive use and visualization of resources inJupyternotebooks.Final NotesQuantLET is an open source project that I put together andhave been using for a very long timeto test ideas, hold discussions with fellow practitioners, and extend mydoctorate research in scientific crowdsand thetheory of enablers. The doctorate thesis was finished many years ago, in 2018, and isavailable onlineif you are curious and want to learn more about the subject.Bear in mind that the materialization of QuantLET was a result of volunteering my time in one of my many passions: investigations in technology, engineering, humans, and incentives that make humans do what they do. Nevertheless, unless I feel a compeling reason for a change, QuantLET is basically unsupported.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITYorFITNESS FOR A PARTICULAR PURPOSE.  See theGNU Affero General Public Licensefor more details. The license file is also shipped as part of the source code.Last, but not least, it is important to note that QuantLET was the entry point to a number of successful commercial frameworks, such asPlatformandHydra. If you have an idea on how to leverage these frameworks, or extend QuantLET, the power of large scale computing, AI, and crowds, feel free to get in touch.