node-red-contrib-alpaca
Version:
Nodes for connecting to the Alpaca stock trading API.
253 lines (239 loc) • 10.6 kB
HTML
<script type="text/javascript">
/* global RED */
//too savage: RED.nodes.removeNodeSet("node-red-contrib-alpaca-simple/alpaca-simple")
//console.log(RED.nodes.registry.getModule("node-red-contrib-alpaca-simple"))
//if(!RED.nodes.registry.getModule("node-red-contrib-alpaca-simple")){
// ok, nothing works, just leave it
RED.nodes.registerType('submit-order', {
category: 'alpaca',
color: '#EEEEEE',
defaults: {
name: { value: "" },
symbol: { value: "" },
ordertype: { value: "market" },
qty: { value: 0 },
limit_price: { value: 0 },
stop_price: { value: 0 },
tif: { value: "day" },
side: { value: "" },
auth: { value: "", type: "alpaca-config" }
},
inputs: 1,
outputs: 1,
icon: "alpaca.svg",
paletteLabel: "Submit Order",
label: function() {
return this.name || "Alpaca Submit";
}
});
RED.nodes.registerType('get-order', {
category: 'alpaca',
color: '#EEEEEE',
defaults: {
name: { value: "" },
auth: { value: "", type: "alpaca-config" }
},
inputs: 1,
outputs: 1,
icon: "alpaca.svg",
paletteLabel: "Get Orders",
label: function() {
return this.name || "Alpaca Orders";
}
});
RED.nodes.registerType('get-bars', {
category: 'alpaca',
color: '#EEEEEE',
defaults: {
name: { value: "" },
symbol: { value: "" },
limit: { value: 20 },
auth: { value: "", type: "alpaca-config" }
},
inputs: 1,
outputs: 1,
icon: "alpaca.svg",
paletteLabel: "Get Bars",
label: function() {
return this.name || "Alpaca Bars";
}
});
RED.nodes.registerType('get-account', {
category: 'alpaca',
color: '#EEEEEE',
defaults: {
name: { value: "" },
auth: { value: "", type: "alpaca-config" }
},
inputs: 1,
outputs: 1,
icon: "alpaca.svg",
paletteLabel: "Get Account",
label: function() {
return this.name || "Alpaca Account";
}
});
//}
</script>
<script type="text/x-red" data-template-name="submit-order">
<div class="form-row">
<label for="node-input-auth"><i class="fa fa-key"></i> Auth</label>
<input type="text" id="node-input-auth" placeholder="API Keys">
</div>
<!-- TODO: Implement typed input on this page
div class="red-ui-typedInput-container red-ui-typedInput-focus" style="width: 250px; margin-right: 0px; margin-left: 0px;"><button class="red-ui-typedInput-type-select" tabindex="0"><i class="red-ui-typedInput-icon fa fa-caret-down"></i><span class="red-ui-typedInput-type-label">msg.</span></button>
<div class="red-ui-typedInput-input-wrap"><input class="red-ui-typedInput-input" type="text" placeholder="payload" autocomplete="off" style="width: 100%; margin-right: 0px; margin-left: 0px;"></div>
<div class="red-ui-typedInput-value-label" style="display: none;"></div><button tabindex="0" class="red-ui-typedInput-option-trigger" style="display: none;"><span class="red-ui-typedInput-option-label"></span><span class="red-ui-typedInput-option-caret"><i class="red-ui-typedInput-icon fa fa-caret-down"></i></span></button>
<button
tabindex="0" class="red-ui-typedInput-option-expand" style="display: none;"><i class="red-ui-typedInput-icon fa fa-ellipsis-h"></i></button>
</div-->
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-symbol"><i class="fa fa-tag"></i> Symbol</label>
<input type="text" id="node-input-symbol" placeholder="Symbol">
<br />
<small style="padding-left: 100px;">Incoming <code>.symbol</code> overwrites this value</small>
</div>
<div class="form-row">
<label for="node-input-ordertype"><i class="fa fa-question"></i> Order Type</label>
<select id="node-input-ordertype" placeholder="Order Type">
<option value="market">Market</option>
<option value="limit">Limit</option>
<option value="stop">Stop</option>
<option value="stop_limit">Stop Limit</option>
</select>
<br />
<small style="padding-left: 100px;">Incoming <code>.type</code> overwrites this value</small>
<br />
<small style="padding-left: 100px;">"market" | "limit" | "stop" | "stop_limit"</small>
</div>
<div class="form-row">
<label for="node-input-qty"><i class="fa fa-hashtag"></i> Quantity</label>
<input type="text" id="node-input-qty" placeholder="0">
<br />
<small style="padding-left: 100px;">Incoming <code>.qty</code> overwrites this value</small>
</div>
<div class="form-row" id="order-limit_price">
<label for="node-input-limit_price"><i class="fa fa-usd"></i> Limit Price</label>
<input type="text" id="node-input-limit_price" placeholder="0.0">
<br />
<small style="padding-left: 100px;">Incoming <code>.limit_price</code> overwrites this value</small>
</div>
<div class="form-row" id="order-stop_price">
<label for="node-input-stop_price"><i class="fa fa-usd"></i> Stop Price</label>
<input type="text" id="node-input-stop_price" placeholder="0.0">
<br />
<small style="padding-left: 100px;">Incoming <code>.stop_price</code> overwrites this value</small>
</div>
<div class="form-row">
<label for="node-input-side"><i class="fa fa-suitcase"></i> Side</label>
<select id="node-input-side" placeholder="Side">
<option value="buy">Buy</option>
<option value="sell">Sell</option>
</select>
<br />
<small style="padding-left: 100px;">Incoming <code>.side</code> overwrites this value</small>
<br />
<small style="padding-left: 100px;">"buy" | "sell"</small>
</div>
<div class="form-row">
<label for="node-input-tif"><i class="fa fa-clock-o"></i> Time In Force</label>
<select id="node-input-tif" placeholder="Day">
<option value="day">Day</option>
<option value="gtc">Good-til-close</option>
</select>
<br />
<small style="padding-left: 100px;">Incoming <code>.tif</code> overwrites this value</small>
<br />
<small style="padding-left: 100px;">"day" | "gtc"</small>
</div>
</script>
<script type="text/x-red" data-help-name="submit-order">
<p>Node for submitting orders to Alpaca </p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<h3>Details</h3>
<p>Payload is the full response object from the API</p>
</script>
<script type="text/x-red" data-template-name="get-order">
<div class="form-row">
<label for="node-input-auth"><i class="fa fa-key"></i> Auth</label>
<input type="text" id="node-input-auth" placeholder="API Keys">
</div>
<div class="form-row">
<label for="node-input-limit"><i class="fa-fa-hashtag"></i> Return Limit</label>
<input type="text" id="node-input-limit" placeholder="Limit">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="get-order">
<p>Node for retrieving a list of orders associated with your account </p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<h3>Details</h3>
<p>Payload is the full response object from the API</p>
</script>
<script type="text/x-red" data-template-name="get-account">
<div class="form-row">
<label for="node-input-auth"><i class="fa fa-key"></i> Auth</label>
<input type="text" id="node-input-auth" placeholder="API Keys">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="get-account">
<p>Node for retrieving your account details </p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<h3>Details</h3>
<p>Payload is the full response object from the API</p>
</script>
<script type="text/x-red" data-template-name="get-bars">
<div class="form-row">
<label for="node-input-auth"><i class="fa fa-key"></i> Auth</label>
<input type="text" id="node-input-auth" placeholder="API Keys">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-symbol"><i class="fa fa-tag"></i> Symbol</label>
<input type="text" id="node-input-symbol" placeholder="Symbol">
<br />
<small style="padding-left: 100px;">Incoming <code>.symbol</code> overwrites this value</small>
</div>
<div class="form-row">
<label for="node-input-limit"><i class="fa fa-history"></i> Limit</label>
<input type="text" id="node-input-limit" placeholder="Limit">
<br />
<small style="padding-left: 100px;">Incoming <code>.limit</code> overwrites this value</small>
</div>
</script>
<script type="text/x-red" data-help-name="get-bars">
<p>Node for retrieving your account details </p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<h3>Details</h3>
<p>Payload is the full response object from the API</p>
</script>