From 41351c28c991718f53261250bb4d07debdac0f62 Mon Sep 17 00:00:00 2001 From: Miles Holt Date: Fri, 14 Aug 2020 11:04:46 +0100 Subject: [PATCH] Changed currency to Stellar and adjusted size and limit parameters --- main.js | 32 ++++++++++++++-------------- node_modules/node-ig-api/tokens.json | 2 +- pricedata.json | 2 +- tests/test_template.js | 20 ++++++++++++----- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/main.js b/main.js index 9ca5f420a8ea1..e8f101366464e 100644 --- a/main.js +++ b/main.js @@ -34,7 +34,7 @@ global.rangedata = {'resistance': {}, 'support': {}, 'bumps': []}; global.linedata = {'support': 0, 'resistance': 0, 'midrange': 0}; global.confirmations = {'resistance': 0, 'support': 0, 'resistance_index': [], 'support_index':[]}; let confirmationlimit = 3; -const epic = 'CS.D.BITCOIN.TODAY.IP'; +const epic = 'CS.D.XLMUSD.TODAY.IP'; const resolution = 'HOUR'; let date1 = moment().add(1, 'days').format('YYYY-MM-DD'); let date2 = moment(date1).subtract(3, 'days').format('YYYY-MM-DD'); @@ -66,7 +66,7 @@ let beforeRangeData; run(); -async function run(){ +async function run(){ //Login and check for open positions first await init(); //Then execute main function, looping initially @@ -120,14 +120,14 @@ async function exec(){ console.log('lasthour: ' + lasthour); console.log('--------BEGIN EXEC: ' + timestamp ); console.log('--------BEGIN EXEC AUTO TRADE'); - + //get stored price and beforeRangeData from GitHub github.shas = []; prices = await github.actions.getFile(pricedataDir); let pricesSha = github.sha; beforeRangeData = await github.actions.getFile(beforeRangeDir); let beforeRangeSha = github.sha; - + console.log('priceSha: ' + pricesSha); console.log('beforeRangeSha: ' + beforeRangeSha); @@ -135,7 +135,7 @@ async function exec(){ console.log('written beforerange data:'); console.log(beforeRangeData); - //set beforeRangeData + //set beforeRangeData if(beforeRangeData.lastBeforeRangeTrendMovement !== ''){ console.log('using stored beforerangedata'); lastBeforeRangeTrendMovement = beforeRangeData.lastBeforeRangeTrendMovement; @@ -155,7 +155,7 @@ async function exec(){ await api.histPrc(epic, resolution, from, to).then(r => { prices = r.prices; pricedatacount = prices.length; - + github.actions.updateFile(prices,pricedataDir); //store back to the file /*fs.writeFile(pricedataDir, JSON.stringify(prices), 'utf8', (e) => { @@ -165,7 +165,7 @@ async function exec(){ console.log('Price data written to file.'); } });*/ - + var mailOptions = { from: 'contact@milesholt.co.uk', to: 'miles_holt@hotmail.com', @@ -232,7 +232,7 @@ async function exec(){ console.log('Removing first hour'); prices.shift(); //store back to the file - + github.actions.updateFile(prices,pricedataDir); /* fs.writeFile(pricedataDir, JSON.stringify(prices), 'utf8', (e) => { @@ -357,14 +357,14 @@ if(noError){ 'lastBeforeRangeTrendMovementClose' : lastBeforeRangeTrendMovementClose, 'lastBeforeRangeTrendMovementTime' : lastBeforeRangeTrendMovementTime } - + setTimeout(()=>{ console.log('updating beforeRangeData file after 10 seconds'); github.actions.updateFile(beforeRangeData,beforeRangeDir); },10000); - - - + + + // fs.writeFile(beforeRangeDir, JSON.stringify(beforeRangeData), 'utf8', (e) => { // if (e) { @@ -504,8 +504,8 @@ if(noError){ //let bumps = []; let rd = rangedata.support.prices_idx; rangedata.bumps = []; - - + + pricedata2.support.forEach((price,idx) => { //if(trend == 'bearish') if(price.close >= resistanceline && rangedata.support.prices_idx.indexOf(idx) !== -1) bumps.push({ 'idx' : idx, 'close' : price.close }); //if(trend == 'bullish') if(price.close <= supportline && rangedata.support.prices_idx.indexOf(idx) !== -1) bumps.push({ 'idx' : idx, 'close' : price.close }); @@ -712,11 +712,11 @@ if(noError){ 'direction': trend == 'bullish' ? 'BUY' : 'SELL', 'epic': epic, 'expiry': 'DFB', - 'size': 1.5, + 'size': 50, 'forceOpen': true, 'orderType': 'MARKET', 'level': null, - 'limitDistance': 100, + 'limitDistance': 0.5, 'limitLevel': null, 'stopDistance': stopDistance, 'stopLevel': null, diff --git a/node_modules/node-ig-api/tokens.json b/node_modules/node-ig-api/tokens.json index a76d87f6e33b1..bb50640ed10b2 100644 --- a/node_modules/node-ig-api/tokens.json +++ b/node_modules/node-ig-api/tokens.json @@ -1 +1 @@ -{"tokens_exp":1586205127535,"x-request-id":"NOT_AVAILABLE","x-security-token":"0b8093fb914e82f3b319548f0d4c8a82a4d13cb24b74b683523027476cb8c3da01112","cst":"79e97a583f3ab19729f864dbb49bc6c338d807c0b4f0ea9bb151d471793d6b5a01112","lightstreamerEndpoint":"https://demo-apd.marketdatasystems.com","currentAccountId":"Z32EDV"} \ No newline at end of file +{"tokens_exp":1597441996168,"x-request-id":"NOT_AVAILABLE","x-security-token":"e84d1f08b01bf0a84c82a951c4d26fdf05747e5e9db8f1a4d6194121df0302CD01112","cst":"108dab617e58ca91043209cae68186c139b85561e979f2c1cf07172a57af18CU01112","lightstreamerEndpoint":"https://demo-apd.marketdatasystems.com","currentAccountId":"Z32EDV"} \ No newline at end of file diff --git a/pricedata.json b/pricedata.json index bead49fb4eb82..fe51488c7066f 100644 --- a/pricedata.json +++ b/pricedata.json @@ -1 +1 @@ -[{"snapshotTime":"2020/08/11 17:00:00","openPrice":{"bid":11473,"ask":11509,"lastTraded":null},"closePrice":{"bid":11412.86,"ask":11448.86,"lastTraded":null},"highPrice":{"bid":11476.77,"ask":11512.77,"lastTraded":null},"lowPrice":{"bid":11270.59,"ask":11306.59,"lastTraded":null},"lastTradedVolume":11102},{"snapshotTime":"2020/08/11 18:00:00","openPrice":{"bid":11412.81,"ask":11448.81,"lastTraded":null},"closePrice":{"bid":11476.14,"ask":11512.14,"lastTraded":null},"highPrice":{"bid":11530.69,"ask":11566.69,"lastTraded":null},"lowPrice":{"bid":11358.06,"ask":11394.06,"lastTraded":null},"lastTradedVolume":8995},{"snapshotTime":"2020/08/11 19:00:00","openPrice":{"bid":11475.46,"ask":11511.46,"lastTraded":null},"closePrice":{"bid":11431.32,"ask":11467.32,"lastTraded":null},"highPrice":{"bid":11475.9,"ask":11511.9,"lastTraded":null},"lowPrice":{"bid":11395.56,"ask":11431.56,"lastTraded":null},"lastTradedVolume":7882},{"snapshotTime":"2020/08/11 20:00:00","openPrice":{"bid":11430.57,"ask":11466.57,"lastTraded":null},"closePrice":{"bid":11372.37,"ask":11408.37,"lastTraded":null},"highPrice":{"bid":11461.95,"ask":11497.95,"lastTraded":null},"lowPrice":{"bid":11371.64,"ask":11407.64,"lastTraded":null},"lastTradedVolume":8120},{"snapshotTime":"2020/08/11 21:00:00","openPrice":{"bid":11372.1,"ask":11408.1,"lastTraded":null},"closePrice":{"bid":11193.87,"ask":11229.87,"lastTraded":null},"highPrice":{"bid":11372.36,"ask":11408.36,"lastTraded":null},"lowPrice":{"bid":11113,"ask":11149,"lastTraded":null},"lastTradedVolume":13127},{"snapshotTime":"2020/08/11 22:00:00","openPrice":{"bid":11193.91,"ask":11229.91,"lastTraded":null},"closePrice":{"bid":11278.6,"ask":11314.6,"lastTraded":null},"highPrice":{"bid":11344.44,"ask":11380.44,"lastTraded":null},"lowPrice":{"bid":11110.64,"ask":11146.64,"lastTraded":null},"lastTradedVolume":10874},{"snapshotTime":"2020/08/11 23:00:00","openPrice":{"bid":11278.71,"ask":11314.71,"lastTraded":null},"closePrice":{"bid":11330.97,"ask":11366.97,"lastTraded":null},"highPrice":{"bid":11342.46,"ask":11378.46,"lastTraded":null},"lowPrice":{"bid":11253.94,"ask":11289.94,"lastTraded":null},"lastTradedVolume":9122},{"snapshotTime":"2020/08/12 01:00:00","openPrice":{"bid":11370.02,"ask":11406.02,"lastTraded":null},"closePrice":{"bid":11308.75,"ask":11344.75,"lastTraded":null},"highPrice":{"bid":11389.73,"ask":11425.73,"lastTraded":null},"lowPrice":{"bid":11293.55,"ask":11329.55,"lastTraded":null},"lastTradedVolume":6305},{"snapshotTime":"2020/08/12 02:00:00","openPrice":{"bid":11308.38,"ask":11344.38,"lastTraded":null},"closePrice":{"bid":11325.6,"ask":11361.6,"lastTraded":null},"highPrice":{"bid":11368.95,"ask":11404.95,"lastTraded":null},"lowPrice":{"bid":11307.46,"ask":11343.46,"lastTraded":null},"lastTradedVolume":5927},{"snapshotTime":"2020/08/12 03:00:00","openPrice":{"bid":11325.71,"ask":11361.71,"lastTraded":null},"closePrice":{"bid":11227.7,"ask":11263.7,"lastTraded":null},"highPrice":{"bid":11329.33,"ask":11365.33,"lastTraded":null},"lowPrice":{"bid":11205.03,"ask":11241.03,"lastTraded":null},"lastTradedVolume":8101},{"snapshotTime":"2020/08/12 04:00:00","openPrice":{"bid":11227.85,"ask":11263.85,"lastTraded":null},"closePrice":{"bid":11358.96,"ask":11394.96,"lastTraded":null},"highPrice":{"bid":11358.96,"ask":11394.96,"lastTraded":null},"lowPrice":{"bid":11224.01,"ask":11260.01,"lastTraded":null},"lastTradedVolume":6981},{"snapshotTime":"2020/08/12 05:00:00","openPrice":{"bid":11359.73,"ask":11395.73,"lastTraded":null},"closePrice":{"bid":11295.44,"ask":11331.44,"lastTraded":null},"highPrice":{"bid":11373.51,"ask":11409.51,"lastTraded":null},"lowPrice":{"bid":11287.18,"ask":11323.18,"lastTraded":null},"lastTradedVolume":6706},{"snapshotTime":"2020/08/12 06:00:00","openPrice":{"bid":11292.09,"ask":11328.09,"lastTraded":null},"closePrice":{"bid":11243.5,"ask":11279.5,"lastTraded":null},"highPrice":{"bid":11326.11,"ask":11362.11,"lastTraded":null},"lowPrice":{"bid":11243.5,"ask":11279.5,"lastTraded":null},"lastTradedVolume":8051},{"snapshotTime":"2020/08/12 07:00:00","openPrice":{"bid":11243.48,"ask":11279.48,"lastTraded":null},"closePrice":{"bid":11312.71,"ask":11348.71,"lastTraded":null},"highPrice":{"bid":11337.29,"ask":11373.29,"lastTraded":null},"lowPrice":{"bid":11150.16,"ask":11186.16,"lastTraded":null},"lastTradedVolume":7556},{"snapshotTime":"2020/08/12 08:00:00","openPrice":{"bid":11312.72,"ask":11348.72,"lastTraded":null},"closePrice":{"bid":11431,"ask":11467,"lastTraded":null},"highPrice":{"bid":11455.28,"ask":11491.28,"lastTraded":null},"lowPrice":{"bid":11298.23,"ask":11334.23,"lastTraded":null},"lastTradedVolume":6013},{"snapshotTime":"2020/08/12 09:00:00","openPrice":{"bid":11431.15,"ask":11467.15,"lastTraded":null},"closePrice":{"bid":11415.07,"ask":11451.07,"lastTraded":null},"highPrice":{"bid":11471.33,"ask":11507.33,"lastTraded":null},"lowPrice":{"bid":11409.83,"ask":11445.83,"lastTraded":null},"lastTradedVolume":8887},{"snapshotTime":"2020/08/12 10:00:00","openPrice":{"bid":11415.1,"ask":11451.1,"lastTraded":null},"closePrice":{"bid":11464.02,"ask":11500.02,"lastTraded":null},"highPrice":{"bid":11483.96,"ask":11519.96,"lastTraded":null},"lowPrice":{"bid":11414.82,"ask":11450.82,"lastTraded":null},"lastTradedVolume":6041},{"snapshotTime":"2020/08/12 11:00:00","openPrice":{"bid":11463.8,"ask":11499.8,"lastTraded":null},"closePrice":{"bid":11498.01,"ask":11534.01,"lastTraded":null},"highPrice":{"bid":11516.13,"ask":11552.13,"lastTraded":null},"lowPrice":{"bid":11448.14,"ask":11484.14,"lastTraded":null},"lastTradedVolume":7033},{"snapshotTime":"2020/08/12 12:00:00","openPrice":{"bid":11497.9,"ask":11533.9,"lastTraded":null},"closePrice":{"bid":11447.81,"ask":11483.81,"lastTraded":null},"highPrice":{"bid":11510.98,"ask":11546.98,"lastTraded":null},"lowPrice":{"bid":11423.54,"ask":11459.54,"lastTraded":null},"lastTradedVolume":7802},{"snapshotTime":"2020/08/12 13:00:00","openPrice":{"bid":11448.06,"ask":11484.06,"lastTraded":null},"closePrice":{"bid":11498.18,"ask":11534.18,"lastTraded":null},"highPrice":{"bid":11499.25,"ask":11535.25,"lastTraded":null},"lowPrice":{"bid":11419.8,"ask":11455.8,"lastTraded":null},"lastTradedVolume":7065},{"snapshotTime":"2020/08/12 14:00:00","openPrice":{"bid":11498.5,"ask":11534.5,"lastTraded":null},"closePrice":{"bid":11550.51,"ask":11586.51,"lastTraded":null},"highPrice":{"bid":11558.29,"ask":11594.29,"lastTraded":null},"lowPrice":{"bid":11467.41,"ask":11503.41,"lastTraded":null},"lastTradedVolume":6882},{"snapshotTime":"2020/08/12 15:00:00","openPrice":{"bid":11550.76,"ask":11586.76,"lastTraded":null},"closePrice":{"bid":11576.69,"ask":11612.69,"lastTraded":null},"highPrice":{"bid":11578.9,"ask":11614.9,"lastTraded":null},"lowPrice":{"bid":11525.58,"ask":11561.58,"lastTraded":null},"lastTradedVolume":6888},{"snapshotTime":"2020/08/12 16:00:00","openPrice":{"bid":11577.4,"ask":11613.4,"lastTraded":null},"closePrice":{"bid":11563.75,"ask":11599.75,"lastTraded":null},"highPrice":{"bid":11601.37,"ask":11637.37,"lastTraded":null},"lowPrice":{"bid":11533.69,"ask":11569.69,"lastTraded":null},"lastTradedVolume":5711},{"snapshotTime":"2020/08/12 17:00:00","openPrice":{"bid":11563.62,"ask":11599.62,"lastTraded":null},"closePrice":{"bid":11534.28,"ask":11570.28,"lastTraded":null},"highPrice":{"bid":11595.72,"ask":11631.72,"lastTraded":null},"lowPrice":{"bid":11531.39,"ask":11567.39,"lastTraded":null},"lastTradedVolume":6695},{"snapshotTime":"2020/08/12 18:00:00","openPrice":{"bid":11534.21,"ask":11570.21,"lastTraded":null},"closePrice":{"bid":11523.58,"ask":11559.58,"lastTraded":null},"highPrice":{"bid":11536.65,"ask":11572.65,"lastTraded":null},"lowPrice":{"bid":11467.22,"ask":11503.22,"lastTraded":null},"lastTradedVolume":5759},{"snapshotTime":"2020/08/12 19:00:00","openPrice":{"bid":11523.56,"ask":11559.56,"lastTraded":null},"closePrice":{"bid":11507.89,"ask":11543.89,"lastTraded":null},"highPrice":{"bid":11539.47,"ask":11575.47,"lastTraded":null},"lowPrice":{"bid":11481.73,"ask":11517.73,"lastTraded":null},"lastTradedVolume":7587},{"snapshotTime":"2020/08/12 20:00:00","openPrice":{"bid":11508.16,"ask":11544.16,"lastTraded":null},"closePrice":{"bid":11563.64,"ask":11599.64,"lastTraded":null},"highPrice":{"bid":11584.91,"ask":11620.91,"lastTraded":null},"lowPrice":{"bid":11508.16,"ask":11544.16,"lastTraded":null},"lastTradedVolume":6508},{"snapshotTime":"2020/08/12 21:00:00","openPrice":{"bid":11563.74,"ask":11599.74,"lastTraded":null},"closePrice":{"bid":11547.94,"ask":11583.94,"lastTraded":null},"highPrice":{"bid":11582.07,"ask":11618.07,"lastTraded":null},"lowPrice":{"bid":11529.85,"ask":11565.85,"lastTraded":null},"lastTradedVolume":3599},{"snapshotTime":"2020/08/12 22:00:00","openPrice":{"bid":11547.99,"ask":11583.99,"lastTraded":null},"closePrice":{"bid":11487.44,"ask":11523.44,"lastTraded":null},"highPrice":{"bid":11550.34,"ask":11586.34,"lastTraded":null},"lowPrice":{"bid":11472.69,"ask":11508.69,"lastTraded":null},"lastTradedVolume":6918},{"snapshotTime":"2020/08/12 23:00:00","openPrice":{"bid":11487.47,"ask":11523.47,"lastTraded":null},"closePrice":{"bid":11532.34,"ask":11568.34,"lastTraded":null},"highPrice":{"bid":11566.67,"ask":11602.67,"lastTraded":null},"lowPrice":{"bid":11487.36,"ask":11523.36,"lastTraded":null},"lastTradedVolume":5718},{"snapshotTime":"2020/08/13 01:00:00","openPrice":{"bid":11554.52,"ask":11590.52,"lastTraded":null},"closePrice":{"bid":11620.4,"ask":11656.4,"lastTraded":null},"highPrice":{"bid":11643.22,"ask":11679.22,"lastTraded":null},"lowPrice":{"bid":11538.32,"ask":11574.32,"lastTraded":null},"lastTradedVolume":5684},{"snapshotTime":"2020/08/13 02:00:00","openPrice":{"bid":11620.81,"ask":11656.81,"lastTraded":null},"closePrice":{"bid":11590.83,"ask":11626.83,"lastTraded":null},"highPrice":{"bid":11627.99,"ask":11663.99,"lastTraded":null},"lowPrice":{"bid":11586.64,"ask":11622.64,"lastTraded":null},"lastTradedVolume":4442},{"snapshotTime":"2020/08/13 03:00:00","openPrice":{"bid":11590.85,"ask":11626.85,"lastTraded":null},"closePrice":{"bid":11553.52,"ask":11589.52,"lastTraded":null},"highPrice":{"bid":11613.88,"ask":11649.88,"lastTraded":null},"lowPrice":{"bid":11519.95,"ask":11555.95,"lastTraded":null},"lastTradedVolume":6651},{"snapshotTime":"2020/08/13 04:00:00","openPrice":{"bid":11554.18,"ask":11590.18,"lastTraded":null},"closePrice":{"bid":11556.19,"ask":11592.19,"lastTraded":null},"highPrice":{"bid":11570.58,"ask":11606.58,"lastTraded":null},"lowPrice":{"bid":11523.55,"ask":11559.55,"lastTraded":null},"lastTradedVolume":6310},{"snapshotTime":"2020/08/13 05:00:00","openPrice":{"bid":11555.79,"ask":11591.79,"lastTraded":null},"closePrice":{"bid":11538.2,"ask":11574.2,"lastTraded":null},"highPrice":{"bid":11574.21,"ask":11610.21,"lastTraded":null},"lowPrice":{"bid":11532.33,"ask":11568.33,"lastTraded":null},"lastTradedVolume":6506},{"snapshotTime":"2020/08/13 06:00:00","openPrice":{"bid":11538.15,"ask":11574.15,"lastTraded":null},"closePrice":{"bid":11520.59,"ask":11556.59,"lastTraded":null},"highPrice":{"bid":11538.41,"ask":11574.41,"lastTraded":null},"lowPrice":{"bid":11503,"ask":11539,"lastTraded":null},"lastTradedVolume":2615},{"snapshotTime":"2020/08/13 07:00:00","openPrice":{"bid":11520.58,"ask":11556.58,"lastTraded":null},"closePrice":{"bid":11542.38,"ask":11578.38,"lastTraded":null},"highPrice":{"bid":11550.76,"ask":11586.76,"lastTraded":null},"lowPrice":{"bid":11494.01,"ask":11530.01,"lastTraded":null},"lastTradedVolume":4234},{"snapshotTime":"2020/08/13 08:00:00","openPrice":{"bid":11542.37,"ask":11578.37,"lastTraded":null},"closePrice":{"bid":11506.81,"ask":11542.81,"lastTraded":null},"highPrice":{"bid":11549.14,"ask":11585.14,"lastTraded":null},"lowPrice":{"bid":11489.13,"ask":11525.13,"lastTraded":null},"lastTradedVolume":5134},{"snapshotTime":"2020/08/13 09:00:00","openPrice":{"bid":11506.9,"ask":11542.9,"lastTraded":null},"closePrice":{"bid":11403.86,"ask":11439.86,"lastTraded":null},"highPrice":{"bid":11507.92,"ask":11543.92,"lastTraded":null},"lowPrice":{"bid":11365.97,"ask":11401.97,"lastTraded":null},"lastTradedVolume":7133},{"snapshotTime":"2020/08/13 10:00:00","openPrice":{"bid":11403.83,"ask":11439.83,"lastTraded":null},"closePrice":{"bid":11386.16,"ask":11422.16,"lastTraded":null},"highPrice":{"bid":11411.19,"ask":11447.19,"lastTraded":null},"lowPrice":{"bid":11260.82,"ask":11296.82,"lastTraded":null},"lastTradedVolume":8703},{"snapshotTime":"2020/08/13 11:00:00","openPrice":{"bid":11386.48,"ask":11422.48,"lastTraded":null},"closePrice":{"bid":11456.41,"ask":11492.41,"lastTraded":null},"highPrice":{"bid":11457.3,"ask":11493.3,"lastTraded":null},"lowPrice":{"bid":11347.01,"ask":11383.01,"lastTraded":null},"lastTradedVolume":5662},{"snapshotTime":"2020/08/13 12:00:00","openPrice":{"bid":11456.11,"ask":11492.11,"lastTraded":null},"closePrice":{"bid":11536.02,"ask":11572.02,"lastTraded":null},"highPrice":{"bid":11605.09,"ask":11641.09,"lastTraded":null},"lowPrice":{"bid":11433.09,"ask":11469.09,"lastTraded":null},"lastTradedVolume":9324},{"snapshotTime":"2020/08/13 13:00:00","openPrice":{"bid":11537.22,"ask":11573.22,"lastTraded":null},"closePrice":{"bid":11450.98,"ask":11486.98,"lastTraded":null},"highPrice":{"bid":11571.47,"ask":11607.47,"lastTraded":null},"lowPrice":{"bid":11379.02,"ask":11415.02,"lastTraded":null},"lastTradedVolume":7373},{"snapshotTime":"2020/08/13 14:00:00","openPrice":{"bid":11451.07,"ask":11487.07,"lastTraded":null},"closePrice":{"bid":11493.08,"ask":11529.08,"lastTraded":null},"highPrice":{"bid":11511.56,"ask":11547.56,"lastTraded":null},"lowPrice":{"bid":11410.85,"ask":11446.85,"lastTraded":null},"lastTradedVolume":7903},{"snapshotTime":"2020/08/13 15:00:00","openPrice":{"bid":11492.61,"ask":11528.61,"lastTraded":null},"closePrice":{"bid":11514.07,"ask":11550.07,"lastTraded":null},"highPrice":{"bid":11535.53,"ask":11571.53,"lastTraded":null},"lowPrice":{"bid":11460.69,"ask":11496.69,"lastTraded":null},"lastTradedVolume":6325},{"snapshotTime":"2020/08/13 16:00:00","openPrice":{"bid":11514.16,"ask":11550.16,"lastTraded":null},"closePrice":{"bid":11487.66,"ask":11523.66,"lastTraded":null},"highPrice":{"bid":11521.56,"ask":11557.56,"lastTraded":null},"lowPrice":{"bid":11451.25,"ask":11487.25,"lastTraded":null},"lastTradedVolume":7667},{"snapshotTime":"2020/08/13 17:00:00","openPrice":{"bid":11488.18,"ask":11524.18,"lastTraded":null},"closePrice":{"bid":11515.81,"ask":11551.81,"lastTraded":null},"highPrice":{"bid":11516.15,"ask":11552.15,"lastTraded":null},"lowPrice":{"bid":11433.97,"ask":11469.97,"lastTraded":null},"lastTradedVolume":8028},{"snapshotTime":"2020/08/13 18:00:00","openPrice":{"bid":11515.69,"ask":11551.69,"lastTraded":null},"closePrice":{"bid":11511.86,"ask":11547.86,"lastTraded":null},"highPrice":{"bid":11517.11,"ask":11553.11,"lastTraded":null},"lowPrice":{"bid":11483.46,"ask":11519.46,"lastTraded":null},"lastTradedVolume":7592},{"snapshotTime":"2020/08/13 19:00:00","openPrice":{"bid":11511.78,"ask":11547.78,"lastTraded":null},"closePrice":{"bid":11479.75,"ask":11515.75,"lastTraded":null},"highPrice":{"bid":11525.12,"ask":11561.12,"lastTraded":null},"lowPrice":{"bid":11467.84,"ask":11503.84,"lastTraded":null},"lastTradedVolume":6404},{"snapshotTime":"2020/08/13 20:00:00","openPrice":{"bid":11480.33,"ask":11516.33,"lastTraded":null},"closePrice":{"bid":11502.08,"ask":11538.08,"lastTraded":null},"highPrice":{"bid":11523.31,"ask":11559.31,"lastTraded":null},"lowPrice":{"bid":11476.72,"ask":11512.72,"lastTraded":null},"lastTradedVolume":5368},{"snapshotTime":"2020/08/13 21:00:00","openPrice":{"bid":11502.18,"ask":11538.18,"lastTraded":null},"closePrice":{"bid":11592.41,"ask":11628.41,"lastTraded":null},"highPrice":{"bid":11626.68,"ask":11662.68,"lastTraded":null},"lowPrice":{"bid":11502.09,"ask":11538.09,"lastTraded":null},"lastTradedVolume":8164},{"snapshotTime":"2020/08/13 22:00:00","openPrice":{"bid":11592.6,"ask":11628.6,"lastTraded":null},"closePrice":{"bid":11681.66,"ask":11717.66,"lastTraded":null},"highPrice":{"bid":11720.27,"ask":11756.27,"lastTraded":null},"lowPrice":{"bid":11592.6,"ask":11628.6,"lastTraded":null},"lastTradedVolume":10343},{"snapshotTime":"2020/08/13 23:00:00","openPrice":{"bid":11681.34,"ask":11717.34,"lastTraded":null},"closePrice":{"bid":11728.01,"ask":11764.01,"lastTraded":null},"highPrice":{"bid":11782.18,"ask":11818.18,"lastTraded":null},"lowPrice":{"bid":11681.33,"ask":11717.33,"lastTraded":null},"lastTradedVolume":10057},{"snapshotTime":"2020/08/14 01:00:00","openPrice":{"bid":11773.49,"ask":11809.49,"lastTraded":null},"closePrice":{"bid":11756.91,"ask":11792.91,"lastTraded":null},"highPrice":{"bid":11826.49,"ask":11862.49,"lastTraded":null},"lowPrice":{"bid":11727.65,"ask":11763.65,"lastTraded":null},"lastTradedVolume":8258},{"snapshotTime":"2020/08/14 02:00:00","openPrice":{"bid":11756.87,"ask":11792.87,"lastTraded":null},"closePrice":{"bid":11792.57,"ask":11828.57,"lastTraded":null},"highPrice":{"bid":11798.36,"ask":11834.36,"lastTraded":null},"lowPrice":{"bid":11719.95,"ask":11755.95,"lastTraded":null},"lastTradedVolume":4793},{"snapshotTime":"2020/08/14 03:00:00","openPrice":{"bid":11791.9,"ask":11827.9,"lastTraded":null},"closePrice":{"bid":11730.44,"ask":11766.44,"lastTraded":null},"highPrice":{"bid":11804.62,"ask":11840.62,"lastTraded":null},"lowPrice":{"bid":11727.36,"ask":11763.36,"lastTraded":null},"lastTradedVolume":5240},{"snapshotTime":"2020/08/14 04:00:00","openPrice":{"bid":11730.43,"ask":11766.43,"lastTraded":null},"closePrice":{"bid":11727.51,"ask":11763.51,"lastTraded":null},"highPrice":{"bid":11748.13,"ask":11784.13,"lastTraded":null},"lowPrice":{"bid":11669.22,"ask":11705.22,"lastTraded":null},"lastTradedVolume":5510},{"snapshotTime":"2020/08/14 05:00:00","openPrice":{"bid":11727.55,"ask":11763.55,"lastTraded":null},"closePrice":{"bid":11727.56,"ask":11763.56,"lastTraded":null},"highPrice":{"bid":11757.59,"ask":11793.59,"lastTraded":null},"lowPrice":{"bid":11706.19,"ask":11742.19,"lastTraded":null},"lastTradedVolume":4457},{"snapshotTime":"2020/08/14 06:00:00","openPrice":{"bid":11726.41,"ask":11762.41,"lastTraded":null},"closePrice":{"bid":11725.43,"ask":11761.43,"lastTraded":null},"highPrice":{"bid":11742.59,"ask":11778.59,"lastTraded":null},"lowPrice":{"bid":11692.24,"ask":11728.24,"lastTraded":null},"lastTradedVolume":4155},{"snapshotTime":"2020/08/14 07:00:00","openPrice":{"bid":11725.28,"ask":11761.28,"lastTraded":null},"closePrice":{"bid":11680.17,"ask":11716.17,"lastTraded":null},"highPrice":{"bid":11725.73,"ask":11761.73,"lastTraded":null},"lowPrice":{"bid":11680.17,"ask":11716.17,"lastTraded":null},"lastTradedVolume":3120},{"snapshotTime":"2020/08/14 08:00:00","openPrice":{"bid":11680.15,"ask":11716.15,"lastTraded":null},"closePrice":{"bid":11701.77,"ask":11737.77,"lastTraded":null},"highPrice":{"bid":11705.76,"ask":11741.76,"lastTraded":null},"lowPrice":{"bid":11644.9,"ask":11680.9,"lastTraded":null},"lastTradedVolume":4525},{"snapshotTime":"2020/08/14 09:00:00","openPrice":{"bid":11701.62,"ask":11737.62,"lastTraded":null},"closePrice":{"bid":11679.89,"ask":11715.89,"lastTraded":null},"highPrice":{"bid":11737.7,"ask":11773.7,"lastTraded":null},"lowPrice":{"bid":11668.95,"ask":11704.95,"lastTraded":null},"lastTradedVolume":3561}] \ No newline at end of file +[] diff --git a/tests/test_template.js b/tests/test_template.js index fbbe17792f470..8cc6c9e5d0e54 100644 --- a/tests/test_template.js +++ b/tests/test_template.js @@ -9,11 +9,11 @@ const path = require('path'); moment().format(); //Require strategy -const strategy = require('./strategies/breakoutStrategy.js'); +const strategy = require('../strategies/breakoutStrategy.js'); //Require analytics -const analytics = require('./services/analytics.js'); +const analytics = require('../services/analytics.js'); //Require mailer -const mailer = require('./services/mailer.js'); +const mailer = require('../services/mailer.js'); //Parameters let check1 = false, check2 = false, check3 = false, check4 = false; @@ -21,7 +21,10 @@ let prices; let pricedata = {'support': [], 'resistance': []}; global.confirmations = {'resistance': 0, 'support': 0}; let confirmationlimit = 4; -const epic = 'CS.D.BITCOIN.TODAY.IP'; + +//bitcoin - CS.D.BITCOIN.TODAY.IP +//stellar - CS.D.XLMUSD.TODAY.IP +const epic = 'CS.D.XLMUSD.TODAY.IP'; const resolution = 'HOUR'; let date1 = moment().add(1, 'days').format('YYYY-MM-DD'); let date2 = moment(date1).subtract(3, 'days').format('YYYY-MM-DD'); @@ -62,6 +65,13 @@ async function exec(){ console.log(util.inspect(r,false,null)); }).catch(e => console.log(e)); + //Search contract + //CS.D.BITCOIN.TODAY.IP + // console.log('-------Searching for Epics'); + // await api.search('Stellar').then(r => { + // console.log(r); + // }).catch(e => console.log(e)); + //Retrieve data from epic console.log('-------Retrieving historic pricing data for epic'); @@ -69,7 +79,7 @@ async function exec(){ console.log(to2); //if data from file is empty, load last 3 days - await api.histPrc(epic, resolution, from2, to2).then(r => { + await api.histPrc(epic, resolution, from, to).then(r => { console.log(r); }).catch(e => { //console.log(e);