Hi,
Today, I'm going to write about how to call poloniex API.
Poloniex is a cryptocurrency exchange and they support API calls.
The calls include ticker, historical data, submitting order and checking balance.
You could find all api calls in here (right now at this point, the site not working)
https://www.poloniex.com/support/api/
I'm going to use MATLAB.
First we need a wrapper to call api.
It is found in bitcointalk : https://bitcointalk.org/index.php?topic=1817541.0
You need to download and add the functions to your MATLAB path.
url2.m, DataHash.m, HMAC.m
https://www.mathworks.com/matlabcentral/fileexchange/35693-urlread2
http://www.mathworks.com/matlabcentral/fileexchange/31272-datahash
http://www.mathworks.com/matlabcentral/fileexchange/46182-hmac-hash-message-authentication-code-function
Also, you need to save the functions written in the bitcointalk link such as
function response=POLO_Call(command,params)
% Donate BTC: 3NQ3RpAcXjNRgFXCAXuAf6icjuG31ZSfeT if like it
% appKey and appSecret-----------------------------
appKey='';
appSecret='';
%nonce
nonce=;%create a nonce of your style
%SHA512 encoding---------------------------------------------------------
addr='https://poloniex.com/tradingApi';
parameters=['command=',command,'&nonce=',nonce params];
requestString=HMAC(appSecret,parameters,'SHA-512');%hmac-shaxxx depends on exchange
%header=struct('name',name,'value',value);
header1=struct('name','Content-Type','value','application/x-www-form-urlencoded');
header2=struct('name','Key','value',appKey);
header3=struct('name','Sign','value',requestString);
headers=[header1, header2, header3];
response = urlread2(addr,'POST',parameters,headers);
In the variable appKey and appSecret, you should find and type your own key in the poloniex API.
In the nouce variable, I recommend you to do following
nonce = strrep(num2str(now*1000000-7.34E11), '.', '');
nonce = nonce(1:10);
You just completed the key function POLO_Call(command,params).
Let's see balance of our account using the function
function amt=POLO_Bal(currency)
%eg:POLO_Bal('BTC')
command='returnBalances';
params='';
tmp=POLO_Call(command,params);
amt=POLO_J2M(tmp,currency);
If we call POLO_Bal('BTC'), then it returns the balance of bitcoin in your account.
The subfunction, returns all the balance in your account with tmp variable
command='returnBalances';
params='';
tmp=POLO_Call(command,params);
The tmp variable is a JSON string which is not suitable in MATLAB.
Using JSON string parser, let's parse the string. http://www.mathworks.com/matlabcentral/fileexchange/25713
You could see the balance of all coin.
That's it for today, have a wonderful day.
Poloniex is fucked
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Oh man....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
why do you think so?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Can we do this similar things in mathematica?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Yes of course
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Can you offer any insights to the POLO_J2M function which is missing here?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit