Lägga order Python 3

Added by Oliver over 4 years ago

Hej, när jag försöker lägga en order får jag endast ett tomt svar. När jag sedan kollar på lagda ordrar har ingen lags till. Jag använder pythonpaketet requests, med vilket jag lyckats göra ett flertal andra interaktioner med API:t. Här är min kod:

headers = {"Accept": "application/json"}

r = requests.get('http://' + URL + '/next/' + API_VERSION + '/accounts', auth=auth, headers=headers)
data = json.loads(r.text)

acno = data[0]['accno']
market_id = 11
identifier = '101'
price = 80
volume = 10
currency = 'SEK'

form = dict(identifier=identifier, market_id=market_id, price=price, volume=volume, currency=currency, side='SELL',
            order_type='LIMIT', valid_until='2016-04-30')

r = requests.post('http://' + URL + '/next/' + API_VERSION + '/accounts/' + str(acno) + '/orders', data=form, auth=auth,
                  headers=headers)

print(r)

r = requests.get('http://' + URL + '/next/' + API_VERSION + '/accounts/' + str(acno) + '/orders', auth=auth,
                 headers=headers)
print(r)

Vilket ger svaret:

<Response [204]>
<Response [204]>

Alltså helt tomma svar. Är tacksam för all hjälp!

/Oliver


Replies (7)

RE: Lägga order Python 3 - Added by Lars over 4 years ago

Tre förslag:

1) Lägg in en print(r) även efter första requests.get så att du vet säkert att det första anropet fungerar och att accno får rätt värde.

2) Prova med https i stället för http i alla anropen.

3) Prova att explicit ange Content-Type för POST-anropet.

RE: Lägga order Python 3 - Added by Oliver over 4 years ago

Tack för tipsen!

Jag kollade med print och det första anropet fungerar bra. Jag testade även att explicit ange Content-Type, vilket gav samma resultat som tidigare.

När jag sedan ändrade till https fick jag svar. Jag får dock responsen:

{'order_state': 'DELETED', 'message': 'User does not have required agreements.', 'action_state': 'INS_FAIL', 'order_id': 1117310, 'result_code': 'ORDER_MISSING_AGREEMENT'}

Vad kan detta bero på?

Tack igen!

RE: Lägga order Python 3 - Added by Björn over 4 years ago

Det svaret får man om man försöker blanka utan att ha fyllt i rätt papper för det. I testsystemet behöver man bara be Nordnet att fixa det, här på forumet.

RE: Lägga order Python 3 - Added by Oliver over 4 years ago

Okej, tack! Då skriver jag till en av admin.

RE: Lägga order Python 3 - Added by sunh 2 days ago

토토레프리 I finally found the article 먹튀검증 I was looking for! I'm so happy. 먹튀 Until I read your article, 먹튀검증업체 I've been looking for it through countless sites. https://elephonemobile.com/ I finally found 먹튀사이트 the article I was looking for. 메이저놀이터 You don't know how hard I've been trying to find these posts. 메이저놀이터 I will read all the other articles 사설토토 on your website. 메이저사설토토 That much, your post impressed me very deeply. I also run my own website. 사설놀이터 I'm reviewing a lot of materials 안전놀이터 to write on the same topic as you. I will also refer 안전놀이터 to your article 토토사이트 in running my website. Anyway, 메이저토토사이트 thank you again for allowing me to read these good posts, and I hope you have a good day. 토토사이트추천 Thank you. 토토사이트

RE: Lägga order Python 3 - Added by sunh 2 days ago

안전놀이터검증및연구센터 Hello, 토토사이트분석전문블로그 I read your article for 먹튀검증의새로운패러다임 the first time today. https://kipu.com.ua/ It's a post that https://remarka.kz/ I've never seen before. https://subtitles.ee/ That's amazing. 안전놀이터 You must have 먹튀검증 a genius for writing. 토토사이트 I wish I could write like you. 먹튀사이트검증 When did you start posting like this? 메이저토토사이트 I think it's very old. 메이저안전놀이터 That's how good you are at writing. 안전한사설토토사이트 Actually, 공식안전놀이터 I have a website with 먹튀검증커뮤니티 a similar topic as you. 먹튀검증토토사이트 But I don't have the skill 먹튀검증토토 to write as well as you do. 사설안전놀이터] Thank you again for letting me read this. COVID-19 is becoming a big problem around the world these days. I hope you pass without any problems. Thank you. Have a good day today!Nowadays,토토사이트검증업체 the weather is getting colder every day토토안전놀이터 , so wear warm clothes and watch out for a cold 확실한먹튀검증 It's really cool 검증토토사이트. I'd like to know more information. Just like your 안전한먹튀검증 I have 최고의안전놀이터

RE: Lägga order Python 3 - Added by sunh 2 days ago

먹튀검증 I've never read this kind of story before. 먹튀검증 What a great story! 안전놀이터 I read it really interestingly. 토토사이트 This article was a great help to me. 꽁머니 I wish I could write something like this! 꽁머니 Actually, I run a similar site. 안전놀이터 I want you to come and take a look.스포츠중계 I would be really happy if you visit my site. Thank you! In addition, https://mtboan.com/ COVID-19 is becoming a problem all over the world these days. 먹튀보안관 I hope there's no harm to you and your family. 먹튀가디언 Thank you https://twiddeo.com/

(1-7/7)