Skip to content

Instantly share code, notes, and snippets.

@prdn
prdn / bfx-auth-rest-v2.java
Created October 19, 2020 17:00
bfx-auth-rest-v2.java
import java.util.Date;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
@prdn
prdn / bfx-market-data-mcast-udp.js
Created May 1, 2020 09:15
bfx-market-data-mcast-udp.js
const dgram = require('dgram')
const UInt64BE = require('int64-buffer').Uint64BE
const BN = require('bignumber.js')
const _ = require('lodash')
const process = require('process')
const PORT = 30000
const MULTICAST_ADDR = '233.255.255.255'
const nBN = v => {
@prdn
prdn / bfx-pulse-rest-v2-del.js
Last active April 20, 2020 08:08
bfx-pulse-rest-v2-del.js
/*
INSTALL DEPENDENCIES:
$ npm install request
CONFIGURE:
set `apiKey` and `apiSecret` variables
RUN:
node bfx-pulse-rest-v2-del.js
*/
/*
INSTALL DEPENDENCIES:
$ npm install request
CONFIGURE:
set `apiKey` and `apiSecret` variables
RUN:
node bfx-pulse-rest-v2-write.js
*/
@prdn
prdn / bfx-rest-notify-mobile.js
Created November 1, 2019 14:25
bfx-rest-notify-mobile.js
const fs = require('fs')
const crypto = require('crypto')
const request = require('request')
const apiKey = '...'
const apiSecret = '...'
const url = 'v2/auth/w/expo/notify'
const nonce = (Date.now() * 1000).toString()
const body = {
@prdn
prdn / vwap.rb
Created September 13, 2019 09:55
vwap-test-rb
# frozen_string_literal: true
def http_get(url)
HTTParty.get(url)
rescue => e
-1
end
# takes in a string pair and timeframe in minutes to use to calculate vwap
# example vwap_bittrex("BTC-LTC", 15)
@prdn
prdn / bfx-perf-auth-order-21.js
Last active April 7, 2020 14:02
bfx-perf-auth-order-21.js
// INSTALL
// requirements: node.js interpreter
// run: npm install ws
const WebSocket = require('ws')
const crypto = require('crypto')
const fs = require('fs')
const w1_apiKey = 'API_KEY'
const w1_apiSecret = 'API_SECRET'
@prdn
prdn / bfx-perf-books-21.js
Last active April 7, 2020 14:00
bfx-perf-books-v2.1
// INSTALL
// requirements: node.js interpreter
// run: npm install ws
// Subscribe to BTCUSD book on Bitfinex's WebSocket v2
const WS = require('ws')
const w = new WS("wss://api-pub.bitfinex.com/ws/2")
w.onmessage = function(msg) { console.log(Date.now(), msg.data) }
@prdn
prdn / bfx_ws2_aggressive.js
Last active September 8, 2018 22:40
bfx_ws2_aggressive.js
/*
mkdir bfx_test
cd bfx_test
// save this script as run.js, and add your api key/secret
npm install ws
npm install async
node run.js
*/
const WebSocket = require('ws');
@prdn
prdn / bfx_pub_shard.js
Last active August 30, 2018 08:11
Bitfinex Public Market Data sharding on multiple sockets
/*
npm install ws request crc-32
*/
const WebSocket = require('ws')
const request = require('request')
const CRC = require('crc-32')
const LIMIT_CHAN = 250