def oanda_get_order(self, market, item): try: request = orders.OrderDetails(accountID=self.oanda_account_id, orderID=item) order_info = self.oanda.request(request)['order'] # Cancelled filled orders are differentiated by replacedByOrderID output = {} output["OrderUuid"] = order_info["id"] # Price may not be in the order (if trying out market orders for example) if 'price' not in list(order_info.keys()): order_info['price'] = self.oanda_ticker(market) # On the platform filledTime in keys mean that the order was actually filled if 'filledTime' in list(order_info.keys()): output["Quantity"] = abs(float(order_info["units"])) output["QuantityRemaining"] = 0 output["PricePerUnit"] = float(order_info['price']) output["Price"] = float(order_info['price'])*float(order_info["units"]) else: output["Quantity"] = abs(float(order_info["units"])) output["QuantityRemaining"] = abs(float(order_info["units"])) output["PricePerUnit"] = 0 output["Price"] = 0 output['CommissionPaid'] = 0 output['Status'] = order_info['state'] output['simpleCumQty'] = abs(float(order_info["units"])) except V20Error as e: print(e) # 404 is order not found output = None return output
def test__order_details(self, mock_get): """details of an order.""" orderID = "2309" tid = "_v3_accounts_accountID_order_details" resp, data = fetchTestData(responses, tid) r = orders.OrderDetails(accountID, orderID=orderID) mock_get.register_uri('GET', "{}/{}".format(api.api_url, r), text=json.dumps(resp)) result = api.request(r) result = result["order"] self.assertTrue(result['id'] == orderID and result['units'] == resp["order"]["units"])
def checkOrder(self, order_id): req = orders.OrderDetails(accountID=self.account_id, orderID=order_id) try: res = self.client.request(req) logger.info(f'Response in checkOder()... {res}', res) except V20Error as e: logger.error(f'Error in checkOrder() ... {e}', e) return None state = res['order']['state'] filling_transaction_id = res['order']['fillingTransactionID'] if state == 'FILLED': r = True else: r = False return (r, state, filling_transaction_id)
def get_order(self, order_id): req = orders.OrderDetails(accountID=self.account_id, orderID=order_id) try: resp = self.client.request(req) logger.info(f'action=get_order resp={resp}') except V20Error as e: logger.error(f'action=get_order error={e}') raise order = Order( product_code=resp['order']['instrument'], side=constants.BUY if float(resp['order']['units']) > 0 else constants.SELL, units=float(resp['order']['units']), order_type=resp['order']['type'], order_state=resp['order']['state'], filling_transaction_id=resp['order'].get('fillingTransactionId') ) return order
'instrument': 'USD_JPY', 'units': '+10000', 'type': 'STOP' } } o = orders.orderCreate(accountID, data=order_data) api.request(o) o.response #--------------------------- # 保留中のオーダー情報を取得する #--------------------------- c = orders.OrderPending(accountID) api.request(c) c.response #--------------------------- # オーダーの詳細を取得する #--------------------------- c = orders.OrderDetails(accountID, orderID='133') api.request(c) c.response #--------------------------- # オーダーをキャンセルする #--------------------------- c = orders.OrderCancel(accountID, orderID='18') api.request(c) c.response
use OrdersPending(), in lieu of the above OrderList() to cancel open orders """ r = orders.OrdersPending(accountID) client.request(r) res = r.response['orders'] last_order_id = res[0][ 'id'] # also used directly below to get details for a single order # print(res) display_all_pending_orders = pd.Series( r.response['orders'][0]) # or pd.Series(res['orders'][0]) print(display_all_pending_orders) """ # 4 Get Details for a Single Order in an Account """ r = orders.OrderDetails(accountID=accountID, orderID=last_order_id) client.request(r) single_order_details = r.response print(single_order_details) """ # 5 Replace an Order in an Account by simultaneously cancelling it and creating a replacement Order. """ replacement_order_data = { "order": { "units": "-500000", "instrument": "EUR_USD", "price": "1.25000", "type": "LIMIT" } }
def get_order_by_id(cls, order_id): """ Get details of a single order by given order_id """ r = orders.OrderDetails(accountID=cls.account_id, orderID=order_id) print cls.client.request(r)
def get_order_details(account_ID: str, order_ID: str) -> Dict: r = orders.OrderDetails(accountID=account_ID, orderID=order_ID) resp = client.request(r) return (resp['order'])
def ordering(self, ticket): r = orders.OrderDetails(self.id, orderID=ticket) return self.req(r)
def OrdersOrderDetails(access_token, accountID, orderID): 'Get details for a single Order in an Account.' r = orders.OrderDetails(accountID=accountID, orderID=orderID) client = API(access_token=access_token) client.request(r) return readable_output(Munch(r.response)), Munch(r.response)
def order_details(accountID, token, orderID): client = oandapyV20.API(access_token=token) r = orders.OrderDetails(accountID=accountID, orderID=orderID) request = client.request(r) return request
"order": { "price": "1.168", "stopLossOnFill": { "timeInForce": "GTC", "price": "1.15" }, "timeInForce": "GTC", "instrument": "EUR_USD", "units": "100", "type": "LIMIT", "positionFill": "DEFAULT" } } r1 = orders.OrderDetails(accountID=accountID, orderID=r.response['lastTransactionID']) client.request(r1) print (r1.response) import json from oandapyV20 import API from oandapyV20.contrib.factories import InstrumentsCandlesFactory client = API(access_token=access_token) instrument, granularity = "EUR_USD", "M15" _from = "2017-08-01T00:00:00Z" params = { "from": _from, "granularity": granularity, "count": 2500