-
-
Save marshluca/7bce74a65c0062dee8c9 to your computer and use it in GitHub Desktop.
request bitfinex API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def headers_for(path, options={}) | |
payload = {} | |
payload['request'] = path | |
payload['nonce'] = (Time.now.to_f * 10000).to_i.to_s | |
payload.merge!(options) | |
payload_enc = Base64.encode64(payload.to_json).gsub(/\s/, '') | |
sig = Digest::HMAC.hexdigest(payload_enc, @api_secret, Digest::SHA384) | |
{ | |
'Content-Type' => 'application/json', | |
'X-BFX-APIKEY' => @api_key, | |
'X-BFX-PAYLOAD' => payload_enc, | |
'x-BFX-SIGNATURE' => sig | |
} | |
end | |
path = "/v1/order/new" | |
params = { | |
symbol: "btcusd", | |
amount: amount, | |
price: price, | |
side: "sell", | |
type: "exchange market", | |
exchange: "bitfinex", | |
is_hidden: false | |
} | |
client.post(path, params, headers_for(path, params)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment