Skip to content

Commit

Permalink
Bug fix dealing with asset name that aren't exactly 6 characters. Its…
Browse files Browse the repository at this point in the history
… kludgy, but

works for now.

Changes to be committed:
	modified:   Extras/OliverTwist/OliverTwistTrades
  • Loading branch information
rapmd73 committed Oct 12, 2024
1 parent b371700 commit 512879f
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions Extras/OliverTwist/OliverTwistTrades
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,20 @@ account=data[2]

if len(data)==5:
asset=data[3]
pair=data[3][:3]+'/'+data[3][3:]
l=len(data[3])
pair=data[3][:l-3]+'/'+data[3][-3:]
else:
asset=data[4]
pair=data[4][:3]+'/'+data[4][3:]
l=len(data[3])
pair=data[4][:l-3]+'/'+data[4][-3:]

# For Mimic, use the Details section to get the Price

OpenOrders=ReadStorehouse(exchange,account,asset)
if OpenOrders!=[]:
OpenOrderDT=datetime.datetime.strptime(OpenOrders[0]['DateTime'], '%Y-%m-%d %H:%M:%S.%f')
OpenEpoch=int(time.mktime(OpenOrderDT.timetuple()))
pair=OpenOrders[0]['Order']['Asset']

# Get ending date for lines

Expand Down Expand Up @@ -203,10 +206,16 @@ fig1=ps.make_subplots(specs=[[{"secondary_y":False}]])
print("Phase 2: making the chart")

# Get the first candle of the trades to set the start of the chart.
fid=lines[0].split(' ')[4]
oDetails=relay.GetOrderDetails(OrderID=fid)[0]
print(oDetails['time'])
sdt=datetime.datetime.strptime(oDetails['time'].split('T')[0], '%Y-%m-%d').timestamp()
dline=lines[0].split(' ')
while '' in dline:
dline.remove('')
fid=dline[3]
std=None
try:
oDetails=relay.GetOrderDetails(OrderID=fid)[0]
sdt=datetime.datetime.strptime(oDetails['time'].split('T')[0], '%Y-%m-%d').timestamp()
except Exception as err:
sdt=StartEpoch

# Plot candles of timeframe just above log
dt=[]
Expand Down Expand Up @@ -235,9 +244,13 @@ for order in OpenOrders:
dt=order['DateTime']

if exchange=='oanda':
oDetails=relay.GetOrderDetails(OrderID=order['ID'])[-1]
dp=float(oDetails['price'])
du=int(oDetails['units'])
try:
oDetails=relay.GetOrderDetails(OrderID=order['ID'])[-1]
dp=float(oDetails['price'])
du=int(oDetails['units'])
except Exception as err:
print("Check OpenOrders",err)
continue
elif exchange=='mimic':
du=float(order['Response']['Details']['Amount'])
dp=float(order['Response']['Details']['Price'])
Expand Down

0 comments on commit 512879f

Please sign in to comment.