Skip to content

Commit

Permalink
fixed timing error
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshuajee committed Apr 3, 2021
1 parent 147b4a8 commit 50e8511
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Cron/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const symbols = require("../Model/Symbols")




//set up default mongoose connection
mongoose.connect(config.DataBaseURI, {useNewUrlParser:true, useUnifiedTopology:true})

Expand Down Expand Up @@ -49,6 +50,8 @@ cron.schedule('0 * * * *', () => {
symbolsObj.totalPositions = element.totalPositions
symbolsObj.avgShortPrice = element.avgShortPrice
symbolsObj.avgLongPrice = element.avgLongPrice
symbolsObj.date = new Date()
symbolsObj.timeStamp = Date.now()

symbolsObj.save()

Expand Down
4 changes: 2 additions & 2 deletions Model/Symbols.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mongoose = require('mongoose')

let date = new Date()


const Symbols = new mongoose.Schema({
name : {type:String, default : ""},
Expand All @@ -13,7 +13,7 @@ const Symbols = new mongoose.Schema({
totalPositions : {type:Number, default : 0},
avgShortPrice : {type:Number, default : 0},
avgLongPrice : {type:Number, default : 0},
date : {type:Date, default : date},
date : {type:Date, default : new Date()},
timeStamp: {type:Number, default : Date.now()}
})

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This webserver collects hourly data on trader sentiments from the [myfxbook](https://www.myfxbook.com/) and stores them in a mongodb

# config
goto the Config forder create a file dev.js under the forder and insert the code below into the file dev.js
Goto the Config forder create a file dev.js under the forder and insert the code below into the file dev.js

```javascript

Expand All @@ -15,10 +15,12 @@ module.exports = {

```

## npm install

To install all the app dependency

## npm start

runs the app on `localhost:5000`
Runs the app on `localhost:5100`


27 changes: 24 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,37 @@ const db = mongoose.connection
//Bind connection to error event (to get notification of connection errors)
db.on('error', console.error.bind(console, 'MongoDB connection error:'))



app.get("/", (req, res) => {

symbols.find((err, data)=>{
symbols.distinct("name", (err, symbol)=>{

console.log(symbol)

symbols.find((err, data)=>{

console.log(data)

res.send([symbol, data])

})

})


})

app.get("/symbol", (req, res) => {

symbols.find({name:"EURUSD"}, (err, data)=>{

console.log(data)

res.send(data)

})

})

app.get("/ping", (req, res) => {
Expand All @@ -41,6 +62,6 @@ app.get("/ping", (req, res) => {


//check if there is an environment port
const PORT = process.env.PORT || 6000
const PORT = process.env.PORT || 5100

app.listen(PORT)

0 comments on commit 50e8511

Please sign in to comment.