-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTest.py
132 lines (107 loc) · 4.62 KB
/
Test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import csv
import asyncio
import datetime
import random
# import oandapyV20.endpoints.accounts as accounts
# import oandapyV20.endpoints.positions as positions
import pprint
import json
import requests
marketsSummary = requests.get("https://trade.mandala.exchange/open/v1/common/symbols")
marketsJson = marketsSummary.json()
symbols = []
for singleMarket in marketsJson['data']['list']:
symbols.append(singleMarket['symbol'])
print (symbols)
# orderBook = requests.get("https://trade.mandala.exchange/open/v1/market/depth?symbol=" + "MDX_USDT")
# orderBookJson = orderBook.json()
# depth = orderBookJson['data']
# for bid in depth['bids']:
# print(bid[0])
# USDTorderBook = requests.get("https://trade.mandala.exchange/open/v1/market/depth?symbol=" + 'BTC_USDT')
# USDTorderBookJson = USDTorderBook.json()
# USDTdepth = USDTorderBookJson['data']
# dollar_exchrate = USDTdepth['bids'][0][0]
# print(dollar_exchrate)
# # print(datetime.datetime.now())
# # current_time = datetime.datetime.now().time()
# # csvName = str(current_time) + ".csv"
# # print(csvName)
# # with open('triarbdata.csv', 'w') as f:
# #
# # fieldnames = ['Bot Start Date', 'Bot Start Time', 'Arb Time','Exchange', 'Initial USD', 'First Market', 'Second Market', 'Third Market', 'Spread', 'Estimated Profit']
# # thewriter = csv.DictWriter(f, fieldnames = fieldnames)
# # thewriter.writeheader()
# # current_time = datetime.datetime.now()
# #
# # def writeToCSV(arbitrageopp):
# # i = 0
# # if (i == 0):
# # thewriter.writerow({'Bot Start Date': current_time.date(), 'Bot Start Time': current_time.time(), 'Arb Time': current_time.now(), 'Exchange': arbitrageopp['exchange'], 'Initial USD': arbitrageopp['initialUSD'], 'First Market': arbitrageopp['sym_list'] [0], 'Second Market': arbitrageopp['sym_list'] [1], 'Third Market': arbitrageopp['sym_list'] [2], 'Spread': arbitrageopp['spread'], 'Estimated Profit': arbitrageopp['estimated_profit']})
# # else:
# # thewriter.writerow({'Arb Time': current_time.now(), 'Exchange': arbitrageopp['exchange'], 'Initial USD': arbitrageopp['initialUSD'], 'First Market': arbitrageopp['sym_list'] [0], 'Second Market': arbitrageopp['sym_list'] [1], 'Third Market': arbitrageopp['sym_list'] [2], 'Spread': arbitrageopp['spread'], 'Estimated Profit': arbitrageopp['estimated_profit']})
# # i+=1
# # arbitrage = {
# # 'exchange': 'Binance',
# # 'sym_list': ['BTC/USD', 'BTC/ETH', 'ETH/USD'],
# # 'initialUSD': 200,
# # 'spread': .2,
# # 'estimated_profit': 300,
# # }
# #
# # writeToCSV(arbitrage)
# #account info for practice acct.
# accountID = "101-001-16023947-001"
# access_token = "9a5cae7cbfacf5f6aa634097bc1bc337-b394ef6856186107ebfdc589260269bf"
# # oanda = API(environment="live", access_token=access_token)
# oanda = API(access_token=access_token)
# fee_pct = 0.0 # YESSIRRR OANDA IS FREE COMMISSION
# client = API(access_token=access_token)
# # r = accounts.AccountSummary(accountID)
# # client.request(r)
# # print(r.response)
# a = positions.OpenPositions(accountID = accountID)
# client.request(a)
# pp = pprint.PrettyPrinter(indent=4)
# #pp.pprint(a.response.get('positions', 0))
# print(a.response.get('positions')[0])
# def findOpenPositionMarkets():
# markets = []
# for i in range(0, len(a.response.get('positions'))):
# markets.append(a.response.get('positions')[i].get('instrument', 0))
# return markets
# markets2 = findOpenPositionMarkets()
# #pp.pprint(markets2)
# print(type(markets2))
# def print_positions(positions, open_only=True):
# """
# Print a list of Positions in table format.
# Args:
# positions: The list of Positions to print
# open_only: Flag that controls if only open Positions are displayed
# """
# filtered_positions = [
# p for p in positions
# if not open_only or p.long.units != "0" or p.short.units != "0"
# ]
# if len(filtered_positions) == 0:
# return
# #
# # Print the Trades in a table with their Instrument, realized PL,
# # unrealized PL long postion summary and shor position summary
# #
# common.view.print_collection(
# "{} {}Positions".format(
# len(filtered_positions),
# "Open " if open_only else ""
# ),
# filtered_positions,
# [
# ("Instrument", lambda p: p.instrument),
# ("P/L", lambda p: p.pl),
# ("Unrealized P/L", lambda p: p.unrealizedPL),
# ("Long", position_side_formatter("long")),
# ("Short", position_side_formatter("short")),
# ]
# )
# print("")