Skip to content

Commit

Permalink
Bug fix with OANDA open trades. Relay now utilizes and properly trcks…
Browse files Browse the repository at this point in the history
… open trades to the maximumallowable level that OANDA supports.

Changes to be committed:
	modified:   Base/Library/JRRoanda.py
	modified:   Extras/CodeProofs/oandaOpenTrades
	new file:   Extras/CodeProofs/place100orders
	modified:   Extras/CodeProofs/readMarkets
  • Loading branch information
rapmd73 committed Nov 7, 2023
1 parent c3ae919 commit d2e3a94
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Base/Library/JRRoanda.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,11 @@ def GetOpenOrders(self,**kwargs):

# As references in GetPosition, a position may consist of one or more actual
# trades. This is NOT the same as an open list of limit orders.
# count is maximum number o allowed open trades.

def GetOpenTrades(self,**kwargs):
symbol=kwargs.get('symbol').replace('/','_')
params={"instrument":symbol }
params={"instrument":symbol,"count":500 }
self.SetPipValue(symbol)

req=v20Trades.TradesList(accountID=self.AccountID,params=params)
Expand Down
2 changes: 1 addition & 1 deletion Extras/CodeProofs/oandaOpenTrades
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ for o in oo:
else:
side='Shrt'
print(f"{o['openTime']} {o['instrument']:10} {o['id']:7} {side:4} {iu:16.5f} {price:16.5f} {upl:16.5f} {fin:16.5f}")
print("\n",round(tpnl,5))
print("\n",round(tpnl,5),len(oo))
40 changes: 40 additions & 0 deletions Extras/CodeProofs/place100orders
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Jackrabbit Relay
# 2021 Copyright © Robert APM Darin
# All rights reserved unconditionally.

import sys
sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library')
import os
import json

import JackrabbitRelay as JRR

###
### Main code base. Place order on exchange
###

relay=JRR.JackrabbitRelay()
if relay.GetArgsLen() > 4:
exchangeName=relay.GetExchange()
account=relay.GetAccount()
asset=relay.GetAsset()
side=relay.GetArgs(4)
amount=relay.GetArgs(5)
else:
print("An exchange, (sub)account, an asset, a side (buy/sell), and an amount must be provided.")
sys.exit(1)

u=float(amount)
for i in range(100):
ticker=relay.GetTicker(symbol=asset)
bPrice=ticker['Ask']
sPrice=ticker['Bid']

mPrice=min(bPrice,sPrice)

result=relay.PlaceOrder(pair=asset,orderType="market",action=side,amount=u,price=bPrice)
print(result)
u+=1
2 changes: 2 additions & 0 deletions Extras/CodeProofs/readMarkets
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ else:
print("An exchange and a (sub)account must be provided.")
sys.exit(1)

print(relay.Broker.Summary)

# Already loaded from login

markets=relay.Markets
Expand Down

0 comments on commit d2e3a94

Please sign in to comment.