diff --git a/_static/basic.css b/_static/basic.css index 6f408303..607b5f55 100644 --- a/_static/basic.css +++ b/_static/basic.css @@ -332,6 +332,11 @@ table.docutils { border-collapse: collapse; } +table.align-center { + margin-left: auto; + margin-right: auto; +} + table caption span.caption-number { font-style: italic; } diff --git a/_static/jquery.js b/_static/jquery.js index f6a6a99e..644d35e2 100644 --- a/_static/jquery.js +++ b/_static/jquery.js @@ -1,4 +1,4 @@ -/*! jQuery v3.1.0 | (c) jQuery Foundation | jquery.org/license */ -!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.1.0",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null!=a?a<0?this[a+this.length]:this[a]:f.call(this)},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"label"in b&&b.disabled===a||"form"in b&&b.disabled===a||"form"in b&&b.disabled===!1&&(b.isDisabled===a||b.isDisabled!==!a&&("label"in b||!ea(b))!==a)}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}},d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(_,aa),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=V.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(_,aa),$.test(j[0].type)&&qa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&sa(j),!a)return G.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,!b||$.test(a)&&qa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext,B=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,C=/^.[^:#\[\.,]*$/;function D(a,b,c){if(r.isFunction(b))return r.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return r.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(C.test(b))return r.filter(b,a,c);b=r.filter(b,a)}return r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType})}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(D(this,a||[],!1))},not:function(a){return this.pushStack(D(this,a||[],!0))},is:function(a){return!!D(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var E,F=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,G=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||E,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:F.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),B.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};G.prototype=r.fn,E=r(d);var H=/^(?:parents|prev(?:Until|All))/,I={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function J(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return J(a,"nextSibling")},prev:function(a){return J(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return a.contentDocument||r.merge([],a.childNodes)}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(I[a]||r.uniqueSort(e),H.test(a)&&e.reverse()),this.pushStack(e)}});var K=/\S+/g;function L(a){var b={};return r.each(a.match(K)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?L(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function M(a){return a}function N(a){throw a}function O(a,b,c){var d;try{a&&r.isFunction(d=a.promise)?d.call(a).done(b).fail(c):a&&r.isFunction(d=a.then)?d.call(a,b,c):b.call(void 0,a)}catch(a){c.call(void 0,a)}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b=f&&(d!==N&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:M,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:M)),c[2][3].add(g(0,a,r.isFunction(d)?d:N))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(O(a,g.done(h(c)).resolve,g.reject),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)O(e[c],h(c),g.reject);return g.promise()}});var P=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&P.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var Q=r.Deferred();r.fn.ready=function(a){return Q.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,holdReady:function(a){a?r.readyWait++:r.ready(!0)},ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||Q.resolveWith(d,[r]))}}),r.ready.then=Q.then;function R(){d.removeEventListener("DOMContentLoaded",R),a.removeEventListener("load",R),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",R),a.addEventListener("load",R));var S=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)S(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0, -r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h1,null,!0)},removeData:function(a){return this.each(function(){W.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=V.get(a,b),c&&(!d||r.isArray(c)?d=V.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return V.get(a,c)||V.access(a,c,{empty:r.Callbacks("once memory").add(function(){V.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length\x20\t\r\n\f]+)/i,ja=/^$|\/(?:java|ecma)script/i,ka={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ka.optgroup=ka.option,ka.tbody=ka.tfoot=ka.colgroup=ka.caption=ka.thead,ka.th=ka.td;function la(a,b){var c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&r.nodeName(a,b)?r.merge([a],c):c}function ma(a,b){for(var c=0,d=a.length;c-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=la(l.appendChild(f),"script"),j&&ma(g),c){k=0;while(f=g[k++])ja.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var pa=d.documentElement,qa=/^key/,ra=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,sa=/^([^.]*)(?:\.(.+)|)/;function ta(){return!0}function ua(){return!1}function va(){try{return d.activeElement}catch(a){}}function wa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)wa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=ua;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(pa,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(K)||[""],j=b.length;while(j--)h=sa.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.hasData(a)&&V.get(a);if(q&&(i=q.events)){b=(b||"").match(K)||[""],j=b.length;while(j--)if(h=sa.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&V.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(V.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c-1:r.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h\x20\t\r\n\f]*)[^>]*)\/>/gi,ya=/\s*$/g;function Ca(a,b){return r.nodeName(a,"table")&&r.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a:a}function Da(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Ea(a){var b=Aa.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Fa(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(V.hasData(a)&&(f=V.access(a),g=V.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c1&&"string"==typeof q&&!o.checkClone&&za.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ha(f,b,c,d)});if(m&&(e=oa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(la(e,"script"),Da),i=h.length;l")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=la(h),f=la(a),d=0,e=f.length;d0&&ma(g,!i&&la(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(T(c)){if(b=c[V.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[V.expando]=void 0}c[W.expando]&&(c[W.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ia(this,a,!0)},remove:function(a){return Ia(this,a)},text:function(a){return S(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ha(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ca(this,a);b.appendChild(a)}})},prepend:function(){return Ha(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ca(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ha(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ha(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(la(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return S(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!ya.test(a)&&!ka[(ia.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c1)}});function Xa(a,b,c,d,e){return new Xa.prototype.init(a,b,c,d,e)}r.Tween=Xa,Xa.prototype={constructor:Xa,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=Xa.propHooks[this.prop];return a&&a.get?a.get(this):Xa.propHooks._default.get(this)},run:function(a){var b,c=Xa.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Xa.propHooks._default.set(this),this}},Xa.prototype.init.prototype=Xa.prototype,Xa.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},Xa.propHooks.scrollTop=Xa.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=Xa.prototype.init,r.fx.step={};var Ya,Za,$a=/^(?:toggle|show|hide)$/,_a=/queueHooks$/;function ab(){Za&&(a.requestAnimationFrame(ab),r.fx.tick())}function bb(){return a.setTimeout(function(){Ya=void 0}),Ya=r.now()}function cb(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=aa[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function db(a,b,c){for(var d,e=(gb.tweeners[b]||[]).concat(gb.tweeners["*"]),f=0,g=e.length;f1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?hb:void 0)),void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&r.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(K); -if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),hb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=ib[b]||r.find.attr;ib[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=ib[g],ib[g]=e,e=null!=c(a,b,d)?g:null,ib[g]=f),e}});var jb=/^(?:input|select|textarea|button)$/i,kb=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return S(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):jb.test(a.nodeName)||kb.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});var lb=/[\t\r\n\f]/g;function mb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,mb(this)))});if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=mb(c),d=1===c.nodeType&&(" "+e+" ").replace(lb," ")){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=r.trim(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,mb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=mb(c),d=1===c.nodeType&&(" "+e+" ").replace(lb," ")){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=r.trim(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,mb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(K)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=mb(this),b&&V.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":V.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+mb(c)+" ").replace(lb," ").indexOf(b)>-1)return!0;return!1}});var nb=/\r/g,ob=/[\x20\t\r\n\f]+/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":r.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(nb,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:r.trim(r.text(a)).replace(ob," ")}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type,g=f?null:[],h=f?e+1:d.length,i=e<0?h:f?e:0;i-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(r.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var pb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!pb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,pb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(V.get(h,"events")||{})[b.type]&&V.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&T(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!T(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=V.access(d,b);e||d.addEventListener(a,c,!0),V.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=V.access(d,b)-1;e?V.access(d,b,e):(d.removeEventListener(a,c,!0),V.remove(d,b))}}});var qb=a.location,rb=r.now(),sb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var tb=/\[\]$/,ub=/\r?\n/g,vb=/^(?:submit|button|image|reset|file)$/i,wb=/^(?:input|select|textarea|keygen)/i;function xb(a,b,c,d){var e;if(r.isArray(b))r.each(b,function(b,e){c||tb.test(a)?d(a,e):xb(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)xb(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(r.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)xb(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&wb.test(this.nodeName)&&!vb.test(a)&&(this.checked||!ha.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:r.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(ub,"\r\n")}}):{name:b.name,value:c.replace(ub,"\r\n")}}).get()}});var yb=/%20/g,zb=/#.*$/,Ab=/([?&])_=[^&]*/,Bb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Cb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Db=/^(?:GET|HEAD)$/,Eb=/^\/\//,Fb={},Gb={},Hb="*/".concat("*"),Ib=d.createElement("a");Ib.href=qb.href;function Jb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(K)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Kb(a,b,c,d){var e={},f=a===Gb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Lb(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Mb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Nb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:qb.href,type:"GET",isLocal:Cb.test(qb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Hb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Lb(Lb(a,r.ajaxSettings),b):Lb(r.ajaxSettings,a)},ajaxPrefilter:Jb(Fb),ajaxTransport:Jb(Gb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Bb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||qb.href)+"").replace(Eb,qb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(K)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Ib.protocol+"//"+Ib.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Kb(Fb,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Db.test(o.type),f=o.url.replace(zb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(yb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(sb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Ab,""),n=(sb.test(f)?"&":"?")+"_="+rb++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Hb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Kb(Gb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Mb(o,y,d)),v=Nb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Ob={0:200,1223:204},Pb=r.ajaxSettings.xhr();o.cors=!!Pb&&"withCredentials"in Pb,o.ajax=Pb=!!Pb,r.ajaxTransport(function(b){var c,d;if(o.cors||Pb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Ob[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r(" - - - - - - - - + + + + + + + + + API Reference — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+ +
+
+

API Reference

Running a Backtest

+
+
+catalyst.run_algorithm(...)[source]
+

Run a trading algorithm.

+ +++ + + + + + +
Parameters:

start : datetime

+
+

The start date of the backtest.

+
+

end : datetime

+
+

The end date of the backtest..

+
+

initialize : callable[context -> None]

+
+

The initialize function to use for the algorithm. This is called once +at the very begining of the backtest and should be used to set up +any state needed by the algorithm.

+
+

capital_base : float

+
+

The starting capital for the backtest.

+
+

handle_data : callable[(context, BarData) -> None], optional

+
+

The handle_data function to use for the algorithm. This is called +every minute when data_frequency == 'minute' or every day +when data_frequency == 'daily'.

+
+

before_trading_start : callable[(context, BarData) -> None], optional

+
+

The before_trading_start function for the algorithm. This is called +once before each trading day (after initialize on the first day).

+
+

analyze : callable[(context, pd.DataFrame) -> None], optional

+
+

The analyze function to use for the algorithm. This function is called +once at the end of the backtest and is passed the context and the +performance data.

+
+

data_frequency : {‘daily’, ‘minute’}, optional

+
+

The data frequency to run the algorithm at.

+
+

data : pd.DataFrame, pd.Panel, or DataPortal, optional

+
+

The ohlcv data to run the backtest with. +This argument is mutually exclusive with: +bundle +bundle_timestamp

+
+

bundle : str, optional

+
+

The name of the data bundle to use to load the data to run the backtest +with. This defaults to ‘quantopian-quandl’. +This argument is mutually exclusive with data.

+
+

bundle_timestamp : datetime, optional

+
+

The datetime to lookup the bundle data for. This defaults to the +current time. +This argument is mutually exclusive with data.

+
+

default_extension : bool, optional

+
+

Should the default catalyst extension be loaded. This is found at +$CATALYST_ROOT/extension.py

+
+

extensions : iterable[str], optional

+
+

The names of any other extensions to load. Each element may either be +a dotted module path like a.b.c or a path to a python file ending +in .py like a/b/c.py.

+
+

strict_extensions : bool, optional

+
+

Should the run fail if any extensions fail to load. If this is false, +a warning will be raised instead.

+
+

environ : mapping[str -> str], optional

+
+

The os environment to use. Many extensions use this to get parameters. +This defaults to os.environ.

+
+

live : bool, optional

+
+

Execute algorithm in live trading mode.

+
+
Returns:

perf : pd.DataFrame

+
+

The daily performance of the algorithm.

+
+
+
+

See also

+
+
catalyst.data.bundles.bundles
+
The available data bundles.
+
+
+
+

Algorithm API

@@ -53,32 +452,1177 @@ currently-executing TradingAlgorithm instance.

Data Object

+
+
+class catalyst.protocol.BarData
+

Provides methods to access spot value or history windows of price data. +Also provides some utility methods to determine if an asset is alive, +has recent trade data, etc.

+

This is what is passed as data to the handle_data function.

+ +++ + + + +
Parameters:

data_portal : DataPortal

+
+

Provider for bar pricing data.

+
+

simulation_dt_func : callable

+
+

Function which returns the current simulation time. +This is usually bound to a method of TradingSimulation.

+
+

data_frequency : {‘minute’, ‘daily’}

+
+

The frequency of the bar data; i.e. whether the data is +daily or minute bars

+
+

restrictions : catalyst.finance.asset_restrictions.Restrictions

+
+

Object that combines and returns restricted list information from +multiple sources

+
+

universe_func : callable, optional

+
+

Function which returns the current ‘universe’. This is for +backwards compatibility with older API concepts.

+
+
+
+

Scheduling Functions

+
+
+catalyst.api.schedule_function(*args, **kwargs)
+

Schedules a function to be called according to some timed rules.

+ +++ + + + +
Parameters:

func : callable[(context, data) -> None]

+
+

The function to execute when the rule is triggered.

+
+

date_rule : EventRule, optional

+
+

The rule for the dates to execute this function.

+
+

time_rule : EventRule, optional

+
+

The rule for the times to execute this function.

+
+

half_days : bool, optional

+
+

Should this rule fire on half days?

+
+

calendar : Sentinel, optional

+
+

Calendar used to reconcile date and time rules.

+
+
+ +
+ +
+
+class catalyst.api.date_rules[source]
+
+
+every_day
+

alias of Always

+
+ +
+
+static month_end(days_offset=0)[source]
+
+ +
+
+static month_start(days_offset=0)[source]
+
+ +
+
+static week_end(days_offset=0)[source]
+
+ +
+
+static week_start(days_offset=0)[source]
+
+ +
+ +
+
+class catalyst.api.time_rules[source]
+
+
+every_minute
+

alias of Always

+
+ +
+
+market_close
+

alias of BeforeClose

+
+ +
+
+market_open
+

alias of AfterOpen

+
+ +
+

Orders

+
+
+catalyst.api.order(*args, **kwargs)
+

Place an order.

+ +++ + + + + + +
Parameters:

asset : Asset

+
+

The asset that this order is for.

+
+

amount : int

+
+

The amount of shares to order. If amount is positive, this is +the number of shares to buy or cover. If amount is negative, +this is the number of shares to sell or short.

+
+

limit_price : float, optional

+
+

The limit price for the order.

+
+

stop_price : float, optional

+
+

The stop price for the order.

+
+

style : ExecutionStyle, optional

+
+

The execution style for the order.

+
+
Returns:

order_id : str or None

+
+

The unique identifier for this order, or None if no order was +placed.

+
+
+ +

Notes

+

The limit_price and stop_price arguments provide shorthands for +passing common execution styles. Passing limit_price=N is +equivalent to style=LimitOrder(N). Similarly, passing +stop_price=M is equivalent to style=StopOrder(M), and passing +limit_price=N and stop_price=M is equivalent to +style=StopLimitOrder(N, M). It is an error to pass both a style +and limit_price or stop_price.

+
+ +
+
+catalyst.api.order_value(*args, **kwargs)
+

Place an order by desired value rather than desired number of +shares.

+ +++ + + + + + +
Parameters:

asset : Asset

+
+

The asset that this order is for.

+
+

value : float

+
+

If the requested asset exists, the requested value is +divided by its price to imply the number of shares to transact. +If the Asset being ordered is a Future, the ‘value’ calculated +is actually the exposure, as Futures have no ‘value’.

+

value > 0 :: Buy/Cover +value < 0 :: Sell/Short

+
+

limit_price : float, optional

+
+

The limit price for the order.

+
+

stop_price : float, optional

+
+

The stop price for the order.

+
+

style : ExecutionStyle

+
+

The execution style for the order.

+
+
Returns:

order_id : str

+
+

The unique identifier for this order.

+
+
+ +

Notes

+

See catalyst.api.order() for more information about +limit_price, stop_price, and style

+
+ +
+
+catalyst.api.order_percent(*args, **kwargs)
+

Place an order in the specified asset corresponding to the given +percent of the current portfolio value.

+ +++ + + + + + +
Parameters:

asset : Asset

+
+

The asset that this order is for.

+
+

percent : float

+
+

The percentage of the porfolio value to allocate to asset. +This is specified as a decimal, for example: 0.50 means 50%.

+
+

limit_price : float, optional

+
+

The limit price for the order.

+
+

stop_price : float, optional

+
+

The stop price for the order.

+
+

style : ExecutionStyle

+
+

The execution style for the order.

+
+
Returns:

order_id : str

+
+

The unique identifier for this order.

+
+
+ +

Notes

+

See catalyst.api.order() for more information about +limit_price, stop_price, and style

+
+ +
+
+catalyst.api.order_target(*args, **kwargs)
+

Place an order to adjust a position to a target number of shares. If +the position doesn’t already exist, this is equivalent to placing a new +order. If the position does exist, this is equivalent to placing an +order for the difference between the target number of shares and the +current number of shares.

+ +++ + + + + + +
Parameters:

asset : Asset

+
+

The asset that this order is for.

+
+

target : int

+
+

The desired number of shares of asset.

+
+

limit_price : float, optional

+
+

The limit price for the order.

+
+

stop_price : float, optional

+
+

The stop price for the order.

+
+

style : ExecutionStyle

+
+

The execution style for the order.

+
+
Returns:

order_id : str

+
+

The unique identifier for this order.

+
+
+ +

Notes

+

order_target does not take into account any open orders. For +example:

+
order_target(sid(0), 10)
+order_target(sid(0), 10)
+
+
+

This code will result in 20 shares of sid(0) because the first +call to order_target will not have been filled when the second +order_target call is made.

+

See catalyst.api.order() for more information about +limit_price, stop_price, and style

+
+ +
+
+catalyst.api.order_target_value(*args, **kwargs)
+

Place an order to adjust a position to a target value. If +the position doesn’t already exist, this is equivalent to placing a new +order. If the position does exist, this is equivalent to placing an +order for the difference between the target value and the +current value. +If the Asset being ordered is a Future, the ‘target value’ calculated +is actually the target exposure, as Futures have no ‘value’.

+ +++ + + + + + +
Parameters:

asset : Asset

+
+

The asset that this order is for.

+
+

target : float

+
+

The desired total value of asset.

+
+

limit_price : float, optional

+
+

The limit price for the order.

+
+

stop_price : float, optional

+
+

The stop price for the order.

+
+

style : ExecutionStyle

+
+

The execution style for the order.

+
+
Returns:

order_id : str

+
+

The unique identifier for this order.

+
+
+ +

Notes

+

order_target_value does not take into account any open orders. For +example:

+
order_target_value(sid(0), 10)
+order_target_value(sid(0), 10)
+
+
+

This code will result in 20 dollars of sid(0) because the first +call to order_target_value will not have been filled when the +second order_target_value call is made.

+

See catalyst.api.order() for more information about +limit_price, stop_price, and style

+
+ +
+
+catalyst.api.order_target_percent(*args, **kwargs)
+

Place an order to adjust a position to a target percent of the +current portfolio value. If the position doesn’t already exist, this is +equivalent to placing a new order. If the position does exist, this is +equivalent to placing an order for the difference between the target +percent and the current percent.

+ +++ + + + + + +
Parameters:

asset : Asset

+
+

The asset that this order is for.

+
+

target : float

+
+

The desired percentage of the porfolio value to allocate to +asset. This is specified as a decimal, for example: +0.50 means 50%.

+
+

limit_price : float, optional

+
+

The limit price for the order.

+
+

stop_price : float, optional

+
+

The stop price for the order.

+
+

style : ExecutionStyle

+
+

The execution style for the order.

+
+
Returns:

order_id : str

+
+

The unique identifier for this order.

+
+
+ +

Notes

+

order_target_value does not take into account any open orders. For +example:

+
order_target_percent(sid(0), 10)
+order_target_percent(sid(0), 10)
+
+
+

This code will result in 20% of the portfolio being allocated to sid(0) +because the first call to order_target_percent will not have been +filled when the second order_target_percent call is made.

+

See catalyst.api.order() for more information about +limit_price, stop_price, and style

+
+ +
+
+class catalyst.finance.execution.ExecutionStyle[source]
+

Abstract base class representing a modification to a standard order.

+
+
+exchange
+

The exchange to which this order should be routed.

+
+ +
+
+get_limit_price(is_buy)[source]
+

Get the limit price for this order. +Returns either None or a numerical value >= 0.

+
+ +
+
+get_stop_price(is_buy)[source]
+

Get the stop price for this order. +Returns either None or a numerical value >= 0.

+
+ +
+ +
+
+class catalyst.finance.execution.MarketOrder(exchange=None)[source]
+

Class encapsulating an order to be placed at the current market price.

+
+ +
+
+class catalyst.finance.execution.LimitOrder(limit_price, exchange=None)[source]
+

Execution style representing an order to be executed at a price equal to or +better than a specified limit price.

+
+ +
+
+class catalyst.finance.execution.StopOrder(stop_price, exchange=None)[source]
+

Execution style representing an order to be placed once the market price +reaches a specified stop price.

+
+ +
+
+class catalyst.finance.execution.StopLimitOrder(limit_price, stop_price, exchange=None)[source]
+

Execution style representing a limit order to be placed with a specified +limit price once the market reaches a specified stop price.

+
+ +
+
+catalyst.api.get_order(*args, **kwargs)
+

Lookup an order based on the order id returned from one of the +order functions.

+ +++ + + + + + +
Parameters:

order_id : str

+
+

The unique identifier for the order.

+
+
Returns:

order : Order

+
+

The order object.

+
+

execution_price: float

+
+

The execution price per share of the order

+
+
+
+ +
+
+catalyst.api.get_open_orders(*args, **kwargs)
+

Retrieve all of the current open orders.

+ +++ + + + + + +
Parameters:

asset : Asset

+
+

If passed and not None, return only the open orders for the given +asset instead of all open orders.

+
+
Returns:

open_orders : dict[list[Order]] or list[Order]

+
+

If no asset is passed this will return a dict mapping Assets +to a list containing all the open orders for the asset. +If an asset is passed then this will return a list of the open +orders for this asset.

+
+
+
+ +
+
+catalyst.api.cancel_order(*args, **kwargs)
+

Cancel an open order.

+ +++ + + + +
Parameters:

order_param : str or Order

+
+

The order_id or order object to cancel.

+
+

exchange_name: name of exchange from

+
+

which you want to cancel the order

+
+

symbol:

+

params:

+
+
+

Order Cancellation Policies

+
+
+catalyst.api.set_cancel_policy(*args, **kwargs)
+

Sets the order cancellation policy for the simulation.

+ +++ + + + +
Parameters:

cancel_policy : CancelPolicy

+
+

The cancellation policy to use.

+
+
+ +
+ +
+
+class catalyst.finance.cancel_policy.CancelPolicy[source]
+

Abstract cancellation policy interface.

+
+
+should_cancel(event)[source]
+

Should all open orders be cancelled?

+ +++ + + + + + +
Parameters:

event : enum-value

+
+
+
An event type, one of:
+
    +
  • catalyst.gens.sim_engine.BAR
  • +
  • catalyst.gens.sim_engine.DAY_START
  • +
  • catalyst.gens.sim_engine.DAY_END
  • +
  • catalyst.gens.sim_engine.MINUTE_END
  • +
+
+
+
+
Returns:

should_cancel : bool

+
+

Should all open orders be cancelled?

+
+
+
+ +
+ +
+
+catalyst.api.EODCancel(warn_on_cancel=True)[source]
+

This policy cancels open orders at the end of the day. For now, +Zipline will only apply this policy to minutely simulations.

+ +++ + + + +
Parameters:

warn_on_cancel : bool, optional

+
+

Should a warning be raised if this causes an order to be cancelled?

+
+
+
+ +
+
+catalyst.api.NeverCancel()[source]
+

Orders are never automatically canceled.

+
+

Assets

+
+
+catalyst.api.symbol(*args, **kwargs)
+

Lookup an Equity by its ticker symbol.

+ +++ + + + + + + + +
Parameters:

symbol_str : str

+
+

The ticker symbol for the equity to lookup.

+
+

exchange_name: str

+
+

The name of the exchange containing the symbol

+
+
Returns:

equity : Equity

+
+

The equity that held the ticker symbol on the current +symbol lookup date.

+
+
Raises:

SymbolNotFound

+
+

Raised when the symbols was not held on the current lookup date.

+
+
+ +
+ +
+
+catalyst.api.symbols(*args, **kwargs)
+

Lookup multuple Equities as a list.

+ +++ + + + + + + + +
Parameters:

*args : iterable[str]

+
+

The ticker symbols to lookup.

+
+
Returns:

equities : list[Equity]

+
+

The equities that held the given ticker symbols on the current +symbol lookup date.

+
+
Raises:

SymbolNotFound

+
+

Raised when one of the symbols was not held on the current +lookup date.

+
+
+ +
+ +
+
+catalyst.api.set_symbol_lookup_date(*args, **kwargs)
+

Set the date for which symbols will be resolved to their assets +(symbols may map to different firms or underlying assets at +different times)

+ +++ + + + +
Parameters:

dt : datetime

+
+

The new symbol lookup date.

+
+
+
+ +
+
+catalyst.api.sid(*args, **kwargs)
+

Lookup an Asset by its unique asset identifier.

+ +++ + + + + + + + +
Parameters:

sid : int

+
+

The unique integer that identifies an asset.

+
+
Returns:

asset : Asset

+
+

The asset with the given sid.

+
+
Raises:

SidsNotFound

+
+

When a requested sid does not map to any asset.

+
+
+
+

Trading Controls

zipline provides trading controls to help ensure that the algorithm is performing as expected. The functions help protect the algorithm from certian bugs that could cause undesirable behavior when trading with real money.

+
+
+catalyst.api.set_do_not_order_list(*args, **kwargs)
+

Set a restriction on which assets can be ordered.

+ +++ + + + +
Parameters:

restricted_list : container[Asset], SecurityList

+
+

The assets that cannot be ordered.

+
+
+
+ +
+
+catalyst.api.set_long_only(*args, **kwargs)
+

Set a rule specifying that this algorithm cannot take short +positions.

+
+ +
+
+catalyst.api.set_max_leverage(*args, **kwargs)
+

Set a limit on the maximum leverage of the algorithm.

+ +++ + + + +
Parameters:

max_leverage : float

+
+

The maximum leverage for the algorithm. If not provided there will +be no maximum.

+
+
+
+ +
+
+catalyst.api.set_max_order_count(*args, **kwargs)
+

Set a limit on the number of orders that can be placed in a single +day.

+ +++ + + + +
Parameters:

max_count : int

+
+

The maximum number of orders that can be placed on any single day.

+
+
+
+ +
+
+catalyst.api.set_max_order_size(*args, **kwargs)
+

Set a limit on the number of shares and/or dollar value of any single +order placed for sid. Limits are treated as absolute values and are +enforced at the time that the algo attempts to place an order for sid.

+

If an algorithm attempts to place an order that would result in +exceeding one of these limits, raise a TradingControlException.

+ +++ + + + +
Parameters:

asset : Asset, optional

+
+

If provided, this sets the guard only on positions in the given +asset.

+
+

max_shares : int, optional

+
+

The maximum number of shares that can be ordered at one time.

+
+

max_notional : float, optional

+
+

The maximum value that can be ordered at one time.

+
+
+
+ +
+
+catalyst.api.set_max_position_size(*args, **kwargs)
+

Set a limit on the number of shares and/or dollar value held for the +given sid. Limits are treated as absolute values and are enforced at +the time that the algo attempts to place an order for sid. This means +that it’s possible to end up with more than the max number of shares +due to splits/dividends, and more than the max notional due to price +improvement.

+

If an algorithm attempts to place an order that would result in +increasing the absolute value of shares/dollar value exceeding one of +these limits, raise a TradingControlException.

+ +++ + + + +
Parameters:

asset : Asset, optional

+
+

If provided, this sets the guard only on positions in the given +asset.

+
+

max_shares : int, optional

+
+

The maximum number of shares to hold for an asset.

+
+

max_notional : float, optional

+
+

The maximum value to hold for an asset.

+
+
+
+

Simulation Parameters

+
+
+catalyst.api.set_benchmark(*args, **kwargs)
+

Set the benchmark asset.

+ +++ + + + +
Parameters:

benchmark : Asset

+
+

The asset to set as the new benchmark.

+
+
+

Notes

+

Any dividends payed out for that new benchmark asset will be +automatically reinvested.

+
+

Commission Models

+
+
+catalyst.api.set_commission(*args, **kwargs)
+
+ +
+
+class catalyst.finance.commission.CommissionModel[source]
+

Abstract commission model interface.

+

Commission models are responsible for accepting order/transaction pairs and +calculating how much commission should be charged to an algorithm’s account +on each transaction.

+
+
+calculate(order, transaction)[source]
+

Calculate the amount of commission to charge on order as a result +of transaction.

+ +++ + + + + + +
Parameters:

order : catalyst.finance.order.Order

+
+

The order being processed.

+

The commission field of order is a float indicating the +amount of commission already charged on this order.

+
+

transaction : catalyst.finance.transaction.Transaction

+
+

The transaction being processed. A single order may generate +multiple transactions if there isn’t enough volume in a given bar +to fill the full amount requested in the order.

+
+
Returns:

amount_charged : float

+
+

The additional commission, in dollars, that we should attribute to +this order.

+
+
+
+ +
+ +
+
+class catalyst.finance.commission.PerShare(cost=0.0075, min_trade_cost=1.0)[source]
+

Calculates a commission for a transaction based on a per share cost with +an optional minimum cost per trade.

+ +++ + + + +
Parameters:

cost : float, optional

+
+

The amount of commissions paid per share traded.

+
+

min_trade_cost : float, optional

+
+

The minimum amount of commissions paid per trade.

+
+
+
+ +
+
+class catalyst.finance.commission.PerTrade(cost=1.0)[source]
+

Calculates a commission for a transaction based on a per trade cost.

+ +++ + + + +
Parameters:

cost : float, optional

+
+

The flat amount of commissions paid per equity trade.

+
+
+
+ +
+
+class catalyst.finance.commission.PerDollar(cost=0.0015)[source]
+

Calculates a commission for a transaction based on a per dollar cost.

+ +++ + + + +
Parameters:

cost : float

+
+

The flat amount of commissions paid per dollar of equities traded.

+
+
+
+

Slippage Models

+
+
+catalyst.api.set_slippage(*args, **kwargs)
+
+ +
+
+class catalyst.finance.slippage.SlippageModel[source]
+

Abstract interface for defining a slippage model.

+
+
+process_order(data, order)[source]
+

Process how orders get filled.

+ +++ + + + + + +
Parameters:

data : BarData

+
+

The data for the given bar.

+
+

order : Order

+
+

The order to simulate.

+
+
Returns:

execution_price : float

+
+

The price to execute the trade at.

+
+

execution_volume : int

+
+

The number of shares that could be filled. This may not be all +the shares ordered in which case the order will be filled over +multiple bars.

+
+
+
+ +
+ +
+
+class catalyst.finance.slippage.FixedSlippage(spread=0.0)[source]
+

Model slippage as a fixed spread.

+ +++ + + + +
Parameters:

spread : float, optional

+
+

spread / 2 will be added to buys and subtracted from sells.

+
+
+
+ +
+
+class catalyst.finance.slippage.VolumeShareSlippage(volume_limit=0.025, price_impact=0.1)[source]
+

Model slippage as a function of the volume of contracts traded.

+
+
@@ -87,13 +1631,984 @@ bugs that could cause undesirable behavior when trading with real money.

Miscellaneous

+
+
+catalyst.api.record(*args, **kwargs)
+

Track and record values each day.

+ +++ + + + +
Parameters:

**kwargs

+
+

The names and values to record.

+
+
+

Notes

+

These values will appear in the performance packets and the performance +dataframe passed to analyze and returned from +run_algorithm().

+
+ +
+
+catalyst.api.get_environment(*args, **kwargs)
+

Query the execution environment.

+ +++ + + + + + + + +
Parameters:

field : {‘platform’, ‘arena’, ‘data_frequency’,

+
+
+

‘start’, ‘end’, ‘capital_base’, ‘platform’, ‘*’}

+
+
+
The field to query. The options have the following meanings:
+
+
arena : str
+

The arena from the simulation parameters. This will normally +be backtest but some systems may use this distinguish +live trading from backtesting.

+
+
data_frequency : {‘daily’, ‘minute’}
+

data_frequency tells the algorithm if it is running with +daily or minute mode.

+
+
start : datetime
+

The start date for the simulation.

+
+
end : datetime
+

The end date for the simulation.

+
+
capital_base : float
+

The starting capital for the simulation.

+
+
platform : str
+

The platform that the code is running on. By default this +will be the string ‘catalyst’. This can allow algorithms to +know if they are running on the Quantopian platform instead.

+
+
\* : dict[str -> any]
+

Returns all of the fields in a dictionary.

+
+
+
+
+
+
Returns:

val : any

+
+

The value for the field queried. See above for more information.

+
+
Raises:

ValueError

+
+

Raised when field is not a valid option.

+
+
+
+ +
+
+catalyst.api.fetch_csv(*args, **kwargs)
+

Fetch a csv from a remote url and register the data so that it is +queryable from the data object.

+ +++ + + + + + +
Parameters:

url : str

+
+

The url of the csv file to load.

+
+

pre_func : callable[pd.DataFrame -> pd.DataFrame], optional

+
+

A callback to allow preprocessing the raw data returned from +fetch_csv before dates are paresed or symbols are mapped.

+
+

post_func : callable[pd.DataFrame -> pd.DataFrame], optional

+
+

A callback to allow postprocessing of the data after dates and +symbols have been mapped.

+
+

date_column : str, optional

+
+

The name of the column in the preprocessed dataframe containing +datetime information to map the data.

+
+

date_format : str, optional

+
+

The format of the dates in the date_column. If not provided +fetch_csv will attempt to infer the format. For information +about the format of this string, see pandas.read_csv().

+
+

timezone : tzinfo or str, optional

+
+

The timezone for the datetime in the date_column.

+
+

symbol : str, optional

+
+

If the data is about a new asset or index then this string will +be the name used to identify the values in data. For example, +one may use fetch_csv to load data for VIX, then this field +could be the string 'VIX'.

+
+

mask : bool, optional

+
+

Drop any rows which cannot be symbol mapped.

+
+

symbol_column : str

+
+

If the data is attaching some new attribute to each asset then this +argument is the name of the column in the preprocessed dataframe +containing the symbols. This will be used along with the date +information to map the sids in the asset finder.

+
+

**kwargs

+
+

Forwarded to pandas.read_csv().

+
+
Returns:

csv_data_source : catalyst.sources.requests_csv.PandasRequestsCSV

+
+

A requests source that will pull data from the url specified.

+
+
+
+

Asset Metadata

+
+
+class catalyst.assets.Asset
+
+
+first_traded
+

first_traded: object

+
+ +
+
+from_dict(type cls, dict_)
+

Build an Asset instance from a dict.

+
+ +
+
+is_alive_for_session(self, session_label)
+

Returns whether the asset is alive at the given dt.

+ +++ + + + + + +
Parameters:

session_label: pd.Timestamp

+
+

The desired session label to check. (midnight UTC)

+
+
Returns:

boolean: whether the asset is alive at the given dt.

+
+
+ +
+
+is_exchange_open(self, dt_minute)
+
+++ + + + + + +
Parameters:

dt_minute: pd.Timestamp (UTC, tz-aware)

+
+

The minute to check.

+
+
Returns:

boolean: whether the asset’s exchange is open at the given minute.

+
+
+ +
+
+to_dict(self)
+

Convert to a python dict.

+
+ +
+ +
+
+class catalyst.assets.AssetConvertible[source]
+

ABC for types that are convertible to integer-representations of +Assets.

+

Includes Asset, six.string_types, and Integral

+
+

Trading Calendar API

+
+
+catalyst.utils.calendars.get_calendar(self, name)
+

Retrieves an instance of an TradingCalendar whose name is given.

+ +++ + + + + + +
Parameters:

name : str

+
+

The name of the TradingCalendar to be retrieved.

+
+
Returns:

calendar : catalyst.utils.calendars.TradingCalendar

+
+

The desired calendar.

+
+
+
+ +
+
+class catalyst.utils.calendars.TradingCalendar(start=Timestamp('1990-01-01 00:00:00+0000', tz='UTC'), end=Timestamp('2019-03-29 17:27:04.135959+0000', tz='UTC'))[source]
+

An TradingCalendar represents the timing information of a single market +exchange.

+

The timing information is made up of two parts: sessions, and opens/closes.

+

A session represents a contiguous set of minutes, and has a label that is +midnight UTC. It is important to note that a session label should not be +considered a specific point in time, and that midnight UTC is just being +used for convenience.

+

For each session, we store the open and close time in UTC time.

+
+
+is_open_on_minute(dt)[source]
+

Given a dt, return whether this exchange is open at the given dt.

+ +++ + + + + + +
Parameters:

dt: pd.Timestamp

+
+

The dt for which to check if this exchange is open.

+
+
Returns:

bool

+
+

Whether the exchange is open on this dt.

+
+
+
+ +
+
+is_session(dt)[source]
+

Given a dt, returns whether it’s a valid session label.

+ +++ + + + + + +
Parameters:

dt: pd.Timestamp

+
+

The dt that is being tested.

+
+
Returns:

bool

+
+

Whether the given dt is a valid session label.

+
+
+
+ +
+
+minute_index_to_session_labels(index)[source]
+

Given a sorted DatetimeIndex of market minutes, return a +DatetimeIndex of the corresponding session labels.

+ +++ + + + + + +
Parameters:

index: pd.DatetimeIndex or pd.Series

+
+

The ordered list of market minutes we want session labels for.

+
+
Returns:

pd.DatetimeIndex (UTC)

+
+

The list of session labels corresponding to the given minutes.

+
+
+
+ +
+
+minute_to_session_label(dt, direction='next')[source]
+

Given a minute, get the label of its containing session.

+ +++ + + + + + +
Parameters:

dt : pd.Timestamp or nanosecond offset

+
+

The dt for which to get the containing session.

+
+

direction: str

+
+

“next” (default) means that if the given dt is not part of a +session, return the label of the next session.

+

“previous” means that if the given dt is not part of a session, +return the label of the previous session.

+

“none” means that a KeyError will be raised if the given +dt is not part of a session.

+
+
Returns:

pd.Timestamp (midnight UTC)

+
+

The label of the containing session.

+
+
+
+ +
+
+minutes_count_for_sessions_in_range(start_session, end_session)[source]
+
+++ + + + + + +
Parameters:

start_session: pd.Timestamp

+
+

The first session.

+
+

end_session: pd.Timestamp

+
+

The last session.

+
+
Returns:

int: The total number of minutes for the contiguous chunk of sessions.

+
+

between start_session and end_session, inclusive.

+
+
+
+ +
+
+minutes_for_session(session_label)[source]
+

Given a session label, return the minutes for that session.

+ +++ + + + + + +
Parameters:

session_label: pd.Timestamp (midnight UTC)

+
+

A session label whose session’s minutes are desired.

+
+
Returns:

pd.DateTimeIndex

+
+

All the minutes for the given session.

+
+
+
+ +
+
+minutes_for_sessions_in_range(start_session_label, end_session_label)[source]
+

Returns all the minutes for all the sessions from the given start +session label to the given end session label, inclusive.

+ +++ + + + + + +
Parameters:

start_session_label: pd.Timestamp

+
+

The label of the first session in the range.

+
+

end_session_label: pd.Timestamp

+
+

The label of the last session in the range.

+
+
Returns:

pd.DatetimeIndex

+
+

The minutes in the desired range.

+
+
+
+ +
+
+minutes_in_range(start_minute, end_minute)[source]
+

Given start and end minutes, return all the calendar minutes +in that range, inclusive.

+

Given minutes don’t need to be calendar minutes.

+ +++ + + + + + +
Parameters:

start_minute: pd.Timestamp

+
+

The minute representing the start of the desired range.

+
+

end_minute: pd.Timestamp

+
+

The minute representing the end of the desired range.

+
+
Returns:

pd.DatetimeIndex

+
+

The minutes in the desired range.

+
+
+
+ +
+
+next_close(dt)[source]
+

Given a dt, returns the next close.

+ +++ + + + + + +
Parameters:

dt: pd.Timestamp

+
+

The dt for which to get the next close.

+
+
Returns:

pd.Timestamp

+
+

The UTC timestamp of the next close.

+
+
+
+ +
+
+next_minute(dt)[source]
+

Given a dt, return the next exchange minute. If the given dt is not +an exchange minute, returns the next exchange open.

+ +++ + + + + + +
Parameters:

dt: pd.Timestamp

+
+

The dt for which to get the next exchange minute.

+
+
Returns:

pd.Timestamp

+
+

The next exchange minute.

+
+
+
+ +
+
+next_open(dt)[source]
+

Given a dt, returns the next open.

+

If the given dt happens to be a session open, the next session’s open +will be returned.

+ +++ + + + + + +
Parameters:

dt: pd.Timestamp

+
+

The dt for which to get the next open.

+
+
Returns:

pd.Timestamp

+
+

The UTC timestamp of the next open.

+
+
+
+ +
+
+next_session_label(session_label)[source]
+

Given a session label, returns the label of the next session.

+ +++ + + + + + +
Parameters:

session_label: pd.Timestamp

+
+

A session whose next session is desired.

+
+
Returns:

pd.Timestamp

+
+

The next session label (midnight UTC).

+
+
+

Notes

+

Raises ValueError if the given session is the last session in this +calendar.

+
+ +
+
+open_and_close_for_session(session_label)[source]
+

Returns a tuple of timestamps of the open and close of the session +represented by the given label.

+ +++ + + + + + +
Parameters:

session_label: pd.Timestamp

+
+

The session whose open and close are desired.

+
+
Returns:

(Timestamp, Timestamp)

+
+

The open and close for the given session.

+
+
+
+ +
+
+previous_close(dt)[source]
+

Given a dt, returns the previous close.

+ +++ + + + + + +
Parameters:

dt: pd.Timestamp

+
+

The dt for which to get the previous close.

+
+
Returns:

pd.Timestamp

+
+

The UTC timestamp of the previous close.

+
+
+
+ +
+
+previous_minute(dt)[source]
+

Given a dt, return the previous exchange minute.

+

Raises KeyError if the given timestamp is not an exchange minute.

+ +++ + + + + + +
Parameters:

dt: pd.Timestamp

+
+

The dt for which to get the previous exchange minute.

+
+
Returns:

pd.Timestamp

+
+

The previous exchange minute.

+
+
+
+ +
+
+previous_open(dt)[source]
+

Given a dt, returns the previous open.

+ +++ + + + + + +
Parameters:

dt: pd.Timestamp

+
+

The dt for which to get the previous open.

+
+
Returns:

pd.Timestamp

+
+

The UTC imestamp of the previous open.

+
+
+
+ +
+
+previous_session_label(session_label)[source]
+

Given a session label, returns the label of the previous session.

+ +++ + + + + + +
Parameters:

session_label: pd.Timestamp

+
+

A session whose previous session is desired.

+
+
Returns:

pd.Timestamp

+
+

The previous session label (midnight UTC).

+
+
+

Notes

+

Raises ValueError if the given session is the first session in this +calendar.

+
+ +
+
+regular_holidays
+
+++ + + + +
Returns:

pd.AbstractHolidayCalendar: a calendar containing the regular holidays

+

for this calendar

+
+
+ +
+
+session_distance(start_session_label, end_session_label)[source]
+

Given a start and end session label, returns the distance between +them. For example, for three consecutive sessions Mon., Tues., and +Wed, session_distance(Mon, Wed) would return 2.

+ +++ + + + + + +
Parameters:

start_session_label: pd.Timestamp

+
+

The label of the start session.

+
+

end_session_label: pd.Timestamp

+
+

The label of the ending session.

+
+
Returns:

int

+
+

The distance between the two sessions.

+
+
+
+ +
+
+sessions_in_range(start_session_label, end_session_label)[source]
+

Given start and end session labels, return all the sessions in that +range, inclusive.

+ +++ + + + + + +
Parameters:

start_session_label: pd.Timestamp (midnight UTC)

+
+

The label representing the first session of the desired range.

+
+

end_session_label: pd.Timestamp (midnight UTC)

+
+

The label representing the last session of the desired range.

+
+
Returns:

pd.DatetimeIndex

+
+

The desired sessions.

+
+
+
+ +
+
+sessions_window(session_label, count)[source]
+

Given a session label and a window size, returns a list of sessions +of size count + 1, that either starts with the given session +(if count is positive) or ends with the given session (if count is +negative).

+ +++ + + + + + +
Parameters:

session_label: pd.Timestamp

+
+

The label of the initial session.

+
+

count: int

+
+

Defines the length and the direction of the window.

+
+
Returns:

pd.DatetimeIndex

+
+

The desired sessions.

+
+
+
+ +
+
+special_closes
+

A list of special close times and corresponding HolidayCalendars.

+ +++ + + + +
Returns:list: List of (time, AbstractHolidayCalendar) tuples
+
+ +
+
+special_closes_adhoc
+
+++ + + + +
Returns:

list: List of (time, DatetimeIndex) tuples that represent special

+
+

closes that cannot be codified into rules.

+
+
+
+ +
+
+special_opens
+

A list of special open times and corresponding HolidayCalendars.

+ +++ + + + +
Returns:list: List of (time, AbstractHolidayCalendar) tuples
+
+ +
+
+special_opens_adhoc
+
+++ + + + +
Returns:

list: List of (time, DatetimeIndex) tuples that represent special

+
+

closes that cannot be codified into rules.

+
+
+
+ +
+ +
+
+catalyst.utils.calendars.register_calendar(self, name, calendar, force=False)
+

Registers a calendar for retrieval by the get_calendar method.

+ +++ + + + + + +
Parameters:

name: str

+
+

The key with which to register this calendar.

+
+

calendar: TradingCalendar

+
+

The calendar to be registered for retrieval.

+
+

force : bool, optional

+
+

If True, old calendars will be overwritten on a name collision. +If False, name collisions will raise an exception. +Default is False.

+
+
Raises:

CalendarNameCollision

+
+

If a calendar is already registered with the given calendar’s name.

+
+
+
+ +
+
+catalyst.utils.calendars.register_calendar_type(self, name, calendar_type, force=False)
+

Registers a calendar by type.

+

This is useful for registering a new calendar to be lazily instantiated +at some future point in time.

+ +++ + + + + + +
Parameters:

name: str

+
+

The key with which to register this calendar.

+
+

calendar_type: type

+
+

The type of the calendar to register.

+
+

force : bool, optional

+
+

If True, old calendars will be overwritten on a name collision. +If False, name collisions will raise an exception. +Default is False.

+
+
Raises:

CalendarNameCollision

+
+

If a calendar is already registered with the given calendar’s name.

+
+
+
+ +
+
+catalyst.utils.calendars.deregister_calendar(self, name)
+

If a calendar is registered with the given name, it is de-registered.

+ +++ + + + +
Parameters:

cal_name : str

+
+

The name of the calendar to be deregistered.

+
+
+
+ +
+
+catalyst.utils.calendars.clear_calendars(self)
+

Deregisters all current registered calendars

+
+

Data API

@@ -102,86 +2617,277 @@ bugs that could cause undesirable behavior when trading with real money.

Utilities

Caching

+
+
+class catalyst.utils.cache.CachedObject(value, expires)[source]
+

A simple struct for maintaining a cached object with an expiration date.

+ +++ + + + +
Parameters:

value : object

+
+

The object to cache.

+
+

expires : datetime-like

+
+

Expiration date of value. The cache is considered invalid for dates +strictly greater than expires.

+
+
+

Examples

+
>>> from pandas import Timestamp, Timedelta
+>>> expires = Timestamp('2014', tz='UTC')
+>>> obj = CachedObject(1, expires)
+>>> obj.unwrap(expires - Timedelta('1 minute'))
+1
+>>> obj.unwrap(expires)
+1
+>>> obj.unwrap(expires + Timedelta('1 minute'))
+... 
+Traceback (most recent call last):
+    ...
+Expired: 2014-01-01 00:00:00+00:00
+
+
+
+ +
+
+class catalyst.utils.cache.ExpiringCache(cache=None)[source]
+

A cache of multiple CachedObjects, which returns the wrapped the value +or raises and deletes the CachedObject if the value has expired.

+ +++ + + + +
Parameters:

cache : dict-like, optional

+
+

An instance of a dict-like object which needs to support at least: +__del__, __getitem__, __setitem__ +If None, than a dict is used as a default.

+
+
+

Examples

+
>>> from pandas import Timestamp, Timedelta
+>>> expires = Timestamp('2014', tz='UTC')
+>>> value = 1
+>>> cache = ExpiringCache()
+>>> cache.set('foo', value, expires)
+>>> cache.get('foo', expires - Timedelta('1 minute'))
+1
+>>> cache.get('foo', expires + Timedelta('1 minute'))
+Traceback (most recent call last):
+    ...
+KeyError: 'foo'
+
+
+
+ +
+
+class catalyst.utils.cache.dataframe_cache(path=None, lock=None, clean_on_failure=True, serialization='msgpack')[source]
+

A disk-backed cache for dataframes.

+

dataframe_cache is a mutable mapping from string names to pandas +DataFrame objects. +This object may be used as a context manager to delete the cache directory +on exit.

+ +++ + + + +
Parameters:

path : str, optional

+
+

The directory path to the cache. Files will be written as +path/<keyname>.

+
+

lock : Lock, optional

+
+

Thread lock for multithreaded/multiprocessed access to the cache. +If not provided no locking will be used.

+
+

clean_on_failure : bool, optional

+
+

Should the directory be cleaned up if an exception is raised in the +context manager.

+
+

serialize : {‘msgpack’, ‘pickle:<n>’}, optional

+
+

How should the data be serialized. If 'pickle' is passed, an +optional pickle protocol can be passed like: 'pickle:3' which says +to use pickle protocol 3.

+
+
+

Notes

+

The syntax cache[:] will load all key:value pairs into memory as a +dictionary. +The cache uses a temporary file format that is subject to change between +versions of catalyst.

+
+ +
+
+class catalyst.utils.cache.working_file(final_path, *args, **kwargs)[source]
+

A context manager for managing a temporary file that will be moved +to a non-temporary location if no exceptions are raised in the context.

+ +++ + + + +
Parameters:

final_path : str

+
+

The location to move the file when committing.

+
+

*args, **kwargs

+
+

Forwarded to NamedTemporaryFile.

+
+
+

Notes

+

The file is moved on __exit__ if there are no exceptions. +working_file uses shutil.move() to move the actual files, +meaning it has as strong of guarantees as shutil.move().

+
+ +
+
+class catalyst.utils.cache.working_dir(final_path, *args, **kwargs)[source]
+

A context manager for managing a temporary directory that will be moved +to a non-temporary location if no exceptions are raised in the context.

+ +++ + + + +
Parameters:

final_path : str

+
+

The location to move the file when committing.

+
+

*args, **kwargs

+
+

Forwarded to tmp_dir.

+
+
+

Notes

+

The file is moved on __exit__ if there are no exceptions. +working_dir uses dir_util.copy_tree() to move the actual files, +meaning it has as strong of guarantees as dir_util.copy_tree().

+
+

Command Line

+
+
+catalyst.utils.cli.maybe_show_progress(it, show_progress, empty_char=' ', fill_char='=', bar_template=' [%(bar)s] %(label)s: %(info)s', **kwargs)[source]
+

Optionally show a progress bar for the given iterator.

+ +++ + + + + + +
Parameters:

it : iterable

+
+

The underlying iterator.

+
+

show_progress : bool

+
+

Should progress be shown.

+
+

**kwargs

+
+

Forwarded to the click progress bar.

+
+
Returns:

itercontext : context manager

+
+

A context manager whose enter is the actual iterator to use.

+
+
+

Examples

+
with maybe_show_progress([1, 2, 3], True) as ns:
+     for n in ns:
+         ...
+
+
+
+
-
-
- -
-
- - - + + + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/beginner-tutorial.html b/beginner-tutorial.html index deef62a5..5fe21e5d 100644 --- a/beginner-tutorial.html +++ b/beginner-tutorial.html @@ -1,52 +1,335 @@ - - - - - Catalyst Beginner Tutorial — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Catalyst Beginner Tutorial — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+ +
+
+

Catalyst Beginner Tutorial

@@ -94,29 +377,29 @@ crypto asset in your universe.

My first algorithm

Lets take a look at a very simple algorithm from the examples directory: buy_btc_simple.py:

-
from catalyst.api import order, record, symbol
+
from catalyst.api import order, record, symbol
 
 
 def initialize(context):
-    context.asset = symbol('btc_usd')
+    context.asset = symbol('btc_usd')
 
 
 def handle_data(context, data):
     order(context.asset, 1)
-    record(btc = data.current(context.asset, 'price'))
+    record(btc = data.current(context.asset, 'price'))
 

As you can see, we first have to import some functions we would like to use. All functions commonly used in your algorithm can be found in -catalyst.api. Here we are using order() which takes +catalyst.api. Here we are using order() which takes twoarguments: a cryptoasset object, and a number specifying how many assets you -wouldlike to order (if negative, order() will sell/short +wouldlike to order (if negative, order() will sell/short assets). In this case we want to order 1 bitcoin at each iteration.

-

Finally, the record() function allows you to save the value +

Finally, the record() function allows you to save the value of a variable at each iteration. You provide it with a name for the variable together with the variable itself: varname=var. After the algorithm finished running you will have access to each variable value you tracked -with record() under the name you provided (we will see this +with record() under the name you provided (we will see this further below). You also see how we can access the current price data of a bitcoin in the data event frame.

@@ -128,7 +411,7 @@ pricing data that Catalyst needs to run your simulation through a process called form from the Enigma servers (which eventually will migrate to the Enigma Data Marketplace), and stores it locally to make it available at runtime.

In order to ingest data, you need to run a command like the following:

-
catalyst ingest-exchange -x bitfinex -i btc_usd
+
catalyst ingest-exchange -x bitfinex -i btc_usd
 

This instructs Catalyst to download pricing data from the Bitfinex exchange @@ -138,10 +421,10 @@ our algorithm using historical pricing data from the Bitfinex exchange. By default, Catalyst assumes that you want data with daily frequency (one candle bar per day). If you want instead minute frequency (one candle bar for every minute), you would need to specify it as follows:

-
catalyst ingest-exchange -x bitfinex -i btc_usd -f minute
+
catalyst ingest-exchange -x bitfinex -i btc_usd -f minute
 
-
Ingesting exchange bundle bitfinex...
+
Ingesting exchange bundle bitfinex...
   [====================================]  Ingesting daily price data on bitfinex:  100%
 
@@ -168,7 +451,7 @@ to the exchange.

The ingest-exchange command in catalyst offers additional parameters to further tweak the data ingestion process. You can learn more by running the following from the command line:

-
catalyst ingest-exchange --help
+
catalyst ingest-exchange --help
 
@@ -178,14 +461,14 @@ following from the command line:

catalyst provides three interfaces:

  • A command-line interface (CLI),
  • -
  • a run_algorithm() that you can call from other +
  • a run_algorithm() that you can call from other Python scripts,
  • and the Jupyter Notebook magic.

We’ll start with the CLI, and introduce the run_algorithm() in the last example of this tutorial. Some of the example algorithms provide instructions on how to run them both from the CLI, and using the -run_algorithm() function. For the third method, refer to the +run_algorithm() function. For the third method, refer to the corresponding section on Catalyst & Jupyter Notebook after you have assimilated the contents of this tutorial.

@@ -193,11 +476,11 @@ have assimilated the contents of this tutorial.

After you installed Catalyst, you should be able to execute the following from your command line (e.g. cmd.exe or the Anaconda Prompt on Windows, or the Terminal application on MacOS).

-
$ catalyst --help
+
$ catalyst --help
 

This is the resulting output, simplified for eductional purposes:

-
Usage: catalyst [OPTIONS] COMMAND [ARGS]...
+
Usage: catalyst [OPTIONS] COMMAND [ARGS]...
 
   Top level catalyst entry point.
 
@@ -218,10 +501,10 @@ given exchange, and the third mode 
$ catalyst run --help
+
$ catalyst run --help
 
-
Usage: catalyst run [OPTIONS]
+
Usage: catalyst run [OPTIONS]
 
   Run a backtest for the given algorithm.
 
@@ -230,7 +513,7 @@ the available options:

-t, --algotext TEXT The algorithm script to run. -D, --define TEXT Define a name to be bound in the namespace before executing the algotext. For example - '-Dname=value'. The value may be any python + '-Dname=value'. The value may be any python expression. These are evaluated in order so they may refer to previously defined names. --data-frequency [daily|minute] @@ -245,7 +528,7 @@ the available options:

-s, --start DATE The start date of the simulation. -e, --end DATE The end date of the simulation. -o, --output FILENAME The location to write the perf data. If this - is '-' the perf will be written to stdout. + is '-' the perf will be written to stdout. [default: -] --print-algo / --no-print-algo Print the algorithm to stdout. -x, --exchange-name [poloniex|bitfinex|bittrex] @@ -272,10 +555,10 @@ conveniently pass to the -c

Thus, to execute our algorithm from above and save the results to buy_btc_simple_out.pickle we would call catalyst run as follows:

-
catalyst run -f buy_btc_simple.py -x bitfinex --start 2016-1-1 --end 2017-9-30 -c usd --capital-base 100000 -o buy_btc_simple_out.pickle
+
catalyst run -f buy_btc_simple.py -x bitfinex --start 2016-1-1 --end 2017-9-30 -c usd --capital-base 100000 -o buy_btc_simple_out.pickle
 
-
INFO: run_algo: running algo in backtest mode
+
INFO: run_algo: running algo in backtest mode
 INFO: exchange_algorithm: initialized trading algorithm in backtest mode
 INFO: Performance: Simulated 639 trading days out of 639.
 INFO: Performance: first open: 2016-01-01 00:00:00+00:00
@@ -300,13 +583,13 @@ the fantastic pandascatalyst makes heavy usage of pandas,
 especially for data analysis and outputting so it’s worth spending some time to
 learn it.

-
import pandas as pd
-perf = pd.read_pickle('buy_btc_simple_out.pickle') # read in perf DataFrame
+
import pandas as pd
+perf = pd.read_pickle('buy_btc_simple_out.pickle') # read in perf DataFrame
 print(perf.head())
 

Which we execute by running:

-
$ python print_results.py
+
$ python print_results.py
 
@@ -479,23 +762,23 @@ which is the pandas dataframe containing the performance data for our algorithm that we reviewed above. Inside the analyze() function is where we can analyze and visualize the results of our strategy. Here’s the revised simple algorithm (note the addition of Line 1, and Lines 11-18)

-
import matplotlib.pyplot as plt
+
import matplotlib.pyplot as plt
 from catalyst.api import order, record, symbol
 
 def initialize(context):
-    context.asset = symbol('btc_usd')
+    context.asset = symbol('btc_usd')
 
 def handle_data(context, data):
     order(context.asset, 1)
-    record(btc = data.current(context.asset, 'price'))
+    record(btc = data.current(context.asset, 'price'))
 
 def analyze(context, perf):
     ax1 = plt.subplot(211)
     perf.portfolio_value.plot(ax=ax1)
-    ax1.set_ylabel('portfolio value')
+    ax1.set_ylabel('portfolio value')
     ax2 = plt.subplot(212, sharex=ax1)
     perf.btc.plot(ax=ax2)
-    ax2.set_ylabel('bitcoin price')
+    ax2.set_ylabel('bitcoin price')
     plt.show()
 
@@ -504,7 +787,7 @@ algorithm (note the addition of Line 1, and Lines 11-18)

alongside enigma-catalyst (with the exception of the Conda install, where it was included by default inside the conda environment we created). If for any reason you don’t have it installed, you can add it by running:

-
(catalyst)$ pip install matplotlib
+
(catalyst)$ pip install matplotlib
 

If everything works well, you’ll see the following chart:

@@ -517,11 +800,11 @@ only bought bitcoin every chance it got.

results refer to MacOS + Matplotlib. Alternatively, some users have reported the following error when running an algo in a Linux environment:

-
ImportError: No module named _tkinter, please install the python-tk package
+
ImportError: No module named _tkinter, please install the python-tk package
 

Which can easily solved by running (in Ubuntu/Debian-based systems):

-
sudo apt install python-tk
+
sudo apt install python-tk
 
@@ -553,7 +836,7 @@ follow. Most of the added some complexity has been added to beautify the output, which you can skim through for now. A copy of this algorithm is available in the examples directory: dual_moving_average.py.

-
import matplotlib.pyplot as plt
+
import matplotlib.pyplot as plt
 import numpy as np
 import pandas as pd
 from logbook import Logger
@@ -562,101 +845,101 @@ the examples dire
 from catalyst.api import (record, symbol, order_target_percent,)
 from catalyst.exchange.utils.stats_utils import extract_transactions
 
-NAMESPACE = 'dual_moving_average'
+NAMESPACE = 'dual_moving_average'
 log = Logger(NAMESPACE)
 
 
 def initialize(context):
     context.i = 0
-    context.asset = symbol('ltc_usd')
+    context.asset = symbol('ltc_usd')
     context.base_price = None
 
 
 def handle_data(context, data):
-    # define the windows for the moving averages
+    # define the windows for the moving averages
     short_window = 50
     long_window = 200
 
-    # Skip as many bars as long_window to properly compute the average
+    # Skip as many bars as long_window to properly compute the average
     context.i += 1
     if context.i < long_window:
         return
 
-    # Compute moving averages calling data.history() for each
-    # moving average with the appropriate parameters. We choose to use
-    # minute bars for this simulation -> freq="1m"
-    # Returns a pandas dataframe.
+    # Compute moving averages calling data.history() for each
+    # moving average with the appropriate parameters. We choose to use
+    # minute bars for this simulation -> freq="1m"
+    # Returns a pandas dataframe.
     short_data = data.history(context.asset,
-                              'price',
+                              'price',
                               bar_count=short_window,
-                              frequency="1T",
+                              frequency="1T",
                               )
     short_mavg = short_data.mean()
     long_data = data.history(context.asset,
-                             'price',
+                             'price',
                              bar_count=long_window,
-                             frequency="1T",
+                             frequency="1T",
                              )
     long_mavg = long_data.mean()
 
-    # Let's keep the price of our asset in a more handy variable
-    price = data.current(context.asset, 'price')
+    # Let's keep the price of our asset in a more handy variable
+    price = data.current(context.asset, 'price')
 
-    # If base_price is not set, we use the current value. This is the
-    # price at the first bar which we reference to calculate price_change.
+    # If base_price is not set, we use the current value. This is the
+    # price at the first bar which we reference to calculate price_change.
     if context.base_price is None:
         context.base_price = price
     price_change = (price - context.base_price) / context.base_price
 
-    # Save values for later inspection
+    # Save values for later inspection
     record(price=price,
            cash=context.portfolio.cash,
            price_change=price_change,
            short_mavg=short_mavg,
            long_mavg=long_mavg)
 
-    # Since we are using limit orders, some orders may not execute immediately
-    # we wait until all orders are executed before considering more trades.
+    # Since we are using limit orders, some orders may not execute immediately
+    # we wait until all orders are executed before considering more trades.
     orders = context.blotter.open_orders
     if len(orders) > 0:
         return
 
-    # Exit if we cannot trade
+    # Exit if we cannot trade
     if not data.can_trade(context.asset):
         return
 
-    # We check what's our position on our portfolio and trade accordingly
+    # We check what's our position on our portfolio and trade accordingly
     pos_amount = context.portfolio.positions[context.asset].amount
 
-    # Trading logic
+    # Trading logic
     if short_mavg > long_mavg and pos_amount == 0:
-        # we buy 100% of our portfolio for this asset
+        # we buy 100% of our portfolio for this asset
         order_target_percent(context.asset, 1)
     elif short_mavg < long_mavg and pos_amount > 0:
-        # we sell all our positions for this asset
+        # we sell all our positions for this asset
         order_target_percent(context.asset, 0)
 
 
 def analyze(context, perf):
-    # Get the base_currency that was passed as a parameter to the simulation
+    # Get the base_currency that was passed as a parameter to the simulation
     exchange = list(context.exchanges.values())[0]
     base_currency = exchange.base_currency.upper()
 
-    # First chart: Plot portfolio value using base_currency
+    # First chart: Plot portfolio value using base_currency
     ax1 = plt.subplot(411)
-    perf.loc[:, ['portfolio_value']].plot(ax=ax1)
+    perf.loc[:, ['portfolio_value']].plot(ax=ax1)
     ax1.legend_.remove()
-    ax1.set_ylabel('Portfolio Value\n({})'.format(base_currency))
+    ax1.set_ylabel('Portfolio Value\n({})'.format(base_currency))
     start, end = ax1.get_ylim()
     ax1.yaxis.set_ticks(np.arange(start, end, (end - start) / 5))
 
-    # Second chart: Plot asset price, moving averages and buys/sells
+    # Second chart: Plot asset price, moving averages and buys/sells
     ax2 = plt.subplot(412, sharex=ax1)
-    perf.loc[:, ['price', 'short_mavg', 'long_mavg']].plot(
+    perf.loc[:, ['price', 'short_mavg', 'long_mavg']].plot(
         ax=ax2,
-        label='Price')
+        label='Price')
     ax2.legend_.remove()
-    ax2.set_ylabel('{asset}\n({base})'.format(
+    ax2.set_ylabel('{asset}\n({base})'.format(
         asset=context.asset.symbol,
         base=base_currency
     ))
@@ -665,72 +948,72 @@ the examples dire
 
     transaction_df = extract_transactions(perf)
     if not transaction_df.empty:
-        buy_df = transaction_df[transaction_df['amount'] > 0]
-        sell_df = transaction_df[transaction_df['amount'] < 0]
+        buy_df = transaction_df[transaction_df['amount'] > 0]
+        sell_df = transaction_df[transaction_df['amount'] < 0]
         ax2.scatter(
             buy_df.index.to_pydatetime(),
-            perf.loc[buy_df.index, 'price'],
-            marker='^',
+            perf.loc[buy_df.index, 'price'],
+            marker='^',
             s=100,
-            c='green',
-            label=''
+            c='green',
+            label=''
         )
         ax2.scatter(
             sell_df.index.to_pydatetime(),
-            perf.loc[sell_df.index, 'price'],
-            marker='v',
+            perf.loc[sell_df.index, 'price'],
+            marker='v',
             s=100,
-            c='red',
-            label=''
+            c='red',
+            label=''
         )
 
-    # Third chart: Compare percentage change between our portfolio
-    # and the price of the asset
+    # Third chart: Compare percentage change between our portfolio
+    # and the price of the asset
     ax3 = plt.subplot(413, sharex=ax1)
-    perf.loc[:, ['algorithm_period_return', 'price_change']].plot(ax=ax3)
+    perf.loc[:, ['algorithm_period_return', 'price_change']].plot(ax=ax3)
     ax3.legend_.remove()
-    ax3.set_ylabel('Percent Change')
+    ax3.set_ylabel('Percent Change')
     start, end = ax3.get_ylim()
     ax3.yaxis.set_ticks(np.arange(start, end, (end - start) / 5))
 
-    # Fourth chart: Plot our cash
+    # Fourth chart: Plot our cash
     ax4 = plt.subplot(414, sharex=ax1)
     perf.cash.plot(ax=ax4)
-    ax4.set_ylabel('Cash\n({})'.format(base_currency))
+    ax4.set_ylabel('Cash\n({})'.format(base_currency))
     start, end = ax4.get_ylim()
     ax4.yaxis.set_ticks(np.arange(0, end, end / 5))
 
     plt.show()
 
 
-if __name__ == '__main__':
+if __name__ == '__main__':
     
     run_algorithm(
             capital_base=1000,
-            data_frequency='minute',
+            data_frequency='minute',
             initialize=initialize,
             handle_data=handle_data,
             analyze=analyze,
-            exchange_name='bitfinex',
+            exchange_name='bitfinex',
             algo_namespace=NAMESPACE,
-            base_currency='usd',
-            start=pd.to_datetime('2017-9-22', utc=True),
-            end=pd.to_datetime('2017-9-23', utc=True),
+            base_currency='usd',
+            start=pd.to_datetime('2017-9-22', utc=True),
+            end=pd.to_datetime('2017-9-23', utc=True),
         )
 

In order to run the code above, you have to ingest the needed data first:

-
catalyst ingest-exchange -x bitfinex -f minute -i ltc_usd
+
catalyst ingest-exchange -x bitfinex -f minute -i ltc_usd
 

And then run the code above with the following command:

-
catalyst run -f dual_moving_average.py -x bitfinex -s 2017-9-22 -e 2017-9-23 --capital-base 1000 --base-currency usd --data-frequency minute -o out.pickle
+
catalyst run -f dual_moving_average.py -x bitfinex -s 2017-9-22 -e 2017-9-23 --capital-base 1000 --base-currency usd --data-frequency minute -o out.pickle
 

Alternatively, we can make use of the run_algorithm() function included at the end of the file, where we can specify all the simulation parameters, and execute this file as a Python script:

-
python dual_moving_average.py
+
python dual_moving_average.py
 

Either way, we obtain the following charts:

@@ -791,11 +1074,11 @@ running algorithms through the command line.

In order to use Jupyter Notebook, you first have to install it inside your environment. It’s available as pip package, so regardless of how you installed Catalyst, go inside your catalyst environemnt and run:

-
(catalyst)$ pip install jupyter
+
(catalyst)$ pip install jupyter
 

Once you have Jupyter Notebook installed, every time you want to use it run:

-
(catalyst)$ jupyter notebook
+
(catalyst)$ jupyter notebook
 

A local server will launch, and will open a new window on your browser. That’s @@ -806,7 +1089,7 @@ the interface through which you will interact with Jupyter Notebook.

Before running your algorithms inside the Jupyter Notebook, remember to ingest the data from the command line interface (CLI). In the example below, you would need to run first:

-
catalyst ingest-exchange -x bitfinex -i btc_usd
+
catalyst ingest-exchange -x bitfinex -i btc_usd
 

To use Catalyst inside a Jupyter Noebook, you have to write your algorithm in a @@ -817,18 +1100,18 @@ takes the same arguments as the command line interface. Thus to run the algorithm just supply the same parameters as the CLI but without the -f and -o arguments. We just have to execute the following cell after importing catalyst to register the magic.

-
# Register the catalyst magic
+
# Register the catalyst magic
 %load_ext catalyst
 
-
# Setup matplotlib to display graphs inline in this Notebook
+
# Setup matplotlib to display graphs inline in this Notebook
 %matplotlib inline
 

Note below that we do not have to specify an input file (-f) since the magic will use the contents of the cell and look for your algorithm functions.

-
%%catalyst --start 2015-3-2 --end 2017-6-28 --capital-base 100000 -x bitfinex -c usd
+
%%catalyst --start 2015-3-2 --end 2017-6-28 --capital-base 100000 -x bitfinex -c usd
 
 from catalyst.finance.slippage import VolumeShareSlippage
 
@@ -841,13 +1124,13 @@ functions.

) def initialize(context): - context.ASSET_NAME = 'btc_usd' + context.ASSET_NAME = 'btc_usd' context.TARGET_HODL_RATIO = 0.8 context.RESERVE_RATIO = 1.0 - context.TARGET_HODL_RATIO - # For all trading pairs in the poloniex bundle, the default denomination - # currently supported by Catalyst is 1/1000th of a full coin. Use this - # constant to scale the price of up to that of a full coin if desired. + # For all trading pairs in the poloniex bundle, the default denomination + # currently supported by Catalyst is 1/1000th of a full coin. Use this + # constant to scale the price of up to that of a full coin if desired. context.TICK_SIZE = 1000.0 context.is_buying = True @@ -862,22 +1145,22 @@ functions.

target_hodl_value = context.TARGET_HODL_RATIO * starting_cash reserve_value = context.RESERVE_RATIO * starting_cash - # Cancel any outstanding orders + # Cancel any outstanding orders orders = get_open_orders(context.asset) or [] for order in orders: cancel_order(order) - # Stop buying after passing the reserve threshold + # Stop buying after passing the reserve threshold cash = context.portfolio.cash if cash <= reserve_value: context.is_buying = False - # Retrieve current asset price from pricing data - price = data.current(context.asset, 'price') + # Retrieve current asset price from pricing data + price = data.current(context.asset, 'price') - # Check if still buying and could (approximately) afford another purchase + # Check if still buying and could (approximately) afford another purchase if context.is_buying and cash > price: - # Place order to make position in asset equal to target_hodl_value + # Place order to make position in asset equal to target_hodl_value order_target_value( context.asset, target_hodl_value, @@ -886,7 +1169,7 @@ functions.

record( price=price, - volume=data.current(context.asset, 'volume'), + volume=data.current(context.asset, 'volume'), cash=cash, starting_cash=context.portfolio.starting_cash, leverage=context.account.leverage, @@ -895,70 +1178,70 @@ functions.

def analyze(context=None, results=None): import matplotlib.pyplot as plt - # Plot the portfolio and asset data. + # Plot the portfolio and asset data. ax1 = plt.subplot(611) - results[['portfolio_value']].plot(ax=ax1) - ax1.set_ylabel('Portfolio Value (USD)') + results[['portfolio_value']].plot(ax=ax1) + ax1.set_ylabel('Portfolio Value (USD)') ax2 = plt.subplot(612, sharex=ax1) - ax2.set_ylabel('{asset} (USD)'.format(asset=context.ASSET_NAME)) - (context.TICK_SIZE * results[['price']]).plot(ax=ax2) + ax2.set_ylabel('{asset} (USD)'.format(asset=context.ASSET_NAME)) + (context.TICK_SIZE * results[['price']]).plot(ax=ax2) trans = results.ix[[t != [] for t in results.transactions]] buys = trans.ix[ - [t[0]['amount'] > 0 for t in trans.transactions] + [t[0]['amount'] > 0 for t in trans.transactions] ] ax2.plot( buys.index, context.TICK_SIZE * results.price[buys.index], - '^', + '^', markersize=10, - color='g', + color='g', ) ax3 = plt.subplot(613, sharex=ax1) - results[['leverage', 'alpha', 'beta']].plot(ax=ax3) - ax3.set_ylabel('Leverage ') + results[['leverage', 'alpha', 'beta']].plot(ax=ax3) + ax3.set_ylabel('Leverage ') ax4 = plt.subplot(614, sharex=ax1) - results[['starting_cash', 'cash']].plot(ax=ax4) - ax4.set_ylabel('Cash (USD)') + results[['starting_cash', 'cash']].plot(ax=ax4) + ax4.set_ylabel('Cash (USD)') results[[ - 'treasury', - 'algorithm', - 'benchmark', + 'treasury', + 'algorithm', + 'benchmark', ]] = results[[ - 'treasury_period_return', - 'algorithm_period_return', - 'benchmark_period_return', + 'treasury_period_return', + 'algorithm_period_return', + 'benchmark_period_return', ]] ax5 = plt.subplot(615, sharex=ax1) results[[ - 'treasury', - 'algorithm', - 'benchmark', + 'treasury', + 'algorithm', + 'benchmark', ]].plot(ax=ax5) - ax5.set_ylabel('Percent Change') + ax5.set_ylabel('Percent Change') ax6 = plt.subplot(616, sharex=ax1) - results[['volume']].plot(ax=ax6) - ax6.set_ylabel('Volume (mCoins/5min)') + results[['volume']].plot(ax=ax6) + ax6.set_ylabel('Volume (mCoins/5min)') plt.legend(loc=3) - # Show the plot. + # Show the plot. plt.gcf().set_size_inches(18, 8) plt.show()
-
[2017-08-11 07:19:46.411748] INFO: Loader: Loading benchmark data for 'USDT_BTC' from 1989-12-31 00:00:00+00:00 to 2017-08-09 00:00:00+00:00
+
[2017-08-11 07:19:46.411748] INFO: Loader: Loading benchmark data for 'USDT_BTC' from 1989-12-31 00:00:00+00:00 to 2017-08-09 00:00:00+00:00
 [2017-08-11 07:19:46.418983] INFO: Loader: Loading data for /Users/<snipped>/.catalyst/data/USDT_BTC_benchmark.csv failed with error [Unknown string format].
 [2017-08-11 07:19:46.419740] INFO: Loader: Cache at /Users/<snipped>/.catalyst/data/USDT_BTC_benchmark.csv does not have data from 1990-01-01 00:00:00+00:00 to 2017-08-09 00:00:00+00:00.
 
-[2017-08-11 07:19:46.420770] INFO: Loader: Downloading benchmark data for 'USDT_BTC' from 1989-12-31 00:00:00+00:00 to 2017-08-09 00:00:00+00:00
-[2017-08-11 07:19:50.060244] WARNING: Loader: Still don't have expected data after redownload!
+[2017-08-11 07:19:46.420770] INFO: Loader: Downloading benchmark data for 'USDT_BTC' from 1989-12-31 00:00:00+00:00 to 2017-08-09 00:00:00+00:00
+[2017-08-11 07:19:50.060244] WARNING: Loader: Still don't have expected data after redownload!
 [2017-08-11 07:19:50.097334] WARNING: Loader: Refusing to download new treasury data because a download succeeded at 2017-08-11 06:56:49+00:00.
 [2017-08-11 07:19:54.618399] INFO: Performance: Simulated 851 trading days out of 851.
 [2017-08-11 07:19:54.619301] INFO: Performance: first open: 2015-03-01 00:00:00+00:00
@@ -2335,7 +2618,7 @@ functions.

Also, instead of defining an output file we are accessing it via the “_” variable that will be created in the name space and contain the performance DataFrame.

-
_.head()
+
_.head()
 

algo_volatility

@@ -2527,84 +2810,68 @@ problems on our -
-

Table Of Contents

- + -

Previous topic

-

Install

-

Next topic

-

Live Trading

-
-

This Page

- -
- -
-
- - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles.html b/bundles.html index 41e23b0b..e7f275a7 100644 --- a/bundles.html +++ b/bundles.html @@ -1,44 +1,333 @@ - - - - - Data Bundles — Catalyst 0.4 documentation - - - - - - - - - - - + + + + + + + + + Data Bundles — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+ +
+
+

Data Bundles

@@ -50,12 +339,12 @@ backtests and store the data for future runs.

Zipline comes with a few bundles by default as well as the ability to register new bundles. To see which bundles we have have available, we may run the bundles command, for example:

-
$ zipline bundles
-my-custom-bundle 2016-05-05 20:35:19.809398
-my-custom-bundle 2016-05-05 20:34:53.654082
-my-custom-bundle 2016-05-05 20:34:48.401767
+
$ zipline bundles
+my-custom-bundle 2016-05-05 20:35:19.809398
+my-custom-bundle 2016-05-05 20:34:53.654082
+my-custom-bundle 2016-05-05 20:34:48.401767
 quandl <no ingestions>
-quantopian-quandl 2016-05-05 20:06:40.894956
+quantopian-quandl 2016-05-05 20:06:40.894956
 

The output here shows that there are 3 bundles available:

@@ -78,7 +367,7 @@ standard location that zipline can find. By default the location where ingested data will be written is $ZIPLINE_ROOT/data/<bundle> where by default ZIPLINE_ROOT=~/.zipline. The ingestion step may take some time as it could involve downloading and processing a lot of data. This can be run with:

-
$ zipline ingest [-b <bundle>]
+
$ zipline ingest [-b <bundle>]
 

where <bundle> is the name of the bundle to ingest, defaulting to @@ -97,17 +386,17 @@ we can list all of the ingestions with the clean, which will clear data bundles based on some time constraints.

For example:

-
# clean everything older than <date>
-$ zipline clean [-b <bundle>] --before <date>
+
# clean everything older than <date>
+$ zipline clean [-b <bundle>] --before <date>
 
-# clean everything newer than <date>
-$ zipline clean [-b <bundle>] --after <date>
+# clean everything newer than <date>
+$ zipline clean [-b <bundle>] --after <date>
 
-# keep everything in the range of [before, after] and delete the rest
-$ zipline clean [-b <bundle>] --before <date> --after <after>
+# keep everything in the range of [before, after] and delete the rest
+$ zipline clean [-b <bundle>] --before <date> --after <after>
 
-# clean all but the last <int> runs
-$ zipline clean [-b <bundle>] --keep-last <int>
+# clean all but the last <int> runs
+$ zipline clean [-b <bundle>] --keep-last <int>
 
@@ -116,7 +405,7 @@ $ zipline clean [-b <bundle>]Now that the data has been ingested we can use it to run backtests with the run command. The bundle to use can be specified with the --bundle option like:

-
$ zipline run --bundle <bundle> --algofile algo.py ...
+
$ zipline run --bundle <bundle> --algofile algo.py ...
 

We may also specify the date to use to look up the bundle data with the @@ -138,7 +427,7 @@ includes daily pricing data, splits, cash dividends, and asset metadata. To ingest the quandl data bundle we recommend creating an account on quandl.com to get an API key to be able to make more API requests per day. Once we have an API key we may run:

-
$ QUANDL_API_KEY=<api-key> zipline ingest -b quandl
+
$ QUANDL_API_KEY=<api-key> zipline ingest -b quandl
 

though we may still run ingest as an anonymous quandl user (with no API @@ -169,23 +458,23 @@ cache the data for a set of equities from yahoo. The yahoo bundles include daily pricing data along with splits, cash dividends, and inferred asset metadata. To create a bundle from a set of equities, add the following to your ~/.zipline/extensions.py file:

-
from zipline.data.bundles import register, yahoo_equities
+
from zipline.data.bundles import register, yahoo_equities
 
-# these are the tickers you would like data for
+# these are the tickers you would like data for
 equities = {
-    'AAPL',
-    'MSFT',
-    'GOOG',
+    'AAPL',
+    'MSFT',
+    'GOOG',
 }
 register(
-    'my-yahoo-equities-bundle',  # name this whatever you like
+    'my-yahoo-equities-bundle',  # name this whatever you like
     yahoo_equities(equities),
 )
 

This may now be used like:

-
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/development-guidelines.html b/development-guidelines.html index 38f97ad4..de33724b 100644 --- a/development-guidelines.html +++ b/development-guidelines.html @@ -1,52 +1,335 @@ - - - - - Development Guidelines — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Development Guidelines — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+ +
+
+

Development Guidelines

@@ -55,23 +338,23 @@

Creating a Development Environment

First, you’ll need to clone Catalyst by running:

-
$ git clone git@github.com:enigmampc/catalyst.git
+
$ git clone git@github.com:enigmampc/catalyst.git
 

Then check out to a new branch where you can make your changes:

-
$ git checkout -b some-short-descriptive-name
+
$ git checkout -b some-short-descriptive-name
 

If you don’t already have them, you’ll need some C library dependencies. You can follow the install guide to get the appropriate dependencies.

The following section assumes you already have virtualenvwrapper and pip installed on your system. Suggested installation of Python library dependencies used for development:

-
$ mkvirtualenv catalyst
-$ ./etc/ordered_pip.sh ./etc/requirements.txt
-$ pip install -r ./etc/requirements_dev.txt
-$ pip install -r ./etc/requirements_blaze.txt
+
$ mkvirtualenv catalyst
+$ ./etc/ordered_pip.sh ./etc/requirements.txt
+$ pip install -r ./etc/requirements_dev.txt
+$ pip install -r ./etc/requirements_blaze.txt
 

Finally, you can build the C extensions by running:

-
$ python setup.py build_ext --inplace
+
$ python setup.py build_ext --inplace
 
@@ -91,20 +374,20 @@ build the DockerfileContributing to the Docs

If you’d like to contribute to the documentation on enigmampc.github.io, you can navigate to docs/source/ where each reStructuredText file is a separate section there. To add a section, create a new file called some-descriptive-name.rst and add some-descriptive-name to index.rst. To edit a section, simply open up one of the existing files, make your changes, and save them.

We use Sphinx to generate documentation for Catalyst, which you will need to install by running:

-
$ pip install -r ./etc/requirements_docs.txt
+
$ pip install -r ./etc/requirements_docs.txt
 

To build and view the docs locally, run:

-
# assuming you're in the Catalyst root directory
-$ cd docs
-$ make html
-$ {BROWSER} build/html/index.html
+
# assuming you're in the Catalyst root directory
+$ cd docs
+$ make html
+$ {BROWSER} build/html/index.html
 

There is a documented issue with sphinx and docutils that causes the error below when trying to build the docs.

-
Exception occurred:
+
Exception occurred:
   File "(...)/env-c/lib/python2.7/site-packages/docutils/writers/_html_base.py", line 671, in depart_document
     assert not self.context, 'len(context) = %s' % len(self.context)
 AssertionError: len(context) = 3
@@ -112,14 +395,14 @@ AssertionError: len(context) = 3
 

If you get this error, you need to downgrade your version of docutils as follows, and build the docs again:

-
$ pip install docutils==0.12
+
$ pip install docutils==0.12
 

Commit messages

Standard prefixes to start a commit message:

-
BLD: change related to building Catalyst
+
BLD: change related to building Catalyst
 BUG: bug fix
 DEP: deprecate something, or remove a deprecated object
 DEV: development tool or utility
@@ -136,7 +419,7 @@ PERF: performance enhancements
 

Some commit style guidelines:

Commit lines should be no longer than 72 characters. The first line of the commit should include one of the above prefixes. There should be an empty line between the commit subject and the body of the commit. In general, the message should be in the imperative tense. Best practice is to include not only what the change is, but why the change was made.

Example:

-
MAINT: Remove unused calculations of max_leverage, et al.
+
MAINT: Remove unused calculations of max_leverage, et al.
 
 In the performance period the max_leverage, max_capital_used,
 cumulative_capital_used were calculated but not used.
@@ -159,68 +442,68 @@ the algorithm has little cash on hand.
 
 
           
-
-
- -
-
- - - + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example-algos.html b/example-algos.html index 13842fdf..3209018a 100644 --- a/example-algos.html +++ b/example-algos.html @@ -1,52 +1,335 @@ - - - - - Example Algorithms — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Example Algorithms — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+ +
+
+

@@ -92,7 +375,7 @@ writting the following article:

Buy BTC Simple Algorithm

Source code: examples/buy_btc_simple.py

-
'''
+
'''
     This is a very simple example referenced in the beginner's tutorial:
     https://enigmampc.github.io/catalyst/beginner-tutorial.html
 
@@ -121,25 +404,25 @@ writting the following article:
 
 
 def initialize(context):
-    context.asset = symbol('btc_usdt')
+    context.asset = symbol('btc_usdt')
 
 
 def handle_data(context, data):
     order(context.asset, 1)
-    record(btc=data.current(context.asset, 'price'))
+    record(btc=data.current(context.asset, 'price'))
 
 
-if __name__ == '__main__':
+if __name__ == '__main__':
     run_algorithm(
         capital_base=10000,
-        data_frequency='daily',
+        data_frequency='daily',
         initialize=initialize,
         handle_data=handle_data,
-        exchange_name='poloniex',
-        algo_namespace='buy_and_hodl',
-        base_currency='usdt',
-        start=pd.to_datetime('2015-03-01', utc=True),
-        end=pd.to_datetime('2017-10-31', utc=True),
+        exchange_name='poloniex',
+        algo_namespace='buy_and_hodl',
+        base_currency='usdt',
+        start=pd.to_datetime('2015-03-01', utc=True),
+        end=pd.to_datetime('2017-10-31', utc=True),
     )
 
@@ -148,16 +431,16 @@ writting the following article:

Buy and Hodl Algorithm

First ingest the historical pricing data needed to run this algorithm:

-
catalyst ingest-exchange -x bitfinex -f daily -i btc_usd
+
catalyst ingest-exchange -x bitfinex -f daily -i btc_usd
 

Then, you can run the code below with the following command:

-
catalyst run -f buy_and_hodl.py --start 2015-3-1 --end 2017-10-31 --capital-base 100000 -x bitfinex -c btc -o bah.pickle
+
catalyst run -f buy_and_hodl.py --start 2015-3-1 --end 2017-10-31 --capital-base 100000 -x bitfinex -c btc -o bah.pickle
 

or using the same parameters specified in the run_algorithm() function at the end of the file:

-
python buy_and_hodl.py
+
python buy_and_hodl.py
 

This command will run the trading algorithm in the specified time range and @@ -167,22 +450,22 @@ that 2015-3-1 is the earliest date that Catalyst supports (if you choose an earlier date, you’ll get an error), and the most recent date you can choose is one day prior to the current date.

Source code: examples/buy_and_hodl.py

-
#!/usr/bin/env python
-#
-# Copyright 2017 Enigma MPC, Inc.
-# Copyright 2015 Quantopian, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+
#!/usr/bin/env python
+#
+# Copyright 2017 Enigma MPC, Inc.
+# Copyright 2015 Quantopian, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 import pandas as pd
 import matplotlib.pyplot as plt
 
@@ -192,7 +475,7 @@ one day prior to the current date.

def initialize(context): - context.ASSET_NAME = 'btc_usdt' + context.ASSET_NAME = 'btc_usdt' context.TARGET_HODL_RATIO = 0.8 context.RESERVE_RATIO = 1.0 - context.TARGET_HODL_RATIO @@ -209,23 +492,23 @@ one day prior to the current date.

target_hodl_value = context.TARGET_HODL_RATIO * starting_cash reserve_value = context.RESERVE_RATIO * starting_cash - # Cancel any outstanding orders + # Cancel any outstanding orders orders = get_open_orders(context.asset) or [] for order in orders: cancel_order(order) - # Stop buying after passing the reserve threshold + # Stop buying after passing the reserve threshold cash = context.portfolio.cash if cash <= reserve_value: context.is_buying = False - # Retrieve current asset price from pricing data - price = data.current(context.asset, 'price') + # Retrieve current asset price from pricing data + price = data.current(context.asset, 'price') - # Check if still buying and could (approximately) afford another purchase + # Check if still buying and could (approximately) afford another purchase if context.is_buying and cash > price: - print('buying') - # Place order to make position in asset equal to target_hodl_value + print('buying') + # Place order to make position in asset equal to target_hodl_value order_target_value( context.asset, target_hodl_value, @@ -234,7 +517,7 @@ one day prior to the current date.

record( price=price, - volume=data.current(context.asset, 'volume'), + volume=data.current(context.asset, 'volume'), cash=cash, starting_cash=context.portfolio.starting_cash, leverage=context.account.leverage, @@ -243,77 +526,77 @@ one day prior to the current date.

def analyze(context=None, results=None): - # Plot the portfolio and asset data. + # Plot the portfolio and asset data. ax1 = plt.subplot(611) - results[['portfolio_value']].plot(ax=ax1) - ax1.set_ylabel('Portfolio\nValue\n(USD)') + results[['portfolio_value']].plot(ax=ax1) + ax1.set_ylabel('Portfolio\nValue\n(USD)') ax2 = plt.subplot(612, sharex=ax1) - ax2.set_ylabel('{asset}\n(USD)'.format(asset=context.ASSET_NAME)) - results[['price']].plot(ax=ax2) + ax2.set_ylabel('{asset}\n(USD)'.format(asset=context.ASSET_NAME)) + results[['price']].plot(ax=ax2) trans = results.ix[[t != [] for t in results.transactions]] buys = trans.ix[ - [t[0]['amount'] > 0 for t in trans.transactions] + [t[0]['amount'] > 0 for t in trans.transactions] ] ax2.scatter( buys.index.to_pydatetime(), results.price[buys.index], - marker='^', + marker='^', s=100, - c='g', - label='' + c='g', + label='' ) ax3 = plt.subplot(613, sharex=ax1) - results[['leverage', 'alpha', 'beta']].plot(ax=ax3) - ax3.set_ylabel('Leverage ') + results[['leverage', 'alpha', 'beta']].plot(ax=ax3) + ax3.set_ylabel('Leverage ') ax4 = plt.subplot(614, sharex=ax1) - results[['starting_cash', 'cash']].plot(ax=ax4) - ax4.set_ylabel('Cash (USD)') + results[['starting_cash', 'cash']].plot(ax=ax4) + ax4.set_ylabel('Cash (USD)') results[[ - 'treasury', - 'algorithm', - 'benchmark', + 'treasury', + 'algorithm', + 'benchmark', ]] = results[[ - 'treasury_period_return', - 'algorithm_period_return', - 'benchmark_period_return', + 'treasury_period_return', + 'algorithm_period_return', + 'benchmark_period_return', ]] ax5 = plt.subplot(615, sharex=ax1) results[[ - 'treasury', - 'algorithm', - 'benchmark', + 'treasury', + 'algorithm', + 'benchmark', ]].plot(ax=ax5) - ax5.set_ylabel('Percent\nChange') + ax5.set_ylabel('Percent\nChange') ax6 = plt.subplot(616, sharex=ax1) - results[['volume']].plot(ax=ax6) - ax6.set_ylabel('Volume') + results[['volume']].plot(ax=ax6) + ax6.set_ylabel('Volume') plt.legend(loc=3) - # Show the plot. + # Show the plot. plt.gcf().set_size_inches(18, 8) plt.show() -if __name__ == '__main__': +if __name__ == '__main__': run_algorithm( capital_base=10000, - data_frequency='daily', + data_frequency='daily', initialize=initialize, handle_data=handle_data, analyze=analyze, - exchange_name='poloniex', - algo_namespace='buy_and_hodl', - base_currency='usdt', - start=pd.to_datetime('2015-03-01', utc=True), - end=pd.to_datetime('2017-10-31', utc=True), + exchange_name='poloniex', + algo_namespace='buy_and_hodl', + base_currency='usdt', + start=pd.to_datetime('2015-03-01', utc=True), + end=pd.to_datetime('2017-10-31', utc=True), )
@@ -324,7 +607,7 @@ one day prior to the current date.

This strategy is covered in detail in the last part of this tutorial.

Source Code: examples/dual_moving_average.py

-
import matplotlib.pyplot as plt
+
import matplotlib.pyplot as plt
 import numpy as np
 import pandas as pd
 from logbook import Logger
@@ -333,101 +616,101 @@ one day prior to the current date.

from catalyst.api import (record, symbol, order_target_percent,) from catalyst.exchange.utils.stats_utils import extract_transactions -NAMESPACE = 'dual_moving_average' +NAMESPACE = 'dual_moving_average' log = Logger(NAMESPACE) def initialize(context): context.i = 0 - context.asset = symbol('ltc_usd') + context.asset = symbol('ltc_usd') context.base_price = None def handle_data(context, data): - # define the windows for the moving averages + # define the windows for the moving averages short_window = 50 long_window = 200 - # Skip as many bars as long_window to properly compute the average + # Skip as many bars as long_window to properly compute the average context.i += 1 if context.i < long_window: return - # Compute moving averages calling data.history() for each - # moving average with the appropriate parameters. We choose to use - # minute bars for this simulation -> freq="1m" - # Returns a pandas dataframe. + # Compute moving averages calling data.history() for each + # moving average with the appropriate parameters. We choose to use + # minute bars for this simulation -> freq="1m" + # Returns a pandas dataframe. short_data = data.history(context.asset, - 'price', + 'price', bar_count=short_window, - frequency="1T", + frequency="1T", ) short_mavg = short_data.mean() long_data = data.history(context.asset, - 'price', + 'price', bar_count=long_window, - frequency="1T", + frequency="1T", ) long_mavg = long_data.mean() - # Let's keep the price of our asset in a more handy variable - price = data.current(context.asset, 'price') + # Let's keep the price of our asset in a more handy variable + price = data.current(context.asset, 'price') - # If base_price is not set, we use the current value. This is the - # price at the first bar which we reference to calculate price_change. + # If base_price is not set, we use the current value. This is the + # price at the first bar which we reference to calculate price_change. if context.base_price is None: context.base_price = price price_change = (price - context.base_price) / context.base_price - # Save values for later inspection + # Save values for later inspection record(price=price, cash=context.portfolio.cash, price_change=price_change, short_mavg=short_mavg, long_mavg=long_mavg) - # Since we are using limit orders, some orders may not execute immediately - # we wait until all orders are executed before considering more trades. + # Since we are using limit orders, some orders may not execute immediately + # we wait until all orders are executed before considering more trades. orders = context.blotter.open_orders if len(orders) > 0: return - # Exit if we cannot trade + # Exit if we cannot trade if not data.can_trade(context.asset): return - # We check what's our position on our portfolio and trade accordingly + # We check what's our position on our portfolio and trade accordingly pos_amount = context.portfolio.positions[context.asset].amount - # Trading logic + # Trading logic if short_mavg > long_mavg and pos_amount == 0: - # we buy 100% of our portfolio for this asset + # we buy 100% of our portfolio for this asset order_target_percent(context.asset, 1) elif short_mavg < long_mavg and pos_amount > 0: - # we sell all our positions for this asset + # we sell all our positions for this asset order_target_percent(context.asset, 0) def analyze(context, perf): - # Get the base_currency that was passed as a parameter to the simulation + # Get the base_currency that was passed as a parameter to the simulation exchange = list(context.exchanges.values())[0] base_currency = exchange.base_currency.upper() - # First chart: Plot portfolio value using base_currency + # First chart: Plot portfolio value using base_currency ax1 = plt.subplot(411) - perf.loc[:, ['portfolio_value']].plot(ax=ax1) + perf.loc[:, ['portfolio_value']].plot(ax=ax1) ax1.legend_.remove() - ax1.set_ylabel('Portfolio Value\n({})'.format(base_currency)) + ax1.set_ylabel('Portfolio Value\n({})'.format(base_currency)) start, end = ax1.get_ylim() ax1.yaxis.set_ticks(np.arange(start, end, (end - start) / 5)) - # Second chart: Plot asset price, moving averages and buys/sells + # Second chart: Plot asset price, moving averages and buys/sells ax2 = plt.subplot(412, sharex=ax1) - perf.loc[:, ['price', 'short_mavg', 'long_mavg']].plot( + perf.loc[:, ['price', 'short_mavg', 'long_mavg']].plot( ax=ax2, - label='Price') + label='Price') ax2.legend_.remove() - ax2.set_ylabel('{asset}\n({base})'.format( + ax2.set_ylabel('{asset}\n({base})'.format( asset=context.asset.symbol, base=base_currency )) @@ -436,57 +719,57 @@ one day prior to the current date.

transaction_df = extract_transactions(perf) if not transaction_df.empty: - buy_df = transaction_df[transaction_df['amount'] > 0] - sell_df = transaction_df[transaction_df['amount'] < 0] + buy_df = transaction_df[transaction_df['amount'] > 0] + sell_df = transaction_df[transaction_df['amount'] < 0] ax2.scatter( buy_df.index.to_pydatetime(), - perf.loc[buy_df.index, 'price'], - marker='^', + perf.loc[buy_df.index, 'price'], + marker='^', s=100, - c='green', - label='' + c='green', + label='' ) ax2.scatter( sell_df.index.to_pydatetime(), - perf.loc[sell_df.index, 'price'], - marker='v', + perf.loc[sell_df.index, 'price'], + marker='v', s=100, - c='red', - label='' + c='red', + label='' ) - # Third chart: Compare percentage change between our portfolio - # and the price of the asset + # Third chart: Compare percentage change between our portfolio + # and the price of the asset ax3 = plt.subplot(413, sharex=ax1) - perf.loc[:, ['algorithm_period_return', 'price_change']].plot(ax=ax3) + perf.loc[:, ['algorithm_period_return', 'price_change']].plot(ax=ax3) ax3.legend_.remove() - ax3.set_ylabel('Percent Change') + ax3.set_ylabel('Percent Change') start, end = ax3.get_ylim() ax3.yaxis.set_ticks(np.arange(start, end, (end - start) / 5)) - # Fourth chart: Plot our cash + # Fourth chart: Plot our cash ax4 = plt.subplot(414, sharex=ax1) perf.cash.plot(ax=ax4) - ax4.set_ylabel('Cash\n({})'.format(base_currency)) + ax4.set_ylabel('Cash\n({})'.format(base_currency)) start, end = ax4.get_ylim() ax4.yaxis.set_ticks(np.arange(0, end, end / 5)) plt.show() -if __name__ == '__main__': +if __name__ == '__main__': run_algorithm( capital_base=1000, - data_frequency='minute', + data_frequency='minute', initialize=initialize, handle_data=handle_data, analyze=analyze, - exchange_name='bitfinex', + exchange_name='bitfinex', algo_namespace=NAMESPACE, - base_currency='usd', - start=pd.to_datetime('2017-9-22', utc=True), - end=pd.to_datetime('2017-9-23', utc=True), + base_currency='usd', + start=pd.to_datetime('2017-9-22', utc=True), + end=pd.to_datetime('2017-9-23', utc=True), )
@@ -500,19 +783,19 @@ Hopefully, we’ll ride the waves.

We are choosing to backtest this trading algorithm with the neo_usd currency pairon the Bitfinex exchange. Thus, first ingest the historical pricing data that we need, with minute resolution:

-
catalyst ingest-exchange -x bitfinex -f minute -i neo_usd
+
catalyst ingest-exchange -x bitfinex -f minute -i neo_usd
 

To run this algorithm, we are opting for the Python interpreter, instead of the command line (CLI). All of the parameters for the simulation are specified in lines 218-245, so in order to run the algorithm we just type:

-
python mean_reversion_simple.py
+
python mean_reversion_simple.py
 

Source code: examples/mean_reversion_simple.py

-
# For this example, we're going to write a simple momentum script.  When the
-# stock goes up quickly, we're going to buy; when it goes down quickly, we're
-# going to sell.  Hopefully we'll ride the waves.
+
# For this example, we're going to write a simple momentum script.  When the
+# stock goes up quickly, we're going to buy; when it goes down quickly, we're
+# going to sell.  Hopefully we'll ride the waves.
 import os
 import tempfile
 import time
@@ -525,33 +808,33 @@ lines 218-245, so in order to run the algorithm we just type:

from catalyst import run_algorithm from catalyst.api import symbol, record, order_target_percent, get_open_orders from catalyst.exchange.utils.stats_utils import extract_transactions -# We give a name to the algorithm which Catalyst will use to persist its state. -# In this example, Catalyst will create the `.catalyst/data/live_algos` -# directory. If we stop and start the algorithm, Catalyst will resume its -# state using the files included in the folder. +# We give a name to the algorithm which Catalyst will use to persist its state. +# In this example, Catalyst will create the `.catalyst/data/live_algos` +# directory. If we stop and start the algorithm, Catalyst will resume its +# state using the files included in the folder. from catalyst.utils.paths import ensure_directory -NAMESPACE = 'mean_reversion_simple' +NAMESPACE = 'mean_reversion_simple' log = Logger(NAMESPACE) -# To run an algorithm in Catalyst, you need two functions: initialize and -# handle_data. +# To run an algorithm in Catalyst, you need two functions: initialize and +# handle_data. def initialize(context): - # This initialize function sets any data or variables that you'll use in - # your algorithm. For instance, you'll want to define the trading pair (or - # trading pairs) you want to backtest. You'll also want to define any - # parameters or values you're going to use. + # This initialize function sets any data or variables that you'll use in + # your algorithm. For instance, you'll want to define the trading pair (or + # trading pairs) you want to backtest. You'll also want to define any + # parameters or values you're going to use. - # In our example, we're looking at Neo in Ether. - context.market = symbol('bnb_eth') + # In our example, we're looking at Neo in Ether. + context.market = symbol('bnb_eth') context.base_price = None context.current_day = None context.RSI_OVERSOLD = 60 context.RSI_OVERBOUGHT = 70 - context.CANDLE_SIZE = '15T' + context.CANDLE_SIZE = '15T' context.start_time = time.time() @@ -560,94 +843,94 @@ lines 218-245, so in order to run the algorithm we just type:

def handle_data(context, data): - # This handle_data function is where the real work is done. Our data is - # minute-level tick data, and each minute is called a frame. This function - # runs on each frame of the data. + # This handle_data function is where the real work is done. Our data is + # minute-level tick data, and each minute is called a frame. This function + # runs on each frame of the data. - # We flag the first period of each day. - # Since cryptocurrencies trade 24/7 the `before_trading_starts` handle - # would only execute once. This method works with minute and daily - # frequencies. - today = data.current_dt.floor('1D') + # We flag the first period of each day. + # Since cryptocurrencies trade 24/7 the `before_trading_starts` handle + # would only execute once. This method works with minute and daily + # frequencies. + today = data.current_dt.floor('1D') if today != context.current_day: context.traded_today = False context.current_day = today - # We're computing the volume-weighted-average-price of the security - # defined above, in the context.market variable. For this example, we're - # using three bars on the 15 min bars. + # We're computing the volume-weighted-average-price of the security + # defined above, in the context.market variable. For this example, we're + # using three bars on the 15 min bars. - # The frequency attribute determine the bar size. We use this convention - # for the frequency alias: - # http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases + # The frequency attribute determine the bar size. We use this convention + # for the frequency alias: + # http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases prices = data.history( context.market, - fields='close', + fields='close', bar_count=50, frequency=context.CANDLE_SIZE ) - # Ta-lib calculates various technical indicator based on price and - # volume arrays. + # Ta-lib calculates various technical indicator based on price and + # volume arrays. - # In this example, we are comp + # In this example, we are comp rsi = talib.RSI(prices.values, timeperiod=14) - # We need a variable for the current price of the security to compare to - # the average. Since we are requesting two fields, data.current() - # returns a DataFrame with - current = data.current(context.market, fields=['close', 'volume']) - price = current['close'] + # We need a variable for the current price of the security to compare to + # the average. Since we are requesting two fields, data.current() + # returns a DataFrame with + current = data.current(context.market, fields=['close', 'volume']) + price = current['close'] - # If base_price is not set, we use the current value. This is the - # price at the first bar which we reference to calculate price_change. + # If base_price is not set, we use the current value. This is the + # price at the first bar which we reference to calculate price_change. if context.base_price is None: context.base_price = price price_change = (price - context.base_price) / context.base_price cash = context.portfolio.cash - # Now that we've collected all current data for this frame, we use - # the record() method to save it. This data will be available as - # a parameter of the analyze() function for further analysis. + # Now that we've collected all current data for this frame, we use + # the record() method to save it. This data will be available as + # a parameter of the analyze() function for further analysis. record( - volume=current['volume'], + volume=current['volume'], price=price, price_change=price_change, rsi=rsi[-1], cash=cash ) - # We are trying to avoid over-trading by limiting our trades to - # one per day. + # We are trying to avoid over-trading by limiting our trades to + # one per day. if context.traded_today: return - # TODO: retest with open orders - # Since we are using limit orders, some orders may not execute immediately - # we wait until all orders are executed before considering more trades. + # TODO: retest with open orders + # Since we are using limit orders, some orders may not execute immediately + # we wait until all orders are executed before considering more trades. orders = context.blotter.open_orders if len(orders) > 0: - log.info('exiting because orders are open: {}'.format(orders)) + log.info('exiting because orders are open: {}'.format(orders)) return - # Exit if we cannot trade + # Exit if we cannot trade if not data.can_trade(context.market): return - # Another powerful built-in feature of the Catalyst backtester is the - # portfolio object. The portfolio object tracks your positions, cash, - # cost basis of specific holdings, and more. In this line, we calculate - # how long or short our position is at this minute. + # Another powerful built-in feature of the Catalyst backtester is the + # portfolio object. The portfolio object tracks your positions, cash, + # cost basis of specific holdings, and more. In this line, we calculate + # how long or short our position is at this minute. pos_amount = context.portfolio.positions[context.market].amount if rsi[-1] <= context.RSI_OVERSOLD and pos_amount == 0: log.info( - '{}: buying - price: {}, rsi: {}'.format( + '{}: buying - price: {}, rsi: {}'.format( data.current_dt, price, rsi[-1] ) ) - # Set a style for limit orders, + # Set a style for limit orders, limit_price = price * 1.005 order_target_percent( context.market, 1, limit_price=limit_price @@ -656,7 +939,7 @@ lines 218-245, so in order to run the algorithm we just type:

elif rsi[-1] >= context.RSI_OVERBOUGHT and pos_amount > 0: log.info( - '{}: selling - price: {}, rsi: {}'.format( + '{}: selling - price: {}, rsi: {}'.format( data.current_dt, price, rsi[-1] ) ) @@ -669,93 +952,93 @@ lines 218-245, so in order to run the algorithm we just type:

def analyze(context=None, perf=None): end = time.time() - log.info('elapsed time: {}'.format(end - context.start_time)) + log.info('elapsed time: {}'.format(end - context.start_time)) import matplotlib.pyplot as plt - # The base currency of the algo exchange + # The base currency of the algo exchange base_currency = list(context.exchanges.values())[0].base_currency.upper() - # Plot the portfolio value over time. + # Plot the portfolio value over time. ax1 = plt.subplot(611) - perf.loc[:, 'portfolio_value'].plot(ax=ax1) - ax1.set_ylabel('Portfolio\nValue\n({})'.format(base_currency)) + perf.loc[:, 'portfolio_value'].plot(ax=ax1) + ax1.set_ylabel('Portfolio\nValue\n({})'.format(base_currency)) - # Plot the price increase or decrease over time. + # Plot the price increase or decrease over time. ax2 = plt.subplot(612, sharex=ax1) - perf.loc[:, 'price'].plot(ax=ax2, label='Price') + perf.loc[:, 'price'].plot(ax=ax2, label='Price') - ax2.set_ylabel('{asset}\n({base})'.format( + ax2.set_ylabel('{asset}\n({base})'.format( asset=context.market.symbol, base=base_currency )) transaction_df = extract_transactions(perf) if not transaction_df.empty: - buy_df = transaction_df[transaction_df['amount'] > 0] - sell_df = transaction_df[transaction_df['amount'] < 0] + buy_df = transaction_df[transaction_df['amount'] > 0] + sell_df = transaction_df[transaction_df['amount'] < 0] ax2.scatter( buy_df.index.to_pydatetime(), - perf.loc[buy_df.index.floor('1 min'), 'price'], - marker='^', + perf.loc[buy_df.index.floor('1 min'), 'price'], + marker='^', s=100, - c='green', - label='' + c='green', + label='' ) ax2.scatter( sell_df.index.to_pydatetime(), - perf.loc[sell_df.index.floor('1 min'), 'price'], - marker='v', + perf.loc[sell_df.index.floor('1 min'), 'price'], + marker='v', s=100, - c='red', - label='' + c='red', + label='' ) ax4 = plt.subplot(613, sharex=ax1) - perf.loc[:, 'cash'].plot( - ax=ax4, label='Base Currency ({})'.format(base_currency) + perf.loc[:, 'cash'].plot( + ax=ax4, label='Base Currency ({})'.format(base_currency) ) - ax4.set_ylabel('Cash\n({})'.format(base_currency)) + ax4.set_ylabel('Cash\n({})'.format(base_currency)) - perf['algorithm'] = perf.loc[:, 'algorithm_period_return'] + perf['algorithm'] = perf.loc[:, 'algorithm_period_return'] ax5 = plt.subplot(614, sharex=ax1) - perf.loc[:, ['algorithm', 'price_change']].plot(ax=ax5) - ax5.set_ylabel('Percent\nChange') + perf.loc[:, ['algorithm', 'price_change']].plot(ax=ax5) + ax5.set_ylabel('Percent\nChange') ax6 = plt.subplot(615, sharex=ax1) - perf.loc[:, 'rsi'].plot(ax=ax6, label='RSI') - ax6.set_ylabel('RSI') - ax6.axhline(context.RSI_OVERBOUGHT, color='darkgoldenrod') - ax6.axhline(context.RSI_OVERSOLD, color='darkgoldenrod') + perf.loc[:, 'rsi'].plot(ax=ax6, label='RSI') + ax6.set_ylabel('RSI') + ax6.axhline(context.RSI_OVERBOUGHT, color='darkgoldenrod') + ax6.axhline(context.RSI_OVERSOLD, color='darkgoldenrod') if not transaction_df.empty: ax6.scatter( buy_df.index.to_pydatetime(), - perf.loc[buy_df.index.floor('1 min'), 'rsi'], - marker='^', + perf.loc[buy_df.index.floor('1 min'), 'rsi'], + marker='^', s=100, - c='green', - label='' + c='green', + label='' ) ax6.scatter( sell_df.index.to_pydatetime(), - perf.loc[sell_df.index.floor('1 min'), 'rsi'], - marker='v', + perf.loc[sell_df.index.floor('1 min'), 'rsi'], + marker='v', s=100, - c='red', - label='' + c='red', + label='' ) plt.legend(loc=3) start, end = ax6.get_ylim() ax6.yaxis.set_ticks(np.arange(0, end, end / 5)) - # Show the plot. + # Show the plot. plt.gcf().set_size_inches(18, 8) plt.show() pass -if __name__ == '__main__': - # The execution mode: backtest or live +if __name__ == '__main__': + # The execution mode: backtest or live live = True if live: @@ -764,41 +1047,41 @@ lines 218-245, so in order to run the algorithm we just type:

initialize=initialize, handle_data=handle_data, analyze=analyze, - exchange_name='binance', + exchange_name='binance', live=True, algo_namespace=NAMESPACE, - base_currency='eth', + base_currency='eth', live_graph=False, simulate_orders=False, stats_output=None, - # auth_aliases=dict(poloniex='auth2') + # auth_aliases=dict(poloniex='auth2') ) else: folder = os.path.join( - tempfile.gettempdir(), 'catalyst', NAMESPACE + tempfile.gettempdir(), 'catalyst', NAMESPACE ) ensure_directory(folder) - timestr = time.strftime('%Y%m%d-%H%M%S') - out = os.path.join(folder, '{}.p'.format(timestr)) - # catalyst run -f catalyst/examples/mean_reversion_simple.py \ - # -x bitfinex -s 2017-10-1 -e 2017-11-10 -c usdt -n mean-reversion \ - # --data-frequency minute --capital-base 10000 + timestr = time.strftime('%Y%m%d-%H%M%S') + out = os.path.join(folder, '{}.p'.format(timestr)) + # catalyst run -f catalyst/examples/mean_reversion_simple.py \ + # -x bitfinex -s 2017-10-1 -e 2017-11-10 -c usdt -n mean-reversion \ + # --data-frequency minute --capital-base 10000 run_algorithm( capital_base=0.035, - data_frequency='minute', + data_frequency='minute', initialize=initialize, handle_data=handle_data, analyze=analyze, - exchange_name='bitfinex', + exchange_name='bitfinex', algo_namespace=NAMESPACE, - base_currency='btc', - start=pd.to_datetime('2017-10-01', utc=True), - end=pd.to_datetime('2017-11-10', utc=True), + base_currency='btc', + start=pd.to_datetime('2017-10-01', utc=True), + end=pd.to_datetime('2017-11-10', utc=True), output=out ) - log.info('saved perf stats: {}'.format(out)) + log.info('saved perf stats: {}'.format(out))
https://s3.amazonaws.com/enigmaco-docs/github.io/example_mean_reversion_simple.png @@ -830,11 +1113,11 @@ environment). The first one retrieves all the pricing data needed for this script to run (only needs to be run once), and the second one executes this script with the parameters specified in the run_algorithm() call at the end of the file:

-
catalyst ingest-exchange -x bitfinex -f minute
+
catalyst ingest-exchange -x bitfinex -f minute
 

Source code: examples/simple_universe.py

-
"""
+
"""
 Requires Catalyst version 0.3.0 or above
 Tested on Catalyst version 0.3.3
 
@@ -876,67 +1159,67 @@ of the file:

def initialize(context): - context.i = -1 # minute counter + context.i = -1 # minute counter context.exchange = list(context.exchanges.values())[0].name.lower() context.base_currency = list(context.exchanges.values())[0].base_currency.lower() def handle_data(context, data): context.i += 1 - lookback_days = 7 # 7 days + lookback_days = 7 # 7 days - # current date & time in each iteration formatted into a string + # current date & time in each iteration formatted into a string now = data.current_dt - date, time = now.strftime('%Y-%m-%d %H:%M:%S').split(' ') + date, time = now.strftime('%Y-%m-%d %H:%M:%S').split(' ') lookback_date = now - timedelta(days=lookback_days) - # keep only the date as a string, discard the time - lookback_date = lookback_date.strftime('%Y-%m-%d %H:%M:%S').split(' ')[0] + # keep only the date as a string, discard the time + lookback_date = lookback_date.strftime('%Y-%m-%d %H:%M:%S').split(' ')[0] - one_day_in_minutes = 1440 # 60 * 24 assumes data_frequency='minute' - # update universe everyday at midnight + one_day_in_minutes = 1440 # 60 * 24 assumes data_frequency='minute' + # update universe everyday at midnight if not context.i % one_day_in_minutes: context.universe = universe(context, lookback_date, date) - # get data every 30 minutes + # get data every 30 minutes minutes = 30 - # get lookback_days of history data: that is 'lookback' number of bins + # get lookback_days of history data: that is 'lookback' number of bins lookback = int(one_day_in_minutes / minutes * lookback_days) if not context.i % minutes and context.universe: - # we iterate for every pair in the current universe + # we iterate for every pair in the current universe for coin in context.coins: pair = str(coin.symbol) - # Get 30 minute interval OHLCV data. This is the standard data - # required for candlestick or indicators/signals. Return Pandas - # DataFrames. 30T means 30-minute re-sampling of one minute data. - # Adjust it to your desired time interval as needed. + # Get 30 minute interval OHLCV data. This is the standard data + # required for candlestick or indicators/signals. Return Pandas + # DataFrames. 30T means 30-minute re-sampling of one minute data. + # Adjust it to your desired time interval as needed. opened = fill(data.history(coin, - 'open', + 'open', bar_count=lookback, - frequency='30T')).values + frequency='30T')).values high = fill(data.history(coin, - 'high', + 'high', bar_count=lookback, - frequency='30T')).values + frequency='30T')).values low = fill(data.history(coin, - 'low', + 'low', bar_count=lookback, - frequency='30T')).values + frequency='30T')).values close = fill(data.history(coin, - 'price', + 'price', bar_count=lookback, - frequency='30T')).values + frequency='30T')).values volume = fill(data.history(coin, - 'volume', + 'volume', bar_count=lookback, - frequency='30T')).values + frequency='30T')).values - # close[-1] is the last value in the set, which is the equivalent - # to current price (as in the most recent value) - # displays the minute price for each pair every 30 minutes - print('{now}: {pair} -\tO:{o},\tH:{h},\tL:{c},\tC{c},' - '\tV:{v}'.format( + # close[-1] is the last value in the set, which is the equivalent + # to current price (as in the most recent value) + # displays the minute price for each pair every 30 minutes + print('{now}: {pair} -\tO:{o},\tH:{h},\tL:{c},\tC{c},' + '\tV:{v}'.format( now=now, pair=pair, o=opened[-1], @@ -946,39 +1229,39 @@ of the file:

v=volume[-1], )) - # ------------------------------------------------------------- - # --------------- Insert Your Strategy Here ------------------- - # ------------------------------------------------------------- + # ------------------------------------------------------------- + # --------------- Insert Your Strategy Here ------------------- + # ------------------------------------------------------------- def analyze(context=None, results=None): pass -# Get the universe for a given exchange and a given base_currency market -# Example: Poloniex BTC Market +# Get the universe for a given exchange and a given base_currency market +# Example: Poloniex BTC Market def universe(context, lookback_date, current_date): - # get all the pairs for the given exchange + # get all the pairs for the given exchange json_symbols = get_exchange_symbols(context.exchange) - # convert into a DataFrame for easier processing + # convert into a DataFrame for easier processing df = pd.DataFrame.from_dict(json_symbols).transpose().astype(str) - df['base_currency'] = df.apply(lambda row: row.symbol.split('_')[1], + df['base_currency'] = df.apply(lambda row: row.symbol.split('_')[1], axis=1) - df['market_currency'] = df.apply(lambda row: row.symbol.split('_')[0], + df['market_currency'] = df.apply(lambda row: row.symbol.split('_')[0], axis=1) - # Filter all the pairs to get only the ones for a given base_currency - df = df[df['base_currency'] == context.base_currency] + # Filter all the pairs to get only the ones for a given base_currency + df = df[df['base_currency'] == context.base_currency] - # Filter all pairs to ensure that pair existed in the current date range + # Filter all pairs to ensure that pair existed in the current date range df = df[df.start_date < lookback_date] df = df[df.end_daily >= current_date] - context.coins = symbols(*df.symbol) # convert all the pairs to symbols + context.coins = symbols(*df.symbol) # convert all the pairs to symbols return df.symbol.tolist() -# Replace all NA, NAN or infinite values with its nearest value +# Replace all NA, NAN or infinite values with its nearest value def fill(series): if isinstance(series, pd.Series): return series.replace([np.inf, -np.inf], np.nan).ffill().bfill() @@ -990,21 +1273,21 @@ of the file:

return series -if __name__ == '__main__': - start_date = pd.to_datetime('2017-11-10', utc=True) - end_date = pd.to_datetime('2017-11-13', utc=True) +if __name__ == '__main__': + start_date = pd.to_datetime('2017-11-10', utc=True) + end_date = pd.to_datetime('2017-11-13', utc=True) performance = run_algorithm(start=start_date, end=end_date, - capital_base=100.0, # amount of base_currency + capital_base=100.0, # amount of base_currency initialize=initialize, handle_data=handle_data, analyze=analyze, - exchange_name='poloniex', - data_frequency='minute', - base_currency='btc', + exchange_name='poloniex', + data_frequency='minute', + base_currency='btc', live=False, live_graph=False, - algo_namespace='simple_universe') + algo_namespace='simple_universe')
@@ -1016,7 +1299,7 @@ use 180 days of historical data and rebalance every 30 days. This code was used in writting the following article: Markowitz Portfolio Optimization for Cryptocurrencies.

Source code: examples/simple_universe.py

-
'''Use this code to execute a portfolio optimization model. This code
+
'''Use this code to execute a portfolio optimization model. This code
    will select the portfolio with the maximum Sharpe Ratio. The parameters
    are set to use 180 days of historical data and rebalance every 30 days.
 
@@ -1039,49 +1322,49 @@ in writting the following article:
 from catalyst.api import record, symbols, order_target_percent
 from catalyst.utils.run_algo import run_algorithm
 
-np.set_printoptions(threshold='nan', suppress=True)
+np.set_printoptions(threshold='nan', suppress=True)
 
 
 def initialize(context):
-    # Portfolio assets list
-    context.assets = symbols('btc_usdt', 'eth_usdt', 'ltc_usdt', 'dash_usdt',
-                             'xmr_usdt')
+    # Portfolio assets list
+    context.assets = symbols('btc_usdt', 'eth_usdt', 'ltc_usdt', 'dash_usdt',
+                             'xmr_usdt')
     context.nassets = len(context.assets)
-    # Set the time window that will be used to compute expected return
-    # and asset correlations
+    # Set the time window that will be used to compute expected return
+    # and asset correlations
     context.window = 180
-    # Set the number of days between each portfolio rebalancing
+    # Set the number of days between each portfolio rebalancing
     context.rebalance_period = 30
     context.i = 0
 
 
 def handle_data(context, data):
-    # Only rebalance at the beggining of the algorithm execution and
-    # every multiple of the rebalance period
+    # Only rebalance at the beggining of the algorithm execution and
+    # every multiple of the rebalance period
     if context.i == 0 or context.i % context.rebalance_period == 0:
         n = context.window
-        prices = data.history(context.assets, fields='price',
-                              bar_count=n + 1, frequency='1d')
+        prices = data.history(context.assets, fields='price',
+                              bar_count=n + 1, frequency='1d')
         pr = np.asmatrix(prices)
         t_prices = prices.iloc[1:n + 1]
         t_val = t_prices.values
         tminus_prices = prices.iloc[0:n]
         tminus_val = tminus_prices.values
-        # Compute daily returns (r)
+        # Compute daily returns (r)
         r = np.asmatrix(t_val / tminus_val - 1)
-        # Compute the expected returns of each asset with the average
-        # daily return for the selected time window
+        # Compute the expected returns of each asset with the average
+        # daily return for the selected time window
         m = np.asmatrix(np.mean(r, axis=0))
-        # ###
+        # ###
         stds = np.std(r, axis=0)
-        # Compute excess returns matrix (xr)
+        # Compute excess returns matrix (xr)
         xr = r - m
-        # Matrix algebra to get variance-covariance matrix
+        # Matrix algebra to get variance-covariance matrix
         cov_m = np.dot(np.transpose(xr), xr) / n
-        # Compute asset correlation matrix (informative only)
+        # Compute asset correlation matrix (informative only)
         corr_m = cov_m / np.dot(np.transpose(stds), stds)
 
-        # Define portfolio optimization parameters
+        # Define portfolio optimization parameters
         n_portfolios = 50000
         results_array = np.zeros((3 + context.nassets, n_portfolios))
         for p in range(n_portfolios):
@@ -1092,47 +1375,47 @@ in writting the following article:
             p_std = np.sqrt(np.dot(np.dot(w, cov_m),
                                    np.transpose(w))) * np.sqrt(365)
 
-            # store results in results array
+            # store results in results array
             results_array[0, p] = p_r
             results_array[1, p] = p_std
-            # store Sharpe Ratio (return / volatility) - risk free rate element
-            # excluded for simplicity
+            # store Sharpe Ratio (return / volatility) - risk free rate element
+            # excluded for simplicity
             results_array[2, p] = results_array[0, p] / results_array[1, p]
             i = 0
             for iw in weights:
                 results_array[3 + i, p] = weights[i]
                 i += 1
 
-        # convert results array to Pandas DataFrame
+        # convert results array to Pandas DataFrame
         results_frame = pd.DataFrame(np.transpose(results_array),
-                                     columns=['r', 'stdev', 'sharpe']
+                                     columns=['r', 'stdev', 'sharpe']
                                              + context.assets)
-        # locate position of portfolio with highest Sharpe Ratio
-        max_sharpe_port = results_frame.iloc[results_frame['sharpe'].idxmax()]
-        # locate positon of portfolio with minimum standard deviation
-        # min_vol_port = results_frame.iloc[results_frame['stdev'].idxmin()]
+        # locate position of portfolio with highest Sharpe Ratio
+        max_sharpe_port = results_frame.iloc[results_frame['sharpe'].idxmax()]
+        # locate positon of portfolio with minimum standard deviation
+        # min_vol_port = results_frame.iloc[results_frame['stdev'].idxmin()]
 
-        # order optimal weights for each asset
+        # order optimal weights for each asset
         for asset in context.assets:
             if data.can_trade(asset):
                 order_target_percent(asset, max_sharpe_port[asset])
 
-        # create scatter plot coloured by Sharpe Ratio
+        # create scatter plot coloured by Sharpe Ratio
         plt.scatter(results_frame.stdev,
                     results_frame.r,
                     c=results_frame.sharpe,
-                    cmap='RdYlGn')
-        plt.xlabel('Volatility')
-        plt.ylabel('Returns')
+                    cmap='RdYlGn')
+        plt.xlabel('Volatility')
+        plt.ylabel('Returns')
         plt.colorbar()
-        # plot red star to highlight position of portfolio
-        # with highest Sharpe Ratio
+        # plot red star to highlight position of portfolio
+        # with highest Sharpe Ratio
         plt.scatter(max_sharpe_port[1],
                     max_sharpe_port[0],
-                    marker='o',
-                    color='b',
+                    marker='o',
+                    color='b',
                     s=200)
-        # plot green star to highlight position of minimum variance portfolio
+        # plot green star to highlight position of minimum variance portfolio
         plt.show()
         print(max_sharpe_port)
         record(pr=pr,
@@ -1145,17 +1428,17 @@ in writting the following article:
 
 
 def analyze(context=None, results=None):
-    # Form DataFrame with selected data
-    data = results[['pr', 'r', 'm', 'stds', 'max_sharpe_port', 'corr_m',
-                    'portfolio_value']]
+    # Form DataFrame with selected data
+    data = results[['pr', 'r', 'm', 'stds', 'max_sharpe_port', 'corr_m',
+                    'portfolio_value']]
 
-    # Save results in CSV file
-    filename = os.path.splitext(os.path.basename(__file__))[0]
-    data.to_csv(filename + '.csv')
+    # Save results in CSV file
+    filename = os.path.splitext(os.path.basename(__file__))[0]
+    data.to_csv(filename + '.csv')
 
 
-if __name__ == '__main__':
-    # Bitcoin data is available from 2015-3-2. Dates vary for other tokens.
+if __name__ == '__main__':
+    # Bitcoin data is available from 2015-3-2. Dates vary for other tokens.
     start = datetime(2017, 1, 1, 0, 0, 0, 0, pytz.utc)
     end = datetime(2017, 8, 16, 0, 0, 0, 0, pytz.utc)
     results = run_algorithm(initialize=initialize,
@@ -1163,9 +1446,9 @@ in writting the following article:
                             analyze=analyze,
                             start=start,
                             end=end,
-                            exchange_name='poloniex',
+                            exchange_name='poloniex',
                             capital_base=100000,
-                            base_currency='usdt', )
+                            base_currency='usdt', )
 
https://cdn-images-1.medium.com/max/1600/0*EjjiKZHlYF3sn7yQ. @@ -1174,69 +1457,68 @@ in writting the following article:
-
-
- -
-
- - - + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/features.html b/features.html index 981851f8..8a9ba6fd 100644 --- a/features.html +++ b/features.html @@ -1,52 +1,335 @@ - - - - - Features — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Features — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+ +
+
+

Features

@@ -119,29 +402,29 @@ exchange. Catalyst will always expect in all its functions that you will refer t the asset pairs by using the Catalyst naming convention.

If at any point, you input the wrong name for an asset pair, you will get an error of that pair not found in the given exchange, and a list of pairs available on that exchange:

-
$ catalyst ingest-exchange -x poloniex -i btc_usd
+
$ catalyst ingest-exchange -x poloniex -i btc_usd
 
-
Ingesting exchange bundle poloniex...
+
Ingesting exchange bundle poloniex...
 Error traceback: /Volumes/Data/Users/victoris/Desktop/Enigma/user-install/catalyst-dev/catalyst/exchange/exchange.py (line 175)
 SymbolNotFoundOnExchange:  Symbol btc_usd not found on exchange Poloniex.
-Choose from: ['rep_usdt', 'gno_btc', 'xvc_btc', 'pink_btc', 'sys_btc',
-'emc2_btc', 'rads_btc', 'note_btc', 'maid_btc', 'bch_btc', 'gnt_btc',
-'bcn_btc', 'rep_btc', 'bcy_btc', 'cvc_btc', 'nxt_xmr', 'zec_usdt',
-'fct_btc', 'gas_btc', 'pot_btc', 'eth_usdt', 'btc_usdt', 'lbc_btc',
-'dcr_btc', 'etc_usdt', 'omg_eth', 'amp_btc', 'xpm_btc', 'nxt_btc',
-'vtc_btc', 'steem_eth', 'blk_xmr', 'pasc_btc', 'zec_xmr', 'grc_btc',
-'nxc_btc', 'btcd_btc', 'ltc_btc', 'dash_btc', 'naut_btc', 'zec_eth',
-'zec_btc', 'burst_btc', 'zrx_eth', 'bela_btc', 'steem_btc', 'etc_btc',
-'eth_btc', 'huc_btc', 'strat_btc', 'lsk_btc', 'exp_btc', 'clam_btc',
-'rep_eth', 'dash_xmr', 'cvc_eth', 'bch_usdt', 'zrx_btc', 'dash_usdt',
-'blk_btc', 'xrp_btc', 'nxt_usdt', 'neos_btc', 'omg_btc', 'bts_btc',
-'doge_btc', 'gnt_eth', 'sbd_btc', 'gno_eth', 'xcp_btc', 'ltc_usdt',
-'btm_btc', 'xmr_usdt', 'lsk_eth', 'omni_btc', 'nav_btc', 'fldc_btc',
-'ppc_btc', 'xbc_btc', 'dgb_btc', 'sc_btc', 'btcd_xmr', 'vrc_btc',
-'ric_btc', 'str_btc', 'maid_xmr', 'xmr_btc', 'sjcx_btc', 'via_btc',
-'xem_btc', 'nmc_btc', 'etc_eth', 'ltc_xmr', 'ardr_btc', 'gas_eth',
-'flo_btc', 'xrp_usdt', 'game_btc', 'bch_eth', 'bcn_xmr', 'str_usdt']
+Choose from: ['rep_usdt', 'gno_btc', 'xvc_btc', 'pink_btc', 'sys_btc',
+'emc2_btc', 'rads_btc', 'note_btc', 'maid_btc', 'bch_btc', 'gnt_btc',
+'bcn_btc', 'rep_btc', 'bcy_btc', 'cvc_btc', 'nxt_xmr', 'zec_usdt',
+'fct_btc', 'gas_btc', 'pot_btc', 'eth_usdt', 'btc_usdt', 'lbc_btc',
+'dcr_btc', 'etc_usdt', 'omg_eth', 'amp_btc', 'xpm_btc', 'nxt_btc',
+'vtc_btc', 'steem_eth', 'blk_xmr', 'pasc_btc', 'zec_xmr', 'grc_btc',
+'nxc_btc', 'btcd_btc', 'ltc_btc', 'dash_btc', 'naut_btc', 'zec_eth',
+'zec_btc', 'burst_btc', 'zrx_eth', 'bela_btc', 'steem_btc', 'etc_btc',
+'eth_btc', 'huc_btc', 'strat_btc', 'lsk_btc', 'exp_btc', 'clam_btc',
+'rep_eth', 'dash_xmr', 'cvc_eth', 'bch_usdt', 'zrx_btc', 'dash_usdt',
+'blk_btc', 'xrp_btc', 'nxt_usdt', 'neos_btc', 'omg_btc', 'bts_btc',
+'doge_btc', 'gnt_eth', 'sbd_btc', 'gno_eth', 'xcp_btc', 'ltc_usdt',
+'btm_btc', 'xmr_usdt', 'lsk_eth', 'omni_btc', 'nav_btc', 'fldc_btc',
+'ppc_btc', 'xbc_btc', 'dgb_btc', 'sc_btc', 'btcd_xmr', 'vrc_btc',
+'ric_btc', 'str_btc', 'maid_xmr', 'xmr_btc', 'sjcx_btc', 'via_btc',
+'xem_btc', 'nmc_btc', 'etc_eth', 'ltc_xmr', 'ardr_btc', 'gas_eth',
+'flo_btc', 'xrp_usdt', 'game_btc', 'bch_eth', 'bcn_xmr', 'str_usdt']
 

In the example above, exchange Poloniex does not use USD, but uses instead the @@ -149,10 +432,10 @@ USDT cryptocurrency asset that is issued on the Bitcoin blockchain via the Omni Layer Protocol. Each USDT unit is backed by a U.S Dollar held in the reserves of Tether Limited. USDT can be transferred, stored, and spent, just like bitcoins or any other cryptocurrency. Given its 1:1 mapping to the USD, is a viable alternative.

-
$ catalyst ingest-exchange -x poloniex -i btc_usdt
+
$ catalyst ingest-exchange -x poloniex -i btc_usdt
 
-
Ingesting exchange bundle poloniex...
+
Ingesting exchange bundle poloniex...
     [====================================]  Fetching poloniex daily candles: :  100%
 
@@ -161,65 +444,68 @@ or any other cryptocurrency. Given its 1:1 mapping to the USD, is a viable alter
-
-
- -
-
- - - + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/genindex.html b/genindex.html index 7e41e8d9..5ee9c11e 100644 --- a/genindex.html +++ b/genindex.html @@ -1,88 +1,759 @@ - - - - - Index — Catalyst 0.4 documentation - - - - - - - - - - - + + + + + + + + + Index — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • +
  • + + + +
  • +
+
+
+

Index

+ A + | B + | C + | D + | E + | F + | G + | I + | L + | M + | N + | O + | P + | R + | S + | T + | V + | W
+

A

+ + + +
+ +

B

+ + +
+ +

C

+ + + +
+ +

D

+ + + +
+ +

E

+ + + +
+ +

F

+ + + +
+ +

G

+ + + +
+ +

I

+ + + +
+ +

L

+ + +
+ +

M

+ + + +
+ +

N

+ + + +
+ +

O

+ + + +
+ +

P

+ + + +
+ +

R

+ + + +
+ +

S

+ + + +
+ +

T

+ + + +
+ +

V

+ + +
+ +

W

+ + + +
+
+
+ + +
+ +
+

+ © Copyright 2018, Enigma MPC, Inc.. +

+
+ Built with Sphinx using a theme provided by Read the Docs. + +
+
-
+ +
+ + + + + + + + + + + + + + + + + + + + - - -
-
-
-
- - - + \ No newline at end of file diff --git a/index.html b/index.html index d9daed20..56cabf5d 100644 --- a/index.html +++ b/index.html @@ -1,48 +1,334 @@ - - - - - Overview — Catalyst 0.4 documentation - - - - - - - - - - - - + + + + + + + + + Overview — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+ +
+
+
Enigma | Catalyst

version tag @@ -119,57 +405,66 @@ performance across trading algorithms.

-
-
- -
-
- - - + + + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/install.html b/install.html index 11748863..ad1b48de 100644 --- a/install.html +++ b/install.html @@ -1,52 +1,335 @@ - - - - - Install — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Install — Catalyst 0.4 documentation + -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+ +
+
+

Install

@@ -116,7 +399,7 @@ to a folder you can remember. Make sure that the file gets saved with the saved the above .yml file.

  • Install using this file. This step can take about 5-10 minutes to install.

    -
    conda env create -f python3.6-environment.yml
    +
    conda env create -f python3.6-environment.yml
     
  • @@ -124,7 +407,7 @@ saved the above .yml

    or

    -
    conda env create -f python2.7-environment.yml
    +
    conda env create -f python2.7-environment.yml
     
    @@ -133,16 +416,16 @@ saved the above .yml

    Activate the environment (which you need to do every time you start a new session to run Catalyst):

    Linux or MacOS:

    -
    source activate catalyst
    +
    source activate catalyst
     

    Windows:

    -
    activate catalyst
    +
    activate catalyst
     
  • Verify that Catalyst is install correctly:

    -
    catalyst --version
    +
    catalyst --version
     

    which should display the current version.

    @@ -158,13 +441,13 @@ with the following steps:

  • If the above installation failed, and you have a partially set up catalyst environment, remove it first. If you are starting from scratch, proceed to step #2:

    -
    conda env remove --name catalyst
    +
    conda env remove --name catalyst
     
  • Create the environment:

    for python 2.7:

    -
    conda create --name catalyst python=2.7 scipy zlib
    +
    conda create --name catalyst python=2.7 scipy zlib
     
  • @@ -172,7 +455,7 @@ step #2:

    or for python 3.6:

    -
    conda create --name catalyst python=3.6 scipy zlib
    +
    conda create --name catalyst python=3.6 scipy zlib
     
    @@ -180,21 +463,21 @@ step #2:

    1. Activate the environment:

      Linux or MacOS:

      -
      source activate catalyst
      +
      source activate catalyst
       

      Windows:

      -
      activate catalyst
      +
      activate catalyst
       
    2. Install the Catalyst inside the environment:

      -
      pip install enigma-catalyst matplotlib
      +
      pip install enigma-catalyst matplotlib
       
    3. Verify that Catalyst is installed correctly:

      -
      catalyst --version
      +
      catalyst --version
       

      which should display the current version.

      @@ -224,14 +507,14 @@ distribution, refer to the virtualenv. The Hitchhiker’s Guide to Python provides an excellent tutorial on virtualenv. Here’s a summarized version:

      -
      $ pip install virtualenv
      -$ virtualenv catalyst-venv
      -$ source ./catalyst-venv/bin/activate
      +
      $ pip install virtualenv
      +$ virtualenv catalyst-venv
      +$ source ./catalyst-venv/bin/activate
       

      Once you’ve installed the necessary additional dependencies for your system (GNU/Linux Requirements, MacOS Requirements or Windows Requirements) and have activated your virtualenv, you should be able to simply run

      -
      $ pip install enigma-catalyst matplotlib
      +
      $ pip install enigma-catalyst matplotlib
       

      Note that in the command above we install two different packages. The second @@ -246,11 +529,11 @@ recommend you install it, as well.

      Package enigma-catalyst cannot be found
      Solution:

      Make sure you have the most up-to-date version of pip installed, by running:

      -
      $ pip install --upgrade pip
      +
      $ pip install --upgrade pip
       

      On Windows, the recommended command is:

      -
      $ python -m pip install --upgrade pip
      +
      $ python -m pip install --upgrade pip
       
      @@ -260,10 +543,10 @@ recommend you install it, as well.

      Issue:

      Package enigma-catalyst cannot still be found, even after upgrading pip (see above), with an error similar to:

      -
      Downloading/unpacking enigma-catalyst
      +
      Downloading/unpacking enigma-catalyst
       Could not find a version that satisfies the requirement enigma-catalyst
      -(from versions: 0.1.dev9, 0.2.dev2, 0.1.dev4, 0.1.dev5, 0.1.dev3,
      -0.2.dev1, 0.1.dev8, 0.1.dev6)
      +(from versions: 0.1.dev9, 0.2.dev2, 0.1.dev4, 0.1.dev5, 0.1.dev3,
      +0.2.dev1, 0.1.dev8, 0.1.dev6)
       Cleaning up...
       No distributions matching the version for enigma-catalyst
       
      @@ -275,7 +558,7 @@ to only find stable versions by default. Since Catalyst is in alpha version, pip cannot find a matching version that satisfies the installation requirements. The solution is to include the –pre flag to include pre-release and development versions:

      -
      $ pip install --pre enigma-catalyst
      +
      $ pip install --pre enigma-catalyst
       
      @@ -286,7 +569,7 @@ pre-release and development versions:

      Package enigma-catalyst fails to install because of outdated setuptools
      Solution:

      Upgrade to the most up-to-date setuptools package by running:

      -
      $ pip install --upgrade pip setuptools
      +
      $ pip install --upgrade pip setuptools
       
      @@ -299,7 +582,7 @@ pre-release and development versions:

      Download requirements.txt (click on the Raw button and Right click -> Save As…) and use it to install all the required dependencies by running:

      -
      $ pip install -r requirements.txt
      +
      $ pip install -r requirements.txt
       
      @@ -314,7 +597,7 @@ install all the required dependencies by running:

      for the proper build and installation of package dependencies. The solution is to install python-dev, which is independent of the virtual environment. In Ubuntu, you would need to run:

      -
      $ sudo apt-get install python-dev
      +
      $ sudo apt-get install python-dev
       
      @@ -333,21 +616,21 @@ In Ubuntu, you would need to run:

      Installing with pipenv

      Installing Catalyst via pipenv is perhaps easier that installing it via pip itself but you need to install pipenv first via pip.

      -
      $ pip install pipenv
      +
      $ pip install pipenv
       

      Once pipenv is installed you can proceed by creating a project folder and installing Catalyst on that project automagically as follows:

      -
      $ mkdir project
      -$ cd project
      -$ pipenv --two
      -$ pipenv install enigma-catalyst matplotlib
      +
      $ mkdir project
      +$ cd project
      +$ pipenv --two
      +$ pipenv install enigma-catalyst matplotlib
       

      Until now the workflow compared to pip is almost identical, the difference is that you don’t need to load manually any virtualenv however you need to use the pipenv run prefix to run the catalyst command as follows:

      -
      $ pipenv run catalyst --version
      +
      $ pipenv run catalyst --version
       

      If you want to know more about pipenv go to the pipenv github repo

      @@ -356,29 +639,29 @@ the pipenv run prefix to run the catalyst command as f

      GNU/Linux Requirements

      On Debian-derived Linux distributions, you can acquire all the necessary binary dependencies from apt by running:

      -
      $ sudo apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev
      +
      $ sudo apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev
       

      On recent RHEL-derived derived Linux distributions (e.g. Fedora), the following should be sufficient to acquire the necessary additional dependencies:

      -
      $ sudo dnf install atlas-devel gcc-c++ gcc-gfortran libgfortran python-devel redhat-rep-config
      +
      $ sudo dnf install atlas-devel gcc-c++ gcc-gfortran libgfortran python-devel redhat-rep-config
       

      On Arch Linux, you can acquire the additional dependencies via pacman:

      -
      $ pacman -S lapack gcc gcc-fortran pkg-config
      +
      $ pacman -S lapack gcc gcc-fortran pkg-config
       

      Amazon Linux AMI Notes

      The packages pip and setuptools that come shipped by default are very outdated. Thus, you first need to run:

      -
      $ pip install --upgrade pip setuptools
      +
      $ pip install --upgrade pip setuptools
       

      The default installation is also missing the C and C++ compilers, which you install by:

      -
      $ sudo yum install gcc gcc-c++
      +
      $ sudo yum install gcc gcc-c++
       

      Then you should follow the regular installation instructions outlined at the @@ -395,14 +678,14 @@ to which explains how to install Python with the Homebrew manager.

      Assuming you’ve installed Python with Homebrew, you’ll also likely need the following brew packages:

      -
      $ brew install freetype pkg-config gcc openssl
      +
      $ brew install freetype pkg-config gcc openssl
       

      MacOS + virtualenv/conda + matplotlib

      The first time that you try to run an algorithm that loads the matplotlib library, you may get the following error:

      -
      RuntimeError: Python is not installed as a framework. The Mac OS X backend
      +
      RuntimeError: Python is not installed as a framework. The Mac OS X backend
       will not be able to function correctly if Python is not installed as a
       framework. See the Python documentation for more information on installing
       Python as a framework on Mac OS X. Please either reinstall Python as a
      @@ -414,7 +697,7 @@ information.
       

      This is a matplotlib-specific error, that will go away once you run the following command:

      -
      $ echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc
      +
      $ echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc
       

      in order to override the default MacOS backend for your system, which @@ -492,12 +775,12 @@ update Catalyst frequently. Once installed, Catalyst can easily be updated as a pip package regardless of the environemnt used for installation. Make sure you activate your environment first as you did in your first install, and then execute:

      -
      $ pip uninstall enigma-catalyst
      -$ pip install enigma-catalyst
      +
      $ pip uninstall enigma-catalyst
      +$ pip install enigma-catalyst
       

      Alternatively, you could update Catalyst issuing the following command:

      -
      $ pip install -U enigma-catalyst
      +
      $ pip install -U enigma-catalyst
       

      but this command will also upgrade all the Catalyst dependencies to the latest @@ -531,82 +814,68 @@ and you get a hint on how to solve it.

    -
    -
    - -
    -
  • - - - + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live-trading.html b/live-trading.html index 34b8ada9..37c1faaf 100644 --- a/live-trading.html +++ b/live-trading.html @@ -1,52 +1,335 @@ - - - - - Live Trading — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Live Trading — Catalyst 0.4 documentation + -
    -
    -
    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + + + + + + +
    +
    +
    + +
    +
    +

    Live Trading

    @@ -131,7 +414,7 @@ Here is how to generate key and secret values for the Bitfinex exchange: https://docs.bitfinex.com/v1/docs/api-access. Most exchanges follow a similar process.

    The auth.json file:

    -
    {
    +
    {
       "name": "bitfinex",
       "key": "my-key",
       "secret": "my-secret"
    @@ -161,13 +444,13 @@ seperator.

    [Market Currency]_[Base Currency] all lowercase.

    Currency symbols (e.g. btc, eth, ltc) follow the Bittrex convention.

    Here are some examples:

    -
    # With Bitfinex
    -bitcoin_usd_asset = symbol('btc_usd')
    -ethereum_bitcoin_asset = symbol('eth_btc')
    +
    # With Bitfinex
    +bitcoin_usd_asset = symbol('btc_usd')
    +ethereum_bitcoin_asset = symbol('eth_btc')
     
    -# With Bittrex
    -ethereum_bitcoin_asset = symbol('eth_btc')
    -neo_ethereum_asset = symbol('neo_eth)
    +# With Bittrex
    +ethereum_bitcoin_asset = symbol('eth_btc')
    +neo_ethereum_asset = symbol('neo_eth)
     

    Note that the trading pairs are always referenced in the same manner. @@ -184,17 +467,17 @@ algorithm for live trading. The same algorithm should work in backtest and live execution mode without modification.

    What differs are the arguments provided to the catalyst client or run_algorithm() interface. Here is the same example in both interfaces:

    -
    catalyst live -f my_algo_code -x bitfinex -c btc -n my_algo_name
    +
    catalyst live -f my_algo_code -x bitfinex -c btc -n my_algo_name
     
    -
    run_algorithm(
    +
    run_algorithm(
         initialize=initialize,
         handle_data=handle_data,
         analyze=analyze,
    -    exchange_name='bitfinex',
    +    exchange_name='bitfinex',
         live=True,
    -    algo_namespace='my_algo_name',
    -    base_currency='btc'
    +    algo_namespace='my_algo_name',
    +    base_currency='btc'
     )
     
    @@ -225,7 +508,7 @@ essentially sleep and when the predefined time comes, it would start executing.<

    The catalyst live command offers additional parameters. You can learn more by running the following from the command line:

    -
    catalyst live --help
    +
    catalyst live --help
     

    Here is a complete algorithm for reference: @@ -235,67 +518,68 @@ You can learn more by running the following from the command line:

    -
    -
    - -
    -
    - - - + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/objects.inv b/objects.inv index b28ed073..b91e801a 100644 Binary files a/objects.inv and b/objects.inv differ diff --git a/release-process.html b/release-process.html index e33a004e..e56f5201 100644 --- a/release-process.html +++ b/release-process.html @@ -1,44 +1,333 @@ - - - - - Release Process — Catalyst 0.4 documentation - - - - - - - - - - - + + + + + + + + + Release Process — Catalyst 0.4 documentation + -
    -
    -
    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + + + + + + +
    +
    +
    + +
    +
    +

    Release Process

    @@ -53,7 +342,7 @@ page. We will have been maintaining a whatsnew file while working on the release with the new version. First, find that file in: docs/source/whatsnew/<version>.txt. It will be the highest version number. Edit the release date field to be today’s date in the format:

    -
    <month> <day>, <year>
    +
    <month> <day>, <year>
     

    for example, November 6, 2015. @@ -64,9 +353,9 @@ update the underline of the title to match the title’s width.

    If you are renaming the release at this point, you’ll need to git mv the file and also update releases.rst to reference the renamed file.

    To build and view the docs locally, run:

    -
    $ cd docs
    -$ make html
    -$ {BROWSER} build/html/index.html
    +
    $ cd docs
    +$ make html
    +$ {BROWSER} build/html/index.html
     
    @@ -78,7 +367,7 @@ namespace is populated at import time by decorators on TradingAlgorithm methods. Those functions are therefore hidden from static analysis tools, but we can generate static files to make them available. Under Python 3, run the following to generate any stub files:

    -
    $ python etc/gen_type_stubs.py
    +
    $ python etc/gen_type_stubs.py
     
    @@ -100,8 +389,8 @@ manage the __version__

    To upgrade the version use the git tag command like:

    -
    $ git tag <major>.<minor>.<micro>
    -$ git push && git push --tags
    +
    $ git tag <major>.<minor>.<micro>
    +$ git push && git push --tags
     

    This will push the the code and the tag information.

    @@ -113,15 +402,15 @@ choose the tag you just pushed, and publish the release.

    sdist

    To build the sdist (source distribution) run:

    -
    $ python setup.py sdist
    +
    $ python setup.py sdist
     

    from the zipline root. This will create a gzipped tarball that includes all the python, cython, and miscellaneous files needed to install zipline. To test that the source dist worked correctly, cd into an empty directory, create a new virtualenv and then run:

    -
    $ pip install <zipline-root>/dist/zipline-<major>.<minor>.<micro>.tar.gz
    -$ python -c 'import zipline;print(zipline.__version__)'
    +
    $ pip install <zipline-root>/dist/zipline-<major>.<minor>.<micro>.tar.gz
    +$ python -c 'import zipline;print(zipline.__version__)'
     

    This should print the version we are expecting to release.

    @@ -135,7 +424,7 @@ all the required packages.

    Now that we have tested the package locally, it should be tested using the test PyPI server.

    Edit your ~/.pypirc file to look like:

    -
    [distutils]
    +
    [distutils]
     index-servers =
         pypi
         pypitest
    @@ -151,7 +440,7 @@ PyPI server.

    after that, run:

    -
    $ python setup.py sdist upload -r pypitest
    +
    $ python setup.py sdist upload -r pypitest
     
    @@ -168,14 +457,14 @@ debugging packaging problems on the test server.

    This will upload zipline to the pypi test server. To test installing from pypi, create a new virtualenv, cd into a clean directory and then run:

    -
    $ pip install --extra-index-url https://testpypi.python.org/pypi zipline
    -$ python -c 'import zipline;print(zipline.__version__)'
    +
    $ pip install --extra-index-url https://testpypi.python.org/pypi zipline
    +$ python -c 'import zipline;print(zipline.__version__)'
     

    This should pull the package you just uploaded and then print the version number.

    Now that we have tested locally and on PyPI test, it is time to upload to PyPI:

    -
    $ python setup.py sdist upload
    +
    $ python setup.py sdist upload
     
    @@ -190,7 +479,7 @@ they were compiled.

    Documentation

    To update zipline.io, checkout the latest master and run:

    -
    python <zipline_root>/docs/deploy.py
    +
    python <zipline_root>/docs/deploy.py
     

    This will build the documentation, checkout a fresh copy of the gh-pages @@ -205,9 +494,9 @@ correct arguments.

    Now, using our browser of choice, view the index.html page and verify that the docs look correct.

    Once we are happy, push the updated docs to the GitHub gh-pages branch.

    -
    $ git add .
    -$ git commit -m "DOC: update zipline.io"
    -$ git push origin gh-pages
    +
    $ git add .
    +$ git commit -m "DOC: update zipline.io"
    +$ git push origin gh-pages
     

    zipline.io will update in a few moments.

    @@ -222,14 +511,14 @@ is also a good time to remove all the old “ci” packages from anaconda.

    Travis and AppVeyor only build and upload linux-64 and win-64 packages. We’ll need to build and upload osx-64 packages manually on an OSX machine.

    To build the conda packages for zipline locally, run:

    -
    $ python etc/conda_build_matrix.py
    +
    $ python etc/conda_build_matrix.py
     

    If all of the builds succeed, then this will not print anything and exit with EXIT_SUCCESS. If there are build issues, we must address them and decide what to do.

    Once all of the builds in the matrix pass, we can upload them to anaconda with:

    -
    $ python etc/conda_build_matrix.py --upload
    +
    $ python etc/conda_build_matrix.py --upload
     

    If you would like to test this command by uploading to a different user, this @@ -244,7 +533,7 @@ renamed when that’s decided. You can use

    Include the whatsnew file in docs/source/releases.rst. New releases should appear at the top. The syntax for this is:

    -
    .. include:: whatsnew/<version>.txt
    +
    .. include:: whatsnew/<version>.txt
     
    @@ -252,61 +541,59 @@ appear at the top. The syntax for this is:

    -
    -
    - -
    -
    - - - + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/releases.html b/releases.html index fb84c27c..e738adb0 100644 --- a/releases.html +++ b/releases.html @@ -1,48 +1,334 @@ - - - - - Release Notes — Catalyst 0.4 documentation - - - - - - - - - - - - + + + + + + + + + Release Notes — Catalyst 0.4 documentation + -
    -
    -
    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + + + + + + + - - - + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources.html b/resources.html index 27558caa..e6af4ae1 100644 --- a/resources.html +++ b/resources.html @@ -1,52 +1,335 @@ - - - - - Resources — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Resources — Catalyst 0.4 documentation + -
    -
    -
    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + + + + + + +
    +
    +
    + +
    +
    +

    Resources

    @@ -79,63 +362,68 @@ trading algorithms
    -
    -
    - -
    -
    - - - + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/search.html b/search.html index 7aad015d..62290c03 100644 --- a/search.html +++ b/search.html @@ -1,29 +1,399 @@ - - - - - Search — Catalyst 0.4 documentation - - + + + + + + + + + Search — Catalyst 0.4 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + + + + + + +
    +
    +
    +
      +
    • Docs »
    • + +
    • +
    • + +
    • +
    +
    +
    +
    + + + + +
    + +
    + +
    +
    + + +
    + +
    +

    + © Copyright 2018, Enigma MPC, Inc.. +

    +
    + Built with Sphinx using a theme provided by Read the Docs. + +
    + +
    +
    + +
    + +
    + + + + + - - - - - - + + + + + + + + + + + + + + + + @@ -31,68 +401,6 @@ - - - -
    -
    -
    -
    - -

    Search

    -
    - -

    - Please activate JavaScript to enable the search - functionality. -

    -
    -

    - From here you can search these documents. Enter your search - words into the box below and click "search". Note that the search - function will automatically search for all of the words. Pages - containing fewer words won't appear in the result list. -

    -
    - - - -
    - -
    - -
    - -
    -
    -
    - -
    -
    - - - + \ No newline at end of file diff --git a/searchindex.js b/searchindex.js index 924abba1..130d1123 100644 --- a/searchindex.js +++ b/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["appendix","beginner-tutorial","bundles","development-guidelines","example-algos","features","index","install","live-trading","release-process","releases","resources","unit-tests","utilities","videos"],envversion:53,filenames:["appendix.rst","beginner-tutorial.rst","bundles.rst","development-guidelines.rst","example-algos.rst","features.rst","index.rst","install.rst","live-trading.rst","release-process.rst","releases.rst","resources.rst","unit-tests.rst","utilities.rst","videos.rst"],objects:{},objnames:{},objtypes:{},terms:{"000000e":1,"0b11":10,"0b7":10,"1000th":1,"15t":4,"1st":1,"30t":4,"328842e":1,"340mb":10,"380954e":1,"40mb":10,"460mb":10,"505275d6646a41f3856b22b16678d":1,"536708e":1,"5min":1,"650729e":1,"7869f7828fa140328eb40477bb7d":1,"998236e":1,"998677e":1,"999120e":1,"999558e":1,"99mb":10,"boolean":[2,8],"break":[7,10],"case":[1,2,3,7,13],"class":[3,9],"default":[1,5,7,8,10,13],"export":9,"final":[1,2,3],"float":[1,10],"function":[1,2,3,4,6,7,9,10,11,13],"import":[1,2,4,9,13],"int":[2,4],"long":[1,2,4],"new":[1,3,7,8,9],"null":12,"public":10,"return":[1,4,8,9,10,11],"short":[1,3,4],"static":9,"switch":[8,10],"throw":10,"true":[1,4,8,10],"try":[3,4,7],"var":1,"while":[5,7,9,10],AWS:10,Added:10,And:[1,7],For:[1,2,4,5,7,8,9,12],Not:[0,12],One:2,That:[1,7],The:[0,1,2,3,4,7,8,9,10,13],Then:[2,3,4,7],There:[1,3,7,8],These:[1,8,13],Use:[1,4,13],Using:[9,10],Will:8,With:8,__file__:[4,13],__future__:4,__main__:[1,4],__name__:[1,4],__wrapped__:9,_html_base:3,_tkinter:1,aapl:2,abil:[2,10],abl:[1,2,7],about:[1,2,6,7],abov:[1,3,4,5,7,8,9],accept:[2,7,9],access:[5,6,7,8],accord:9,accordingli:[1,4],account:[1,2,4,6,10],acquir:[2,7],across:[5,6,10],activ:[7,8,9],actual:1,add:[1,2,3,7,9,13],added:[1,2,5,6,7,9],adding:[1,3],addit:[1,3,5,6,7,8,10],addition:8,address:9,adjust:[2,4,10],administr:7,advanc:7,advantag:7,afford:[1,4],aforement:1,after:[1,2,4,7,9,10],again:[1,3],against:[1,6,8,10,14],agre:4,ahead:1,aim:[4,11],algebra:[4,7],algo:[1,2,4,8,10],algo_namespac:[1,4,8],algo_volatil:1,algofil:[1,2],algorithm:[3,5,6,7,10,11,12,13,14],algorithm_period_return:[1,4],algotext:1,alia:4,alias:[4,10],all:[0,1,2,3,4,5,6,7,8,9,10,12],allow:[1,2,5,6,7],almost:7,along:2,alongsid:1,alpha:[1,4,7,8],alreadi:[1,2,3,7],also:[1,2,3,4,6,7,8,9],altern:[1,5,7],although:1,alwai:[2,5,8,9,10],among:1,amount:[1,4,8,10],amp_btc:5,ana:7,anaconda2:1,anaconda:[1,7,9],analog:1,analysi:[1,4,6,9,10,11],analyst:11,analyt:[6,7],analyz:[1,4,8,10,13],ani:[1,2,4,5,7,8,9,13],anonym:2,anoth:[1,2,4,5],anymor:1,anyth:[1,7,9],apach:4,api:[1,2,4,5,6,7,8,9,13],app:7,appar:1,appear:[2,9],append:9,appli:[1,4],applic:[1,4],appropri:[1,3,4],approxim:[1,4],appveyor:9,apt:[1,7],arang:[1,4],arbitrag:5,arbitrari:[8,10],arbitrarili:1,arch:7,architectur:1,ardr_btc:5,arg:[1,9],argument:[0,1,2,8,9],argv:13,around:[6,7,9],arrai:[4,7],art:6,articl:[3,4],ask:[1,3],asmatrix:4,assert:[3,12],assertionerror:3,assess:1,asset:[1,2,4,5,6,8,10,13],asset_nam:[1,4],assetdbwrit:2,assign:[1,8],assimil:1,assist:7,assum:[1,3,4,7],astyp:4,atla:7,attempt:[2,8],attribut:[4,9],audit:10,auth2:4,auth:[8,10],auth_alias:4,authent:10,auto:10,automag:7,avail:[0,1,4,5,7,8,9,10,12,13],averag:7,avoid:[1,2,4,10],awai:7,awar:9,ax1:[1,4],ax2:[1,4],ax3:[1,4],ax4:[1,4],ax5:[1,4],ax6:[1,4],axhlin:4,axi:4,b23c38652556:4,back:[3,5,7],backbon:4,backend:7,backtest:[1,4,5,6,7,8,10,11],bah:4,bar:[1,4,10],bar_count:[1,4],base:[1,2,4,5,6,7,8,14],base_curr:[1,4,5,8,13],base_pric:[1,4],basenam:[4,13],basi:[4,10],batch:7,batteri:1,battl:7,bch_btc:5,bch_eth:5,bch_usdt:5,bcn_btc:5,bcn_xmr:5,bcolz:2,bcolzdailybarread:2,bcolzdailybarwrit:2,bcolzminutebarread:2,bcolzminutebarwrit:2,bcy_btc:5,be62ff77760c4599abaac43be9cc9:1,bear:[1,4],beautifi:1,becaus:[1,4,7,9,10],been:[1,2,7,9],befor:[1,2,4,7,8,10],before_trading_start:[0,4],beggin:4,begin:[1,4,7],beginn:[4,6],behavior:0,being:[1,6],bela_btc:5,believ:[1,10],below:[1,3,4,13],benchmark:[1,4,5,6,10],benchmark_period_return:[1,4],benchmark_volatil:1,benefit:1,best:[3,6,7],beta:[1,4],better:1,between:[1,3,4,5,6,10,12],beyond:5,bfill:4,bia:1,big:7,bin:[1,4,7],binanc:[4,8,10],binari:[1,7,9],bit:[3,7],bitbox:10,bitcoin:[1,4,5,6,8,13],bitcoin_usd_asset:8,bitfinex:[1,4,5,6,8,10],bitmex:8,bittrex:[1,5,6,8,10,14],blank:12,bld:3,blk_btc:5,blk_xmr:5,blockchain:5,blog:4,blotter:[1,4,13],blue:1,bnb_eth:4,bodi:3,book:1,both:[1,3,5,8,9,12],bought:[1,8],bound:1,box:1,branch:9,breakdown:8,brew:7,brother:7,brows:7,browser:[1,3,9],btc:[1,8,10],btc_usd:[1,4,5,8],btc_usdt:[4,5,6,10,13],btcd_btc:5,btcd_xmr:5,btm_btc:5,bts_btc:5,bug:[0,2,3],bui:[1,8,11,12,14],build:[1,3,6,7,9],build_ext:3,built:[4,9,12],bundl:[1,5,10],burst_btc:5,button:[1,7,9],buy_and_hodl:[4,10],buy_btc_simpl:[1,4],buy_btc_simple_out:[1,4],buy_df:[1,4],buy_low_sell_high:10,cach:[1,10],calcul:[1,3,4,8,10,12],call:[1,2,3,4,10],can:[1,2,3,4,5,6,7,8,9,10,13],can_trad:[1,4,10],cancel:[1,4,10,12],cancel_ord:[1,4],candl:[1,5,10,12],candle_s:4,candlestick:4,cannot:[1,4,7],canon:3,capabl:10,capit:[1,4],capital_bas:[1,4,8,10,13],capital_us:1,captur:1,cash:[1,2,3,4,10],catalyst:[3,4,5,6,8,10,11,12,13,14],catalyst_dev:[1,6,7],catalyst_setup:6,caus:[0,1,2,3],ccxt:[8,10],cell:1,cert:10,certian:0,chanc:1,chang:[1,3,4,6,7,9,10],channel:[1,6,7],charact:3,charg:1,chart:[1,4,7],check:[1,2,3,4,5,7,8],checker:9,checkout:[3,9],choic:9,choos:[1,4,5,7,9,10,13],chosen:[1,13],chunk:[1,10],circumv:7,clam_btc:5,classic:[1,4],classifi:1,clean:[2,7,9,10,12],clear:2,cli:[1,4,10,13],click:[1,7,9],client:8,clone:3,close:[1,4,5,13],cmap:4,cmd:[1,7],code:[1,4,7,9,10,13],codebas:3,coin:[1,4,10],collect:[1,2,4],color:[1,4],colorbar:4,colour:4,column:[1,2,4],com:[1,2,3,8],combin:[7,8],come:[1,2,7,8],command:[2,4,7,8,9,10],comment:1,commiss:[1,5,10],common:[1,7],commonli:1,commun:[1,5,7,11],comp:4,compar:[1,4,5,6,7,12],comparison:10,compat:[6,10],compil:[7,9,10],complement:4,complet:8,complex:[1,7],complianc:4,complimentari:13,comprehens:10,compress:[1,10],comput:[1,4,7,10,11],concept:1,conda:[1,10],conda_build_matrix:9,condit:4,confid:8,config:7,configur:[1,7,10],congratul:7,consid:[1,4],consist:[1,5,12],constant:[1,10],constraint:2,consum:9,contain:[1,2,3,4,7,12],content:[1,13],context:[1,3,4,10,13],continu:1,continuo:1,continuum:7,contract:10,contribut:5,control:[8,9],conveni:1,convent:[4,8],convers:[2,7],convert:[2,4],copi:[1,2,3,4,9],copyright:4,core:7,corr_m:4,correct:[2,7,8,9],correctli:[1,7,9],correctwai:7,correl:4,correspond:[1,7,8,13],cost:[1,4],could:[0,1,2,4,7,13],count:2,counter:4,coupl:1,cov_m:4,covari:4,cover:[1,4,8,13],coverag:[5,6,8],cpython:7,crash:2,creat:[1,2,4,7,8,9,10,11,12,13],creation:10,critic:5,cross:5,crossov:1,crowd:11,crypto:[1,6,10],cryptoasset:[1,4,13,14],cryptocurr:[4,5,8],csv:[1,4,10],csvfile:13,csvwriter:13,cumul:10,cumulative_capital_us:3,curat:[1,6],currenc:[1,4],current:[0,1,2,4,7,8,9,10,13],current_d:4,current_dai:4,current_dt:[4,13],custom:[1,2,5,13],cvc_btc:5,cvc_eth:5,cython:9,d6dca79513214346a646079213526:1,dai:[1,2,4,7,9],daili:[1,2,4,5,6,10,13],darkgoldenrod:4,dash:8,dash_btc:5,dash_usdt:[4,5],dash_xmr:5,data:[4,5,6,7,8,10,11],data_frequ:[1,4,13],databas:2,datafram:[1,2,4,5,6,11,12,13],dataframe_cach:2,dataset:[1,2,5,10],date:[1,2,4,7,8,9,10,12,13],datetim:[4,13],dcr_btc:5,debian:[1,7],debug:9,debugg:1,decentr:5,decid:9,decim:10,decor:9,decreas:4,dedic:6,def:[1,4,13],defin:[1,4,8],delai:1,delet:2,demonstr:1,denomin:1,dep:3,depart_docu:3,depend:[1,3,7,9,10,13],deploi:[9,10],deprec:3,deriv:7,describ:5,descript:[3,7],desir:[1,4,12,13],desktop:5,detail:[4,5],determin:4,dev1:7,dev2:7,dev3:7,dev4:7,dev5:7,dev6:7,dev8:7,dev9:7,dev:[3,5,7],devel:7,develop:[1,6,7,8,9,10,11,13],deviat:4,devis:1,dgb_btc:5,dict:[4,10],dictionari:10,did:[6,7],didn:7,differ:[1,2,4,5,7,8,9,13],digit:10,dir:7,directli:[1,2,7,10,13],directori:[1,2,3,4,7,8,9],disabl:10,disablemsi:7,discard:4,discord:[1,3,6,7],discuss:1,disk:10,dismiss:1,displai:[1,4,7,9,10],dist:9,distribut:[4,7,9],distutil:9,divid:3,dividend:2,divis:4,dma:1,dname:1,dnf:7,doc:[2,4,8,9],dockerfil:3,docstr:10,document:[3,4,5,6,7,8],docutil:3,doe:[1,2,4,5,7],doesn:[2,10],doge_btc:5,dollar:5,don:[1,3,7,14],done:[1,4,9],door:5,dot:4,down:[1,4,14],downgrad:3,download:[1,2,7,10],draft:9,drawback:2,drive:1,driven:[1,6,8],drop:1,dropbox:10,dual_moving_averag:[1,4],dword:7,dynam:4,each:[1,2,3,4,5,6,7,8,10,12,13],earlier:[1,2,3,4],earliest:4,eas:6,easi:[1,2,4,11],easier:[1,2,4,5,7],easiest:7,easili:[1,6,7],echo:7,eco:6,ecosystem:5,edit:[3,4,7,9],editor:7,educ:1,educt:1,effect:7,either:[1,4,7],elaps:4,element:4,elif:[1,4],els:[4,7],emc2_btc:5,empow:[1,6],empti:[1,2,3,4,8,9,10],empyr:10,enabl:8,encount:7,encourag:8,end:[1,4,10,12,13],end_daili:4,end_dat:[1,4,8],ending_cash:1,ending_exposur:1,engin:11,enh:3,enhanc:3,enigma:[1,4,5,6,7,10],enigmampc:[1,3,4],enough:[1,5,7],ensur:[0,4,7,8,9,10],ensure_directori:4,enter:[1,7],entir:3,entri:[1,7],env:[1,3,4,7],enviorn:2,environ:[1,4,7,10,13],environemnt:[1,7],equal:[1,2,4,8,13],equiti:2,equival:[4,12],error:[1,3,4,5,7,8,10,12],especi:1,essenti:8,establish:6,estim:1,etc:[3,9,10],etc_btc:5,etc_eth:5,etc_usdt:5,eth:[1,4,8],eth_btc:[5,8],eth_usdt:[4,5],ether:4,ethereum_bitcoin_asset:8,evalu:1,even:[2,7],event:1,eventu:1,everi:[1,4,7],everydai:4,everyth:[1,2],exact:[4,10,13],examin:1,exampl:[2,3,5,6,8,9,10,11,13],excel:7,except:[1,3,4],excess:4,exchang:[1,2,4,5,6,10,14],exchange_algorithm:1,exchange_nam:[1,4,8,13],exchange_util:4,exclud:4,exe:1,execut:[0,1,4,7,8,10],exist:[1,2,3,4,5,6,7],exit:[1,4,9],exit_success:9,exp_btc:5,expect:[0,1,2,4,5,7,9],experi:7,experienc:7,explain:[7,8],explicitli:9,explictili:7,express:[1,4,6],extend:1,extens:[2,3,7,8],extern:[1,4,7],extra:9,extract_transact:[1,4],face:7,facto:1,fail:[1,2,7],failur:2,fairli:[1,3],fals:[1,4,8],familiar:3,fantast:1,faq:7,far:2,fast:2,fatal:7,fct_btc:5,featur:[1,4,6],fedora:7,fee:5,feedback:[2,10],feel:1,fetch:[2,5,8,10,12],few:[1,2,7,9],fewer:7,ffill:4,field:[2,4,9],file:[1,2,3,4,7,8,10,12],filenam:[1,4,13],fill:[1,4,10],filter:[4,10],financ:1,financi:[1,10],find:[1,2,7,9],fine:9,finish:[1,8],first:[2,3,4,7,8,9,14],fix:[3,12],flag:[1,4,7,8,9],flake8:3,fldc_btc:5,flo_btc:5,floor:4,focu:[1,4,6],folder:[4,7,10],follow:[0,1,2,3,4,5,7,8,9,13],footprint:7,fork:11,form:[1,4,5],format:[1,2,4,9,10],fortran:7,forum:[6,7],forward:[2,12],foster:11,found:[1,3,5,7],fourth:[1,4],fraction:10,frame:[1,4],framework:7,free:[1,4],freelanc:11,freetyp:7,freq:[1,4],frequenc:[1,4,10,12],frequent:7,fresh:9,from:[0,1,2,3,4,5,7,8,9,10,12,13],from_dict:4,full:[1,8,13],fulli:[8,10],fund:11,fundament:11,further:[1,4],futur:[1,2,5,8],game_btc:5,gas_btc:5,gas_eth:5,gave:1,gcc:7,gcf:[1,4],gdax:8,gear:1,gen_type_stub:9,gener:[2,3,6,7,8,9,10,13],get:[1,2,3,4,5,6,8,10,13],get_exchange_symbol:4,get_open_ord:[1,4],get_ylim:[1,4],gettempdir:4,gfortran:7,git:9,github:[1,3,4,7,9],give:[4,10],given:[1,2,4,5,13],global:1,gno_btc:5,gno_eth:5,gnt_btc:5,gnt_eth:5,goe:[4,8,14],going:[4,7,14],good:[1,9],goog:2,got:1,govern:4,gracefulli:[8,10],grain:9,granular:[5,10],graph:1,grc_btc:5,greatli:8,green:[1,4],group:[1,3,6],grow:2,guid:[3,7,10],guidelin:[6,7,10],gzip:9,hand:3,handi:[1,4,7],handl:[3,4,10],handle_data:[0,1,4,8,13],hang:7,happen:[1,2,8],happi:9,hard:1,has:[1,2,3,7,8,9,10],hash:10,have:[1,2,3,6,7,8,9,14],haven:1,head:[1,7],header:[7,9],heavi:[1,4],heavili:11,hedg:11,held:5,help:[0,1,2,8],henc:1,here:[1,2,4,7,8],hidden:9,high:[1,4,8,11,13],highest:[4,9],highlight:4,hint:[7,9],histor:[1,4,5,6,8,10],histori:[2,4,10],hit:[1,10],hitchhik:7,hkey_local_machin:7,hold:[4,8],home:10,homebrew:7,hope:1,hopefulli:[4,14],hourli:10,how:[1,2,4,7,8,10],howev:[7,8,9],html:[3,4,9],http:[1,4,8,9],huc_btc:5,idea:[1,2,3],ident:7,idxmax:4,idxmin:4,illustr:8,iloc:4,immedi:[1,4],impact:10,imper:3,implement:[1,2,4,8,10,14],impli:4,implicitli:0,importerror:1,improv:[3,10],inadvert:7,inc:4,includ:[1,2,3,4,7,9,10,13],incomplet:2,inconsist:8,incorpor:10,increas:[2,4,10],increment:[1,9],independ:[5,7],index:[1,3,4,9],indic:[2,4,7,10],individu:[1,8],ineffici:10,inf:4,infer:2,infinit:4,influenc:1,info:[1,4,10],inform:[1,2,4,7,9],ingest:[4,5,10],initi:[0,1,4,8,10,13],inlin:1,inner:1,inplac:3,input:[1,5,6],insert:4,insid:[1,4,7],insight:[1,6],inspect:[1,4],instal:[3,5,6,9,10],installt:7,instanc:[0,2,4,12],instead:[1,2,3,4,5,8,10],instruct:[1,3,7,10],integ:[2,10],integr:[1,5,6,8,10],intend:[1,3,9],interact:[1,8,10],interfac:[5,8,9,10,13],intern:[2,7],interpret:[1,4,13],interv:[4,12],introduc:[1,4,5,8,10],invest:[1,6],invok:[1,2],involv:[2,7],ipython:1,is_bui:[1,4],isinst:4,issu:[1,3,5,7,9,10],iter:[1,2,4,13],its:[1,4,5,7,8],itself:[1,7],jan:1,join:[4,6,7],json:[8,10],json_symbol:4,juli:13,jump:7,jupyt:10,just:[1,2,4,5,9],keep:[1,2,4,7,10],kei:[2,6,7,8,10],kept:[1,8],keyerror:10,keystor:10,kind:4,know:[1,7],knowledg:6,kpi:12,kwarg:9,label:[1,4,8,9],lack:5,lambda:4,languag:[1,4],lapack:7,larg:2,larger:10,last:[1,2,4,7,10,12],later:[1,2,3,4,10],latest:[7,9,10],launch:[1,7],law:4,layer:5,lazi:2,lbc_btc:5,leak:2,learn:[1,4,6,7,8],least:[1,3,12],ledger:10,legend:[1,4],legend_:[1,4],len:[1,3,4],less:2,let:[1,4,10],level:[1,2,4],leverag:[1,4,11],lib:[3,4,10],libatla:7,libfreetype6:7,libgfortran:7,librari:[1,3,4,6,7,8,10,11],licens:4,lifetim:2,like:[1,2,3,5,6,7,9,10,12],limit:[1,4,5,10,12],limit_pric:[1,4],line:[3,4,5,8,10,13],linear:7,link:[7,10],linter:9,linux:[1,5,9],list:[0,1,2,4,5,7,8,9,10,13],littl:[1,3],live:[1,4,5,6,7,10,11],live_algo:4,live_graph:4,load:[1,2,7,10],load_ext:1,loader:[1,2],loc:[1,4],local:[1,2,3,7,9],locat:[1,2,4,13],log1p:10,log:[1,4,7,10],logbook:[1,4],logger:[1,4],logic:[1,4,10],long_data:[1,4],long_mavg:[1,4],long_window:[1,4],longer:[1,3,9],look:[1,2,4,7,9,12,13],lookback:4,lookback_d:4,lookback_dai:4,lookup:1,loop:2,loss:10,lot:[2,10],low:[1,4,8],lower:[4,8,10],lowercas:[5,8],lsk_btc:5,lsk_eth:5,ltc:8,ltc_btc:5,ltc_usd:[1,4],ltc_usdt:[4,5],ltc_xmr:5,mac:7,machin:[2,6,9],maco:[1,5],made:[2,3,10],magic:1,mai:[1,2,4,7,8,9],maid_btc:5,maid_xmr:5,main:[1,7,9],mainnet:10,maint:3,maintain:[5,9],mainten:3,major:9,make:[1,2,3,4,5,7,9,10],maker:4,manag:[1,4,7,9],mani:[1,2,4,7,9,11],manifest:9,manner:8,manual:[7,9],map:[2,5,10],marker:[1,4],markers:1,market:[1,4,5,6,8,10],market_curr:[4,5],marketplac:[1,7,10],markowitz:4,master:9,match:[1,7,8,9,12],matplotlib:[1,4,6,11],matplotlibrc:7,matrix:[4,9],matter:3,mavg:1,max_capital_us:3,max_leverag:3,max_sharpe_port:4,maxim:6,maximum:4,maybe_show_progress:2,mcoin:1,mean:[1,2,7,9,10,14],mean_reversion_simpl:4,memori:2,mention:[1,7,8,9],menu:[1,7],merg:1,merger:2,messag:[1,10],metadata:2,metamask:10,method:[0,1,2,4,7,9,10,12,13],metric:[1,10],micro:9,microsoft:7,midnight:4,might:1,migrat:1,min:4,min_vol_port:4,mind:[1,4],miniconda:7,minim:[6,10],minimum:[4,10],minor:[7,9],minut:[1,2,4,5,6,7,10,13],miscellan:9,miss:[1,7,8,10],mix:7,mkdir:7,mkvirtualenv:3,mode:[1,4,5,6,10],model:[1,3,4,5],modif:[3,8],modifi:13,modul:1,moment:[7,9],momentum:[1,4,14],monei:0,month:[9,13],more:[1,2,4,6,7,8,10,13],most:[1,2,4,7,8,10],mostli:1,move:[2,9],movement:1,mpc:[1,4],msft:2,msi:7,msiexec:7,much:[1,2],multipl:[2,4,5,9,10],must:[1,2,8,9],my_algo_cod:8,my_algo_nam:8,mycrypto:10,myetherwallet:10,n_portfolio:4,name:[1,2,3,4,7,8,9,13],name_of_project:1,namespac:[1,4,9],nan:[1,4],nano:9,nasset:4,nativ:7,naut_btc:5,nav_btc:5,navig:[1,3,7],nchang:4,ndarrai:[1,4],nearest:4,necessari:7,nee:7,need:[1,2,3,4,5,7,9,11,13],neg:1,neo:4,neo_eth:8,neo_ethereum_asset:8,neo_usd:4,neos_btc:5,never:[2,8],newer:[2,7],next:[2,7],nice:[5,6],nmc_btc:5,noebook:1,non:7,none:[1,4,13],nor:4,normal:10,note:[1,4,5,6,8,13],note_btc:5,notebook:10,notenoughcasherror:10,noth:7,notic:4,notion:4,novemb:9,now:[1,2,4,7,9,10,14],number:[1,2,4,7,9,10],numer:7,numpi:[1,3,4,7,9,11],nvalu:4,nxc_btc:5,nxt_btc:5,nxt_usdt:5,nxt_xmr:5,object:[1,2,3,4],observ:7,obtain:[1,4,8],occur:[1,3,8],off:11,offer:[1,8],offset:4,ohlc:1,ohlcv:[4,10,12],old:9,older:2,omg_btc:5,omg_eth:5,omni:5,omni_btc:5,onc:[1,2,4,7,8,9],one:[1,2,3,4,5,7,10,12,13],one_day_in_minut:4,ones:4,onli:[1,2,3,4,6,7,9,13],onlin:10,open:[1,3,4,5,7,10,12,13],open_ord:[1,4],openssl:7,oper:7,operatbl:7,opportun:5,opt:[4,7],optim:[1,11],option:[1,2,7,10,13],order:[1,4,5,7,8,9,10],order_id:1,order_target_perc:[1,4,8],order_target_valu:[1,4],ordered_pip:3,org:[4,9],organ:1,origin:[1,9],osx:[7,9],other:[1,2,4,5,7,9,13],otherwis:7,our:[1,3,4,6,7,9,14],out:[1,2,3,4,6,7,9,12],outdat:7,outlin:7,output:[1,2,4,5,6],outstand:[1,4],over:[3,4,5,6,7],overcom:5,overfit:1,overrid:[7,9,10],overview:[1,5],overwhelm:1,own:[2,4,7,8],p_r:4,p_std:4,packag:[1,3,7,11],pacman:7,page:[3,5,7,9,10],pair:[1,4,5,8,10],pairon:4,panda:[1,2,4,5,6,11],paper:[3,5,10],param:10,paramet:[1,4,8,9,10,13],parent:7,pars:2,part:[1,2,4,7,8,14],partial:[7,10,12],particular:[6,7],pasc_btc:5,pass:[1,2,4,9],password:9,past:[1,4],patch:10,path:[2,4,7,10,13],pattern:12,pend:9,peopl:3,pep8:3,per:[1,2,4,5,10],percent:[1,4],percentag:[1,4],perf:[1,3,4],perform:[0,1,3,4,5,6,7,10,11],perhap:7,period:[3,4],permiss:[4,7],persist:[1,4,10],pickl:[1,4],piec:[2,7],pink_btc:5,pip:[1,3,9],pipelin:[5,10],pkg:7,place:[1,4,8,10],plan:[5,7],platform:[7,10,11],pleas:[1,6,7,13],plot:[1,4,11],plt:[1,4],plu:13,point:[1,5,9],polici:7,poloniex:[1,4,5,6,8,10,13],popul:9,portfolio:[1,10,13],portfolio_optim:4,portfolio_valu:[1,4],pos_amount:[1,4],posit:[1,4,10],positon:4,possibl:[2,3,7],post:9,pot_btc:5,power:[1,4,11],ppc_btc:5,practic:[1,3],pre:[2,7],precis:10,predefin:8,predict:[1,8],prefer:[1,7],prefix:[3,7],preload:2,prepare_chunk:10,preprocess:9,prerequisit:[1,7],present:[1,8,10],preserv:10,prevent:[2,7,9],previou:[7,14],previous:1,price:[2,4,5,6,8,10,13],price_chang:[1,4],primari:7,print:[1,4,7,9],print_result:1,prior:[1,4,10],privat:10,privileg:7,probabl:1,problem:[1,2,7,9],proce:7,proceed:7,process:[1,2,4,8],produc:[2,4,7],profit:[1,6],program:[1,7],progress:[2,10],project:[1,6,7,11],prompt:[1,7],proper:[7,8],properli:[1,4,7,10,13],protect:0,protocol:[1,5],provid:[0,1,2,4,5,6,7,8,10,11,13],publish:[9,10],pull:[3,9],pun:1,purchas:[1,4],purpos:[1,5,8],push:9,put:[7,8],pycharm:[9,10],pydata:[4,5,6],pyfolio:10,pypirc:9,pypitest:9,pyplot:[1,4],python2:[3,5,7,10],python3:[5,7,10],python:[1,3,4,6,7,10,11,13],pythonw:7,pytz:[4,13],quandl_api_kei:2,quandl_download_attempt:2,quantit:[1,11],quantopian:[4,11],queri:2,question:[1,3,6],quick:1,quickli:[4,14],quirk:7,quit:2,rads_btc:5,rais:[3,10],ran:2,random:[4,12],randomli:12,rang:[1,2,4,8,12],rate:[4,10],rather:[1,7],ratio:4,raw:[2,7],rdylgn:4,reach:8,read:[1,2,7,10],read_pickl:1,readi:9,real:[0,4,8],realist:[1,4],reason:[1,2,7],rebal:4,rebalanc:[1,4],rebalance_period:4,recal:1,receiv:[1,2,10],recent:[1,2,4,5,7],recogn:7,recommend:[2,7],reconstruct:1,record:[1,4,13],red:[1,4],redhat:7,redon:10,redownload:[1,2],reduc:10,redund:10,refactor:3,refer:[1,3,4,5,7,8,9],referenc:[1,4,8],refus:1,regard:6,regardless:[1,7,8],regedit:7,regist:[1,2],registri:7,regular:7,reinstal:7,rel:3,relat:3,relationship:2,releas:[3,5,6,7],reli:[7,11],remain:10,rememb:[1,7],remot:2,remov:[1,3,4,7,9,10],renam:9,rep:7,rep_btc:5,rep_eth:5,rep_usdt:5,repeat:10,replac:[4,7],repo:7,report:[1,3,7],repositori:[7,9,10],repres:[2,8],reproduc:2,req:10,request:[1,2,3,4,10],requir:[1,3,4,8,9,10],requirements_blaz:3,requirements_dev:3,requirements_doc:3,research:1,reserv:[1,4,5],reserve_ratio:[1,4],reserve_valu:[1,4],resolut:[1,4,5,6,10,13],resolv:[7,10],resourc:[2,6,10],respect:[3,9,13],respons:[2,7],rest:2,restart:10,restor:10,restrict:7,restructuredtext:3,result:[1,2,4,7,8,10,12,13],results_arrai:4,results_fram:4,resum:4,retest:4,retri:2,retriev:[1,4,10,12],rev:3,revers:[10,14],revert:3,review:[1,7],revis:1,rhel:7,ric_btc:5,ride:[4,14],right:[1,7],rinkebi:10,risk:[1,4,10],roll:1,rollup:2,root:[3,9],ropstein:10,round:10,routin:7,row:[1,4],rsi:4,rsi_overbought:4,rsi_oversold:4,rst:[3,9],run:[3,4,5,7,8,9,10,12,13],run_algo:[1,4,13],run_algorithm:[1,4,8,13],runtim:1,runtimeerror:7,safe:1,said:1,same:[1,2,4,5,7,8,9,10,13],sampl:[4,10,12],satisfi:7,save:[1,2,3,4,7,13],sbd_btc:5,sc_btc:5,scale:[1,10],scatter:[1,4],schedul:8,scientif:11,scikit:1,scipi:[6,7],scratch:7,script:[1,4,9,13],scriptnam:13,seamless:[5,6],search:7,second:[1,4,7,14],secret:8,section:[1,3,4,7,8,9,13],secur:[4,6,11],see:[1,2,4,5,6,7,8,13],seek:7,seen:4,select:[1,4,7,12],self:[0,3],sell:[1,4,8,10,11,12,14],sell_df:[1,4],separ:[1,3,5,7,8],seper:8,seri:[1,4,14],seriou:1,server:[1,2,9],servic:2,session:7,set:[1,2,4,5,7,8,10],set_benchmark:5,set_commiss:4,set_printopt:4,set_size_inch:[1,4],set_slippag:4,set_tick:[1,4],set_ylabel:[1,4],setup:[3,9],setuptool:7,seven:4,sever:[1,6,7,10],share:[1,5,6],sharex:[1,4],sharp:[1,4],ship:[2,7,9],short_data:[1,4],short_exposur:1,short_mavg:[1,4],short_valu:1,short_window:[1,4],shorter:1,shorts_count:1,should:[1,2,3,7,8,9,10],shourc:2,show:[1,2,4],shown:2,sid:[1,2,10],side:7,sign_msg:10,sign_tx:10,signal:[2,4],signatur:2,signific:4,similar:[1,7,8],simpl:[1,14],simple_univers:4,simpler:13,simplest:4,simpli:[1,3,4,7,13],simplic:4,simplifi:1,simul:[1,4,5,7,8],simulate_ord:[4,8,10],simultan:10,sinc:[1,4,7,8,9,13],singl:[2,4,7,10],site:3,size:[4,7,10],sjcx_btc:5,skeleton:9,skim:1,skip:[1,4,10],sklearn:6,sleep:8,slighlti:4,slightli:7,slippag:[1,4,10],smaller:[7,10],smoothli:14,snip:1,snippet:13,softwar:[4,7],sold:8,solut:7,solv:[1,2,7,10],some:[1,2,3,4,7,8,10,11],someon:7,someth:3,somewhat:1,sortino:[1,10],sourc:[1,2,3,4,7,9,10,11],space:1,special:8,specif:[1,4,7,10],specifi:[1,2,4,5,8,9,10],spend:1,spent:5,sphinx:[3,9],split:[1,2,4],splitext:[4,13],spread:4,spring:11,sqliteadjustmentwrit:2,sqrt:4,ssl:10,stabl:[4,7],stai:[9,10],standard:[2,3,4,5,10],star:4,start:[1,2,3,4,6,7,8,12,13],start_dat:[1,4,8],start_tim:4,starting_cash:[1,4],starting_exposur:1,starting_valu:1,stat:[4,10],state:[1,2,4,6,10],statist:[1,5,6,8,10],stats_output:4,stats_util:[1,4],statsmodel:6,statu:4,std:4,stdev:4,stdout:1,steem_btc:5,steem_eth:5,step:[2,7],still:[1,2,4,5,7],stock:[1,2,4],stop:[1,4,10],storag:[1,8,10],store:[1,2,4,5,10,13],str:4,str_btc:5,str_usdt:5,straightforward:4,strat_btc:5,strategi:[1,4,6,8],stream:1,streamlin:1,strftime:4,strictli:[2,7],string:[1,2,4,9],strongli:7,structur:[5,6,8,11],sty:3,style:[3,4],subdirectori:2,subject:3,submit:3,subplot:[1,4],subset:4,substanti:1,succe:9,succeed:1,success:[2,3],successfulli:8,sudo:[1,7],suffici:7,suggest:3,sum:4,summar:7,summari:10,suppli:1,support:[0,1,4,5,6,7,9,10,12],suppos:1,suppress:4,sure:[4,7],surpris:1,suspect:3,symbol:[1,2,4,5,10,13],symbolnotfoundonexchang:5,sync:9,synchron:10,syntax:[9,10],sys:13,sys_btc:5,system:[1,3,6,7],t_price:4,t_val:4,ta_lib:7,tag:9,take:[1,2,7,10,14],taken:9,taker:4,talib:4,tar:9,tarbal:9,target:[1,8,10,12],target_hodl_ratio:[1,4],target_hodl_valu:[1,4],technic:[4,6],tempfil:4,templat:9,temporari:[9,10],ten:1,tend:8,tens:3,tent:10,term:1,termin:[1,4,7],test:[1,3,4,7,8,9,10,11],testnet:10,testpypi:9,tether:5,text:1,than:[1,2,3,7,8,10],thei:[1,2,9,10,11],them:[1,3,7,9],therefor:9,therein:7,thi:[1,2,3,4,5,7,8,9,13,14],thing:[1,14],think:8,third:[1,4],thorough:7,those:[1,3,4,8,9],though:2,three:[1,2,4,5,6,8],threshold:[1,4],through:[1,2,5,7],throughli:8,throughout:1,thu:[1,4,7],tick:4,tick_siz:1,ticker:[2,10],time:[1,2,4,6,7,8,9,13],timedelta:4,timefram:10,timeperiod:4,timeseri:4,timestamp:[1,2,10],timestr:4,titl:9,tkagg:7,tminus_pric:4,tminus_v:4,to_csv:[4,13],to_datetim:[1,4],to_pydatetim:[1,4],todai:[4,9],todo:4,togeth:1,token:[4,8,13],tolist:4,tool:[2,3,7,9,11],top:[1,6,9],topic:7,total:2,toward:1,traceback:5,track:[1,3,4,10],tracker:[1,5],trade:[1,4,5,6,7,10,11,13],traded_todai:4,trader:[1,11],trading_dai:1,tradingalgorithm:[0,9],tradingcalendar:2,tradingpair:12,tradit:1,train:1,tran:[1,4],transact:[1,4,8,10],transaction:2,transaction_df:[1,4],transfer:5,transform:1,transit:[5,6],transpos:4,travi:9,treasuri:[1,4],treasury_period_return:[1,4],trend:1,trezor:10,tri:[1,6],trigger:4,trip:10,troubleshoot:10,tst:3,tupl:2,turn:9,tutori:[4,6,7,8],tweak:1,twice:9,two:[1,4,5,6,7,8,12,13,14],twoargument:1,txt:[3,7,9],type:[4,7,9],typo:3,ubuntu:[1,7],uncompress:10,under:[1,2,4,7,8,9],underli:[1,7],underlin:9,underscor:5,understand:[1,7],undesir:0,unexpect:7,uninstal:7,unit:[1,5,10],univers:[1,8],unknown:[1,10],unless:4,unlik:2,unpack:7,unresolv:10,unsupport:10,untar:2,until:[1,4,7],unus:3,updat:[1,4,10],upgrad:[7,9,10],upper:[1,4],upward:1,url:9,usabl:10,usag:1,usd:[1,4,5],usdt:[4,5,13],usdt_btc:1,usdt_btc_benchmark:1,use:[0,1,2,3,4,5,6,7,8,9,10,11,13],used:[1,2,3,4,7,8],useful:7,user:[1,2,4,5,6,7,9],usernam:9,uses:[1,2,5,8],using:[2,3,4,5,7,8,9,10,12,13,14],usr:4,usual:1,utc:[1,4,13],util:[1,2,3,4,6],utilit:13,valid:10,valu:[1,4,7,8,10],vari:[4,7,8,13],variabl:[1,2,4,8,13],varianc:4,varieti:[7,13],variou:[1,2,4],varnam:1,vcforpython27:7,venv:7,veri:[1,2,4,7,9],verifi:[7,9],versatil:13,version:[1,3,4,5,7,8,9,13],via:[1,5,7],via_btc:5,viabl:5,victori:5,video:[4,6,10],view:[3,9],virtual:[1,7],virtualenv:9,virtualenvwrapp:3,visit:[4,6],visual:[1,4,6,7,10],volatil:4,volum:[1,4,5,6,10,12,13],volumeshareslippag:1,vrc_btc:5,vtc_btc:5,wai:[1,2,4,6,7],wait:[1,4],wallet:10,want:[1,2,3,4,5,7],warn:[1,9,10],warranti:4,wave:[4,14],web3:10,web:[5,9],websit:[1,6],weight:4,welcom:3,well:[1,2,6,7],were:[3,4,9],what:[1,3,4,5,7,8,9],whatev:2,whatsnew:9,wheel:[7,9],when:[0,1,2,3,4,7,8,9,10,14],where:[1,2,3,4,5,7,8,10,13,14],which:[1,2,3,4,5,7,8,9,10,13],whitepap:11,whitespac:3,who:3,whole:1,why:[3,7],width:9,win:9,window:[1,4,5,10],within:[1,7,8],without:[1,2,4,7,8,10],work:[2,3,4,7,8,9,10],workaround:10,workflow:7,world:1,wors:1,worth:1,would:[1,2,4,7,8,9],wouldlik:1,wrap:9,wrapper:7,writ:4,write:[1,4,8,13],writer:[2,3,13],writerow:13,written:[1,2,5,6],wrong:5,www:4,xbc_btc:5,xbt:8,xcp_btc:5,xem_btc:5,xlabel:4,xmr_btc:5,xmr_usdt:[4,5],xpm_btc:5,xrp_btc:5,xrp_usdt:5,xvc_btc:5,yahoo_equ:2,yaxi:[1,4],year:9,yet:[0,1],ylabel:4,yml:[7,10],you:[1,2,3,4,5,6,7,8,9,10,13],your:[1,2,3,4,5,6,7,8,9,11,13],yourself:3,yum:7,zec_btc:5,zec_eth:5,zec_usdt:5,zec_xmr:5,zero:[3,4],ziplin:[0,2,3,6,9,11],zipline_root:[2,9],zlib:7,zrx_btc:5,zrx_eth:5},titles:["API Reference","Catalyst Beginner Tutorial","Data Bundles","Development Guidelines","Example Algorithms","Features","Overview","Install","Live Trading","Release Process","Release Notes","Resources","Unit Tests","Utilities","Videos"],titleterms:{"3rd":11,"default":2,"function":[0,5],"new":2,IDE:1,__version__:9,access:1,adjustment_writ:2,algo:12,algorithm:[0,1,4,8],amazon:7,ami:7,api:[0,11],asset:0,asset_db_writ:2,authent:[8,12],avail:2,averag:[1,4],backtest:[0,2,14],basic:1,bdist:9,beginn:1,branch:3,btc:4,bug:10,bui:4,build:10,bundl:[2,12],cach:[0,2],calendar:[0,2],cancel:0,catalyst:[1,7],command:[0,1],commiss:0,commit:[3,9],conda:[7,9],content:6,contribut:3,control:0,convent:5,creat:3,cross:1,crossov:4,csv:[12,13],currenc:8,current:[5,12],daily_bar_writ:2,data:[0,1,2,12,13],dev1:10,dev2:10,dev3:10,dev4:10,dev5:10,dev6:10,dev7:10,dev8:10,dev9:10,develop:3,discov:2,doc:3,docker:3,docstr:3,document:[9,10],dual:[1,4],end_sess:2,environ:[2,3],exampl:[1,4],exchang:[8,12],extract:13,factori:2,featur:5,file:[9,13],first:1,fix:10,format:3,get:7,git:3,gnu:7,guidelin:3,help:7,histor:12,histori:1,hodl:4,ingest:[1,2,12],instal:[1,7,14],interfac:1,jupyt:1,line:[0,1],linux:7,live:[8,14],maco:[7,14],market:[12,13],matplotlib:7,mean:4,messag:3,metadata:0,minute_bar_writ:2,mirror:2,miscellan:0,mode:8,model:0,move:[1,4],name:5,next:[1,9],note:[7,9,10],notebook:1,object:0,old:2,optim:4,order:[0,12],output:13,output_dir:2,over:1,overview:[4,6],packag:9,paper:8,paramet:0,parti:11,pip:7,pipelin:0,pipenv:7,polici:0,portfolio:4,previou:1,price:[1,12],process:9,pycharm:1,pypi:9,python:9,quandl:2,quantopian:2,refer:0,relat:11,releas:[9,10],requir:7,resourc:11,revers:4,run:[0,1,2],schedul:0,sdist:9,setup:1,show_progress:2,simpl:4,simul:0,slippag:0,start_sess:2,stat:12,step:1,strategi:14,structur:3,stub:9,support:8,symbol:8,tabl:6,test:12,ticker:12,trade:[0,8,14],troubleshoot:7,tutori:1,unit:12,univers:4,upcom:5,updat:[7,9],upload:9,using:1,util:[0,13],valid:12,version:10,video:14,virtualenv:7,wiki:2,window:[7,14],work:1,write:2,yahoo:2}}) \ No newline at end of file +Search.setIndex({docnames:["appendix","beginner-tutorial","bundles","development-guidelines","example-algos","features","index","install","live-trading","release-process","releases","resources","unit-tests","utilities","videos"],envversion:52,filenames:["appendix.rst","beginner-tutorial.rst","bundles.rst","development-guidelines.rst","example-algos.rst","features.rst","index.rst","install.rst","live-trading.rst","release-process.rst","releases.rst","resources.rst","unit-tests.rst","utilities.rst","videos.rst"],objects:{"catalyst.api":{EODCancel:[0,0,1,""],NeverCancel:[0,0,1,""],cancel_order:[0,0,1,""],date_rules:[0,1,1,""],fetch_csv:[0,0,1,""],get_environment:[0,0,1,""],get_open_orders:[0,0,1,""],get_order:[0,0,1,""],order:[0,0,1,""],order_percent:[0,0,1,""],order_target:[0,0,1,""],order_target_percent:[0,0,1,""],order_target_value:[0,0,1,""],order_value:[0,0,1,""],record:[0,0,1,""],schedule_function:[0,0,1,""],set_benchmark:[0,0,1,""],set_cancel_policy:[0,0,1,""],set_commission:[0,0,1,""],set_do_not_order_list:[0,0,1,""],set_long_only:[0,0,1,""],set_max_leverage:[0,0,1,""],set_max_order_count:[0,0,1,""],set_max_order_size:[0,0,1,""],set_max_position_size:[0,0,1,""],set_slippage:[0,0,1,""],set_symbol_lookup_date:[0,0,1,""],sid:[0,0,1,""],symbol:[0,0,1,""],symbols:[0,0,1,""],time_rules:[0,1,1,""]},"catalyst.api.date_rules":{every_day:[0,2,1,""],month_end:[0,3,1,""],month_start:[0,3,1,""],week_end:[0,3,1,""],week_start:[0,3,1,""]},"catalyst.api.time_rules":{every_minute:[0,2,1,""],market_close:[0,2,1,""],market_open:[0,2,1,""]},"catalyst.assets":{Asset:[0,1,1,""],AssetConvertible:[0,1,1,""]},"catalyst.assets.Asset":{first_traded:[0,2,1,""],from_dict:[0,4,1,""],is_alive_for_session:[0,4,1,""],is_exchange_open:[0,4,1,""],to_dict:[0,4,1,""]},"catalyst.finance.cancel_policy":{CancelPolicy:[0,1,1,""]},"catalyst.finance.cancel_policy.CancelPolicy":{should_cancel:[0,4,1,""]},"catalyst.finance.commission":{CommissionModel:[0,1,1,""],PerDollar:[0,1,1,""],PerShare:[0,1,1,""],PerTrade:[0,1,1,""]},"catalyst.finance.commission.CommissionModel":{calculate:[0,4,1,""]},"catalyst.finance.execution":{ExecutionStyle:[0,1,1,""],LimitOrder:[0,1,1,""],MarketOrder:[0,1,1,""],StopLimitOrder:[0,1,1,""],StopOrder:[0,1,1,""]},"catalyst.finance.execution.ExecutionStyle":{exchange:[0,2,1,""],get_limit_price:[0,4,1,""],get_stop_price:[0,4,1,""]},"catalyst.finance.slippage":{FixedSlippage:[0,1,1,""],SlippageModel:[0,1,1,""],VolumeShareSlippage:[0,1,1,""]},"catalyst.finance.slippage.SlippageModel":{process_order:[0,4,1,""]},"catalyst.protocol":{BarData:[0,1,1,""]},"catalyst.utils.cache":{CachedObject:[0,1,1,""],ExpiringCache:[0,1,1,""],dataframe_cache:[0,1,1,""],working_dir:[0,1,1,""],working_file:[0,1,1,""]},"catalyst.utils.calendars":{TradingCalendar:[0,1,1,""],clear_calendars:[0,0,1,""],deregister_calendar:[0,0,1,""],get_calendar:[0,0,1,""],register_calendar:[0,0,1,""],register_calendar_type:[0,0,1,""]},"catalyst.utils.calendars.TradingCalendar":{is_open_on_minute:[0,4,1,""],is_session:[0,4,1,""],minute_index_to_session_labels:[0,4,1,""],minute_to_session_label:[0,4,1,""],minutes_count_for_sessions_in_range:[0,4,1,""],minutes_for_session:[0,4,1,""],minutes_for_sessions_in_range:[0,4,1,""],minutes_in_range:[0,4,1,""],next_close:[0,4,1,""],next_minute:[0,4,1,""],next_open:[0,4,1,""],next_session_label:[0,4,1,""],open_and_close_for_session:[0,4,1,""],previous_close:[0,4,1,""],previous_minute:[0,4,1,""],previous_open:[0,4,1,""],previous_session_label:[0,4,1,""],regular_holidays:[0,2,1,""],session_distance:[0,4,1,""],sessions_in_range:[0,4,1,""],sessions_window:[0,4,1,""],special_closes:[0,2,1,""],special_closes_adhoc:[0,2,1,""],special_opens:[0,2,1,""],special_opens_adhoc:[0,2,1,""]},"catalyst.utils.cli":{maybe_show_progress:[0,0,1,""]},catalyst:{run_algorithm:[0,0,1,""]}},objnames:{"0":["py","function","Python function"],"1":["py","class","Python class"],"2":["py","attribute","Python attribute"],"3":["py","staticmethod","Python static method"],"4":["py","method","Python method"]},objtypes:{"0":"py:function","1":"py:class","2":"py:attribute","3":"py:staticmethod","4":"py:method"},terms:{"000000e":1,"0b11":10,"0b7":10,"1000th":1,"15t":4,"1st":1,"30t":4,"328842e":1,"340mb":10,"380954e":1,"40mb":10,"460mb":10,"505275d6646a41f3856b22b16678d":1,"536708e":1,"5min":1,"650729e":1,"7869f7828fa140328eb40477bb7d":1,"998236e":1,"998677e":1,"999120e":1,"999558e":1,"99mb":10,"abstract":0,"boolean":[0,2,8],"break":[7,10],"case":[0,1,2,3,7,13],"class":[0,3,9],"default":[0,1,5,7,8,10,13],"enum":0,"export":9,"final":[1,2,3],"float":[0,1,10],"function":[1,2,3,4,6,7,9,10,11,13],"import":[0,1,2,4,9,13],"int":[0,2,4],"long":[1,2,4],"new":[0,1,3,7,8,9],"null":12,"public":10,"return":[0,1,4,8,9,10,11],"short":[0,1,3,4],"static":[0,9],"switch":[8,10],"throw":10,"true":[0,1,4,8,10],"try":[3,4,7],"var":1,"while":[5,7,9,10],AWS:10,Added:10,And:[1,7],For:[0,1,2,4,5,7,8,9,12],Not:[0,12],One:2,That:[1,7],The:[0,1,2,3,4,7,8,9,10,13],Then:[2,3,4,7],There:[1,3,7,8],These:[0,1,8,13],Use:[1,4,13],Using:[9,10],Will:8,With:8,__del__:0,__exit__:0,__file__:[4,13],__future__:4,__getitem__:0,__main__:[1,4],__name__:[1,4],__setitem__:0,__wrapped__:9,_html_base:3,_tkinter:1,aapl:2,abc:0,abil:[2,10],abl:[1,2,7],about:[0,1,2,6,7],abov:[0,1,3,4,5,7,8,9],absolut:0,abstractholidaycalendar:0,accept:[0,2,7,9],access:[0,5,6,7,8],accord:[0,9],accordingli:[1,4],account:[0,1,2,4,6,10],acquir:[2,7],across:[5,6,10],activ:[7,8,9],actual:[0,1],add:[1,2,3,7,9,13],added:[0,1,2,5,6,7,9],adding:[1,3],addit:[0,1,3,5,6,7,8,10],addition:8,address:9,adjust:[0,2,4,10],administr:7,advanc:7,advantag:7,afford:[1,4],aforement:1,after:[0,1,2,4,7,9,10],afteropen:0,again:[1,3],against:[1,6,8,10,14],agre:4,ahead:1,aim:[4,11],algebra:[4,7],algo:[0,1,2,4,8,10],algo_namespac:[1,4,8],algo_volatil:1,algofil:[1,2],algorithm:[3,5,6,7,10,11,12,13,14],algorithm_period_return:[1,4],algotext:1,alia:[0,4],alias:[4,10],aliv:0,all:[0,1,2,3,4,5,6,7,8,9,10,12],alloc:0,allow:[0,1,2,5,6,7],almost:7,along:[0,2],alongsid:1,alpha:[1,4,7,8],alreadi:[0,1,2,3,7],also:[0,1,2,3,4,6,7,8,9],altern:[1,5,7],although:1,alwai:[0,2,5,8,9,10],among:1,amount:[0,1,4,8,10],amount_charg:0,amp_btc:5,ana:7,anaconda2:1,anaconda:[1,7,9],analog:1,analysi:[1,4,6,9,10,11],analyst:11,analyt:[6,7],analyz:[0,1,4,8,10,13],ani:[0,1,2,4,5,7,8,9,13],anonym:2,anoth:[1,2,4,5],anymor:1,anyth:[1,7,9],apach:4,api:[1,2,4,5,6,7,8,9,13],app:7,appar:1,appear:[0,2,9],append:9,appli:[0,1,4],applic:[1,4],appropri:[1,3,4],approxim:[1,4],appveyor:9,apt:[1,7],arang:[1,4],arbitrag:5,arbitrari:[8,10],arbitrarili:1,arch:7,architectur:1,ardr_btc:5,arena:0,arg:[0,1,9],argument:[0,1,2,8,9],argv:13,around:[6,7,9],arrai:[4,7],art:6,articl:[3,4],ask:[1,3],asmatrix:4,assert:[3,12],assertionerror:3,assess:1,asset:[1,2,4,5,6,8,10,13],asset_nam:[1,4],asset_restrict:0,assetconvert:0,assetdbwrit:2,assign:[1,8],assimil:1,assist:7,assum:[1,3,4,7],astyp:4,atla:7,attach:0,attempt:[0,2,8],attribut:[0,4,9],audit:10,auth2:4,auth:[8,10],auth_alias:4,authent:10,auto:10,automag:7,automat:0,avail:[0,1,4,5,7,8,9,10,12,13],averag:7,avoid:[1,2,4,10],awai:7,awar:[0,9],ax1:[1,4],ax2:[1,4],ax3:[1,4],ax4:[1,4],ax5:[1,4],ax6:[1,4],axhlin:4,axi:4,b23c38652556:4,back:[0,3,5,7],backbon:4,backend:7,backtest:[1,4,5,6,7,8,10,11],backward:0,bah:4,bar:[0,1,4,10],bar_count:[1,4],bar_templ:0,bardata:0,base:[0,1,2,4,5,6,7,8,14],base_curr:[1,4,5,8,13],base_pric:[1,4],basenam:[4,13],basi:[4,10],batch:7,batteri:1,battl:7,bch_btc:5,bch_eth:5,bch_usdt:5,bcn_btc:5,bcn_xmr:5,bcolz:2,bcolzdailybarread:2,bcolzdailybarwrit:2,bcolzminutebarread:2,bcolzminutebarwrit:2,bcy_btc:5,be62ff77760c4599abaac43be9cc9:1,bear:[1,4],beautifi:1,becaus:[0,1,4,7,9,10],been:[0,1,2,7,9],befor:[0,1,2,4,7,8,10],before_trading_start:[0,4],beforeclos:0,beggin:4,begin:[0,1,4,7],beginn:[4,6],behavior:0,being:[0,1,6],bela_btc:5,believ:[1,10],below:[1,3,4,13],benchmark:[0,1,4,5,6,10],benchmark_period_return:[1,4],benchmark_volatil:1,benefit:1,best:[3,6,7],beta:[1,4],better:[0,1],between:[0,1,3,4,5,6,10,12],beyond:5,bfill:4,bia:1,big:7,bin:[1,4,7],binanc:[4,8,10],binari:[1,7,9],bit:[3,7],bitbox:10,bitcoin:[1,4,5,6,8,13],bitcoin_usd_asset:8,bitfinex:[1,4,5,6,8,10],bitmex:8,bittrex:[1,5,6,8,10,14],blank:12,bld:3,blk_btc:5,blk_xmr:5,blockchain:5,blog:4,blotter:[1,4,13],blue:1,bnb_eth:4,bodi:3,book:1,bool:0,both:[0,1,3,5,8,9,12],bought:[1,8],bound:[0,1],box:1,branch:9,breakdown:8,brew:7,brother:7,brows:7,browser:[1,3,9],btc:[1,8,10],btc_usd:[1,4,5,8],btc_usdt:[4,5,6,10,13],btcd_btc:5,btcd_xmr:5,btm_btc:5,bts_btc:5,bug:[0,2,3],bui:[0,1,8,11,12,14],build:[0,1,3,6,7,9],build_ext:3,built:[4,9,12],bundl:[0,1,5,10],bundle_timestamp:0,burst_btc:5,button:[1,7,9],buy_and_hodl:[4,10],buy_btc_simpl:[1,4],buy_btc_simple_out:[1,4],buy_df:[1,4],buy_low_sell_high:10,cach:[1,10],cachedobject:0,cal_nam:0,calcul:[0,1,3,4,8,10,12],calendar_typ:0,calendarnamecollis:0,call:[0,1,2,3,4,10],callabl:0,callback:0,can:[0,1,2,3,4,5,6,7,8,9,10,13],can_trad:[1,4,10],cancel:[1,4,10,12],cancel_ord:[0,1,4],cancel_polici:0,cancelpolici:0,candl:[1,5,10,12],candle_s:4,candlestick:4,cannot:[0,1,4,7],canon:3,capabl:10,capit:[0,1,4],capital_bas:[0,1,4,8,10,13],capital_us:1,captur:1,cash:[1,2,3,4,10],catalyst:[0,3,4,5,6,8,10,11,12,13,14],catalyst_dev:[1,6,7],catalyst_root:0,catalyst_setup:6,caus:[0,1,2,3],ccxt:[8,10],cell:1,cert:10,certian:0,chanc:1,chang:[0,1,3,4,6,7,9,10],channel:[1,6,7],charact:3,charg:[0,1],chart:[1,4,7],check:[0,1,2,3,4,5,7,8],checker:9,checkout:[3,9],choic:9,choos:[1,4,5,7,9,10,13],chosen:[1,13],chunk:[0,1,10],circumv:7,clam_btc:5,classic:[1,4],classifi:1,clean:[0,2,7,9,10,12],clean_on_failur:0,clear:2,clear_calendar:0,cli:[0,1,4,10,13],click:[0,1,7,9],client:8,clone:3,close:[0,1,4,5,13],cls:0,cmap:4,cmd:[1,7],code:[0,1,4,7,9,10,13],codebas:3,codifi:0,coin:[1,4,10],collect:[1,2,4],collis:0,color:[1,4],colorbar:4,colour:4,column:[0,1,2,4],com:[1,2,3,8],combin:[0,7,8],come:[1,2,7,8],command:[2,4,7,8,9,10],comment:1,commiss:[1,5,10],commissionmodel:0,commit:0,common:[0,1,7],commonli:1,commun:[1,5,7,11],comp:4,compar:[1,4,5,6,7,12],comparison:10,compat:[0,6,10],compil:[7,9,10],complement:4,complet:8,complex:[1,7],complianc:4,complimentari:13,comprehens:10,compress:[1,10],comput:[1,4,7,10,11],concept:[0,1],conda:[1,10],conda_build_matrix:9,condit:4,confid:8,config:7,configur:[1,7,10],congratul:7,consecut:0,consid:[0,1,4],consist:[1,5,12],constant:[1,10],constraint:2,consum:9,contain:[0,1,2,3,4,7,12],content:[1,13],context:[0,1,3,4,10,13],contigu:0,continu:1,continuo:1,continuum:7,contract:[0,10],contribut:5,control:[8,9],conveni:[0,1],convent:[4,8],convers:[2,7],convert:[0,2,4],copi:[1,2,3,4,9],copy_tre:0,copyright:4,core:7,corr_m:4,correct:[2,7,8,9],correctli:[1,7,9],correctwai:7,correl:4,correspond:[0,1,7,8,13],cost:[0,1,4],could:[0,1,2,4,7,13],count:[0,2],counter:4,coupl:1,cov_m:4,covari:4,cover:[0,1,4,8,13],coverag:[5,6,8],cpython:7,crash:2,creat:[1,2,4,7,8,9,10,11,12,13],creation:10,critic:5,cross:5,crossov:1,crowd:11,crypto:[1,6,10],cryptoasset:[1,4,13,14],cryptocurr:[4,5,8],csv:[0,1,4,10],csv_data_sourc:0,csvfile:13,csvwriter:13,cumul:10,cumulative_capital_us:3,curat:[1,6],currenc:[1,4],current:[0,1,2,4,7,8,9,10,13],current_d:4,current_dai:4,current_dt:[4,13],custom:[1,2,5,13],cvc_btc:5,cvc_eth:5,cython:9,d6dca79513214346a646079213526:1,dai:[0,1,2,4,7,9],daili:[0,1,2,4,5,6,10,13],darkgoldenrod:4,dash:8,dash_btc:5,dash_usdt:[4,5],dash_xmr:5,data:[4,5,6,7,8,10,11],data_frequ:[0,1,4,13],data_port:0,databas:2,datafram:[0,1,2,4,5,6,11,12,13],dataframe_cach:[0,2],dataport:0,dataset:[1,2,5,10],date:[0,1,2,4,7,8,9,10,12,13],date_column:0,date_format:0,date_rul:0,datetim:[0,4,13],datetimeindex:0,day_end:0,day_start:0,days_offset:0,dcr_btc:5,debian:[1,7],debug:9,debugg:1,decentr:5,decid:9,decim:[0,10],decor:9,decreas:4,dedic:6,def:[1,4,13],default_extens:0,defin:[0,1,4,8],delai:1,delet:[0,2],demonstr:1,denomin:1,dep:3,depart_docu:3,depend:[1,3,7,9,10,13],deploi:[9,10],deprec:3,deregist:0,deregister_calendar:0,deriv:7,describ:5,descript:[3,7],desir:[0,1,4,12,13],desktop:5,detail:[4,5],determin:[0,4],dev1:7,dev2:7,dev3:7,dev4:7,dev5:7,dev6:7,dev8:7,dev9:7,dev:[3,5,7],devel:7,develop:[1,6,7,8,9,10,11,13],deviat:4,devis:1,dgb_btc:5,dict:[0,4,10],dict_:0,dictionari:[0,10],did:[6,7],didn:7,differ:[0,1,2,4,5,7,8,9,13],digit:10,dir:7,dir_util:0,direct:0,directli:[1,2,7,10,13],directori:[0,1,2,3,4,7,8,9],disabl:10,disablemsi:7,discard:4,discord:[1,3,6,7],discuss:1,disk:[0,10],dismiss:1,displai:[1,4,7,9,10],dist:9,distanc:0,distinguish:0,distribut:[4,7,9],distutil:9,divid:[0,3],dividend:[0,2],divis:4,dma:1,dname:1,dnf:7,doc:[2,4,8,9],dockerfil:3,docstr:10,doctest:0,document:[3,4,5,6,7,8],docutil:3,doe:[0,1,2,4,5,7],doesn:[0,2,10],doge_btc:5,dollar:[0,5],don:[0,1,3,7,14],done:[1,4,9],door:5,dot:[0,4],down:[1,4,14],downgrad:3,download:[1,2,7,10],draft:9,drawback:2,drive:1,driven:[1,6,8],drop:[0,1],dropbox:10,dt_minut:0,dual_moving_averag:[1,4],due:0,dword:7,dynam:4,each:[0,1,2,3,4,5,6,7,8,10,12,13],earlier:[1,2,3,4],earliest:4,eas:6,easi:[1,2,4,11],easier:[1,2,4,5,7],easiest:7,easili:[1,6,7],echo:7,eco:6,ecosystem:5,edit:[3,4,7,9],editor:7,educ:1,educt:1,effect:7,either:[0,1,4,7],elaps:4,element:[0,4],elif:[1,4],els:[4,7],emc2_btc:5,empow:[1,6],empti:[1,2,3,4,8,9,10],empty_char:0,empyr:10,enabl:8,encapsul:0,encount:7,encourag:8,end:[0,1,4,10,12,13],end_daili:4,end_dat:[1,4,8],end_minut:0,end_sess:0,end_session_label:0,ending_cash:1,ending_exposur:1,enforc:0,engin:11,enh:3,enhanc:3,enigma:[1,4,5,6,7,10],enigmampc:[1,3,4],enough:[0,1,5,7],ensur:[0,4,7,8,9,10],ensure_directori:4,enter:[0,1,7],entir:3,entri:[1,7],env:[1,3,4,7],enviorn:2,environ:[0,1,4,7,10,13],environemnt:[1,7],eodcancel:0,equal:[0,1,2,4,8,13],equiti:[0,2],equival:[0,4,12],error:[0,1,3,4,5,7,8,10,12],especi:1,essenti:8,establish:6,estim:1,etc:[0,3,9,10],etc_btc:5,etc_eth:5,etc_usdt:5,eth:[1,4,8],eth_btc:[5,8],eth_usdt:[4,5],ether:4,ethereum_bitcoin_asset:8,evalu:1,even:[2,7],event:[0,1],eventrul:0,eventu:1,everi:[0,1,4,7],every_dai:0,every_minut:0,everydai:4,everyth:[1,2],exact:[4,10,13],examin:1,exampl:[0,2,3,5,6,8,9,10,11,13],exceed:0,excel:7,except:[0,1,3,4],excess:4,exchang:[0,1,2,4,5,6,10,14],exchange_algorithm:1,exchange_nam:[0,1,4,8,13],exchange_util:4,exclud:4,exclus:0,exe:1,execut:[0,1,4,7,8,10],execution_pric:0,execution_volum:0,executionstyl:0,exist:[0,1,2,3,4,5,6,7],exit:[0,1,4,9],exit_success:9,exp_btc:5,expect:[0,1,2,4,5,7,9],experi:7,experienc:7,expir:0,expiringcach:0,explain:[7,8],explicitli:9,explictili:7,exposur:0,express:[1,4,6],extend:1,extens:[0,2,3,7,8],extern:[1,4,7],extra:9,extract_transact:[1,4],face:7,facto:1,fail:[0,1,2,7],failur:2,fairli:[1,3],fals:[0,1,4,8],familiar:3,fantast:1,faq:7,far:2,fast:2,fatal:7,fct_btc:5,featur:[1,4,6],fedora:7,fee:5,feedback:[2,10],feel:1,fetch:[0,2,5,8,10,12],fetch_csv:0,few:[1,2,7,9],fewer:7,ffill:4,field:[0,2,4,9],file:[0,1,2,3,4,7,8,10,12],filenam:[1,4,13],fill:[0,1,4,10],fill_char:0,filter:[4,10],final_path:0,financ:[0,1],financi:[1,10],find:[1,2,7,9],finder:0,fine:9,finish:[1,8],fire:0,firm:0,first:[0,2,3,4,7,8,9,14],first_trad:0,fix:[0,3,12],fixedslippag:0,flag:[1,4,7,8,9],flake8:3,flat:0,fldc_btc:5,flo_btc:5,floor:4,focu:[1,4,6],folder:[4,7,10],follow:[0,1,2,3,4,5,7,8,9,13],foo:0,footprint:7,forc:0,fork:11,form:[1,4,5],format:[0,1,2,4,9,10],fortran:7,forum:[6,7],forward:[0,2,12],foster:11,found:[0,1,3,5,7],fourth:[1,4],fraction:10,frame:[1,4],framework:7,free:[1,4],freelanc:11,freetyp:7,freq:[1,4],frequenc:[0,1,4,10,12],frequent:7,fresh:9,from:[0,1,2,3,4,5,7,8,9,10,12,13],from_dict:[0,4],full:[0,1,8,13],fulli:[8,10],func:0,fund:11,fundament:11,further:[1,4],futur:[0,1,2,5,8],game_btc:5,gas_btc:5,gas_eth:5,gave:1,gcc:7,gcf:[1,4],gdax:8,gear:1,gen:0,gen_type_stub:9,gener:[0,2,3,6,7,8,9,10,13],get:[0,1,2,3,4,5,6,8,10,13],get_calendar:0,get_environ:0,get_exchange_symbol:4,get_limit_pric:0,get_open_ord:[0,1,4],get_ord:0,get_stop_pric:0,get_ylim:[1,4],gettempdir:4,gfortran:7,git:9,github:[1,3,4,7,9],give:[4,10],given:[0,1,2,4,5,13],global:1,gno_btc:5,gno_eth:5,gnt_btc:5,gnt_eth:5,goe:[4,8,14],going:[4,7,14],good:[1,9],goog:2,got:1,govern:4,gracefulli:[8,10],grain:9,granular:[5,10],graph:1,grc_btc:5,greater:0,greatli:8,green:[1,4],group:[1,3,6],grow:2,guarante:0,guard:0,guid:[3,7,10],guidelin:[6,7,10],gzip:9,half:0,half_dai:0,hand:3,handi:[1,4,7],handl:[3,4,10],handle_data:[0,1,4,8,13],hang:7,happen:[0,1,2,8],happi:9,hard:1,has:[0,1,2,3,7,8,9,10],hash:10,have:[0,1,2,3,6,7,8,9,14],haven:1,head:[1,7],header:[7,9],heavi:[1,4],heavili:11,hedg:11,held:[0,5],help:[0,1,2,8],henc:1,here:[1,2,4,7,8],hidden:9,high:[1,4,8,11,13],highest:[4,9],highlight:4,hint:[7,9],histor:[1,4,5,6,8,10],histori:[0,2,4,10],hit:[1,10],hitchhik:7,hkey_local_machin:7,hold:[0,4,8],holidai:0,holidaycalendar:0,home:10,homebrew:7,hope:1,hopefulli:[4,14],hourli:10,how:[0,1,2,4,7,8,10],howev:[7,8,9],html:[3,4,9],http:[1,4,8,9],huc_btc:5,idea:[1,2,3],ident:7,identifi:0,idxmax:4,idxmin:4,ignore_exception_detail:0,illustr:8,iloc:4,imestamp:0,immedi:[1,4],impact:10,imper:3,implement:[1,2,4,8,10,14],impli:[0,4],implicitli:0,importerror:1,improv:[0,3,10],inadvert:7,inc:4,includ:[0,1,2,3,4,7,9,10,13],inclus:0,incomplet:2,inconsist:8,incorpor:10,increas:[0,2,4,10],increment:[1,9],independ:[5,7],index:[0,1,3,4,9],indic:[0,2,4,7,10],individu:[1,8],ineffici:10,inf:4,infer:[0,2],infinit:4,influenc:1,info:[0,1,4,10],inform:[0,1,2,4,7,9],ingest:[4,5,10],initi:[0,1,4,8,10,13],inlin:1,inner:1,inplac:3,input:[1,5,6],insert:4,insid:[1,4,7],insight:[1,6],inspect:[1,4],instal:[3,5,6,9,10],installt:7,instanc:[0,2,4,12],instanti:0,instead:[0,1,2,3,4,5,8,10],instruct:[1,3,7,10],integ:[0,2,10],integr:[0,1,5,6,8,10],intend:[1,3,9],interact:[1,8,10],interfac:[0,5,8,9,10,13],intern:[2,7],interpret:[1,4,13],interv:[4,12],introduc:[1,4,5,8,10],invalid:0,invest:[1,6],invok:[1,2],involv:[2,7],ipython:1,is_alive_for_sess:0,is_bui:[0,1,4],is_exchange_open:0,is_open_on_minut:0,is_sess:0,isinst:4,isn:0,issu:[1,3,5,7,9,10],iter:[0,1,2,4,13],itercontext:0,its:[0,1,4,5,7,8],itself:[1,7],jan:1,join:[4,6,7],json:[8,10],json_symbol:4,juli:13,jump:7,jupyt:10,just:[0,1,2,4,5,9],keep:[1,2,4,7,10],kei:[0,2,6,7,8,10],kept:[1,8],keyerror:[0,10],keynam:0,keystor:10,kind:4,know:[0,1,7],knowledg:6,kpi:12,kwarg:[0,9],label:[0,1,4,8,9],lack:5,lambda:4,languag:[1,4],lapack:7,larg:2,larger:10,last:[0,1,2,4,7,10,12],later:[1,2,3,4,10],latest:[7,9,10],launch:[1,7],law:4,layer:5,lazi:2,lazili:0,lbc_btc:5,leak:2,learn:[1,4,6,7,8],least:[0,1,3,12],ledger:10,legend:[1,4],legend_:[1,4],len:[1,3,4],length:0,less:2,let:[1,4,10],level:[1,2,4],leverag:[0,1,4,11],lib:[3,4,10],libatla:7,libfreetype6:7,libgfortran:7,librari:[1,3,4,6,7,8,10,11],licens:4,lifetim:2,like:[0,1,2,3,5,6,7,9,10,12],limit:[0,1,4,5,10,12],limit_pric:[0,1,4],limitord:0,line:[3,4,5,8,10,13],linear:7,link:[7,10],linter:9,linux:[1,5,9],list:[0,1,2,4,5,7,8,9,10,13],littl:[1,3],live:[0,1,4,5,6,7,10,11],live_algo:4,live_graph:4,load:[0,1,2,7,10],load_ext:1,loader:[1,2],loc:[1,4],local:[1,2,3,7,9],locat:[0,1,2,4,13],lock:0,log1p:10,log:[1,4,7,10],logbook:[1,4],logger:[1,4],logic:[1,4,10],long_data:[1,4],long_mavg:[1,4],long_window:[1,4],longer:[1,3,9],look:[1,2,4,7,9,12,13],lookback:4,lookback_d:4,lookback_dai:4,lookup:[0,1],loop:2,loss:10,lot:[2,10],low:[1,4,8],lower:[4,8,10],lowercas:[5,8],lsk_btc:5,lsk_eth:5,ltc:8,ltc_btc:5,ltc_usd:[1,4],ltc_usdt:[4,5],ltc_xmr:5,mac:7,machin:[2,6,9],maco:[1,5],made:[0,2,3,10],magic:1,mai:[0,1,2,4,7,8,9],maid_btc:5,maid_xmr:5,main:[1,7,9],mainnet:10,maint:3,maintain:[0,5,9],mainten:3,major:9,make:[1,2,3,4,5,7,9,10],maker:4,manag:[0,1,4,7,9],mani:[0,1,2,4,7,9,11],manifest:9,manner:8,manual:[7,9],map:[0,2,5,10],marker:[1,4],markers:1,market:[0,1,4,5,6,8,10],market_clos:0,market_curr:[4,5],market_open:0,marketord:0,marketplac:[1,7,10],markowitz:4,mask:0,master:9,match:[1,7,8,9,12],matplotlib:[1,4,6,11],matplotlibrc:7,matrix:[4,9],matter:3,mavg:1,max:0,max_capital_us:3,max_count:0,max_leverag:[0,3],max_not:0,max_shar:0,max_sharpe_port:4,maxim:6,maximum:[0,4],maybe_show_progress:[0,2],mcoin:1,mean:[0,1,2,7,9,10,14],mean_reversion_simpl:4,memori:[0,2],mention:[1,7,8,9],menu:[1,7],merg:1,merger:2,messag:[1,10],metadata:2,metamask:10,method:[0,1,2,4,7,9,10,12,13],metric:[1,10],micro:9,microsoft:7,midnight:[0,4],might:1,migrat:1,min:4,min_trade_cost:0,min_vol_port:4,mind:[1,4],miniconda:7,minim:[6,10],minimum:[0,4,10],minor:[7,9],minut:[0,1,2,4,5,6,7,10,13],minute_end:0,minute_index_to_session_label:0,minute_to_session_label:0,minutes_count_for_sessions_in_rang:0,minutes_for_sess:0,minutes_for_sessions_in_rang:0,minutes_in_rang:0,miscellan:9,miss:[1,7,8,10],mix:7,mkdir:7,mkvirtualenv:3,mode:[0,1,4,5,6,10],model:[1,3,4,5],modif:[0,3,8],modifi:13,modul:[0,1],moment:[7,9],momentum:[1,4,14],mon:0,monei:0,month:[9,13],month_end:0,month_start:0,more:[0,1,2,4,6,7,8,10,13],most:[0,1,2,4,7,8,10],mostli:1,move:[0,2,9],movement:1,mpc:[1,4],msft:2,msgpack:0,msi:7,msiexec:7,much:[0,1,2],multipl:[0,2,4,5,9,10],multiprocess:0,multithread:0,multupl:0,must:[1,2,8,9],mutabl:0,mutual:0,my_algo_cod:8,my_algo_nam:8,mycrypto:10,myetherwallet:10,n_portfolio:4,name:[0,1,2,3,4,7,8,9,13],name_of_project:1,namedtemporaryfil:0,namespac:[1,4,9],nan:[1,4],nano:9,nanosecond:0,nasset:4,nativ:7,naut_btc:5,nav_btc:5,navig:[1,3,7],nchang:4,ndarrai:[1,4],nearest:4,necessari:7,nee:7,need:[0,1,2,3,4,5,7,9,11,13],neg:[0,1],neo:4,neo_eth:8,neo_ethereum_asset:8,neo_usd:4,neos_btc:5,never:[0,2,8],nevercancel:0,newer:[2,7],next:[0,2,7],next_clos:0,next_minut:0,next_open:0,next_session_label:0,nice:[5,6],nmc_btc:5,noebook:1,non:[0,7],none:[0,1,4,13],nor:4,normal:[0,10],note:[0,1,4,5,6,8,13],note_btc:5,notebook:10,notenoughcasherror:10,noth:7,notic:4,notion:[0,4],novemb:9,now:[0,1,2,4,7,9,10,14],number:[0,1,2,4,7,9,10],numer:[0,7],numpi:[1,3,4,7,9,11],nvalu:4,nxc_btc:5,nxt_btc:5,nxt_usdt:5,nxt_xmr:5,obj:0,object:[1,2,3,4],observ:7,obtain:[1,4,8],occur:[1,3,8],off:11,offer:[1,8],offset:[0,4],ohlc:1,ohlcv:[0,4,10,12],old:[0,9],older:[0,2],omg_btc:5,omg_eth:5,omni:5,omni_btc:5,onc:[0,1,2,4,7,8,9],one:[0,1,2,3,4,5,7,10,12,13],one_day_in_minut:4,ones:4,onli:[0,1,2,3,4,6,7,9,13],onlin:10,open:[0,1,3,4,5,7,10,12,13],open_and_close_for_sess:0,open_ord:[0,1,4],openssl:7,oper:7,operatbl:7,opportun:5,opt:[4,7],optim:[1,11],option:[0,1,2,7,10,13],order:[1,4,5,7,8,9,10],order_id:[0,1],order_param:0,order_perc:0,order_target:0,order_target_perc:[0,1,4,8],order_target_valu:[0,1,4],order_valu:0,ordered_pip:3,org:[4,9],organ:1,origin:[1,9],osx:[7,9],other:[0,1,2,4,5,7,9,13],otherwis:7,our:[1,3,4,6,7,9,14],out:[0,1,2,3,4,6,7,9,12],outdat:7,outlin:7,output:[1,2,4,5,6],outstand:[1,4],over:[0,3,4,5,6,7],overcom:5,overfit:1,overrid:[7,9,10],overview:[1,5],overwhelm:1,overwritten:0,own:[2,4,7,8],p_r:4,p_std:4,packag:[1,3,7,11],packet:0,pacman:7,page:[3,5,7,9,10],pai:0,paid:0,pair:[0,1,4,5,8,10],pairon:4,panda:[0,1,2,4,5,6,11],pandasrequestscsv:0,panel:0,paper:[3,5,10],param:[0,10],paramet:[1,4,8,9,10,13],parent:7,pares:0,pars:2,part:[0,1,2,4,7,8,14],partial:[7,10,12],particular:[6,7],pasc_btc:5,pass:[0,1,2,4,9],password:9,past:[1,4],patch:10,path:[0,2,4,7,10,13],pattern:12,pend:9,peopl:3,pep8:3,per:[0,1,2,4,5,10],percent:[0,1,4],percentag:[0,1,4],perdollar:0,perf:[0,1,3,4],perform:[0,1,3,4,5,6,7,10,11],perhap:7,period:[3,4],permiss:[4,7],pershar:0,persist:[1,4,10],pertrad:0,pickl:[0,1,4],piec:[2,7],pink_btc:5,pip:[1,3,9],pipelin:[5,10],pkg:7,place:[0,1,4,8,10],plan:[5,7],platform:[0,7,10,11],pleas:[1,6,7,13],plot:[1,4,11],plt:[1,4],plu:13,point:[0,1,5,9],polici:7,poloniex:[1,4,5,6,8,10,13],popul:9,porfolio:0,portfolio:[0,1,10,13],portfolio_optim:4,portfolio_valu:[1,4],pos_amount:[1,4],posit:[0,1,4,10],positon:4,possibl:[0,2,3,7],post:9,post_func:0,postprocess:0,pot_btc:5,power:[1,4,11],ppc_btc:5,practic:[1,3],pre:[2,7],pre_func:0,precis:10,predefin:8,predict:[1,8],prefer:[1,7],prefix:[3,7],preload:2,prepare_chunk:10,preprocess:[0,9],prerequisit:[1,7],present:[1,8,10],preserv:10,prevent:[2,7,9],previou:[0,7,14],previous:1,previous_clos:0,previous_minut:0,previous_open:0,previous_session_label:0,price:[0,2,4,5,6,8,10,13],price_chang:[1,4],price_impact:0,primari:7,print:[1,4,7,9],print_result:1,prior:[1,4,10],privat:10,privileg:7,probabl:1,problem:[1,2,7,9],proce:7,proceed:7,process:[0,1,2,4,8],process_ord:0,produc:[2,4,7],profit:[1,6],program:[1,7],progress:[0,2,10],project:[1,6,7,11],prompt:[1,7],proper:[7,8],properli:[1,4,7,10,13],protect:0,protocol:[0,1,5],provid:[0,1,2,4,5,6,7,8,10,11,13],publish:[9,10],pull:[0,3,9],pun:1,purchas:[1,4],purpos:[1,5,8],push:9,put:[7,8],pycharm:[9,10],pydata:[4,5,6],pyfolio:10,pypirc:9,pypitest:9,pyplot:[1,4],python2:[3,5,7,10],python3:[5,7,10],python:[0,1,3,4,6,7,10,11,13],pythonw:7,pytz:[4,13],quandl:0,quandl_api_kei:2,quandl_download_attempt:2,quantit:[1,11],quantopian:[0,4,11],queri:[0,2],queryabl:0,question:[1,3,6],quick:1,quickli:[4,14],quirk:7,quit:2,rads_btc:5,rais:[0,3,10],ran:2,random:[4,12],randomli:12,rang:[0,1,2,4,8,12],rate:[4,10],rather:[0,1,7],ratio:4,raw:[0,2,7],rdylgn:4,reach:[0,8],read:[1,2,7,10],read_csv:0,read_pickl:1,readi:9,real:[0,4,8],realist:[1,4],reason:[1,2,7],rebal:4,rebalanc:[1,4],rebalance_period:4,recal:1,receiv:[1,2,10],recent:[0,1,2,4,5,7],recogn:7,recommend:[2,7],reconcil:0,reconstruct:1,record:[0,1,4,13],red:[1,4],redhat:7,redon:10,redownload:[1,2],reduc:10,redund:10,refactor:3,refer:[1,3,4,5,7,8,9],referenc:[1,4,8],refus:1,regard:6,regardless:[1,7,8],regedit:7,regist:[0,1,2],register_calendar:0,register_calendar_typ:0,registri:7,regular:[0,7],regular_holidai:0,reinstal:7,reinvest:0,rel:3,relat:3,relationship:2,releas:[3,5,6,7],reli:[7,11],remain:10,rememb:[1,7],remot:[0,2],remov:[1,3,4,7,9,10],renam:9,rep:7,rep_btc:5,rep_eth:5,rep_usdt:5,repeat:10,replac:[4,7],repo:7,report:[1,3,7],repositori:[7,9,10],repres:[0,2,8],represent:0,reproduc:2,req:10,request:[0,1,2,3,4,10],requests_csv:0,requir:[1,3,4,8,9,10],requirements_blaz:3,requirements_dev:3,requirements_doc:3,research:1,reserv:[1,4,5],reserve_ratio:[1,4],reserve_valu:[1,4],resolut:[1,4,5,6,10,13],resolv:[0,7,10],resourc:[2,6,10],respect:[3,9,13],respons:[0,2,7],rest:2,restart:10,restor:10,restrict:[0,7],restricted_list:0,restructuredtext:3,result:[0,1,2,4,7,8,10,12,13],results_arrai:4,results_fram:4,resum:4,retest:4,retri:2,retriev:[0,1,4,10,12],rev:3,revers:[10,14],revert:3,review:[1,7],revis:1,rhel:7,ric_btc:5,ride:[4,14],right:[1,7],rinkebi:10,risk:[1,4,10],roll:1,rollup:2,root:[3,9],ropstein:10,round:10,rout:0,routin:7,row:[0,1,4],rsi:4,rsi_overbought:4,rsi_oversold:4,rst:[3,9],rule:0,run:[3,4,5,7,8,9,10,12,13],run_algo:[1,4,13],run_algorithm:[0,1,4,8,13],runtim:1,runtimeerror:7,safe:1,sai:0,said:1,same:[1,2,4,5,7,8,9,10,13],sampl:[4,10,12],satisfi:7,save:[1,2,3,4,7,13],sbd_btc:5,sc_btc:5,scale:[1,10],scatter:[1,4],schedul:8,schedule_funct:0,scientif:11,scikit:1,scipi:[6,7],scratch:7,script:[1,4,9,13],scriptnam:13,seamless:[5,6],search:7,second:[0,1,4,7,14],secret:8,section:[1,3,4,7,8,9,13],secur:[4,6,11],securitylist:0,see:[0,1,2,4,5,6,7,8,13],seek:7,seen:4,select:[1,4,7,12],self:[0,3],sell:[0,1,4,8,10,11,12,14],sell_df:[1,4],sentinel:0,separ:[1,3,5,7,8],seper:8,seri:[0,1,4,14],serial:0,seriou:1,server:[1,2,9],servic:2,session:[0,7],session_dist:0,session_label:0,sessions_in_rang:0,sessions_window:0,set:[0,1,2,4,5,7,8,10],set_benchmark:[0,5],set_cancel_polici:0,set_commiss:[0,4],set_do_not_order_list:0,set_long_onli:0,set_max_leverag:0,set_max_order_count:0,set_max_order_s:0,set_max_position_s:0,set_printopt:4,set_size_inch:[1,4],set_slippag:[0,4],set_symbol_lookup_d:0,set_tick:[1,4],set_ylabel:[1,4],setup:[3,9],setuptool:7,seven:4,sever:[1,6,7,10],share:[0,1,5,6],sharex:[1,4],sharp:[1,4],ship:[2,7,9],short_data:[1,4],short_exposur:1,short_mavg:[1,4],short_valu:1,short_window:[1,4],shorter:1,shorthand:0,shorts_count:1,should:[0,1,2,3,7,8,9,10],should_cancel:0,shourc:2,show:[0,1,2,4],show_progress:0,shown:[0,2],shutil:0,sid:[0,1,2,10],side:7,sidsnotfound:0,sign_msg:10,sign_tx:10,signal:[2,4],signatur:2,signific:4,sim_engin:0,similar:[1,7,8],similarli:0,simpl:[0,1,14],simple_univers:4,simpler:13,simplest:4,simpli:[1,3,4,7,13],simplic:4,simplifi:1,simul:[1,4,5,7,8],simulate_ord:[4,8,10],simulation_dt_func:0,simultan:10,sinc:[1,4,7,8,9,13],singl:[0,2,4,7,10],site:3,six:0,size:[0,4,7,10],sjcx_btc:5,skeleton:9,skim:1,skip:[1,4,10],sklearn:6,sleep:8,slighlti:4,slightli:7,slippag:[1,4,10],slippagemodel:0,smaller:[7,10],smoothli:14,snip:1,snippet:13,softwar:[4,7],sold:8,solut:7,solv:[1,2,7,10],some:[0,1,2,3,4,7,8,10,11],someon:7,someth:3,somewhat:1,sort:0,sortino:[1,10],sourc:[0,1,2,3,4,7,9,10,11],space:1,special:[0,8],special_clos:0,special_closes_adhoc:0,special_open:0,special_opens_adhoc:0,specif:[0,1,4,7,10],specifi:[0,1,2,4,5,8,9,10],spend:1,spent:5,sphinx:[3,9],split:[0,1,2,4],splitext:[4,13],spot:0,spread:[0,4],spring:11,sqliteadjustmentwrit:2,sqrt:4,ssl:10,stabl:[4,7],stai:[9,10],standard:[0,2,3,4,5,10],star:4,start:[0,1,2,3,4,6,7,8,12,13],start_dat:[1,4,8],start_minut:0,start_sess:0,start_session_label:0,start_tim:4,starting_cash:[1,4],starting_exposur:1,starting_valu:1,stat:[4,10],state:[0,1,2,4,6,10],statist:[1,5,6,8,10],stats_output:4,stats_util:[1,4],statsmodel:6,statu:4,std:4,stdev:4,stdout:1,steem_btc:5,steem_eth:5,step:[2,7],still:[1,2,4,5,7],stock:[1,2,4],stop:[0,1,4,10],stop_pric:0,stoplimitord:0,stopord:0,storag:[1,8,10],store:[0,1,2,4,5,10,13],str:[0,4],str_btc:5,str_usdt:5,straightforward:4,strat_btc:5,strategi:[1,4,6,8],stream:1,streamlin:1,strftime:4,strict_extens:0,strictli:[0,2,7],string:[0,1,2,4,9],string_typ:0,strong:0,strongli:7,struct:0,structur:[5,6,8,11],sty:3,style:[0,3,4],subdirectori:2,subject:[0,3],submit:3,subplot:[1,4],subset:4,substanti:1,subtract:0,succe:9,succeed:1,success:[2,3],successfulli:8,sudo:[1,7],suffici:7,suggest:3,sum:4,summar:7,summari:10,suppli:1,support:[0,1,4,5,6,7,9,10,12],suppos:1,suppress:4,sure:[4,7],surpris:1,suspect:3,symbol:[0,1,2,4,5,10,13],symbol_column:0,symbol_str:0,symbolnotfound:0,symbolnotfoundonexchang:5,sync:9,synchron:10,syntax:[0,9,10],sys:13,sys_btc:5,system:[0,1,3,6,7],t_price:4,t_val:4,ta_lib:7,tag:9,take:[0,1,2,7,10,14],taken:9,taker:4,talib:4,tar:9,tarbal:9,target:[0,1,8,10,12],target_hodl_ratio:[1,4],target_hodl_valu:[1,4],technic:[4,6],tell:0,tempfil:4,templat:9,temporari:[0,9,10],ten:1,tend:8,tens:3,tent:10,term:1,termin:[1,4,7],test:[0,1,3,4,7,8,9,10,11],testnet:10,testpypi:9,tether:5,text:1,than:[0,1,2,3,7,8,10],thei:[0,1,2,9,10,11],them:[0,1,3,7,9],therefor:9,therein:7,thi:[0,1,2,3,4,5,7,8,9,13,14],thing:[1,14],think:8,third:[1,4],thorough:7,those:[1,3,4,8,9],though:2,thread:0,three:[0,1,2,4,5,6,8],threshold:[1,4],through:[1,2,5,7],throughli:8,throughout:1,thu:[1,4,7],tick:4,tick_siz:1,ticker:[0,2,10],time:[0,1,2,4,6,7,8,9,13],time_rul:0,timedelta:[0,4],timefram:10,timeperiod:4,timeseri:4,timestamp:[0,1,2,10],timestr:4,timezon:0,titl:9,tkagg:7,tminus_pric:4,tminus_v:4,tmp_dir:0,to_csv:[4,13],to_datetim:[1,4],to_dict:0,to_pydatetim:[1,4],todai:[4,9],todo:4,togeth:1,token:[4,8,13],tolist:4,tool:[2,3,7,9,11],top:[1,6,9],topic:7,total:[0,2],toward:1,traceback:[0,5],track:[0,1,3,4,10],tracker:[1,5],trade:[1,4,5,6,7,10,11,13],traded_todai:4,trader:[1,11],trading_dai:1,tradingalgorithm:[0,9],tradingcalendar:[0,2],tradingcontrolexcept:0,tradingpair:12,tradingsimul:0,tradit:1,train:1,tran:[1,4],transact:[0,1,4,8,10],transaction:2,transaction_df:[1,4],transfer:5,transform:1,transit:[5,6],transpos:4,travi:9,treasuri:[1,4],treasury_period_return:[1,4],treat:0,trend:1,trezor:10,tri:[1,6],trigger:[0,4],trip:10,troubleshoot:10,tst:3,tue:0,tupl:[0,2],turn:9,tutori:[4,6,7,8],tweak:1,twice:9,two:[0,1,4,5,6,7,8,12,13,14],twoargument:1,txt:[3,7,9],type:[0,4,7,9],typo:3,tzinfo:0,ubuntu:[1,7],uncompress:10,under:[1,2,4,7,8,9],underli:[0,1,7],underlin:9,underscor:5,understand:[1,7],undesir:0,unexpect:7,uninstal:7,uniqu:0,unit:[1,5,10],univers:[0,1,8],universe_func:0,unknown:[1,10],unless:4,unlik:2,unpack:7,unresolv:10,unsupport:10,untar:2,until:[1,4,7],unus:3,unwrap:0,updat:[1,4,10],upgrad:[7,9,10],upper:[1,4],upward:1,url:[0,9],usabl:10,usag:1,usd:[1,4,5],usdt:[4,5,13],usdt_btc:1,usdt_btc_benchmark:1,use:[0,1,2,3,4,5,6,7,8,9,10,11,13],used:[0,1,2,3,4,7,8],useful:[0,7],user:[1,2,4,5,6,7,9],usernam:9,uses:[0,1,2,5,8],using:[2,3,4,5,7,8,9,10,12,13,14],usr:4,usual:[0,1],utc:[0,1,4,13],util:[1,2,3,4,6],utilit:13,val:0,valid:[0,10],valu:[0,1,4,7,8,10],valueerror:0,vari:[4,7,8,13],variabl:[1,2,4,8,13],varianc:4,varieti:[7,13],variou:[1,2,4],varnam:1,vcforpython27:7,venv:7,veri:[0,1,2,4,7,9],verifi:[7,9],versatil:13,version:[0,1,3,4,5,7,8,9,13],via:[1,5,7],via_btc:5,viabl:5,victori:5,video:[4,6,10],view:[3,9],virtual:[1,7],virtualenv:9,virtualenvwrapp:3,visit:[4,6],visual:[1,4,6,7,10],vix:0,volatil:4,volum:[0,1,4,5,6,10,12,13],volume_limit:0,volumeshareslippag:[0,1],vrc_btc:5,vtc_btc:5,wai:[1,2,4,6,7],wait:[1,4],wallet:10,want:[0,1,2,3,4,5,7],warn:[0,1,9,10],warn_on_cancel:0,warranti:4,wave:[4,14],web3:10,web:[5,9],websit:[1,6],wed:0,week_end:0,week_start:0,weight:4,welcom:3,well:[1,2,6,7],were:[3,4,9],what:[0,1,3,4,5,7,8,9],whatev:2,whatsnew:9,wheel:[7,9],when:[0,1,2,3,4,7,8,9,10,14],where:[1,2,3,4,5,7,8,10,13,14],whether:0,which:[0,1,2,3,4,5,7,8,9,10,13],whitepap:11,whitespac:3,who:3,whole:1,whose:0,why:[3,7],width:9,win:9,window:[0,1,4,5,10],within:[1,7,8],without:[1,2,4,7,8,10],work:[2,3,4,7,8,9,10],workaround:10,workflow:7,working_dir:0,working_fil:0,world:1,wors:1,worth:1,would:[0,1,2,4,7,8,9],wouldlik:1,wrap:[0,9],wrapper:7,writ:4,write:[1,4,8,13],writer:[2,3,13],writerow:13,written:[0,1,2,5,6],wrong:5,www:4,xbc_btc:5,xbt:8,xcp_btc:5,xem_btc:5,xlabel:4,xmr_btc:5,xmr_usdt:[4,5],xpm_btc:5,xrp_btc:5,xrp_usdt:5,xvc_btc:5,yahoo_equ:2,yaxi:[1,4],year:9,yet:[0,1],ylabel:4,yml:[7,10],you:[0,1,2,3,4,5,6,7,8,9,10,13],your:[1,2,3,4,5,6,7,8,9,11,13],yourself:3,yum:7,zec_btc:5,zec_eth:5,zec_usdt:5,zec_xmr:5,zero:[3,4],ziplin:[0,2,3,6,9,11],zipline_root:[2,9],zlib:7,zrx_btc:5,zrx_eth:5},titles:["API Reference","Catalyst Beginner Tutorial","Data Bundles","Development Guidelines","Example Algorithms","Features","Overview","Install","Live Trading","Release Process","Release Notes","Resources","Unit Tests","Utilities","Videos"],titleterms:{"3rd":11,"default":2,"function":[0,5],"new":2,IDE:1,__version__:9,access:1,adjustment_writ:2,algo:12,algorithm:[0,1,4,8],amazon:7,ami:7,api:[0,11],asset:0,asset_db_writ:2,authent:[8,12],avail:2,averag:[1,4],backtest:[0,2,14],basic:1,bdist:9,beginn:1,branch:3,btc:4,bug:10,bui:4,build:10,bundl:[2,12],cach:[0,2],calendar:[0,2],cancel:0,catalyst:[1,7],command:[0,1],commiss:0,commit:[3,9],conda:[7,9],content:6,contribut:3,control:0,convent:5,creat:3,cross:1,crossov:4,csv:[12,13],currenc:8,current:[5,12],daily_bar_writ:2,data:[0,1,2,12,13],dev1:10,dev2:10,dev3:10,dev4:10,dev5:10,dev6:10,dev7:10,dev8:10,dev9:10,develop:3,discov:2,doc:3,docker:3,docstr:3,document:[9,10],dual:[1,4],end_sess:2,environ:[2,3],exampl:[1,4],exchang:[8,12],extract:13,factori:2,featur:5,file:[9,13],first:1,fix:10,format:3,get:7,git:3,gnu:7,guidelin:3,help:7,histor:12,histori:1,hodl:4,ingest:[1,2,12],instal:[1,7,14],interfac:1,jupyt:1,line:[0,1],linux:7,live:[8,14],maco:[7,14],market:[12,13],matplotlib:7,mean:4,messag:3,metadata:0,minute_bar_writ:2,mirror:2,miscellan:0,mode:8,model:0,move:[1,4],name:5,next:[1,9],note:[7,9,10],notebook:1,object:0,old:2,optim:4,order:[0,12],output:13,output_dir:2,over:1,overview:[4,6],packag:9,paper:8,paramet:0,parti:11,pip:7,pipelin:0,pipenv:7,polici:0,portfolio:4,previou:1,price:[1,12],process:9,pycharm:1,pypi:9,python:9,quandl:2,quantopian:2,refer:0,relat:11,releas:[9,10],requir:7,resourc:11,revers:4,run:[0,1,2],schedul:0,sdist:9,setup:1,show_progress:2,simpl:4,simul:0,slippag:0,start_sess:2,stat:12,step:1,strategi:14,structur:3,stub:9,support:8,symbol:8,tabl:6,test:12,ticker:12,trade:[0,8,14],troubleshoot:7,tutori:1,unit:12,univers:4,upcom:5,updat:[7,9],upload:9,using:1,util:[0,13],valid:12,version:10,video:14,virtualenv:7,wiki:2,window:[7,14],work:1,write:2,yahoo:2}}) \ No newline at end of file diff --git a/utilities.html b/utilities.html index fd0c760c..148209de 100644 --- a/utilities.html +++ b/utilities.html @@ -1,52 +1,335 @@ - - - - - Utilities — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Utilities — Catalyst 0.4 documentation + -
    -
    -
    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + + + + + + +
    +
    +
    + +
    +
    +

    Utilities

    @@ -64,25 +347,25 @@ script that you need to use depends on the interface that you are using to run your trading algorithm, which could be the CLI or a Python Interpreter.

    1. Script to use with CLI:

      -
      def analyze(context=None, results=None):
      +
      def analyze(context=None, results=None):
           import sys
           import os
           from os.path import basename
       
      -    # Save results in CSV file
      +    # Save results in CSV file
           filename = os.path.splitext(basename(sys.argv[3]))[0]
      -    results.to_csv(filename + '.csv')
      +    results.to_csv(filename + '.csv')
       
    2. Script to use with Python Interpreter:

      -
      def analyze(context=None, results=None):
      +
      def analyze(context=None, results=None):
           import os
           from os.path import basename
       
      -    # Save results in CSV file
      -    filename = os.path.splitext(os.path.basename(__file__))[0]
      -    results.to_csv(filename + '.csv')
      +    # Save results in CSV file
      +    filename = os.path.splitext(os.path.basename(__file__))[0]
      +    results.to_csv(filename + '.csv')
       
    3. @@ -97,7 +380,7 @@ Run this script directly from your development environment: python scriptname.py where the contents of ‘scriptname.py’ are as follows. Two different version are provided as an example for daily- and minute-resolution data respectively:

      Simpler case for daily data

      -
      import os
      +
      import os
       import pytz
       from datetime import datetime
       
      @@ -105,23 +388,23 @@ provided as an example for daily- and minute-resolution data respectively:

      from catalyst.utils.run_algo import run_algorithm def initialize(context): - # Portfolio assets list - context.asset = symbol('btc_usdt') # Bitcoin on Poloniex + # Portfolio assets list + context.asset = symbol('btc_usdt') # Bitcoin on Poloniex def handle_data(context, data): - # Variables to record for a given asset: price and volume - price = data.current(context.asset, 'price') - volume = data.current(context.asset, 'volume') + # Variables to record for a given asset: price and volume + price = data.current(context.asset, 'price') + volume = data.current(context.asset, 'volume') record(price=price, volume=volume) def analyze(context=None, results=None): - # Generate DataFrame with Price and Volume only - data = results[['price','volume']] + # Generate DataFrame with Price and Volume only + data = results[['price','volume']] - # Save results in CSV file - filename = os.path.splitext(os.path.basename(__file__))[0] - data.to_csv(filename + '.csv') + # Save results in CSV file + filename = os.path.splitext(os.path.basename(__file__))[0] + data.to_csv(filename + '.csv') ''' Bitcoin data is available on Poloniex since 2015-3-1. Dates vary for other tokens. In the example below, we choose the @@ -134,13 +417,13 @@ provided as an example for daily- and minute-resolution data respectively:

      analyze=analyze, start=start, end=end, - exchange_name='poloniex', + exchange_name='poloniex', capital_base=10000, - base_currency = 'usdt') + base_currency = 'usdt')

      More versatile case for minute data

      -
      import os
      +
      import os
       import csv
       import pytz
       from datetime import datetime
      @@ -150,31 +433,31 @@ provided as an example for daily- and minute-resolution data respectively:

      def initialize(context): -# Portfolio assets list -context.asset = symbol('btc_usdt') # Bitcoin on Poloniex +# Portfolio assets list +context.asset = symbol('btc_usdt') # Bitcoin on Poloniex -# Creates a .CSV file with the same name as this script to store results +# Creates a .CSV file with the same name as this script to store results context.csvfile = open(os.path.splitext( - os.path.basename(__file__))[0]+'.csv', 'w+') + os.path.basename(__file__))[0]+'.csv', 'w+') context.csvwriter = csv.writer(context.csvfile) def handle_data(context, data): -# Variables to record for a given asset: price and volume -# Other options include 'open', 'high', 'open', 'close' -# Please note that 'price' equals 'close' -date = context.blotter.current_dt # current time in each iteration -price = data.current(context.asset, 'price') -volume = data.current(context.asset, 'volume') +# Variables to record for a given asset: price and volume +# Other options include 'open', 'high', 'open', 'close' +# Please note that 'price' equals 'close' +date = context.blotter.current_dt # current time in each iteration +price = data.current(context.asset, 'price') +volume = data.current(context.asset, 'volume') -# Writes one line to CSV on each iteration with the chosen variables +# Writes one line to CSV on each iteration with the chosen variables context.csvwriter.writerow([date,price,volume]) def analyze(context=None, results=None): -# Close open file properly at the end +# Close open file properly at the end context.csvfile.close() -# Bitcoin data is available from 2015-3-2. Dates vary for other tokens. +# Bitcoin data is available from 2015-3-2. Dates vary for other tokens. start = datetime(2017, 7, 30, 0, 0, 0, 0, pytz.utc) end = datetime(2017, 7, 31, 0, 0, 0, 0, pytz.utc) results = run_algorithm(initialize=initialize, @@ -182,9 +465,9 @@ provided as an example for daily- and minute-resolution data respectively:

      analyze=analyze, start=start, end=end, - exchange_name='poloniex', - data_frequency='minute', - base_currency ='usdt', + exchange_name='poloniex', + data_frequency='minute', + base_currency ='usdt', capital_base=10000 )
      @@ -193,64 +476,68 @@ provided as an example for daily- and minute-resolution data respectively:

      -
      -
      - -
      -
      - - - + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/videos.html b/videos.html index 13437f49..8d280d00 100644 --- a/videos.html +++ b/videos.html @@ -1,52 +1,335 @@ - - - - - Videos — Catalyst 0.4 documentation - - - - - - - - - - - - - + + + + + + + + + Videos — Catalyst 0.4 documentation + -
    -
    -
    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + + + + + + +
    +
    +
    + +
    +
    +

    Videos

    @@ -95,66 +378,68 @@ in the previous video, we now take it to trade live against the Bittrex exchange
    -
    -
    - -
    -
    - - - + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file