Пример #1
0
 /**
  * @param Order $order
  * @return Response
  */
 public function sendOrder(Order $order)
 {
     $url = sprintf("%s/venues/%s/stocks/%s/orders", $this->getUrl(), $order->getVenue(), $order->getSymbol());
     $response = new Response();
     try {
         $request = $this->client->post($url, ['json' => $order->toJson()]);
         $response->parseFromJson($request->getBody());
     } catch (RequestException $e) {
         // Do some magic Things...
     }
     return $response;
 }
    die('You must set up the project dependencies.');
}
use Twinsen\StockFighterApi\Models\Order\Response\Response;
$orderResponseJson = '
{
"ok": true,
"symbol": "BAR",
"venue": "FOOEX",
"direction": "buy",
"originalQty": 100,
"qty": 20,
"price":  5100,
"type": "limit",
"id": 12345,
"account" : "OGB12345",
"ts": "2015-07-05T22:16:18+00:00",
"fills":
[
{
"price": 5050,
"qty": 50,
"ts": "2015-07-05T22:16:18+00:00"
}
],
"totalFilled": 80,
"open": true
}
';
$response = new Response();
$response->parseFromJson($orderResponseJson);
var_dump($response);