Skip to content

Commit

Permalink
Merge pull request #3 from spotware/dev
Browse files Browse the repository at this point in the history
Created web app sample
  • Loading branch information
amusleh-spotware-com authored Mar 11, 2022
2 parents 2a59a8a + 9189bcc commit 3ad8c49
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 302 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@ dmypy.json
/samples/jupyter/credentials-dev.json
/samples/ConsoleSample/config-trade.json
/samples/ConsoleSample/config-quote.json
/samples/KleinWebAppSample/config-trade.json
/samples/KleinWebAppSample/config-quote.json
18 changes: 18 additions & 0 deletions samples/ConsoleSample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,21 @@ This sample uses [inputimeout](https://pypi.org/project/inputimeout/) Python pac
Before running the sample you have to create a config file and fill it with your trading account FIX API credentials.

Then replace the config file name on sample main file to your config file name.

Config file sample:

```json
{
"Host": "",
"Port": 0,
"SSL": false,
"Username": "",
"Password": "",
"BeginString": "FIX.4.4",
"SenderCompID": "",
"SenderSubID": "QUOTE",
"TargetCompID": "cServer",
"TargetSubID": "QUOTE",
"HeartBeat": "30"
}
```
2 changes: 1 addition & 1 deletion samples/ConsoleSample/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def showHelp():
print("* TestRequest: *TestReqId")
print("* ResendRequest: *BeginSeqNo *EndSeqNo")
print("* SequenceReset: *NewSeqNo GapFillFlag")
print("* SecurityListRequest: *SecurityReqID *SecurityListRequestType Symbol ")
print("* SecurityListRequest: *SecurityReqID *SecurityListRequestType Symbol")
print("\n")
print("QUOTE Commands:")
print("* MarketDataRequest: *MDReqID *SubscriptionRequestType *MarketDepth *NoMDEntryTypes *MDEntryType *NoRelatedSym *Symbol MDUpdateType")
Expand Down
24 changes: 21 additions & 3 deletions samples/KleinWebAppSample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,27 @@ It's based on Twisted [Klein](https://github.com/twisted/klein) web framework.

You can send and receive API commands by using this sample, it's very similar to Console sample.

To use the sample you have to create a copy of "credentials.json" file and rename it to "credentials-dev.json".

Then fill the file with your Open API application credentials.
Before running the sample you have to create a config file and fill it with your trading account FIX API credentials.

Then replace the config file name on sample main file to your config file name.

Config file sample:

```json
{
"Host": "",
"Port": 0,
"SSL": false,
"Username": "",
"Password": "",
"BeginString": "FIX.4.4",
"SenderCompID": "",
"SenderSubID": "QUOTE",
"TargetCompID": "cServer",
"TargetSubID": "QUOTE",
"HeartBeat": "30"
}
```

After that install Klein with pip:
```
Expand Down
13 changes: 13 additions & 0 deletions samples/KleinWebAppSample/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Host": "",
"Port": 0,
"SSL": false,
"Username": "",
"Password": "",
"BeginString": "FIX.4.4",
"SenderCompID": "",
"SenderSubID": "QUOTE",
"TargetCompID": "cServer",
"TargetSubID": "QUOTE",
"HeartBeat": "30"
}
5 changes: 0 additions & 5 deletions samples/KleinWebAppSample/credentials.json

This file was deleted.

3 changes: 1 addition & 2 deletions samples/KleinWebAppSample/js/site.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
$(document).ready(function () {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const token = urlParams.get("token");

$("#sendButton").click(function () {
$.getJSON(`/get-data?token=${token}&command=${$('#commandInput').val()}`, function (data, status, xhr) {
$.getJSON(`/get-data?command=${$('#commandInput').val()}`, function (data, status, xhr) {
response = "result" in data ? data["result"] : JSON.stringify(data)
if ($("#outputTextarea").val() == "") {
$("#outputTextarea").val(response + "\n").change()
Expand Down
Loading

0 comments on commit 3ad8c49

Please sign in to comment.