Jump to content

saeeds255

New Members
  • Posts

    3
  • Joined

  • Last visited

saeeds255's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. that json_decode() can help too much . actually they are exchange market data and the new data will be added every second , see this : https://www.okcoin.cn/api/v1/trades.do?symbol=ltc_cny I'm thinking about something like this : $obj = THE CODE TO REQUEST THE JSON FROM THE WEBSERVER $obj = json_decode($obj); $sell = 0; $buy = 0; //loop through object and increment $buy and $sell by value of each row foreach($obj as $key => $row){ if($row->type == "sell"){ $sell = $sell + intval($row->amount); } else if($row->type == "buy"){ $buy = $buy + intval($row->amount); } } My problem is how to handle all that data that fast and how to store them in one variable like $buy or $sell ? I think that variables will reset after every refresh .
  2. yeah my language is awful but you could give me some functions to research them , I didn't ask anyone to give me the full code . if you can't help others you are free to leave this topic because it's PHP coding help .
  3. Hello, look at this data : {"amount":"2.001","date":1436471288,"date_ms":1436471288000,"price":"46.94","tid":109134569,"type":"sell"},{"amount":"2.001","date":1436471289,"date_ms":1436471289000,"price":"46.94","tid":109134571,"type":"sell"},{"amount":"2.001","date":1436471290,"date_ms":1436471290000,"price":"46.94","tid":109134576,"type":"sell"},{"amount":"2.001","date":1436471290,"date_ms":1436471290000,"price":"46.94","tid":109134579,"type":"sell"},{"amount":"1","date":1436471292,"date_ms":1436471292000,"price":"46.95","tid":109134587,"type":"buy"},{"amount":"4.21","date":1436471292,"date_ms":1436471292000,"price":"46.95","tid":109134589,"type":"buy"},{"amount":"8.299","date":1436471292,"date_ms":1436471292000,"price":"46.96","tid":109134591,"type":"buy"},{"amount":"5.346","date":1436471292,"date_ms":1436471292000,"price":"46.97","tid":109134593,"type":"buy"},{"amount":"2.001","date":1436471292,"date_ms":1436471292000,"price":"46.94","tid":109134594,"type":"sell"},{"amount":"10.2","date":1436471295,"date_ms":1436471295000,"price":"46.94","tid":109134615,"type":"sell"}, They are market data from a URL that refreshing too fast so new data will be added every second . I want to write a code to add amount of buy requests and amount of sell requests every second that the new data comes then have the buy sum and sell sum sepratelly . how to do this ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.