- make visual studio project
- datamgr insert
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
__pycache__/
|
||||
32
CoinTrader.pyproj
Normal file
32
CoinTrader.pyproj
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{b3dc52bc-017a-4af1-a886-71d83ac4fa61}</ProjectGuid>
|
||||
<ProjectHome />
|
||||
<StartupFile>main.py</StartupFile>
|
||||
<SearchPath />
|
||||
<WorkingDirectory>.</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
|
||||
<LaunchProvider>Standard Python launcher</LaunchProvider>
|
||||
<InterpreterId />
|
||||
<InterpreterVersion />
|
||||
<IsWindowsApplication>True</IsWindowsApplication>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
|
||||
<PtvsTargetsFile>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="api_test.py" />
|
||||
<Compile Include="data_manager.py" />
|
||||
<Compile Include="main.py" />
|
||||
<Compile Include="xcoin_api_client.py" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(PtvsTargetsFile)" Condition="Exists($(PtvsTargetsFile))" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="!Exists($(PtvsTargetsFile))" />
|
||||
</Project>
|
||||
31
data_manager.py
Normal file
31
data_manager.py
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
class Transaction:
|
||||
def __init__(self):
|
||||
self.time = None
|
||||
self.price = None
|
||||
self.unit = 0
|
||||
self.type = None
|
||||
|
||||
def __init__(self, item):
|
||||
self.time = item['transaction_date']
|
||||
self.price = int(item['price'])
|
||||
self.unit = float(item['units_traded'])
|
||||
self.type = item['type']
|
||||
|
||||
def __str__(self, **kwargs):
|
||||
return '[{}] {} {}'.format(self.time, self.type, self.price)
|
||||
|
||||
|
||||
class DataMgr:
|
||||
def __init__(self):
|
||||
self.transactions = {}
|
||||
|
||||
def insert(self, item):
|
||||
transactions_new = {}
|
||||
tr = Transaction(item)
|
||||
if tr.time in self.transactions:
|
||||
return False
|
||||
|
||||
self.transactions[tr.time] = tr
|
||||
print(tr)
|
||||
return True
|
||||
12
datamgr.py
12
datamgr.py
@@ -1,12 +0,0 @@
|
||||
|
||||
class Tick:
|
||||
def __init__(self):
|
||||
self.time = None
|
||||
self.price = None
|
||||
|
||||
|
||||
class DataMgr:
|
||||
def __init__(self):
|
||||
self.tick_list = None
|
||||
|
||||
def insert(self, time, price, ask):
|
||||
36
main.py
36
main.py
@@ -1,24 +1,56 @@
|
||||
from xcoin_api_client import *
|
||||
import sched
|
||||
import time
|
||||
import data_manager
|
||||
|
||||
|
||||
api_key = "api_connect_key"
|
||||
api_secret = "api_secret_key"
|
||||
api = XCoinAPI(api_key, api_secret)
|
||||
|
||||
# public api
|
||||
#
|
||||
# /public/ticker
|
||||
# /public/recent_ticker
|
||||
# /public/orderbook
|
||||
# /public/recent_transactions
|
||||
#
|
||||
# private api
|
||||
#
|
||||
# endpoint => parameters
|
||||
# /info/current
|
||||
# /info/account
|
||||
# /info/balance
|
||||
# /info/wallet_address
|
||||
|
||||
|
||||
rgParams = {
|
||||
"order_currency": "xrp",
|
||||
"payment_currency": "KRW"
|
||||
}
|
||||
|
||||
scheduler = sched.scheduler(time.time, time.sleep)
|
||||
timer_delay = 0.2
|
||||
timer_delay = 0.1
|
||||
|
||||
def printTicker(result):
|
||||
print("["+time.strftime("%H:%M:%S")+"]" + " status: " + result["status"] + " last: " + result["data"]["closing_price"])
|
||||
|
||||
def printTransaction(result):
|
||||
print("["+time.strftime("%H:%M:%S")+"]" + " status: " + result["status"])
|
||||
for item in result['data']:
|
||||
print('\t[' + item['transaction_date']+']' + item['type'] + ' ' + item['price']);
|
||||
|
||||
|
||||
datamgr = data_manager.DataMgr()
|
||||
def main(arg):
|
||||
#result = api.xcoinApiCall("/public/ticker/" + rgParams["order_currency"], rgParams)
|
||||
#if result is not None:
|
||||
# printTicker(result)
|
||||
|
||||
result = api.xcoinApiCall("/public/recent_transactions/" + rgParams["order_currency"], rgParams)
|
||||
if result is not None:
|
||||
print("["+time.strftime("%H:%M:%S")+"]" + " status: " + result["status"] + " last: " + result["data"]["closing_price"])
|
||||
for item in reversed(result['data']):
|
||||
datamgr.insert(item)
|
||||
|
||||
scheduler.enter(timer_delay, 1, main, (arg, ))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user