devalpha-io / devalpha-node

A stream-based approach to algorithmic trading and backtesting in Node.js
https://devalpha.io
GNU General Public License v3.0
247 stars 40 forks source link

Quickstart problems #3

Closed unsaved closed 6 years ago

unsaved commented 6 years ago

I'm creating issue here, as instructed at end of Quickstart section of the product docs at https://devalpha.io/.

In the https://devalpha.io/ Quickstart it says to create new file "index.js" and then you have 4 snippets that all start with "// index.js" as if you have 4 files all named "index.js". You said nothing about where the files belong or a directory structure, so I guess you are working in a single directory and all of the snippets get concatenated into a single file.

When I run "node index.js" as instructed, node dies complaining about the import statement. I run pretty leading-edge Arch Linux, but web searches tell me that current Node JS doesn't support the import statement. The example project works for me, so you are obviously doing something in the example project that is not happening when I clone and build the base project. What?

Postnote: I got the Quickstart to work.

  1. I looked at the example project and saw that you use require instead of import there, so I changed the Quickstart "index.js" to do the same.
  2. I fixed the line "const strategy = (context, action) {" to be "const strategy = function(context, action) {".
fhqvst commented 6 years ago
  1. import statements do not work in native Node just yet. You need to use a transpiler such as Babel, or use TypeScript instead.
  2. Good catch - fixed now!