ccxt Binance Futures Testnet Connection Example
I have some need to test the bot that i created on testnet Binance.
i'm using ccxt library to connect.
Good Knex.js Tutorial
I can recommend this articles:
Build your own REST API with Node, Express, Knex and PostgreSQL
https://medium.com/javascript-in-plain-english/build-your-own-rest-api-with-node-express-knex-and-postgresql-aec98fe75e5
Build your own REST API with Node, Express, Knex and PostgreSQL — part 2
https://medium.com/javascript-in-plain-english/build-your-own-rest-api-with-node-express-knex-and-postgresql-part-2-d9ff74f6f2fa
Build your own REST API with Node, Express, Knex and PostgreSQL — part 3
https://medium.com/javascript-in-plain-english/build-your-own-rest-api-with-node-express-knex-and-postgresql-part-3-c1e904478bfa
Build your own REST API with Node, Express, Knex and PostgreSQL — part 4
https://medium.com/swlh/build-your-own-rest-api-with-node-express-knex-and-postgresql-part-4-44205b1dc7f0
Build your own REST API with Node, Express, Knex and PostgreSQL — part 5
https://medium.com/@fajardocj/build-your-own-rest-api-with-node-express-knex-and-postgresql-part-5-6c6b57f85315
In Search of Async Retry
my current method to retry if error occured is this:
let tryCounter = 1;
const retryCount = 99;
let result = null;
let error = [];
while (tryCounter <= retryCount) {
let errContainer = null;
try {
result = await executeAsyncMethod();
break;
} catch (e) {
errContainer = e;
console.log('error');
}
tryCounter += 1;
if (tryCounter === retryCount) {
error.push(errContainer);
}
}
this is what i use:
node.js - nodejs retry function if failed X times - Stack Overflow
https://stackoverflow.com/questions/55031780/nodejs-retry-function-if-failed-x-times
References:
javascript - Promise Retry Design Patterns - Stack Overflow
https://stackoverflow.com/questions/38213668/promise-retry-design-patterns
node.js - recursive retry function in nodejs - Stack Overflow
https://stackoverflow.com/questions/52396265/recursive-retry-function-in-nodejs?noredirect=1&lq=1
javascript - how to handle connect error 5 times and create an exception? - Stack Overflow
https://stackoverflow.com/questions/47859951/how-to-handle-connect-error-5-times-and-create-an-exception/47861553#47861553
Javascript fetch, retry upon failure. - DEV Community 👩💻👨💻
https://dev.to/ycmjason/javascript-fetch-retry-upon-failure-3p6g
node.js - Retry a Promise resolution N times, with a delay between the attempts - Code Review Stack Exchange
https://codereview.stackexchange.com/questions/217199/retry-a-promise-resolution-n-times-with-a-delay-between-the-attempts
Async Retries - ITNEXT
https://itnext.io/blog-md-3f9801f99454
node.js - How can you retry after an exception in Javascript when using promises? - Stack Overflow
https://stackoverflow.com/questions/30471131/how-can-you-retry-after-an-exception-in-javascript-when-using-promises
A few general patterns for retries using promises
https://gist.github.com/briancavalier/842626
javascript - How to do repeated requests until one succeeds without blocking in node? - Stack Overflow
https://stackoverflow.com/questions/18581483/how-to-do-repeated-requests-until-one-succeeds-without-blocking-in-node
Coly010/notry: Clean up code by removing try-catch-finally blocks! 🚀
https://github.com/Coly010/notry
My Sequelize Notes
It's been 1 years since i'm into NodeJS, and sequelize is my favorite ORM to works with database.
1.After create a new Row, you want to get the ID of the data, you must make some changes in the model, and add this.
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
2.If your current server timezone is not the same as your timezone, but you want to get the datetime fields using your specified timezone, you can use this (i'm using day.js), so don't forget to import the library first.
const moment = require('dayjs');
const utc = require('dayjs/plugin/utc')
dateTime:{
type: DataTypes.DATE,
get() {
const rawValue = this.getDataValue('dateTime');
// parse raw value using whatever logic you want
// this won't work, but you get the idea
return moment(rawValue).utc().format('YYYY-MM-DD HH:mm:ss');
}
},
3.Associations - HasOne
This is almost the same as
belongsTowith one exception - The foreign key will be defined on the target model.
So the Example Table:
Person
-id
-name
-createdAt
-modifiedAt
Identity
-id
-name
-createdAt
-modifiedAt
-personId*
The code example is:
Person.hasOne(Identity, {
foreignKey: 'personId'
});
To Get the Identity, you can use this code:
person.getIdentity();
Has is a property, Belogs is more like a relation.
4.Associations - BelongsTo
So the Example Table:
Person
-id
-name
-createdAt
-modifiedAt
Identity
-id
-name
-createdAt
-modifiedAt
-personId*
The code example is:
Identity.belongsTo(Person, {
});
To Get the Identity, you can use this code:
person.getIdentity();
References:
Manual | Sequelize
https://sequelize.org/master/manual/model-basics.html
Manual | Sequelize
https://sequelize.org/v5/manual/models-definition.html
Manual | Sequelize
https://sequelize.org/master/manual/migrations.html
Sequelize BelongsTo & HasMany Associations - Edward Timmer - Medium
https://medium.com/@edtimmer/sequelize-associations-basics-bde90c0deeaa
Sequelize relationships — Ultimate guide - David MARIE - Medium
https://medium.com/@eth3rnit3/sequelize-relationships-ultimate-guide-f26801a75554
How to define Sequelize associations using migrations
https://medium.com/@andrewoons/how-to-define-sequelize-associations-using-migrations-de4333bf75a7
Sequelizeを使用してデータベースを操作するための基本的な情報 - Qiita
https://qiita.com/mima_ita/items/014dcb42872f3a10855b
Node.js, Express, sequelize, React で始めるモダン WEB アプリケーション入門(Express/sequelize編) - Qiita
https://qiita.com/tatsurou313/items/2ba0387806b07f442b8c
ruby on rails - What's the difference between belongs_to and has_one? - Stack Overflow
https://stackoverflow.com/questions/3808926/whats-the-difference-between-belongs-to-and-has-one
Ruby on Rails : Has_One versus Belongs_To
http://duanesbrain.blogspot.com/2006/05/ruby-on-rails-hasone-versus-belongsto.html
Database Associations- "Has One" vs "Belongs To" - In Lehman's Terms
http://inlehmansterms.net/2014/07/28/has_one-vs-belongs_to/
Recommended Terminal Application Replacement
1.exa
A modern version of ‘ls’. https://the.exa.website/
Github Repo: https://github.com/ogham/exa
Exa have a similar options like ls , my usual way to use exa is
exa -lah
2.bat
A cat(1) clone with wings.
Github Repo: https://github.com/sharkdp/bat
Bat is replacement for cat, with syntax highlighting support, lines number, and many more
bat filename.js [otherfile.js]
3.procs
A modern replacement for ps written in Rust
Github Repo: https://github.com/dalance/procs
Thred of using ps aux | grep 'keyword' to search for running, it's easier by using procs
procs keyword --or anything else
4.fd
A simple, fast and user-friendly alternative to 'find'
Github Repo: https://github.com/sharkdp/fd
It's more user friendly than find to search for file since i'ts not require any options to find, just use
fd anything
5.ripgrep
ripgrep recursively searches directories for a regex pattern
Github Repo: https://github.com/BurntSushi/ripgrep
If you need to find for regex pattern in every file under directory, just use
ripgrep anything
6.peco
Simplistic interactive filtering tool
Github Repo: https://github.com/peco/peco
Make text on the screen filterable, my usual way of using
ps aux | peco
cat anyfile.js | peco
Versions
0.0.2 - Add peco
0.0.1 - Initial Publish
Configure NodeJS and oracledb in Linux Server
There is many other ways, but this is my way to configure:
Server:
Steps:
- Do upgrade repository
apt-get update - Install alien, wget and other dependency package by doing
apt-get install alien wget libaio1 libaio-dev - Create directory by running
mkdir oracleclient - Go to the directory
cd oracleclient - Using browser, go to https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
- Download the rpm package , example :
wget https://download.oracle.com/otn_software/linux/instantclient/19600/oracle-instantclient19.6-basic-19.6.0.0.0-1.x86_64.rpm - Unpack the rpm package using
sudo alien oracle-instantclient19.6-basic-19.6.0.0.0-1.x86_64.rpm - Wait a few moment, until debian package is created
- Install debian package by running
sudo dpkg -i oracle-instantclient19.6-basic_19.6.0.0.0-2_amd64.deb - Now you can develop nodejs by connecting to oracle database.
My recommended npm package for connecting to oracle database is using oracledb ( https://www.npmjs.com/package/oracledb )
If ORM is your kind, you can try TypeORM & sworn
Current version of Instant Client as this post is created is : Instant Client 19.6
References:
TypeORM - Amazing ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
https://typeorm.io/#/
featurist/sworm: a write-only ORM for Node.js
https://github.com/featurist/sworm
ODPI-C Installation — ODPI-C v3.3.0
https://oracle.github.io/odpi/doc/installation.html#linux
Instant Client for Linux x86-64 (64-bit)
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
Installation and Upgrading
https://docs.oracle.com/en/database/oracle/oracle-database/19/lncpp/installation-and-upgrading.html#GUID-3116D5A2-B910-4DED-9E50-B240C1AEDA05
Oracle Instant Client RPM installation where to find things | Martins Blog
https://martincarstenbach.wordpress.com/2019/05/13/oracle-instant-client-rpm-installation-where-to-find-things/
node-oracledb: Node.js module for accessing Oracle Database
https://oracle.github.io/node-oracledb/
Introducing node-oracledb - a Node.js driver for Oracle Database | Oracle Scripting and Oracle: Christopher Jones Blog
https://blogs.oracle.com/opal/introducing-node-oracledb-a-nodejs-driver-for-oracle-database
node-oracledb 4.2 Documentation for the Oracle Database Node.js Add-on | node-oracledb
https://oracle.github.io/node-oracledb/doc/api.html#getstarted
Node.js - Node.js with Oracle | node.js Tutorial
https://riptutorial.com/node-js/topic/8248/node-js-with-oracle
Node.js Oracle CRUD Example: Database Connection & SQL Queries | Techiediaries
https://www.techiediaries.com/node-oracle-database-crud/
How to Install Node.js 10 with node-oracledb and Connect it to Oracle Database | Oracle Linux Blog
https://blogs.oracle.com/linux/how-to-install-nodejs-10-with-node-oracledb-and-connect-it-to-the-database